added "analysis has been suspended" message
authorAlexey Kudravtsev <cdr@intellij.com>
Tue, 14 Sep 2010 10:15:02 +0000 (14:15 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Wed, 15 Sep 2010 11:53:15 +0000 (15:53 +0400)
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java

index 15d2d5e8375416a1ce436795001aab57dbda2248..6c74a538fb77e059fd935e5c5c92d99a52776f40 100644 (file)
@@ -558,58 +558,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
     }
   }
 
-  //private static void stripWarningsCoveredByErrors(final Project project, IntervalTree<HighlightInfo> highlights, MarkupModel markup) {
-  //  final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
-  //
-  //  final Set<HighlightInfo> currentErrors = new THashSet<HighlightInfo>();
-  //  final Set<HighlightInfo> covered = new THashSet<HighlightInfo>();
-  //
-  //
-  //  final PriorityQueue<HighlightInfo> ends = new PriorityQueue<HighlightInfo>(1, new Comparator<HighlightInfo>() {
-  //    public int compare(HighlightInfo o1, HighlightInfo o2) {
-  //      return o1.getActualEndOffset() - o2.getActualEndOffset();
-  //    }
-  //  });
-  //  highlights.process(new Processor<HighlightInfo>() {
-  //    public boolean process(HighlightInfo info) {
-  //      int startOffset = info.getActualStartOffset();
-  //
-  //      for (HighlightInfo nearestEnd = ends.peek(); nearestEnd != null && nearestEnd.getActualEndOffset() <= startOffset; nearestEnd = ends.peek()) {
-  //        currentErrors.remove(nearestEnd);
-  //        Interval t = ends.poll();
-  //        assert t == nearestEnd;
-  //      }
-  //
-  //      boolean isError = severityRegistrar.compare(HighlightSeverity.ERROR, info.getSeverity()) <= 0;
-  //      if (isError) {
-  //        currentErrors.add(info);
-  //      }
-  //      else {
-  //        if (info.getSeverity().myVal > 0) {
-  //          // warning, check for everlaps
-  //          for (HighlightInfo error : currentErrors) {
-  //            if (isCoveredBy(info, error)) {
-  //              covered.add(info);
-  //            }
-  //          }
-  //        }
-  //      }
-  //      ends.add(info);
-  //
-  //      return true;
-  //    }
-  //  });
-  //
-  //  for (HighlightInfo warning : covered) {
-  //    highlights.remove(warning);
-  //
-  //    RangeHighlighter highlighter = warning.highlighter;
-  //    if (highlighter != null) {
-  //      markup.removeHighlighter(highlighter);
-  //    }
-  //  }
-  //}
-
   static boolean isCoveredBy(HighlightInfo info, HighlightInfo coveredBy) {
     return coveredBy.startOffset <= info.startOffset && info.endOffset <= coveredBy.endOffset && info.getGutterIconRenderer() == null;
   }
index f312f8105d0c5e243b6411e08fc986a013e9c585..6ffe64f72da044f933f573cb3da3c3e66753835f 100644 (file)
@@ -41,6 +41,7 @@ import javax.swing.*;
 import java.awt.*;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 public class TrafficLightRenderer implements ErrorStripeRenderer {
@@ -70,10 +71,11 @@ public class TrafficLightRenderer implements ErrorStripeRenderer {
 
   public static class DaemonCodeAnalyzerStatus {
     public boolean errorAnalyzingFinished; // all passes done
-    public final List<ProgressableTextEditorHighlightingPass> passStati = new ArrayList<ProgressableTextEditorHighlightingPass>();
+    public List<ProgressableTextEditorHighlightingPass> passStati = Collections.emptyList();
     public String[/*rootsNumber*/] noHighlightingRoots;
     public String[/*rootsNumber*/] noInspectionRoots;
     public int[] errorCount = ArrayUtil.EMPTY_INT_ARRAY;
+    public boolean enabled = true;
 
     public int rootsNumber;
     public String toString() {
@@ -110,6 +112,8 @@ public class TrafficLightRenderer implements ErrorStripeRenderer {
     status.rootsNumber = roots.length;
     fillDaemonCodeAnalyzerErrorsStatus(status, fillErrorsCount, severityRegistrar);
     List<TextEditorHighlightingPass> passes = myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
+    status.passStati = passes.isEmpty() ? Collections.<ProgressableTextEditorHighlightingPass>emptyList() :
+                       new ArrayList<ProgressableTextEditorHighlightingPass>(passes.size());
     for (TextEditorHighlightingPass tepass : passes) {
       if (!(tepass instanceof ProgressableTextEditorHighlightingPass)) continue;
       ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass)tepass;
@@ -118,6 +122,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer {
       status.passStati.add(pass);
     }
     status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
+    status.enabled = myDaemonCodeAnalyzer.isUpdateByTimerEnabled();
 
     return status;
   }
@@ -260,7 +265,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer {
     if (status == null) {
       return NO_ICON;
     }
-    if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
+    if (!status.enabled || status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
       return NO_ANALYSIS_ICON;
     }
 
index 0d6ecb2b56356c17daa8049dc6119b85ab7059f7..4e62cca8dfaeb813e80d9b33ad328ef6157cde79 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.codeInsight.daemon.impl;
 
 import com.intellij.codeInsight.daemon.DaemonBundle;
-import com.intellij.codeInsight.hint.LineTooltipRenderer;
 import com.intellij.ide.PowerSaveMode;
 import com.intellij.lang.annotation.HighlightSeverity;
 import com.intellij.openapi.editor.Editor;
@@ -56,6 +55,7 @@ public class TrafficProgressPanel extends JPanel {
     fakeStatusLargeEnough.errorCount = new int[]{1,1,1,1};
     Project project = trafficLightRenderer.getProject();
     PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
+    fakeStatusLargeEnough.passStati = new ArrayList<ProgressableTextEditorHighlightingPass>();
     for (int i=0; i<3;i++) {
       fakeStatusLargeEnough.passStati.add(new ProgressableTextEditorHighlightingPass(project, null, DaemonBundle.message("pass.wolf"), psiFile, false) {
         @Override
@@ -107,6 +107,12 @@ public class TrafficProgressPanel extends JPanel {
       statistics.setText("");
       return;
     }
+    if (!status.enabled) {
+      statusLabel.setText("Code analysis has been suspended.");
+      passStatuses.setVisible(false);
+      statistics.setText("");
+      return;
+    }
     if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
       statusLabel.setText(DaemonBundle.message("analysis.hasnot.been.run"));
       passStatuses.setVisible(false);