コード例 #1
0
  @Nullable
  protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(
      boolean fillErrorsCount, SeverityRegistrar severityRegistrar) {
    if (myFile == null
        || myProject.isDisposed()
        || !myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) return null;

    List<String> noInspectionRoots = new ArrayList<String>();
    List<String> noHighlightingRoots = new ArrayList<String>();
    FileViewProvider provider = myFile.getViewProvider();
    Set<Language> languages = provider.getLanguages();
    for (Language language : languages) {
      PsiFile root = provider.getPsi(language);
      if (!HighlightLevelUtil.shouldHighlight(root)) {
        noHighlightingRoots.add(language.getID());
      } else if (!HighlightLevelUtil.shouldInspect(root)) {
        noInspectionRoots.add(language.getID());
      }
    }
    DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
    status.noInspectionRoots =
        noInspectionRoots.isEmpty() ? null : ArrayUtil.toStringArray(noInspectionRoots);
    status.noHighlightingRoots =
        noHighlightingRoots.isEmpty() ? null : ArrayUtil.toStringArray(noHighlightingRoots);

    status.errorCount = errorCount.clone();
    status.rootsNumber = languages.size();
    fillDaemonCodeAnalyzerErrorsStatus(status, fillErrorsCount, severityRegistrar);
    List<TextEditorHighlightingPass> passes =
        myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
    status.passStati =
        passes.isEmpty()
            ? Collections.<ProgressableTextEditorHighlightingPass>emptyList()
            : new ArrayList<ProgressableTextEditorHighlightingPass>(passes.size());
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < passes.size(); i++) {
      TextEditorHighlightingPass tepass = passes.get(i);
      if (!(tepass instanceof ProgressableTextEditorHighlightingPass)) continue;
      ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass) tepass;

      if (pass.getProgress() < 0) continue;
      status.passStati.add(pass);
    }
    status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
    status.enabled = myDaemonCodeAnalyzer.isUpdateByTimerEnabled();

    return status;
  }