How do I turn off superfluous code completion lex/parse?

Just when I think I have tricked intellij into accepting that I want to ignore that auto completion string INTELLIJ_IDEA_RULEZ, something else goes wrong. I might have to accept defeat, given that I have beaten my head against this for over a week now.

My problems would go away if intellij simply did not invoke a second lexer and parser for auto completion when it doesn't need to. Aside from being inefficient, it sends me things I don't want to parse. My token nodes are trivial and should in no way insist upon auto completion:

public class PreviewTokenNode extends LeafPsiElement {
      public PreviewTokenNode(IElementType type, CharSequence text) {
           super(type, text);

      public String getName() {
           return getText();

there is no getRef, getVariant, named element... any of that stuff. There is nothing in my plugin.xml that would make it do that as far as I can tell. This is all I have in there related to the preview window:

   <lang.ast.factory language="PreviewParserInput"
   <lang.parserDefinition language="PreviewParserInput"

Does anybody know how I can turn off auto completion completely? There are so many threads going on, doing invokeLater, that I can't look back up in the stack to figure out who is triggering the second parse.

Comment actions Permalink

Hi Terence,

Second lexing/parsing is invoked just after inserting DUMMY_IDENTIFIER (com.intellij.codeInsight.completion.CodeCompletionHandlerBase#insertDummyIdentifier). AFAIK there is no posibility to disable it at all. Maybe it makes sense do not copy file if you override DUMMY_IDENTIFIER with empty string, but this approach should be investigated and you still have no any garantees that any other plugin doesn't provide extra completion for your context.

Comment actions Permalink

Essentially, since any plugin can provide completion variants for any file, it's not your business to decide that you don't want code completion; even if you don't have any completion variants, some other plugin may have. And the only way for IntelliJ IDEA to check whether it's the case is to create a copy of the file, add the identifier, and then query the registered completion contributors to see whether any of them match the context.

Comment actions Permalink

Hi Dmitry, thanks. Yes,I can see how it cannot be disabled because other people may want it in their plug-ins.

I have solved this whole issue after 10 days of banging my head against the internal parsing infrastructure by simply avoiding it completely and doing my own tooltips and text annotation. That only took a few hours ;) The infrastructure you have is excellent, though force fitting ANTLR into it has been challenging to say the least. This last problem of hooking in an arbitrary language over which I do not have control, proved too difficult so I simply re-implemented your annotation functionality for ANTLR parser stuff. The other infrastructure you have for pop-ups and hints and so on is very easy to understand so I just went that route.


Please sign in to leave a comment.