Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,14 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
result.addElement(LookupElementBuilder.create(match.name))
}
// Add ForDirective Items
val forDirectives = ForDirectiveUtil.getForDirectiveBlocks(position)
val parentForDirectiveExpr =
PsiTreeUtil.getParentOfType(position, SqlElForDirective::class.java)
?: PsiTreeUtil.getChildOfType(position.parent, SqlElForDirective::class.java)
val forDirectives =
ForDirectiveUtil.getForDirectiveBlocks(position).filter {
PsiTreeUtil.getParentOfType(it.item, SqlElForDirective::class.java) !=
parentForDirectiveExpr
}
addForDirectiveSuggestions(forDirectives, result)
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import org.domaframework.doma.intellij.psi.SqlBlockComment
import org.domaframework.doma.intellij.psi.SqlElFieldAccessExpr
import org.domaframework.doma.intellij.psi.SqlElForDirective
import org.domaframework.doma.intellij.psi.SqlElIdExpr
import org.domaframework.doma.intellij.psi.SqlElPrimaryExpr
import org.domaframework.doma.intellij.psi.SqlElStaticFieldAccessExpr
import org.domaframework.doma.intellij.psi.SqlTypes

fun SqlElForDirective.getForItem(): PsiElement? =
PsiTreeUtil
.getChildOfType(this, SqlElIdExpr::class.java)
.getChildOfType(this, SqlElPrimaryExpr::class.java)

fun SqlElForDirective.getForItemDeclaration(): ForDeclarationItem? {
val parentCommentBlock =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class SqlCompleteTest : DomaSqlTest() {
innerDirectiveCompleteTest(
"$testDapName/completeDirectiveInsideFor.sql",
listOf("project"),
listOf("employee"),
listOf("employee", "member", "%for"),
)
}

Expand Down