CompletionContributor not work on PsiLiteralExpression

已回答

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!

0

Please try removing:

withLanguage(Language.ANY)  from code

and

language="any" in plugin.xml

0

I have same question, and try it's it still not working.

0

Mario Luo Please create your own thread and link your code.

0

Has this problem been resolved?

0

请先登录再写评论。