How to deal with INTELLIJIDEARULEZZZ in Reference Code Completion?

Answered

I'm implementing Reference Completion by implementing getVariants in class MyReferece.  When testing the code completion by pressing Ctrl+Space after

A = @FO

I'm expecting to complete with, e.g., FOOBAR.  Instead, getVariants is called with label FOINTELLIJIDEARULEZZZ.

I read elsewhere that this is supposed to happen, for whatever reason.

So should I just remove that string?  If so, what's the point really?

5 comments
Comment actions Permalink

See com.intellij.codeInsight.completion.CompletionUtilCore#DUMMY_IDENTIFIER

> A default string that is inserted to the file before completion to guarantee that there'll always be some non-empty element there

0
Comment actions Permalink

Thanks for your answer, Yann.

I know what it is intended for, but WHAT DOES IT MEAN?

Does that magic string in MyReference.getVariants() indicate an error in my grammar?  Why is it appended to already non-empty arguments?  Is it always present in the string argument and should it simply be removed?  Should the magic string be placed into my grammar to help with code completion?

Lastly, if it isn't an error of some kind, I don't get the thing about a non-empty element.  Sure, completion needs  an element, but why is its text important?  Why can't it be "", or at least leave the current value alone?

1
Comment actions Permalink

Sorry for delay.

The chosen text is really random - it just needs to represent something represents a fake "identifier" in the current position for completion contributors to start working. If needed, it can be adjusted to something else/a valid ID in your language via com.intellij.codeInsight.completion.CompletionContributor#beforeCompletion.

0
Comment actions Permalink

I'm also having the same problem. And also understand why it is there for, but how can I avoid it being appended to non empty strings? My workaround is just to filter that but it makes the code a bit dirty. 

0
Comment actions Permalink

Also, I have never had a code completion without that magic string -- am I doing something wrong, or does it work as designed?

1

Please sign in to leave a comment.