use of com.intellij.lang.BracePair in project intellij-elixir by KronicDeth.
the class NonTrivial method findPair.
@Nullable
@Override
public BracePair findPair(boolean left, HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
BracePair pair = super.findPair(left, iterator, fileText, fileType);
if (pair == Paired.DO_END || pair == Paired.FN_END) {
iterator.advance();
if (!iterator.atEnd()) {
IElementType tokenType = iterator.getTokenType();
if (tokenType == ElixirTypes.KEYWORD_PAIR_COLON) {
pair = null;
}
}
iterator.retreat();
}
return pair;
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class XmlBraceMatcher method isLBraceToken.
@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;
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class XmlBraceMatcher method isRBraceToken.
@Override
public boolean isRBraceToken(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.getRightBraceType() == tokenType)
return true;
}
}
if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER || tokenType == XmlTokenType.XML_CDATA_END) {
return true;
} else if (tokenType == XmlTokenType.XML_TAG_END) {
final boolean result = findEndTagStart(iterator);
if (isFileTypeWithSingleHtmlTags(fileType)) {
final String tagName = getTagName(fileText, iterator);
if (tagName != null && HtmlUtil.isSingleHtmlTag(tagName)) {
return !result;
}
}
return result;
} else {
return false;
}
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class JavaPairedBraceMatcher method isBrace.
private boolean isBrace(HighlighterIterator iterator, CharSequence fileText, FileType fileType, boolean left) {
final BracePair pair = findPair(left, iterator, fileText, fileType);
if (pair == null)
return false;
final IElementType opposite = left ? JavaTokenType.GT : JavaTokenType.LT;
if ((left ? pair.getRightBraceType() : pair.getLeftBraceType()) != opposite)
return true;
if (fileType != JavaFileType.INSTANCE)
return false;
final IElementType braceElementType = left ? JavaTokenType.LT : JavaTokenType.GT;
int count = 0;
try {
int paired = 1;
while (true) {
count++;
if (left) {
iterator.advance();
} else {
iterator.retreat();
}
if (iterator.atEnd())
break;
final IElementType tokenType = iterator.getTokenType();
if (tokenType == opposite) {
paired--;
if (paired == 0)
return true;
continue;
}
if (tokenType == braceElementType) {
paired++;
continue;
}
if (!Holder.TYPE_TOKENS.contains(tokenType)) {
return false;
}
}
return false;
} finally {
while (count-- > 0) {
if (left) {
iterator.retreat();
} else {
iterator.advance();
}
}
}
}
use of com.intellij.lang.BracePair in project intellij-plugins by JetBrains.
the class CfmlBraceMatcher method isLBraceToken.
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;
}
}
if (!tokenType.getLanguage().equals(CfmlLanguage.INSTANCE)) {
FileType tokenFileType = iterator.getTokenType().getLanguage().getAssociatedFileType();
if (tokenFileType != null && tokenFileType != CfmlFileType.INSTANCE) {
for (FileTypeExtensionPoint<BraceMatcher> ext : Extensions.getExtensions(BraceMatcher.EP_NAME)) {
if (ext.filetype != null && ext.filetype.equals(tokenFileType.getName())) {
return ext.getInstance().isLBraceToken(iterator, fileText, tokenFileType instanceof XmlFileType ? StdFileTypes.HTML : tokenFileType);
}
}
}
}
for (BracePair pair : PAIRS) {
if (pair.getLeftBraceType() == tokenType) {
return true;
}
}
return tokenType.equals(CfmlTokenTypes.OPENER) && (!CfmlUtil.isEndTagRequired(getTagName(fileText, iterator), null) || findEndTag(fileText, iterator));
}
Aggregations