Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add intention to expand wildcard in select statement into column names#822

Merged
AlecKazakova merged 1 commit intomasterfrom
egorand/expand-columns-intention
May 3, 2018
Merged

Add intention to expand wildcard in select statement into column names#822
AlecKazakova merged 1 commit intomasterfrom
egorand/expand-columns-intention

Conversation

@Egorand
Copy link
Copy Markdown
Contributor

@Egorand Egorand commented May 2, 2018

Closes #812


override fun getText() = INTENTION_EXPAND_COLUMN_NAMES_TEXT

override fun isAvailable(project: Project, editor: Editor?, psiFile: PsiFile?) = true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psiFile is SqlDelightFile probably so we can be typesafe below


override fun invoke(project: Project, editor: Editor, psiFile: PsiFile) {
ApplicationManager.getApplication().invokeLater {
expandWildcard(project, editor, psiFile.virtualFile)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass psiFile as SqlDelightFile here instead of the virtualfile.

object : WriteCommandAction.Simple<Project>(project) {
override fun run() {
val file = PsiManager.getInstance(project).findFile(virtualFile) as SqlDelightFile
val selectStatement = findStatementAtCaret(editor, file.findChildrenOfType())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be

val selectStatement = PsiTreeUtil.findElementOfClassAtOffset(file, offset, SqliteSelectStmt::class.java, false)

which could probably be wrapped into a nice extension function on PsiFile

@AlecKazakova
Copy link
Copy Markdown
Collaborator

Closes #812

@Egorand Egorand force-pushed the egorand/expand-columns-intention branch from b0a62ee to 933ab4a Compare May 3, 2018 16:26
@Egorand
Copy link
Copy Markdown
Contributor Author

Egorand commented May 3, 2018

@AlecStrong PTAL

@AlecKazakova AlecKazakova merged commit 3f55f81 into master May 3, 2018
@AlecKazakova
Copy link
Copy Markdown
Collaborator

hell yea awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants