I'm having an issue with quote handling in my custom language plugin. I realize that there are MANY potential contributing factors, but I'll explain the behavior and share my findings so far in hopes that it's enough to drive some guidance on how it might be resolved.
Basically if you have a line like:
String str = foo;
which you change to:
String str = 'foo;
String str = 'foo';
by adding quotes at the beginning and end of the desired string respectively, all is well. However, if you do the same thing with:
String str = foo.bar;
then when you try to add the closing quote, it doubles the quote and doesn't highlight the actual string literal properly:
String str = 'foo.bar'';
Looking at PsiViewer, 'foo.bar' is properly recognized by my lexer/parser as a string literal, and if you cut/paste the string literal it highlights properly, so it seems to be an issue with the highlighter.
To add some substance to that assertion, stepping through the code in my SimpleTokenSetQuoteHandler implementation I'm seeing that in the former/working case isOpeningQuote() is passed a HighlighterIterator with a text range that includes the full quote ('foo') and returns false, but in the latter/broken case it's passed a HighlighterIterator with a text range that includes only the just-typed closing quote and returns true, hence the doubled quotes. It thinks it's auto-closing a new string literal.
So obviously the issue is that the HighlighterIterator is being computed improperly in the latter case, but I'm not sure what options are available for me to control how that determines the range. My hope/guess is that it's just a matter of implementing some EP properly, but I'm not sure which one to implement.