Search in sources :

Example 6 with DomElementProblemDescriptor

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

the class DomElementsGroupNode method hasErrors.

private boolean hasErrors() {
    if (!myParentElement.isValid())
        return false;
    for (DomElement domElement : myChildDescription.getStableValues(myParentElement)) {
        final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(getProject());
        final DomElementsProblemsHolder holder = annotationsManager.getCachedProblemHolder(domElement);
        final List<DomElementProblemDescriptor> problems = holder.getProblems(domElement, true, HighlightSeverity.ERROR);
        if (problems.size() > 0)
            return true;
    }
    return false;
}
Also used : DomElementsProblemsHolder(com.intellij.util.xml.highlighting.DomElementsProblemsHolder) DomElement(com.intellij.util.xml.DomElement) DomElementProblemDescriptor(com.intellij.util.xml.highlighting.DomElementProblemDescriptor) DomElementAnnotationsManager(com.intellij.util.xml.highlighting.DomElementAnnotationsManager)

Example 7 with DomElementProblemDescriptor

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

the class ComboControl method updateComponent.

@Override
protected void updateComponent() {
    final DomElement domElement = getDomElement();
    if (domElement == null || !domElement.isValid())
        return;
    final JComboBox comboBox = getComponent();
    final Project project = getProject();
    ApplicationManager.getApplication().invokeLater(() -> {
        if (!project.isOpen())
            return;
        if (!getDomWrapper().isValid())
            return;
        final DomElement domElement1 = getDomElement();
        if (domElement1 == null || !domElement1.isValid())
            return;
        final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
        final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(domElement1);
        final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(domElement1);
        final List<DomElementProblemDescriptor> warningProblems = holder.getProblems(domElement1, true, HighlightSeverity.WARNING);
        Color background = getDefaultBackground();
        comboBox.setToolTipText(null);
        if (errorProblems.size() > 0) {
            background = getErrorBackground();
            comboBox.setToolTipText(TooltipUtils.getTooltipText(errorProblems));
        } else if (warningProblems.size() > 0) {
            background = getWarningBackground();
            comboBox.setToolTipText(TooltipUtils.getTooltipText(warningProblems));
        }
        final Pair<String, Icon> pair = (Pair<String, Icon>) comboBox.getSelectedItem();
        final String s = pair == null ? null : pair.first;
        background = s != null && s.trim().length() > 0 ? getDefaultBackground() : background;
        comboBox.setBackground(background);
        comboBox.getEditor().getEditorComponent().setBackground(background);
    });
}
Also used : Project(com.intellij.openapi.project.Project) DomElementsProblemsHolder(com.intellij.util.xml.highlighting.DomElementsProblemsHolder) DomElementProblemDescriptor(com.intellij.util.xml.highlighting.DomElementProblemDescriptor) JBColor(com.intellij.ui.JBColor) DomElementAnnotationsManager(com.intellij.util.xml.highlighting.DomElementAnnotationsManager) Pair(com.intellij.openapi.util.Pair)

Example 8 with DomElementProblemDescriptor

use of com.intellij.util.xml.highlighting.DomElementProblemDescriptor 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)

Example 9 with DomElementProblemDescriptor

use of com.intellij.util.xml.highlighting.DomElementProblemDescriptor 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

DomElementProblemDescriptor (com.intellij.util.xml.highlighting.DomElementProblemDescriptor)9 DomElementsProblemsHolder (com.intellij.util.xml.highlighting.DomElementsProblemsHolder)6 DomElementAnnotationsManager (com.intellij.util.xml.highlighting.DomElementAnnotationsManager)5 Project (com.intellij.openapi.project.Project)4 DomElement (com.intellij.util.xml.DomElement)4 ArrayList (java.util.ArrayList)3 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 JavaClassReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReference)1 JavaClassReferenceProvider (com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider)1 XmlElement (com.intellij.psi.xml.XmlElement)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 ProcessingContext (com.intellij.util.ProcessingContext)1 SmartList (com.intellij.util.SmartList)1 DomCollectionProblemDescriptor (com.intellij.util.xml.highlighting.DomCollectionProblemDescriptor)1