AnalyzerStatus () { // this method is rather expensive and PSI-related, need to execute in BGT and cache the result to show in EDT later ApplicationManager.getApplication().assertIsNonDispatchThread(); ApplicationManager.getApplication().assertReadAccessAllowed(); if (PowerSaveMode.isEnabled()) { return new AnalyzerStatus(AllIcons.General.InspectionsPowerSaveMode, InspectionsBundle.message("code.analysis.is.disabled.in.power.save.mode"), "", myUIController); } DaemonCodeAnalyzerStatus status = getDaemonCodeAnalyzerStatus(mySeverityRegistrar); String title; String details; boolean isDumb = DumbService.isDumb(myProject); List<SeverityStatusItem> statusItems = new ArrayList<>(); int[] errorCounts = status.errorCounts; for (int i = errorCounts.length - 1; i >= 0; i--) { int count = errorCounts[i]; if (count > 0) { HighlightSeverity severity = mySeverityRegistrar.getSeverityByIndex(i); if (severity != null) { Icon icon = mySeverityRegistrar.getRendererIconBySeverity(severity, status.minimumLevel == FileHighlightingSetting.FORCE_HIGHLIGHTING); SeverityStatusItem next = new SeverityStatusItem(severity, icon, count, severity.getCountMessage(count)); while (!statusItems.isEmpty()) { SeverityStatusItem merged = StatusItemMerger.runMerge(ContainerUtil.getLastItem(statusItems), next); if (merged == null) break; statusItems.remove(statusItems.size() - 1); next = merged; } statusItems.add(next); } } } if (status.errorAnalyzingFinished) { if (isDumb) { title = DaemonBundle.message("shallow.analysis.completed"); details = DaemonBundle.message("shallow.analysis.completed.details"); } else if (myFileHighlightingSettings.containsValue(FileHighlightingSetting.ESSENTIAL)) { title = DaemonBundle.message("essential.analysis.completed"); details = DaemonBundle.message("essential.analysis.completed.details"); } else { title = statusItems.isEmpty() ? DaemonBundle.message("no.errors.or.warnings.found") : ""; details = ""; } } else { title = DaemonBundle.message("performing.code.analysis"); details = ""; } if (!statusItems.isEmpty()) { AnalyzerStatus result = new AnalyzerStatus(statusItems.get(0).getIcon(), title, "", myUIController). withNavigation(). withExpandedStatus(ContainerUtil.map(statusItems, i -> new StatusItem(Integer.toString(i.getProblemCount()), i.getIcon(), i.getCountMessage()))); return status.errorAnalyzingFinished ? result : result.withAnalyzingType(AnalyzingType.PARTIAL). withPasses(ContainerUtil.map(status.passes, pass -> new PassWrapper(pass.getPresentableName(), toPercent(pass.getProgress(), pass.isFinished())))); } if (StringUtil.isNotEmpty(status.reasonWhyDisabled)) { return new AnalyzerStatus(AllIcons.General.InspectionsTrafficOff, DaemonBundle.message("no.analysis.performed"), status.reasonWhyDisabled, myUIController).withTextStatus(DaemonBundle.message("iw.status.off")); } if (StringUtil.isNotEmpty(status.reasonWhySuspended)) { return new AnalyzerStatus(AllIcons.General.InspectionsPause, DaemonBundle.message("analysis.suspended"), status.reasonWhySuspended, myUIController). withTextStatus(status.heavyProcessType != null ? status.heavyProcessType.toString() : DaemonBundle.message("iw.status.paused")). withAnalyzingType(AnalyzingType.SUSPENDED); } if (status.errorAnalyzingFinished) { Icon inspectionsCompletedIcon = status.minimumLevel == FileHighlightingSetting.FORCE_HIGHLIGHTING ? AllIcons.General.InspectionsOK : AllIcons.General.InspectionsOKEmpty; return isDumb ? new AnalyzerStatus(AllIcons.General.InspectionsPause, title, details, myUIController). withTextStatus(UtilBundle.message("heavyProcess.type.indexing")). withAnalyzingType(AnalyzingType.SUSPENDED) : new AnalyzerStatus(inspectionsCompletedIcon, title, details, myUIController); } return new AnalyzerStatus(AllIcons.General.InspectionsEye, DaemonBundle.message("no.errors.or.warnings.found"), details, myUIController). withTextStatus(DaemonBundle.message("iw.status.analyzing")). withAnalyzingType(AnalyzingType.EMPTY). withPasses(ContainerUtil.map(status.passes, pass -> new PassWrapper(pass.getPresentableName(), toPercent(pass.getProgress(), pass.isFinished())))); }