Search in sources :

Example 96 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.

the class ActionLinkReferenceProviderTest method checkActionReference.

/**
   * Checks the Action-reference.
   *
   * @param filename   File to check.
   * @param actionName Name of the Action to resolve to.
   * @throws Throwable On errors.
   */
private void checkActionReference(@NonNls final String filename, @NonNls final String actionName) {
    final PsiReference psiReference = myFixture.getReferenceAtCaretPositionWithAssertion(filename);
    final PsiElement psiElement = psiReference.resolve();
    assertNotNull("no resolve element " + actionName, psiElement);
    assertTrue(psiElement instanceof XmlTag);
    final DomElement actionElement = DomManager.getDomManager(getProject()).getDomElement((XmlTag) psiElement);
    assertNotNull(actionElement);
    assertInstanceOf(actionElement, Action.class);
    assertEquals("Action name differs for " + actionName, actionName, ((Action) actionElement).getName().getStringValue());
}
Also used : Action(com.intellij.struts2.dom.struts.action.Action) DomElement(com.intellij.util.xml.DomElement) PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 97 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.

the class StructureViewTreeElement method getTextAttributesKey.

/**
   * Highlight invalid elements with red underwave.
   *
   * @return null if no errors.
   */
@Nullable
@Override
public TextAttributesKey getTextAttributesKey() {
    final DomElement element = getElement();
    if (!element.isValid()) {
        return null;
    }
    final XmlTag tag = element.getXmlTag();
    if (tag == null) {
        return null;
    }
    final DomElementsProblemsHolder holder = DomElementAnnotationsManager.getInstance(tag.getProject()).getCachedProblemHolder(element);
    final List<DomElementProblemDescriptor> problems = holder.getProblems(element, true, HighlightSeverity.ERROR);
    if (!problems.isEmpty()) {
        return CodeInsightColors.ERRORS_ATTRIBUTES;
    }
    return null;
}
Also used : DomElementsProblemsHolder(com.intellij.util.xml.highlighting.DomElementsProblemsHolder) DomElement(com.intellij.util.xml.DomElement) DomElementProblemDescriptor(com.intellij.util.xml.highlighting.DomElementProblemDescriptor) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DomElement (com.intellij.util.xml.DomElement)97 XmlTag (com.intellij.psi.xml.XmlTag)34 PsiElement (com.intellij.psi.PsiElement)19 Nullable (org.jetbrains.annotations.Nullable)19 NotNull (org.jetbrains.annotations.NotNull)15 Project (com.intellij.openapi.project.Project)11 PsiFile (com.intellij.psi.PsiFile)11 XmlFile (com.intellij.psi.xml.XmlFile)11 XmlAttribute (com.intellij.psi.xml.XmlAttribute)10 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)9 ArrayList (java.util.ArrayList)8 LayoutViewElement (org.jetbrains.android.dom.layout.LayoutViewElement)7 ResourceElement (org.jetbrains.android.dom.resources.ResourceElement)6 DomManager (com.intellij.util.xml.DomManager)5 Style (org.jetbrains.android.dom.resources.Style)5 AntDomTarget (com.intellij.lang.ant.dom.AntDomTarget)4 XmlElement (com.intellij.psi.xml.XmlElement)4 DomElementProblemDescriptor (com.intellij.util.xml.highlighting.DomElementProblemDescriptor)4 LookupElement (com.intellij.codeInsight.lookup.LookupElement)3 TextRange (com.intellij.openapi.util.TextRange)3