public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements JavaLikeQuoteHandler, MultiCharQuoteHandler
myLiteralTokenSet
Constructor and Description |
---|
JavaQuoteHandler() |
Modifier and Type | Method and Description |
---|---|
java.lang.CharSequence |
getClosingQuote(HighlighterIterator iterator,
int offset)
Returns a closing quote for an opening quote placed immediately before offset, or
null when there is no matching quote. |
TokenSet |
getConcatenatableStringTokenTypes() |
java.lang.String |
getStringConcatenationOperatorRepresentation() |
TokenSet |
getStringTokenTypes() |
boolean |
hasNonClosedLiteral(Editor editor,
HighlighterIterator iterator,
int offset)
Called after the quote has been inserted in the editor to check that it belongs
to an empty string literal that has only the opening quote and therefore, can be completed
by inserting the respective closing one.
|
void |
insertClosingQuote(Editor editor,
int offset,
PsiFile file,
java.lang.CharSequence closingQuote)
Should insert the
closingQuote returned from MultiCharQuoteHandler.getClosingQuote(HighlighterIterator, int) into the document. |
boolean |
isAppropriateElementTypeForLiteral(IElementType tokenType) |
boolean |
isClosingQuote(HighlighterIterator iterator,
int offset)
Checks whether there is the closing quote or the last one of the set of closing quotes
of a string literal at the given offset.
|
boolean |
isOpeningQuote(HighlighterIterator iterator,
int offset)
Checks whether there is the opening quote or the last one of the set of opening quotes
of a string literal at the given offset.
|
boolean |
needParenthesesAroundConcatenation(PsiElement element) |
isInsideLiteral, isNonClosedLiteral
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canBeConcatenated
insertClosingQuote
isInsideLiteral
public boolean isOpeningQuote(HighlighterIterator iterator, int offset)
QuoteHandler
isOpeningQuote
in interface QuoteHandler
isOpeningQuote
in class SimpleTokenSetQuoteHandler
iterator
- highlighting iterator at the state corresponding to the offset
offset
- the offset at which the quote was insertedpublic boolean isClosingQuote(HighlighterIterator iterator, int offset)
QuoteHandler
Upon insertion, this method is called before the quote is actually inserted in the editor in order to check whether it's going to be typed over an existing one closing a string literal and, thus, should be omitted (only the caret position will be adjusted in this case).
isClosingQuote
in interface QuoteHandler
isClosingQuote
in class SimpleTokenSetQuoteHandler
iterator
- highlighting iterator at the state corresponding to the offset
offset
- the offset at which the quote is going to be inserted/deletedpublic TokenSet getConcatenatableStringTokenTypes()
getConcatenatableStringTokenTypes
in interface JavaLikeQuoteHandler
public java.lang.String getStringConcatenationOperatorRepresentation()
getStringConcatenationOperatorRepresentation
in interface JavaLikeQuoteHandler
public TokenSet getStringTokenTypes()
getStringTokenTypes
in interface JavaLikeQuoteHandler
public boolean isAppropriateElementTypeForLiteral(IElementType tokenType)
isAppropriateElementTypeForLiteral
in interface JavaLikeQuoteHandler
public boolean needParenthesesAroundConcatenation(PsiElement element)
needParenthesesAroundConcatenation
in interface JavaLikeQuoteHandler
public java.lang.CharSequence getClosingQuote(HighlighterIterator iterator, int offset)
MultiCharQuoteHandler
null
when there is no matching quote.getClosingQuote
in interface MultiCharQuoteHandler
public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset)
QuoteHandler
If both this method and QuoteHandler.isOpeningQuote(HighlighterIterator, int)
return true, the respective closing quote will be inserted automatically.
hasNonClosedLiteral
in interface QuoteHandler
hasNonClosedLiteral
in class SimpleTokenSetQuoteHandler
editor
- an editor instance where the quote was insertediterator
- highlighting iterator at the state corresponding to the offset
offset
- the offset at which the quote was insertedQuoteHandler.isOpeningQuote(HighlighterIterator, int)
public void insertClosingQuote(Editor editor, int offset, PsiFile file, java.lang.CharSequence closingQuote)
MultiCharQuoteHandler
closingQuote
returned from MultiCharQuoteHandler.getClosingQuote(HighlighterIterator, int)
into the document.
Override this method for languages with multi-root PSI.insertClosingQuote
in interface MultiCharQuoteHandler