CompletionContributor not work on PsiLiteralExpression
Answered
I wanna to auto complete when I am typing on a string literal, but it can't work. I found that the fillCompletionVariants method is not called. What's wrong?
Just like when I type "a", it will show "aaa", "abc" and "abb".
private void action() {
String[] names = {"aaa", "abc", "abb"};
String name = "a";
}
@Slf4j
public class MyCompletionContributor extends CompletionContributor {
public MyCompletionContributor() {
log.info("MyCompletionContributor");
extend(CompletionType.BASIC,
PlatformPatterns.psiElement(PsiLiteralExpression.class).withLanguage(Language.ANY),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
log.info("addCompletions: {}, {}", parameters, context);
result.addElement(LookupElementBuilder.create("hello"));
}
});
}
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
log.info("fillCompletionVariants: {}, {}", parameters, result);
super.fillCompletionVariants(parameters, result);
}
}
<completion.contributor order="first" language="any" implementationClass="org.dependcode.dependcodeplugin.MyCompletionContributor"/>
Can anybody help me? Thanks very much!
Please sign in to leave a comment.
Please try removing:
withLanguage(Language.ANY) from code
and
language="any" in plugin.xml
I have same question, and try it's it still not working.
Mario Luo Please create your own thread and link your code.
Has this problem been resolved?