use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class PairedBraceMatcherAdapter method findPair.
@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;
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class PairedBraceMatcherAdapter method isStructuralBrace.
@Override
public boolean isStructuralBrace(HighlighterIterator iterator, CharSequence text, FileType fileType) {
final IElementType tokenType = iterator.getTokenType();
final BracePair[] pairs = myMatcher.getPairs();
for (BracePair pair : pairs) {
if (tokenType == pair.getRightBraceType() || tokenType == pair.getLeftBraceType())
return pair.isStructural();
}
return false;
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class XmlBraceMatcher method isStructuralBrace.
@Override
public boolean isStructuralBrace(HighlighterIterator iterator, CharSequence text, FileType fileType) {
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 || pair.getRightBraceType() == tokenType) && pair.isStructural())
return true;
}
}
if (fileType instanceof XmlLikeFileType) {
return isXmlStructuralBrace(iterator, text, fileType, tokenType);
}
return false;
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class XmlBraceMatcher method getBraceTokenGroupId.
@Override
public int getBraceTokenGroupId(IElementType tokenType) {
final Language l = tokenType.getLanguage();
PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l);
if (matcher != null) {
BracePair[] pairs = matcher.getPairs();
for (BracePair pair : pairs) {
if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType) {
return l.hashCode();
}
}
}
if (tokenType instanceof IXmlLeafElementType) {
return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER ? XML_VALUE_DELIMITER_GROUP : XML_TAG_TOKEN_GROUP;
} else {
return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP;
}
}
use of com.intellij.lang.BracePair in project intellij-community by JetBrains.
the class XmlBraceMatcher method isPairBraces.
@Override
public boolean isPairBraces(IElementType tokenType1, IElementType tokenType2) {
PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType1.getLanguage());
if (matcher != null) {
BracePair[] pairs = matcher.getPairs();
for (BracePair pair : pairs) {
if (pair.getLeftBraceType() == tokenType1)
return pair.getRightBraceType() == tokenType2;
if (pair.getRightBraceType() == tokenType1)
return pair.getLeftBraceType() == tokenType2;
}
}
if (tokenType2.equals(PAIRING_TOKENS.get(tokenType1)))
return true;
List<IElementType> keys = PAIRING_TOKENS.getKeysByValue(tokenType1);
return keys != null && keys.contains(tokenType2);
}
Aggregations