private Color getColor(HighlightSeverity severity) { if (SeverityRegistrar.getInstance(myProject).compare(severity, HighlightSeverity.ERROR) >= 0) { return LightColors.RED; } if (SeverityRegistrar.getInstance(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) { return LightColors.YELLOW; } return Color.white; }
@Override protected void fillDaemonCodeAnalyzerErrorsStatus( DaemonCodeAnalyzerStatus status, boolean fillErrorsCount, SeverityRegistrar severityRegistrar) { for (int i = 0; i < status.errorCount.length; i++) { final HighlightSeverity minSeverity = severityRegistrar.getSeverityByIndex(i); if (minSeverity == null) { continue; } int sum = 0; for (DomElement element : myDomElements) { final DomElementsProblemsHolder holder = myAnnotationsManager.getCachedProblemHolder(element); sum += (SeverityRegistrar.getInstance(getProject()) .compare(minSeverity, HighlightSeverity.WARNING) >= 0 ? holder.getProblems(element, true, true) : holder.getProblems(element, true, minSeverity)) .size(); } status.errorCount[i] = sum; } }
private void reportOneTagProblem( final XmlTag tag, final String name, final String localizedMessage, final IntentionAction basicIntention, final HighlightDisplayKey key, final XmlEntitiesInspection inspection, final int type) { boolean htmlTag = false; if (tag instanceof HtmlTag) { htmlTag = true; if (isAdditionallyDeclared(inspection.getAdditionalEntries(type), name)) return; } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getInspectionProfile(); final IntentionAction intentionAction = inspection.getIntentionAction(name, type); if (htmlTag && profile.isToolEnabled(key, tag)) { addElementsForTagWithManyQuickFixes( tag, localizedMessage, isInjectedHtmlTagForWhichNoProblemsReporting((HtmlTag) tag) ? HighlightInfoType.INFORMATION : SeverityRegistrar.getInstance(tag.getProject()) .getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), intentionAction, basicIntention); } else if (!htmlTag) { addElementsForTag(tag, localizedMessage, HighlightInfoType.ERROR, basicIntention); } }
public FileLevelIntentionComponent( final String description, final HighlightSeverity severity, final List<Pair<HighlightInfo.IntentionActionDescriptor, TextRange>> intentions, final Project project, final PsiFile psiFile, final Editor editor) { myProject = project; final ShowIntentionsPass.IntentionsInfo info = new ShowIntentionsPass.IntentionsInfo(); if (intentions != null) { for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> intention : intentions) { final HighlightInfo.IntentionActionDescriptor descriptor = intention.getFirst(); info.intentionsToShow.add(descriptor); final String text = descriptor.getAction().getText(); createActionLabel( text, new Runnable() { public void run() { ShowIntentionActionsHandler.chooseActionAndInvoke( psiFile, editor, descriptor.getAction(), text); } }); } } myLabel.setText(description); myLabel.setIcon( SeverityRegistrar.getInstance(project).compare(severity, HighlightSeverity.ERROR) >= 0 ? ourQuickFixIcon : ourIntentionIcon); setBackground(getColor(severity)); myLabel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { IntentionListStep step = new IntentionListStep(null, info, editor, psiFile, project); if (intentions != null && !intentions.isEmpty()) { HighlightInfo.IntentionActionDescriptor descriptor = intentions.get(0).getFirst(); IntentionActionWithTextCaching actionWithTextCaching = step.wrapAction(descriptor, psiFile, psiFile, editor); if (step.hasSubstep(actionWithTextCaching)) { step = step.getSubStep(actionWithTextCaching, null); } } JBPopupFactory.getInstance().createListPopup(step).showUnderneathOf(myLabel); } }); }