Code Completion not working
Answered
Hello,
I am building a plugin with Code Completion. The objective is to suggest blocks of code when the user type text. That will work with any language.
For now, I am just trying to add suggestions when the user type. I follow the example online and added a simple code completion provider (you can see it here). In my plugin.xml, I added the following support for JAVA and TEXT (even tried to put "any" in the language).
When I type code, I see my code being triggered (using the Logger output). But I do not see the suggestion being surfaced in the IDE.
Is there something I missed?
Thanks!
Note: code of the extension here: https://github.com/codiga/jetbrains-plugin
Please sign in to leave a comment.
Hello Julien,
It is possible that the code completion suggestion is disabled in your IntelliJ( manually or when using power-saving mode).
So you can check manual code completion by pressing CTRL + SPACE.
Let me know if this helps.
Thanks and regards,
Ajit
Thanks for your message. I checked the settings and auto-completion (basic, type-matching) are all enabled. When triggering, it shows "no suggestion available" while language-based suggestions (not mine) are working.
There can be any number of contributors to code completion and they may add items with different priority, grouping, ... etc. And after that, there could be additional sorting applied to results. Basically, there is no "guarantee" that any item will be shown in completion popup. com.intellij.codeInsight.completion.CompletionContributor javadoc has extensive FAQ on how to debug such situations
Thanks. What I do not understand is why the completion is not showing up when there is no other suggestion. Is there a good example I can rely to to add suggestions to an existing language (let's say Java or Python) I can rely on?
Thanks.
Please try changing https://github.com/codiga/jetbrains-plugin/blob/main/src/main/java/io/codiga/plugins/jetbrains/completion/CodigaCompletion.java#L12 to pass com.intellij.codeInsight.completion.CompletionType#BASIC as first parameter.
Thank you, it worked!