"IntellijIdeaRulezzz" vs. "xxx" dummy token in 8.1

The editor creates a dummy token at the position of the cursor when code completion is invoked. This used to be always "IntellijIdeaRulezzz" in 7.0.
Now I saw that for "Basic" code completion (Ctrl-Space) this stayed put, but for "Smart" code completion (Ctrl-Shift-Space) it changed to "xxx".
My code completion logic depends on this value. I didn't find another way to distinguish the dummy token from the other ones. Is this planed to change in the future? Is there another way to identify this token?
Appreciate any hint.
Dan

8 comments
Comment actions Permalink

It was always xxx in smart completion. It can be anything. You can even
change it in CompletionContributor#beforeCompletion(). But first I
advise you to check your code, maybe there's another way of handling the
context that doesn't depend on this identifier. We in IDEA core have
very few usages of the dummy identifiers, they just don't influence us.
Most often completion variants depend on the left context, where there's
no dummy identifiers.

0
Comment actions Permalink

Many thanks Peter! This gives me a lot of flexibility, so I do not need to rely on the dummy identifier.
Btw. think this is a little too flexible ...the CompletionContributor concept. Because you can do a lot wrong as a plugin developer, like affecting all the other languages by returning false from fillCompletionVariants. Just did this mistake myself... :-)

0
Comment actions Permalink

Yes, apparently this API isn't as good as I thought. There are other
problems with it, so it may be changed in Maia.

0
Comment actions Permalink

No no! Not another major redesign. :-)
The concept i find quite ok. Just needs some language context around it I think. At least for the "foreign" code completion contributors.

0
Comment actions Permalink

Certainly not major, but I'm not sure about bytecode compatibility. For
example, make contributors return void instead of boolean.

And if we'll require some language context (which is certainly a good
idea, but not easy to implement), that will also break all the existing
contributors.

0
Comment actions Permalink

Just learned that CompletionContributor#beforeCompletion() is not a bullet proof solution for changing the dummy token. This may be overruled by another contributor, hence the last contributor called "wins". Is there a certain logic for sorting the contributors? I'm just wondering because of the "from" parameter of CompletionService#getVariantsFromContributors(). The method seems to be considering only the contributors after the given "from" contributor, unless null is provided. What is the logic of this?

0
Comment actions Permalink

The ordering rule for completion contributors is the same as for any other extensions. Any extension can have an id and order attributes, where the latter may specify "before <id>, after <id>, first, last". I agree about non-bullet-proof solution, here's another place where we rely on the plugin developers.

CompletionService#getVariantsFromContributors() behaves that way since it makes the possible to look what other contributors (which go after the active one) can contribute, analyze it, possibly change a bit, and return something depending on them. This has several nice usages.

0
Comment actions Permalink

Thanks Peter. The hint with the sorting was helpful. Alternatively i could have sorted the array of contributors programmatically, which would have been a bit intrusive i think.

0

Please sign in to leave a comment.