1414import com .intellij .codeInsight .completion .CompletionParameters ;
1515import com .intellij .codeInsight .completion .CompletionProvider ;
1616import com .intellij .codeInsight .completion .CompletionResultSet ;
17+ import com .intellij .codeInsight .completion .CompletionUtil ;
1718import com .intellij .codeInsight .lookup .LookupElementBuilder ;
1819import com .intellij .openapi .diagnostic .Logger ;
1920import com .intellij .openapi .project .Project ;
@@ -42,7 +43,7 @@ protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull
4243
4344 PsiElement currentElement = parameters .getPosition ();
4445
45- LOG .info ("currentElement: " + currentElement .getText ());
46+ LOG .info ("currentElement: " + currentElement + " text: " + currentElement .getText ());
4647
4748 Project project = currentElement .getProject ();
4849
@@ -351,15 +352,20 @@ private void scanFields(@NotNull CompletionParameters parameters, GoCallableDesc
351352 comment = GoDocumentationProvider .getCommentText (GoDocumentationProvider .getCommentsForElement (field ), false );
352353 }
353354
354- addElement (result , column , comment , type , goTypeSpec );
355+ GoStringLiteral goStringLiteral = (GoStringLiteral ) parameters .getPosition ().getParent ();
356+ String currentString = goStringLiteral .getDecodedText ().replace (CompletionUtil .DUMMY_IDENTIFIER , "" );
357+
358+ if (column != null && !column .contains (currentString .trim ())) continue ;
359+
360+ addElement (parameters , result , column , comment , type , goTypeSpec );
355361
356362 if (!(parameters .getPosition ().getParent ().getParent () instanceof GoKey )) {
357363 Map <GoCallableDescriptor , List <String >> queryExpr = queryExpr ();
358364 if (queryExpr != null ) {
359365 List <String > whereExpr = queryExpr .get (descriptor );
360366 if (whereExpr != null ) {
361367 for (String s : whereExpr ) {
362- addElement (result , String .format (s , column ), comment , type , goTypeSpec );
368+ addElement (parameters , result , String .format (s , column ), comment , type , goTypeSpec );
363369 }
364370 }
365371 }
@@ -368,7 +374,7 @@ private void scanFields(@NotNull CompletionParameters parameters, GoCallableDesc
368374 }
369375 }
370376
371- private void addElement (@ NotNull CompletionResultSet result , String column , String comment , String type , @ NotNull GoTypeSpec goTypeSpec ) {
377+ private void addElement (@ NotNull CompletionParameters parameters , @ NotNull CompletionResultSet result , String column , String comment , String type , @ NotNull GoTypeSpec goTypeSpec ) {
372378 LookupElementBuilder builder = LookupElementBuilder
373379 .createWithSmartPointer (column , goTypeSpec )
374380 .withPresentableText (column )
0 commit comments