use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class ComponentTree method getHighlightDisplayLevel.
@Nullable
private static HighlightDisplayLevel getHighlightDisplayLevel(Project project, RadComponent component) {
HighlightDisplayLevel displayLevel = null;
SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
for (ErrorInfo errorInfo : RadComponent.getError(component)) {
if (displayLevel == null || severityRegistrar.compare(errorInfo.getLevel().getSeverity(), displayLevel.getSeverity()) > 0) {
displayLevel = errorInfo.getLevel();
}
}
return displayLevel;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class ComponentTree method getAttributeWrapper.
private AttributeWrapper getAttributeWrapper(RadComponent component) {
AttributeWrapper wrapper = AttributeWrapper.DEFAULT;
final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component);
if (level != null) {
TextAttributesKey attributesKey = SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey();
final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
wrapper = new AttributeWrapper() {
@Override
public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) {
Color bgColor = textAttributes.getBackgroundColor();
try {
textAttributes.setBackgroundColor(null);
return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(), textAttributes));
} finally {
textAttributes.setBackgroundColor(bgColor);
}
}
};
}
return wrapper;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class InspectionValidatorWrapper method reportProblems.
private boolean reportProblems(CompileContext context, Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap) {
if (problemsMap.isEmpty()) {
return false;
}
boolean errorsReported = false;
for (Map.Entry<ProblemDescriptor, HighlightDisplayLevel> entry : problemsMap.entrySet()) {
ProblemDescriptor problemDescriptor = entry.getKey();
final PsiElement element = problemDescriptor.getPsiElement();
final PsiFile psiFile = element.getContainingFile();
if (psiFile == null)
continue;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null)
continue;
final CompilerMessageCategory category = myValidator.getCategoryByHighlightDisplayLevel(entry.getValue(), virtualFile, context);
final Document document = myPsiDocumentManager.getDocument(psiFile);
final int offset = problemDescriptor.getStartElement().getTextOffset();
assert document != null;
final int line = document.getLineNumber(offset);
final int column = offset - document.getLineStartOffset(line);
context.addMessage(category, problemDescriptor.getDescriptionTemplate(), virtualFile.getUrl(), line + 1, column + 1);
if (CompilerMessageCategory.ERROR == category) {
errorsReported = true;
}
}
return errorsReported;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class InspectionValidatorWrapper method runXmlFileSchemaValidation.
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));
final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
for (ExternalAnnotator<?, ?> annotator : annotators) {
processAnnotator(xmlFile, holder, annotator);
}
if (!holder.hasAnnotations())
return Collections.emptyMap();
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<>();
for (final Annotation annotation : holder) {
final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
if (info.getSeverity() == HighlightSeverity.INFORMATION)
continue;
final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
if (startElement == null || endElement == null)
continue;
final ProblemDescriptor descriptor = myInspectionManager.createProblemDescriptor(startElement, endElement, info.getDescription(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR ? HighlightDisplayLevel.ERROR : HighlightDisplayLevel.WARNING;
problemsMap.put(descriptor, level);
}
return problemsMap;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class SuppressForTestsScopeFix method addRemoveTestsScope.
private void addRemoveTestsScope(Project project, boolean add) {
final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final String shortName = myInspection.getShortName();
final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
if (tool == null) {
return;
}
if (add) {
final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
profile.addScope(tool, namedScope, level, false, project);
} else {
profile.removeScope(shortName, "Tests", project);
}
profile.scopesChanged();
}
Aggregations