Quote handler in template language
I developed plugin for template language (HTML + HTL) and can't get QuoteHandler working.
I extended SimpleTokenSetQuoteHandler:
public class HtlQuoteHandler extends SimpleTokenSetQuoteHandler {
public HtlQuoteHandler() {
super(HtlTokenTypes.SINGLE_QUOTED_STRING, HtlTokenTypes.DOUBLE_QUOTED_STRING);
}
}
and registered it in plugin.xml:
<quoteHandler fileType="HTL" className="HtlQuoteHandler"/>
I also tried to register it in the following way:
<lang.quoteHandler language="HTL" implementationClass="HtlQuoteHandler"/>
Is there anything special I need to do to get QuoteHandler working for template language?
请先登录再写评论。
Try to debug com.intellij.codeInsight.editorActions.TypedHandler#handleQuote method while typing a quote in HTL content.
EDIT: Solved. I checked how JSON lexer is built and noticed, that string token has optional ending quote. It allows to tokenize unclosed strings. I did the same in my lexer and it works now.
Thanks, it was very helpful, but I still don't know how to solve it.
My string tokens are declared as regexps for entire string with start quote, content and end quote (eg. 'some string' or "some string"). It seems that if I type start quote, then lexer recognizes it as BAD_CHARACTER and this if statement (SimpleTokenSetQuoteHandler):
public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
if (myLiteralTokenSet.contains(iterator.getTokenType())){
int start = iterator.getStart();
return offset == start;
}
return false;
}
returns false. Are additional token types for ' and " required here or it can be done with tokens for entire strings?