use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class LocalInspectionsPass method highlightInfoFromDescriptor.
@Nullable
private HighlightInfo highlightInfoFromDescriptor(@NotNull ProblemDescriptor problemDescriptor, @NotNull HighlightInfoType highlightInfoType, @NotNull String message, String toolTip, PsiElement psiElement) {
TextRange textRange = ((ProblemDescriptorBase) problemDescriptor).getTextRange();
if (textRange == null || psiElement == null)
return null;
boolean isFileLevel = psiElement instanceof PsiFile && textRange.equals(psiElement.getTextRange());
final HighlightSeverity severity = highlightInfoType.getSeverity(psiElement);
TextAttributes attributes = mySeverityRegistrar.getTextAttributesBySeverity(severity);
HighlightInfo.Builder b = HighlightInfo.newHighlightInfo(highlightInfoType).range(psiElement, textRange.getStartOffset(), textRange.getEndOffset()).description(message).severity(severity);
if (toolTip != null)
b.escapedToolTip(toolTip);
if (attributes != null)
b.textAttributes(attributes);
if (problemDescriptor.isAfterEndOfLine())
b.endOfLine();
if (isFileLevel)
b.fileLevelAnnotation();
if (problemDescriptor.getProblemGroup() != null)
b.problemGroup(problemDescriptor.getProblemGroup());
return b.create();
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class TrafficLightRenderer method updatePanel.
// return true if panel needs to be rebuilt
boolean updatePanel(@NotNull DaemonCodeAnalyzerStatus status, Project project) {
progressBarsEnabled = false;
progressBarsCompleted = null;
statistics = "";
passStatusesVisible = false;
statusLabel = null;
statusExtraLine = null;
boolean result = false;
if (!status.passStati.equals(new ArrayList<>(passes.keySet()))) {
// passes set has changed
rebuildPassesMap(status);
result = true;
}
if (PowerSaveMode.isEnabled()) {
statusLabel = "Code analysis is disabled in power save mode";
status.errorAnalyzingFinished = true;
icon = AllIcons.General.SafeMode;
return result;
}
if (status.reasonWhyDisabled != null) {
statusLabel = "No analysis has been performed";
statusExtraLine = "(" + status.reasonWhyDisabled + ")";
passStatusesVisible = true;
progressBarsCompleted = Boolean.FALSE;
icon = AllIcons.General.InspectionsTrafficOff;
return result;
}
if (status.reasonWhySuspended != null) {
statusLabel = "Code analysis has been suspended";
statusExtraLine = "(" + status.reasonWhySuspended + ")";
passStatusesVisible = true;
progressBarsCompleted = Boolean.FALSE;
icon = AllIcons.General.InspectionsPause;
return result;
}
Icon icon = AllIcons.General.InspectionsOK;
for (int i = status.errorCount.length - 1; i >= 0; i--) {
if (status.errorCount[i] > 0) {
icon = SeverityRegistrar.getSeverityRegistrar(project).getRendererIconByIndex(i);
break;
}
}
if (status.errorAnalyzingFinished) {
boolean isDumb = project != null && DumbService.isDumb(project);
if (isDumb) {
statusLabel = "Shallow analysis completed";
statusExtraLine = "Complete results will be available after indexing";
} else {
statusLabel = DaemonBundle.message("analysis.completed");
}
progressBarsCompleted = Boolean.TRUE;
} else {
statusLabel = DaemonBundle.message("performing.code.analysis");
passStatusesVisible = true;
progressBarsEnabled = true;
progressBarsCompleted = null;
}
int currentSeverityErrors = 0;
@org.intellij.lang.annotations.Language("HTML") String text = "";
for (int i = status.errorCount.length - 1; i >= 0; i--) {
if (status.errorCount[i] > 0) {
final HighlightSeverity severity = SeverityRegistrar.getSeverityRegistrar(project).getSeverityByIndex(i);
String name = status.errorCount[i] > 1 ? StringUtil.pluralize(severity.getName().toLowerCase()) : severity.getName().toLowerCase();
text += status.errorAnalyzingFinished ? DaemonBundle.message("errors.found", status.errorCount[i], name) : DaemonBundle.message("errors.found.so.far", status.errorCount[i], name);
text += "<br>";
currentSeverityErrors += status.errorCount[i];
}
}
if (currentSeverityErrors == 0) {
text += status.errorAnalyzingFinished ? DaemonBundle.message("no.errors.or.warnings.found") : DaemonBundle.message("no.errors.or.warnings.found.so.far") + "<br>";
}
statistics = XmlStringUtil.wrapInHtml(text);
this.icon = icon;
return result;
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class TrafficLightRenderer method incErrorCount.
private void incErrorCount(RangeHighlighter highlighter, int delta) {
Object o = highlighter.getErrorStripeTooltip();
if (!(o instanceof HighlightInfo))
return;
HighlightInfo info = (HighlightInfo) o;
HighlightSeverity infoSeverity = info.getSeverity();
if (infoSeverity.myVal <= HighlightSeverity.INFORMATION.myVal)
return;
final int severityIdx = mySeverityRegistrar.getSeverityIdx(infoSeverity);
if (severityIdx != -1) {
errorCount[severityIdx] += delta;
}
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class UnusedDeclarationPresentation method exportResults.
@Override
public void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity, @NotNull Predicate<CommonProblemDescriptor> excludedDescriptions) {
if (!(refEntity instanceof RefJavaElement))
return;
final RefFilter filter = getFilter();
if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement) refEntity)) {
refEntity = getRefManager().getRefinedElement(refEntity);
if (!refEntity.isValid())
return;
RefJavaElement refElement = (RefJavaElement) refEntity;
if (!compareVisibilities(refElement, getTool().getSharedLocalInspectionTool()))
return;
if (skipEntryPoints(refElement))
return;
Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
if (element == null)
return;
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
final HighlightSeverity severity = getSeverity(refElement);
final String attributeKey = getTextAttributeKey(refElement.getRefManager().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
problemClassElement.setAttribute("severity", severity.myName);
problemClassElement.setAttribute("attribute_key", attributeKey);
problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code"));
element.addContent(problemClassElement);
@NonNls Element hintsElement = new Element("hints");
for (UnusedDeclarationHint hint : UnusedDeclarationHint.values()) {
@NonNls Element hintElement = new Element("hint");
hintElement.setAttribute("value", hint.toString().toLowerCase());
hintsElement.addContent(hintElement);
}
element.addContent(hintsElement);
Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
StringBuffer buf = new StringBuffer();
DeadHTMLComposer.appendProblemSynopsis((RefElement) refEntity, buf);
descriptionElement.addContent(buf.toString());
element.addContent(descriptionElement);
}
super.exportResults(parentNode, refEntity, excludedDescriptions);
}
use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.
the class UpdateHighlightersUtil method getLayer.
private static int getLayer(@NotNull HighlightInfo info, @NotNull SeverityRegistrar severityRegistrar) {
final HighlightSeverity severity = info.getSeverity();
int layer;
if (severity == HighlightSeverity.WARNING) {
layer = HighlighterLayer.WARNING;
} else if (severityRegistrar.compare(severity, HighlightSeverity.ERROR) >= 0) {
layer = HighlighterLayer.ERROR;
} else if (severity == HighlightInfoType.INJECTED_FRAGMENT_SEVERITY) {
layer = HighlighterLayer.CARET_ROW - 1;
} else if (severity == HighlightInfoType.ELEMENT_UNDER_CARET_SEVERITY) {
layer = HighlighterLayer.ELEMENT_UNDER_CARET;
} else {
layer = HighlighterLayer.ADDITIONAL_SYNTAX;
}
return layer;
}
Aggregations