@Override public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) { BracePair pair = findPair(false, iterator, fileText, fileType); if (pair == null) return false; if (pair.getRightBraceType() != AppleScriptTypes.END) return super.isRBraceToken(iterator, fileText, fileType);//true; boolean result = false; int count = 0; while (true) { iterator.retreat(); count++; if (iterator.atEnd()) break; IElementType eType = iterator.getTokenType(); if (eType == AppleScriptTypes.NLS || eType == AppleScriptTypes.BLOCK_BODY) result = true; else break; } while (count-- > 0) iterator.advance(); return result; }
private static int calcParensBalance(Document document, EditorHighlighter highlighter, int rangeStart, int rangeEnd){ LOG.assertTrue(0 <= rangeStart); LOG.assertTrue(rangeStart <= rangeEnd); LOG.assertTrue(rangeEnd <= document.getTextLength()); HighlighterIterator iterator = highlighter.createIterator(rangeStart); int balance = 0; while(!iterator.atEnd() && iterator.getStart() < rangeEnd){ IElementType tokenType = iterator.getTokenType(); if (tokenType == JavaTokenType.LPARENTH){ balance++; } else if (tokenType == JavaTokenType.RPARENTH){ balance--; } iterator.advance(); } return balance; }
@Override public boolean isClosingQuote(HighlighterIterator iterator, int offset) { boolean closingQuote = super.isClosingQuote(iterator, offset); if (closingQuote) { // check escape next if (!iterator.atEnd()) { iterator.advance(); if (!iterator.atEnd() && StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(iterator.getTokenType())) { closingQuote = false; } iterator.retreat(); } } return closingQuote; }
public void testCpp() throws Exception { EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp"); // 0123456789012345678 9 0123 45 6 7 highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\""); HighlighterIterator iterator = highlighter.createIterator(2); assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); iterator = highlighter.createIterator(9); assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType()); iterator = highlighter.createIterator(15); assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); iterator = highlighter.createIterator(19); assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(23); assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(25); assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(27); assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType()); }
private static boolean findEndTagStart(HighlighterIterator iterator) { IElementType tokenType = iterator.getTokenType(); int balance = 0; int count = 0; while(balance >= 0){ iterator.retreat(); count++; if (iterator.atEnd()) break; tokenType = iterator.getTokenType(); if (tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END){ balance++; } else if (tokenType == XmlTokenType.XML_END_TAG_START || tokenType == XmlTokenType.XML_START_TAG_START){ balance--; } } while(count-- > 0) iterator.advance(); return tokenType == XmlTokenType.XML_END_TAG_START; }
private static boolean handleBetweenSquareBraces(Editor editor, int caret, DataContext context, Project project, EditorActionHandler originalHandler) { String text = editor.getDocument().getText(); if (text == null || text.isEmpty()) return false; final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); if (caret < 1 || caret > text.length() - 1) { return false; } HighlighterIterator iterator = highlighter.createIterator(caret - 1); if (GroovyTokenTypes.mLBRACK == iterator.getTokenType()) { if (text.length() > caret) { iterator = highlighter.createIterator(caret); if (GroovyTokenTypes.mRBRACK == iterator.getTokenType()) { originalHandler.execute(editor, context); originalHandler.execute(editor, context); editor.getCaretModel().moveCaretRelatively(0, -1, false, false, true); insertSpacesByGroovyContinuationIndent(editor, project); return true; } } } return false; }
private static void processWords(Editor editor, int startOffset, TokenProcessor processor) { CharSequence chars = editor.getDocument().getCharsSequence(); HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(startOffset); while (!iterator.atEnd()) { int start = iterator.getStart(); int end = iterator.getEnd(); while (start < end) { int wordStart = start; while (wordStart < end && !isWordPart(chars.charAt(wordStart))) wordStart++; int wordEnd = wordStart; while (wordEnd < end && isWordPart(chars.charAt(wordEnd))) wordEnd++; if (wordEnd > wordStart && containsLettersOrDigits(chars, wordStart, wordEnd) && !processor.processToken(wordStart, wordEnd)) { return; } start = wordEnd + 1; } iterator.advance(); } }
@Override protected boolean isNonClosedLiteral(HighlighterIterator iterator, CharSequence chars) { int end = iterator.getEnd(); if (getLiteralStartOffset(chars, iterator.getStart()) >= end - 1) { return true; } char endSymbol = chars.charAt(end - 1); if (endSymbol != '"' && endSymbol != '\'') { return true; } //for triple quoted string if (end >= 3 && (endSymbol == chars.charAt(end - 2)) && (chars.charAt(end - 2) == chars.charAt(end - 3)) && (end < 4 || chars.charAt(end - 4) != endSymbol)) { return true; } return false; }
@Override public boolean isClosingQuote(HighlighterIterator iterator, int offset) { final IElementType tokenType = iterator.getTokenType(); if (myLiteralTokenSet.contains(tokenType)) { int start = iterator.getStart(); int end = iterator.getEnd(); if (end - start >= 1 && offset == end - 1) { Document doc = iterator.getDocument(); if (doc == null) return false; CharSequence chars = doc.getCharsSequence(); if (chars.length() > offset + 1) { Character ch = chars.charAt(offset + 1); if (Arrays.binarySearch(ourAutoClosingChars, ch) < 0) return false; } return true; } } return false; }
private void highlightScope(int offset, @NotNull FileType fileType) { if (myEditor.getFoldingModel().isOffsetCollapsed(offset)) return; if (myEditor.getDocument().getTextLength() <= offset) return; HighlighterIterator iterator = getEditorHighlighter().createIterator(offset); final CharSequence chars = myDocument.getCharsSequence(); if (!BraceMatchingUtil.isStructuralBraceToken(fileType, iterator, chars)) { // if (BraceMatchingUtil.isRBraceTokenToHighlight(myFileType, iterator) || BraceMatchingUtil.isLBraceTokenToHighlight(myFileType, iterator)) return; } else { if (BraceMatchingUtil.isRBraceToken(iterator, chars, fileType) || BraceMatchingUtil.isLBraceToken(iterator, chars, fileType)) return; } if (!BraceMatchingUtil.findStructuralLeftBrace(fileType, iterator, chars)) { removeLineMarkers(); return; } highlightLeftBrace(iterator, true, fileType); }
private static boolean isAtTheEndOfEmptyTag(Project project, Editor editor, PsiFile file, HighlighterIterator iterator) { if (iterator.getTokenType() != XmlTokenType.XML_TAG_END) { return false; } PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); final PsiElement element = file.findElementAt(iterator.getStart()); if (element == null) { return false; } final PsiElement parent = element.getParent(); return parent instanceof XmlTag && parent.getTextRange().getEndOffset() == iterator.getEnd(); }
public void testIteratorEnd() { HighlighterIterator iterator = myHighlighter.createIterator(0); assertFalse(iterator.atEnd()); iterator.retreat(); assertTrue(iterator.atEnd()); iterator.advance(); assertFalse(iterator.atEnd()); iterator.advance(); assertFalse(iterator.atEnd()); iterator.advance(); assertFalse(iterator.atEnd()); iterator.advance(); assertTrue(iterator.atEnd()); iterator.advance(); assertTrue(iterator.atEnd()); }
@Override public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) { try { Document doc = editor.getDocument(); CharSequence chars = doc.getCharsSequence(); int lineEnd = doc.getLineEndOffset(doc.getLineNumber(offset)); while (!iterator.atEnd() && iterator.getStart() < lineEnd) { if (isQuotedToken(iterator.getTokenType())) { if (iterator.getStart() >= iterator.getEnd() - 1 || chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') { return true; } } iterator.advance(); } } finally { while (!iterator.atEnd() && iterator.getStart() != offset) iterator.retreat(); } return false; }
@Override public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) { final IElementType tokenType = iterator.getTokenType(); if (tokenType == GroovyTokenTypes.mSTRING_LITERAL || tokenType == GroovyTokenTypes.mGSTRING_BEGIN || tokenType == GroovyTokenTypes.mGSTRING_LITERAL || tokenType == GroovyTokenTypes.mGSTRING_CONTENT) { final Document document = iterator.getDocument(); if (document == null) return false; final String literal = document.getText().substring(iterator.getStart(), offset + 1); if ("'''".equals(literal) || "\"\"\"".equals(literal) || "'".equals(literal) || "\"".equals(literal)) { return true; } } return !(tokenType == GroovyTokenTypes.mGSTRING_CONTENT || tokenType == GroovyTokenTypes.mGSTRING_LITERAL || tokenType == GroovyTokenTypes.mSTRING_LITERAL || tokenType == GroovyTokenTypes.mGSTRING_END); }
@Override public boolean isOpeningQuote(HighlighterIterator iterator, int offset) { if (!myLiteralTokenSet.contains(iterator.getTokenType())) { return false; } int start = iterator.getStart(); if (offset == start) { return true; } final Document document = iterator.getDocument(); if (document == null) { return false; } CharSequence text = document.getCharsSequence(); char theQuote = text.charAt(offset); if (offset >= 2 && text.charAt(offset - 1) == theQuote && text.charAt(offset - 2) == theQuote && (offset < 3 || text.charAt(offset - 3) != theQuote)) { if (super.isOpeningQuote(iterator, offset)) { return true; } } return false; }
private static boolean isAtTokenNeeded(InsertionContext myContext) { HighlighterIterator iterator = ((EditorEx)myContext.getEditor()).getHighlighter().createIterator(myContext.getStartOffset()); LOG.assertTrue(iterator.getTokenType() == JavaTokenType.IDENTIFIER); iterator.retreat(); if (iterator.getTokenType() == TokenType.WHITE_SPACE) iterator.retreat(); return iterator.getTokenType() != JavaTokenType.AT && iterator.getTokenType() != JavaTokenType.DOT; }
private static int getExistingRParenthOffset(final Editor editor, final int tailOffset) { final Document document = editor.getDocument(); if (tailOffset >= document.getTextLength()) return -1; final CharSequence charsSequence = document.getCharsSequence(); EditorHighlighter highlighter = ((EditorEx) editor).getHighlighter(); int existingRParenthOffset = -1; for(HighlighterIterator iterator = highlighter.createIterator(tailOffset); !iterator.atEnd(); iterator.advance()){ final IElementType tokenType = iterator.getTokenType(); if ((!(tokenType instanceof IJavaElementType) || !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(tokenType)) && tokenType != TokenType.WHITE_SPACE) { final int start = iterator.getStart(); if (iterator.getEnd() == start + 1 && ')' == charsSequence.charAt(start)) { existingRParenthOffset = start; } break; } } if (existingRParenthOffset >= 0){ final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(editor.getProject()); psiDocumentManager.commitDocument(document); TextRange range = getRangeToCheckParensBalance(psiDocumentManager.getPsiFile(document), document, editor.getCaretModel().getOffset()); int balance = calcParensBalance(document, highlighter, range.getStartOffset(), range.getEndOffset()); if (balance > 0){ return -1; } } return existingRParenthOffset; }
@Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final SelectionModel selectionModel = editor.getSelectionModel(); if (!(file instanceof GroovyFileBase)) return false; if (selectionModel.hasSelection()) { final HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(selectionModel.getSelectionStart()); final int end = selectionModel.getSelectionEnd(); while (!iterator.atEnd()) { if (iterator.getTokenType() == GroovyTokenTypes.mSEMI) return true; if (iterator.getStart() > end) return false; iterator.advance(); } return false; } int offset = editor.getCaretModel().getOffset(); if (offset >= editor.getDocument().getTextLength()) offset = editor.getDocument().getTextLength() - 1; final PsiElement element = file.findElementAt(offset); if (element == null) return false; if (element.getNode().getElementType() == GroovyTokenTypes.mSEMI) return true; final PsiElement next = PsiTreeUtil.nextLeaf(element); if (next != null && next.getNode().getElementType() == GroovyTokenTypes.mSEMI) return true; final PsiElement prev = PsiTreeUtil.prevLeaf(element); if (prev != null && prev.getNode().getElementType() == GroovyTokenTypes.mSEMI) return true; return false; }
private void selectItem(HighlighterIterator itr, SyntaxHighlighter highlighter, final boolean select) { IElementType tokenType = itr.getTokenType(); if (tokenType == null) return; String type = ClickNavigator.highlightingTypeFromTokenType(tokenType, highlighter); if (select) { myDispatcher.getMulticaster().selectionInPreviewChanged(type); } }
@Override public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) { final IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage()); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getLeftBraceType() == tokenType) return true; } } return tokenType == XmlTokenType.XML_START_TAG_START || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_CDATA_START; }
public static void handleAfterJavaLT(final Editor editor, final IElementType lt, final IElementType gt, final TokenSet invalidInsideReference) { if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) return; int offset = editor.getCaretModel().getOffset(); HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset); while (iterator.getStart() > 0 && !invalidInsideReference.contains(iterator.getTokenType())) { iterator.retreat(); } if (invalidInsideReference.contains(iterator.getTokenType())) iterator.advance(); int balance = 0; while (!iterator.atEnd() && balance >= 0) { final IElementType tokenType = iterator.getTokenType(); if (tokenType == lt) { balance++; } else if (tokenType == gt) { balance--; } else if (invalidInsideReference.contains(tokenType)) { break; } iterator.advance(); } if (balance == 1) { editor.getDocument().insertString(offset, ">"); } }
@Override public boolean isClosingQuote(HighlighterIterator iterator, int offset) { final IElementType tokenType = iterator.getTokenType(); if (!myLiteralTokenSet.contains(tokenType)) { return false; } int start = iterator.getStart(); int end = iterator.getEnd(); if (end - start >= 1 && offset == end - 1) { return true; // single quote } if (end - start < 3 || offset < end - 3) { return false; } // check for triple quote Document doc = iterator.getDocument(); if (doc == null) { return false; } CharSequence chars = doc.getCharsSequence(); char quote = chars.charAt(start); boolean tripleQuote = quote == chars.charAt(start + 1) && quote == chars.charAt(start + 2); if (!tripleQuote) { return false; } for (int i = offset; i < Math.min(offset + 2, end); i++) { if (quote != chars.charAt(i)) { return false; } } return true; }
public static boolean isClassLikeIdentifier(int offset, Editor editor, HighlighterIterator iterator, final IElementType idType) { if (iterator.getTokenType() == idType && iterator.getEnd() == offset) { final CharSequence chars = editor.getDocument().getCharsSequence(); final char startChar = chars.charAt(iterator.getStart()); if (!Character.isUpperCase(startChar)) return false; final CharSequence word = chars.subSequence(iterator.getStart(), iterator.getEnd()); if (word.length() == 1) return true; for (int i = 1; i < word.length(); i++) { if (Character.isLowerCase(word.charAt(i))) return true; } } return false; }
public void testHaskel() throws Exception { EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.hs"); // 0123456789012345678 9 0123 45 6 7 highlighter.setText("{-# #-} module"); HighlighterIterator iterator = highlighter.createIterator(2); assertEquals(CustomHighlighterTokenType.MULTI_LINE_COMMENT, iterator.getTokenType()); iterator = highlighter.createIterator(12); assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); }
public void testBrokenText() { myFixture.configureByText("a.java", "import java.util.ArrayList;" + "class A {" + " ArrayList<caret><String"); final Editor editor = myFixture.getEditor(); final EditorHighlighter editorHighlighter = ((EditorEx)editor).getHighlighter(); final HighlighterIterator iterator = editorHighlighter.createIterator(editor.getCaretModel().getOffset()); boolean matched = BraceMatchingUtil.matchBrace(editor.getDocument().getCharsSequence(), myFixture.getFile().getFileType(), iterator, true); assertFalse(matched); }
public void testBinaryStatement() { myFixture.configureByText("a.java", "import java.util.ArrayList;" + "class A {" + " int i = 3 <caret>< 4 ? 5 > 6 : 1 : 1 : 1;" + "}"); final Editor editor = myFixture.getEditor(); final EditorHighlighter editorHighlighter = ((EditorEx)editor).getHighlighter(); final HighlighterIterator iterator = editorHighlighter.createIterator(editor.getCaretModel().getOffset()); boolean matched = BraceMatchingUtil.matchBrace(editor.getDocument().getCharsSequence(), myFixture.getFile().getFileType(), iterator, true); assertFalse(matched); }
@NotNull @Override public HighlighterIterator createIterator(int startOffset) { int index = Collections.binarySearch(myPieces, new Element(startOffset, 0, null, null), new Comparator<Element>() { @Override public int compare(Element o1, Element o2) { return o1.getStart() - o2.getStart(); } }); // index: (-insertion point - 1), where insertionPoint is the index of the first element greater than the key // and we need index of the first element that is less or equal (floorElement) if (index < 0) index = Math.max(-index - 2, 0); return new ProxyIterator(myDocument, index, myPieces); }
@NotNull @Override public HighlighterIterator createIterator(int startOffset) { // do NOT synchronize before updateLayers due to deadlock with PsiLock final boolean b = updateLayers(); synchronized (this) { if (b) { setText(myText); } return new LayeredHighlighterIteratorImpl(startOffset); } }
public void restart(@NotNull CharSequence text) { lexer.start(text); if (lexer instanceof LexerEditorHighlighterLexer) { HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator(); if (iterator instanceof LayeredHighlighterIterator) { layeredHighlighterIterator = (LayeredHighlighterIterator)iterator; } else { layeredHighlighterIterator = null; } } }
public void resetPosition(int startOffset) { if (lexer instanceof LexerEditorHighlighterLexer) { ((LexerEditorHighlighterLexer)lexer).resetPosition(startOffset); HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator(); if (iterator instanceof LayeredHighlighterIterator) { layeredHighlighterIterator = (LayeredHighlighterIterator)iterator; } else { layeredHighlighterIterator = null; } } else { CharSequence text = lexer.getBufferSequence(); lexer.start(text, startOffset, text.length()); } }
public static List<IElementType> getAllTokens(EditorHighlighter highlighter) { List<IElementType> tokens = new ArrayList<IElementType>(); HighlighterIterator iterator = highlighter.createIterator(0); while (!iterator.atEnd()) { tokens.add(iterator.getTokenType()); iterator.advance(); } return tokens; }
/** * Finds out whether there's a boundary between two lexemes of different type at given offset. */ public static boolean isLexemeBoundary(@NotNull Editor editor, int offset) { if (!(editor instanceof EditorEx) || offset <= 0 || offset >= editor.getDocument().getTextLength()) return false; if (CharArrayUtil.isEmptyOrSpaces(editor.getDocument().getImmutableCharSequence(), offset - 1, offset + 1)) return false; EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); HighlighterIterator it = highlighter.createIterator(offset); if (it.getStart() != offset) { return false; } IElementType rightToken = it.getTokenType(); it.retreat(); IElementType leftToken = it.getTokenType(); return !Comparing.equal(leftToken, rightToken); }
private static List<BidiRun> createRuns(EditorImpl editor, char[] text, int startOffsetInEditor) { int textLength = text.length; if (editor.myDisableRtl) return Collections.singletonList(new BidiRun((byte)0, 0, textLength)); List<BidiRun> runs = new ArrayList<BidiRun>(); if (startOffsetInEditor >= 0) { // running bidi algorithm separately for text fragments corresponding to different lexer tokens int lastOffset = startOffsetInEditor; IElementType lastToken = null; HighlighterIterator iterator = editor.getHighlighter().createIterator(startOffsetInEditor); int endOffsetInEditor = startOffsetInEditor + textLength; while (!iterator.atEnd() && iterator.getStart() < endOffsetInEditor) { IElementType currentToken = iterator.getTokenType(); if (distinctTokens(lastToken, currentToken)) { int tokenStart = Math.max(iterator.getStart(), startOffsetInEditor); addRuns(runs, text, lastOffset - startOffsetInEditor, tokenStart - startOffsetInEditor); lastToken = currentToken; lastOffset = tokenStart; } iterator.advance(); } addRuns(runs, text, lastOffset - startOffsetInEditor, endOffsetInEditor - startOffsetInEditor); } else { addRuns(runs, text, 0, textLength); } return runs; }
private void paintBorderEffect(Graphics2D g, ClipDetector clipDetector, EditorHighlighter highlighter, int clipStartOffset, int clipEndOffset) { HighlighterIterator it = highlighter.createIterator(clipStartOffset); while (!it.atEnd() && it.getStart() < clipEndOffset) { TextAttributes attributes = it.getTextAttributes(); if (isBorder(attributes)) { paintBorderEffect(g, clipDetector, it.getStart(), it.getEnd(), attributes); } it.advance(); } }
public RangeIterator(Gaps foldingModel, Equality<TextAttributes> equality, HighlighterIterator source, Condition<TextAttributes> filter) { mySource = source; myGaps = foldingModel; myEquality = equality; myFilter = filter; }
private static boolean inCommentOrLiteral(CompletionParameters parameters) { HighlighterIterator iterator = ((EditorEx)parameters.getEditor()).getHighlighter().createIterator(parameters.getOffset()); IElementType elementType = iterator.getTokenType(); if (elementType == CustomHighlighterTokenType.WHITESPACE) { iterator.retreat(); elementType = iterator.getTokenType(); } return elementType == CustomHighlighterTokenType.LINE_COMMENT || elementType == CustomHighlighterTokenType.MULTI_LINE_COMMENT || elementType == CustomHighlighterTokenType.STRING || elementType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING; }
@Nullable public BracePair findPair(boolean left, HighlighterIterator iterator, CharSequence fileText, FileType fileType) { final IElementType tokenType = iterator.getTokenType(); final BracePair[] pairs = myMatcher.getPairs(); for (BracePair pair : pairs) { if (tokenType == (left ? pair.getLeftBraceType() : pair.getRightBraceType())) return pair; } return null; }
private boolean isIdentifierBeforeLParenth() { //<caret>String name= HighlighterIterator iterator = ((EditorEx)myContext.getEditor()).getHighlighter().createIterator(myContext.getStartOffset()); if (iterator.atEnd()) return false; if (iterator.getTokenType() == GroovyTokenTypes.mIDENT) { iterator.advance(); } while (!iterator.atEnd() && TokenSets.WHITE_SPACES_OR_COMMENTS.contains(iterator.getTokenType())) { iterator.advance(); } return !iterator.atEnd() && iterator.getTokenType() == GroovyTokenTypes.mLPAREN; }
@Override public boolean shouldStopMatch(boolean forward, @NotNull IElementType braceType, @NotNull HighlighterIterator iterator) { if (myMatcher instanceof BraceMatcherTerminationAspect) { return ((BraceMatcherTerminationAspect)myMatcher).shouldStopMatch(forward, braceType, iterator); } return false; }
MatchBraceContext(@NotNull CharSequence fileText, @NotNull FileType fileType, @NotNull HighlighterIterator iterator, boolean forward, boolean strict) { this.fileText = fileText; this.fileType = fileType; this.iterator = iterator; this.forward = forward; myMatcher = getBraceMatcher(fileType, iterator); brace1Token = this.iterator.getTokenType(); group = getTokenGroup(brace1Token, this.fileType); brace1TagName = getTagName(myMatcher, this.fileText, this.iterator); isCaseSensitive = areTagsCaseSensitive(myMatcher, this.fileType, group); isStrict = strict; }