use of com.intellij.lang.PairedBraceMatcher 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.PairedBraceMatcher 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.PairedBraceMatcher 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));
}
use of com.intellij.lang.PairedBraceMatcher in project intellij-plugins by JetBrains.
the class CfmlBraceMatcher method isRBraceToken.
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.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().isRBraceToken(iterator, fileText, tokenFileType instanceof XmlFileType ? StdFileTypes.HTML : tokenFileType);
}
}
}
}
for (BracePair pair : PAIRS) {
if (pair.getRightBraceType() == tokenType)
return true;
}
return ((tokenType.equals(CfmlTokenTypes.CLOSER)) && findBeginTag(fileText, iterator)) || (tokenType.equals(CfmlTokenTypes.R_ANGLEBRACKET) && !CfmlUtil.isEndTagRequired(getTagName(fileText, iterator), null) && !findEndTag(fileText, iterator));
}
use of com.intellij.lang.PairedBraceMatcher in project intellij-plugins by JetBrains.
the class CfmlBraceMatcher method isPairBraces.
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;
}
}
FileType tokenFileType1 = tokenType1.getLanguage().getAssociatedFileType();
FileType tokenFileType2 = tokenType2.getLanguage().getAssociatedFileType();
if (tokenFileType2 != tokenFileType1) {
return false;
}
if (tokenFileType1 != CfmlFileType.INSTANCE && tokenFileType1 != null) {
for (FileTypeExtensionPoint<BraceMatcher> ext : Extensions.getExtensions(BraceMatcher.EP_NAME)) {
if (ext.filetype.equals(tokenFileType1.getName())) {
return ext.getInstance().isPairBraces(tokenType1, tokenType2);
}
}
}
for (BracePair pair : PAIRS) {
if (pair.getLeftBraceType() == tokenType1)
return pair.getRightBraceType() == tokenType2;
if (pair.getRightBraceType() == tokenType1)
return pair.getLeftBraceType() == tokenType2;
}
return (tokenType1.equals(CfmlTokenTypes.OPENER) && tokenType2.equals(CfmlTokenTypes.CLOSER)) || (tokenType1.equals(CfmlTokenTypes.CLOSER) && tokenType2.equals(CfmlTokenTypes.OPENER)) || (tokenType1.equals(CfmlTokenTypes.R_ANGLEBRACKET) && tokenType2.equals(CfmlTokenTypes.OPENER)) || (tokenType1.equals(CfmlTokenTypes.OPENER) && tokenType2.equals(CfmlTokenTypes.R_ANGLEBRACKET));
}
Aggregations