diff --git a/src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiPatternUtil.kt b/src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiPatternUtil.kt index cca0c059..97c1fa9a 100644 --- a/src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiPatternUtil.kt +++ b/src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiPatternUtil.kt @@ -24,7 +24,6 @@ import com.intellij.psi.TokenType import com.intellij.psi.tree.IElementType import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.elementType -import com.intellij.psi.util.prevLeaf import com.intellij.psi.util.prevLeafs import com.intellij.util.ProcessingContext import org.domaframework.doma.intellij.common.sql.directive.DirectiveCompletion @@ -79,11 +78,11 @@ object PsiPatternUtil { element: PsiElement, context: ProcessingContext?, ): Boolean { - val bindText = element.prevLeaf()?.text ?: "" + val bindText = PsiTreeUtil.prevLeaf(element)?.text ?: "" val directiveSymbol = DirectiveCompletion.directiveSymbols return directiveSymbol.any { bindText.startsWith(it) || - (element.elementType == SqlTypes.EL_IDENTIFIER && element.prevLeaf()?.text == it) || + (element.elementType == SqlTypes.EL_IDENTIFIER && PsiTreeUtil.prevLeaf(element)?.text == it) || ( element.elementType == TokenType.BAD_CHARACTER && element.parent diff --git a/src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/DirectiveHandler.kt b/src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/DirectiveHandler.kt index 2ae0ea6b..045be310 100644 --- a/src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/DirectiveHandler.kt +++ b/src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/DirectiveHandler.kt @@ -16,8 +16,8 @@ package org.domaframework.doma.intellij.common.sql.directive import com.intellij.psi.PsiElement +import com.intellij.psi.util.PsiTreeUtil import org.domaframework.doma.intellij.common.psi.PsiPatternUtil -import org.jetbrains.kotlin.psi.psiUtil.prevLeaf /** * Determine directive elements and perform code completion @@ -31,7 +31,7 @@ open class DirectiveHandler( it: PsiElement, symbol: String, ): Boolean { - val prev = it.prevLeaf() + val prev = PsiTreeUtil.prevLeaf(it) return ( prev?.text == symbol || it.text.startsWith(symbol) diff --git a/src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/visitor/DaoMethodVariableSqlVisitor.kt b/src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/visitor/DaoMethodVariableSqlVisitor.kt index d8b188ff..9a6c10d3 100644 --- a/src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/visitor/DaoMethodVariableSqlVisitor.kt +++ b/src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/visitor/DaoMethodVariableSqlVisitor.kt @@ -43,7 +43,7 @@ class DaoMethodVariableSqlVisitor( element.elementType == SqlTypes.EL_IDENTIFIER || element is SqlElPrimaryExpr ) && - element.prevSibling?.elementType != SqlTypes.DOT + PsiTreeUtil.prevLeaf(element)?.elementType != SqlTypes.DOT ) { iterator = args.minus(elements.toSet()).iterator() while (iterator.hasNext()) { diff --git a/src/test/testData/src/main/java/doma/example/dao/DaoMethodVariableInspectionTestDao.java b/src/test/testData/src/main/java/doma/example/dao/DaoMethodVariableInspectionTestDao.java index aec91b45..920fda60 100644 --- a/src/test/testData/src/main/java/doma/example/dao/DaoMethodVariableInspectionTestDao.java +++ b/src/test/testData/src/main/java/doma/example/dao/DaoMethodVariableInspectionTestDao.java @@ -32,8 +32,8 @@ interface DaoMethodVariableInspectionTestDao { List nonExistSQLFile(String name); @Select - @Sql("select * from employee where name = /* name */'test'") - Employee noArgumentsUsedInSQLAnnotations(String name,Integer id); + @Sql("select * from employee where name = /* employee.employeeName */'test'") + Employee noArgumentsUsedInSQLAnnotations(Employee employee,String employeeName); @SqlProcessor R biFunctionDoesNotCauseError(Integer id, BiFunction handler);