CodeCompletion no longer working
I have several CodeCompletion providers that have been working for years now. Since one of the latest IntelliJ updates, one of them no longer shows any results. When I debug the provider, I see that results are added, but they are not shown in the UI.
After a lot of trying I found out, that it is related to the name of the XML attribute. When the name of the XML attribute is “functionGroup”, the completion is not working (although the completion provider is called and returns some values).
As further test, I additionally registered the same completion provider for the attribute “functionGroup1” and it works as expected.
The popup that is shown seems to be broken too, as it only says “No”
In addition, the quotation marks are shown in different colors and when I hover above the red quotation marks, it says “cannot resolve symbol”.
I do not use XSD validation here. Is this a bug in IntelliJ?
Please sign in to leave a comment.
Hi Tom,
Without more details, it's hard to say whether it is a bug. In the repository, I don't see any “functionGroup” occurrences in the code related to XML.
I suggest sharing more context, like the implementation and registration in plugin.xml at least.
Here is the registration in the plugin.xml:
In the constructor of my contributor, I added
extend(null,
PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN).withParent(
PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE_VALUE).withParent(
PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE).withName("functionGroup"))
),
new FunctionGroupCompletionProvider());
I added exactly the same for “functionGroup1”. For this Tag (and any other Tag I tried) it works, but not for “functionGroup”
My provider derives from CompletionProvider<CompletionParameters> and overwrites the “addCompletions” method.
This is how I add the results inside the provider:
completionResultSet.addElement(LookupElementBuilder.create(fktGrpId)
.withIcon(IconLoader.getIcon("/icons/Logo.png", FunctionGroupCompletionProvider.class)));
This line is called multiple times, when I check it in the debugger, but nothing is shown in the IDE. It does not make any difference, whether I already typed anything in the XML-Attribute-Value, or if it is only an empty string, so there should be also no pre-filtering of the results.
Also removing the part with the Icon does not make a difference.
UPDATE:
I think I found the problem myself. It was not directly related to the CompletionProvider but because of a PsiReferenceContributor, which returned a wrong PsiReference in getReferencesByElementInternal Method.
I guess the IDE tried to compare the results from my CompletionProvider with this Reference and did not find anything.