Search in sources :

Example 1 with HtmlDocumentImpl

use of com.intellij.psi.impl.source.html.HtmlDocumentImpl in project intellij-community by JetBrains.

the class HtmlUtil method isHtmlTagContainingFile.

public static boolean isHtmlTagContainingFile(PsiElement element) {
    if (element == null) {
        return false;
    }
    final PsiFile containingFile = element.getContainingFile();
    if (containingFile != null) {
        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
        if (tag instanceof HtmlTag) {
            return true;
        }
        final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false);
        if (document instanceof HtmlDocumentImpl) {
            return true;
        }
        final FileViewProvider provider = containingFile.getViewProvider();
        Language language;
        if (provider instanceof TemplateLanguageFileViewProvider) {
            language = ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage();
        } else {
            language = provider.getBaseLanguage();
        }
        return language == XHTMLLanguage.INSTANCE;
    }
    return false;
}
Also used : TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) XMLLanguage(com.intellij.lang.xml.XMLLanguage) XHTMLLanguage(com.intellij.lang.xhtml.XHTMLLanguage) HTMLLanguage(com.intellij.lang.html.HTMLLanguage) HtmlDocumentImpl(com.intellij.psi.impl.source.html.HtmlDocumentImpl) PsiFile(com.intellij.psi.PsiFile) HtmlTag(com.intellij.psi.html.HtmlTag) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)

Aggregations

Language (com.intellij.lang.Language)1 HTMLLanguage (com.intellij.lang.html.HTMLLanguage)1 XHTMLLanguage (com.intellij.lang.xhtml.XHTMLLanguage)1 XMLLanguage (com.intellij.lang.xml.XMLLanguage)1 FileViewProvider (com.intellij.psi.FileViewProvider)1 PsiFile (com.intellij.psi.PsiFile)1 HtmlTag (com.intellij.psi.html.HtmlTag)1 HtmlDocumentImpl (com.intellij.psi.impl.source.html.HtmlDocumentImpl)1 TemplateLanguageFileViewProvider (com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider)1