Custom Language Support Completion Contributor
Hi!
I am trying to make completion contributor work for my language. Mostly figured out what to do. The weird issue I am having is anytime I start typing, if there is whitespace ahead, the pattern recognizes that I'm currently standing on a whitespace (screenshot below)
however as soon as I get behind the token (in this example, behind the 'f') it understands that I'm currently working with an identifier and my suggestions work correctly. same goes for when I actually get to a property implementation (finish writing field - from the current 'f'), while giving name to the property my context is yet again whitespace
so is there a way to tell it to recognize what is on the left of my cursor and not on the right? (don't know whether left or right is the correctly used here). It would fix a lot of my current issues
Please sign in to leave a comment.
Eventually you'll need to tweak the ElementPattern for your CompletionContributor, you can obtain the current invocation element/position etc from passed in CompletionParameters.
Yann Cebron
I understand what you are saying, but I think tweaking ElementPatterns won't affect how intellij interprets my current position in code. I have another language plugin on the side as a reference. There in the exact situation I have screenshot, in the 'CompletionContributor.fillCompletionVariants' method, the porposed position is IDENTIFIER, not identifier on the left and whitespace on the right. So my question was, am I missing something in my grammar, parser definition or anywhere else that could possibly be a reason for that wierd behavior?
P.S I don't want to tweak my ElementPatterns around the fact that my current position is WHITE_SPACE when I am clearly typing out an identifier, inside a property rule :D
Sorry but it's hard to understand what the problem is without debugging the actual code.