Skip to content

Commit 33b0414

Browse files
authored
Merge pull request #396 from domaframework/fix/dao-method-not-recognized-autocomplete-error
Fix error on code completion for SQL file with unrecognized DAO method
2 parents 71d4c29 + 83587b3 commit 33b0414

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
189189
val daoMethod = findDaoMethod(originalFile)
190190
val searchText = cleanString(getSearchElementText(position))
191191
var topElementType: PsiType? = null
192-
if (elements.isEmpty() && daoMethod != null) {
192+
if (elements.isEmpty()) {
193193
getElementTypeByFieldAccess(originalFile, position, elements, daoMethod, result)
194194
return
195195
}
@@ -303,15 +303,15 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
303303
originalFile: PsiFile,
304304
position: PsiElement,
305305
elements: List<PsiElement>,
306-
daoMethod: PsiMethod,
306+
daoMethod: PsiMethod?,
307307
result: CompletionResultSet,
308308
): PsiType? {
309309
val topElement = elements.firstOrNull()
310310
val topText = cleanString(getSearchElementText(topElement))
311-
val matchParams = daoMethod.searchParameter(topText)
312-
val findParam = matchParams.find { it.name == topText }
311+
val matchParams = daoMethod?.searchParameter(topText)
312+
val findParam = matchParams?.find { it.name == topText }
313313
if (elements.size <= 1 && findParam == null) {
314-
matchParams.map { match ->
314+
matchParams?.map { match ->
315315
result.addElement(LookupElementBuilder.create(match.name))
316316
}
317317
// Add ForDirective Items

src/test/kotlin/org/domaframework/doma/intellij/complate/sql/SqlSpecificParamTypeCompleteTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class SqlSpecificParamTypeCompleteTest : DomaSqlTest() {
9292
myFixture.configureFromExistingVirtualFile(sqlFile)
9393
val lookupElements = myFixture.completeBasic()
9494
val suggestions = lookupElements.map { it.lookupString }
95-
println(suggestions.map { it })
9695
expectedSuggestions.forEach { expected ->
9796
assertTrue(
9897
"Expected '$expected' in completion suggestions: $suggestions",

0 commit comments

Comments
 (0)