Search in sources :

Example 6 with DomElementsProblemsHolder

use of com.intellij.util.xml.highlighting.DomElementsProblemsHolder in project intellij-community by JetBrains.

the class BaseDomElementNode method doUpdate.

@Override
protected void doUpdate() {
    if (!myDomElement.isValid())
        return;
    final Project project = myDomElement.getManager().getProject();
    if (project.isDisposed())
        return;
    setUniformIcon(getNodeIcon());
    clearColoredText();
    final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
    final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(myDomElement);
    final List<DomElementProblemDescriptor> problems = holder.getProblems(myDomElement, highlightIfChildrenHaveProblems(), HighlightSeverity.ERROR);
    if (problems.size() > 0) {
        final String toolTip = TooltipUtils.getTooltipText(problems);
        addColoredFragment(getNodeName(), toolTip, getWavedAttributes(SimpleTextAttributes.STYLE_PLAIN));
        if (isShowContainingFileInfo()) {
            addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", toolTip, SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
    } else if (myDomElement.getXmlTag() == null && !(myDomElement instanceof DomFileElement)) {
        addColoredFragment(getNodeName(), folder ? SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
    } else if (folder) {
        addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        final int childrenCount = getChildren().length;
        addColoredFragment(" (" + childrenCount + ')', SimpleTextAttributes.GRAY_ATTRIBUTES);
    } else {
        addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
        if (isShowContainingFileInfo()) {
            addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DomElementsProblemsHolder(com.intellij.util.xml.highlighting.DomElementsProblemsHolder) DomElementProblemDescriptor(com.intellij.util.xml.highlighting.DomElementProblemDescriptor) DomElementAnnotationsManager(com.intellij.util.xml.highlighting.DomElementAnnotationsManager)

Aggregations

DomElementProblemDescriptor (com.intellij.util.xml.highlighting.DomElementProblemDescriptor)6 DomElementsProblemsHolder (com.intellij.util.xml.highlighting.DomElementsProblemsHolder)6 DomElementAnnotationsManager (com.intellij.util.xml.highlighting.DomElementAnnotationsManager)5 Project (com.intellij.openapi.project.Project)3 DomElement (com.intellij.util.xml.DomElement)3 ArrayList (java.util.ArrayList)2 Editor (com.intellij.openapi.editor.Editor)1 MarkupModel (com.intellij.openapi.editor.markup.MarkupModel)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 Pair (com.intellij.openapi.util.Pair)1 XmlTag (com.intellij.psi.xml.XmlTag)1 EditorTextField (com.intellij.ui.EditorTextField)1 JBColor (com.intellij.ui.JBColor)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 Nullable (org.jetbrains.annotations.Nullable)1