Search in sources :

Example 1 with AngularJSTagDescriptor

use of org.angularjs.codeInsight.tags.AngularJSTagDescriptor in project intellij-plugins by JetBrains.

the class AngularJSErrorFilter method shouldHighlightErrorElement.

@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
    final Project project = error.getProject();
    final Language language = error.getLanguage();
    if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null && AngularIndexUtil.hasAngularJS(project)) {
        final PsiFile file = error.getContainingFile();
        PsiErrorElement nextError = error;
        while (nextError != null) {
            if (hasAngularInjectionAt(project, file, nextError.getTextOffset()))
                return false;
            nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
        }
    }
    if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
        final PsiElement parent = error.getParent();
        final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag) parent).getDescriptor() : null;
        return !(descriptor instanceof AngularJSTagDescriptor);
    }
    if (XMLLanguage.INSTANCE.is(language) && error.getErrorDescription().equals(XmlErrorMessages.message("xml.parsing.unexpected.tokens"))) {
        return !error.getParent().getLanguage().is(Angular2HTMLLanguage.INSTANCE);
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) PsiErrorElement(com.intellij.psi.PsiErrorElement) XmlAttribute(com.intellij.psi.xml.XmlAttribute) Language(com.intellij.lang.Language) Angular2HTMLLanguage(org.angularjs.html.Angular2HTMLLanguage) XMLLanguage(com.intellij.lang.xml.XMLLanguage) HTMLLanguage(com.intellij.lang.html.HTMLLanguage) PsiFile(com.intellij.psi.PsiFile) AngularJSTagDescriptor(org.angularjs.codeInsight.tags.AngularJSTagDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

Language (com.intellij.lang.Language)1 HTMLLanguage (com.intellij.lang.html.HTMLLanguage)1 XMLLanguage (com.intellij.lang.xml.XMLLanguage)1 Project (com.intellij.openapi.project.Project)1 PsiElement (com.intellij.psi.PsiElement)1 PsiErrorElement (com.intellij.psi.PsiErrorElement)1 PsiFile (com.intellij.psi.PsiFile)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlTag (com.intellij.psi.xml.XmlTag)1 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)1 AngularJSTagDescriptor (org.angularjs.codeInsight.tags.AngularJSTagDescriptor)1 Angular2HTMLLanguage (org.angularjs.html.Angular2HTMLLanguage)1