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;
}
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);
});
}
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);
}
}
}
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;
}
Aggregations