Search in sources :

Example 1 with XmlFileType

use of com.intellij.ide.highlighter.XmlFileType 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));
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PairedBraceMatcher(com.intellij.lang.PairedBraceMatcher) PairedBraceMatcher(com.intellij.lang.PairedBraceMatcher) BraceMatcher(com.intellij.codeInsight.highlighting.BraceMatcher) XmlFileType(com.intellij.ide.highlighter.XmlFileType) FileType(com.intellij.openapi.fileTypes.FileType) CfmlFileType(com.intellij.coldFusion.model.files.CfmlFileType) BracePair(com.intellij.lang.BracePair) XmlFileType(com.intellij.ide.highlighter.XmlFileType)

Example 2 with XmlFileType

use of com.intellij.ide.highlighter.XmlFileType 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));
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PairedBraceMatcher(com.intellij.lang.PairedBraceMatcher) PairedBraceMatcher(com.intellij.lang.PairedBraceMatcher) BraceMatcher(com.intellij.codeInsight.highlighting.BraceMatcher) XmlFileType(com.intellij.ide.highlighter.XmlFileType) FileType(com.intellij.openapi.fileTypes.FileType) CfmlFileType(com.intellij.coldFusion.model.files.CfmlFileType) BracePair(com.intellij.lang.BracePair) XmlFileType(com.intellij.ide.highlighter.XmlFileType)

Aggregations

BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)2 CfmlFileType (com.intellij.coldFusion.model.files.CfmlFileType)2 XmlFileType (com.intellij.ide.highlighter.XmlFileType)2 BracePair (com.intellij.lang.BracePair)2 PairedBraceMatcher (com.intellij.lang.PairedBraceMatcher)2 FileType (com.intellij.openapi.fileTypes.FileType)2 IElementType (com.intellij.psi.tree.IElementType)2