summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/codeInsight/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/codeInsight/daemon')
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java16
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java3
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java32
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java95
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SmartHashMap.java206
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java13
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java108
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java2
10 files changed, 116 insertions, 367 deletions
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index d8fd3ab40508..4ac5e686c5bc 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -709,11 +709,20 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOM
return new Runnable() {
@Override
public void run() {
- if (myDisposed || !myProject.isInitialized()) return;
- if (PowerSaveMode.isEnabled()) return;
- Editor activeEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
+ ApplicationManager.getApplication().assertIsDispatchThread();
+ if (myDisposed || !myProject.isInitialized() || PowerSaveMode.isEnabled()) {
+ return;
+ }
+ if (HeavyProcessLatch.INSTANCE.isRunning()) {
+ if (myAlarm.isEmpty()) {
+ myAlarm.addRequest(myUpdateRunnable, mySettings.AUTOREPARSE_DELAY);
+ }
+ return;
+ }
+ Editor activeEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
final PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject);
+
Runnable runnable = new Runnable() {
@Override
public void run() {
@@ -728,7 +737,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOM
final Collection<FileEditor> activeEditors = getSelectedEditors();
if (activeEditors.isEmpty()) return;
- ApplicationManager.getApplication().assertIsDispatchThread();
if (ApplicationManager.getApplication().isWriteAccessAllowed()) {
// makes no sense to start from within write action, will cancel anyway
// we'll restart when write action finish
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
index c8d5ec4b8ddb..760029d689db 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
@@ -507,7 +507,7 @@ public class DaemonListeners implements Disposable {
}
@Override
- public void profileActivated(@NotNull Profile oldProfile, Profile profile) {
+ public void profileActivated(Profile oldProfile, Profile profile) {
stopDaemonAndRestartAllFiles();
}
@@ -530,6 +530,7 @@ public class DaemonListeners implements Disposable {
StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject);
statusBar.addWidget(myTogglePopupHintsPanel, myProject);
+ updateStatusBar();
stopDaemonAndRestartAllFiles();
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java
index cfa7c029d8fc..c88ac636243a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/EditorTracker.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -209,7 +209,7 @@ public class EditorTracker extends AbstractProjectComponent {
return filtered;
}
- private void setActiveEditors(@NotNull List<Editor> editors) {
+ void setActiveEditors(@NotNull List<Editor> editors) {
myActiveEditors = editors;
if (LOG.isDebugEnabled()) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java
index 2c44451ef260..72b0a4471e9c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IdentifierHighlighterPass.java
@@ -34,6 +34,7 @@ import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
@@ -115,33 +116,50 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
}
}
- private void highlightTargetUsages(@NotNull PsiElement target) {
+ /**
+ * Returns read and write usages of psi element inside single file
+ *
+ * @param target target psi element
+ * @param psiFile psi file for element
+ * @return a pair where first element is read usages and second is write usages
+ */
+ public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiFile psiFile) {
+ Collection<TextRange> readRanges = new ArrayList<TextRange>();
+ Collection<TextRange> writeRanges = new ArrayList<TextRange>();
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
- final LocalSearchScope scope = new LocalSearchScope(myFile);
+ final LocalSearchScope scope = new LocalSearchScope(psiFile);
Collection<PsiReference> refs = findUsagesHandler != null
? findUsagesHandler.findReferencesToHighlight(target, scope)
: ReferencesSearch.search(target, scope).findAll();
for (PsiReference psiReference : refs) {
final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
- myReadAccessRanges.addAll(textRanges);
+ readRanges.addAll(textRanges);
}
else {
- myWriteAccessRanges.addAll(textRanges);
+ writeRanges.addAll(textRanges);
}
}
- final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(myFile, target);
+ final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiFile, target);
if (declRange != null) {
if (detector != null && detector.isDeclarationWriteAccess(target)) {
- myWriteAccessRanges.add(declRange);
+ writeRanges.add(declRange);
}
else {
- myReadAccessRanges.add(declRange);
+ readRanges.add(declRange);
}
}
+
+ return Couple.of(readRanges, writeRanges);
+ }
+
+ private void highlightTargetUsages(@NotNull PsiElement target) {
+ final Couple<Collection<TextRange>> usages = getHighlightUsages(target, myFile);
+ myReadAccessRanges.addAll(usages.first);
+ myWriteAccessRanges.addAll(usages.second);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
index 207b66be6112..0761379652ac 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
@@ -223,7 +223,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
Divider.divideInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, new ArrayList<ProperTextRange>(), outside, new ArrayList<ProperTextRange>(),
true, FILE_FILTER);
- MultiMap<LocalInspectionToolWrapper, String> toolToLanguages = getToolsForElements(toolWrappers, checkDumbAwareness, inside, outside);
+ MultiMap<LocalInspectionToolWrapper, String> toolToLanguages = InspectionEngine.getToolsForElements(toolWrappers, checkDumbAwareness, inside, outside);
setProgressLimit(toolToLanguages.size() * 2L);
final LocalInspectionToolSession session = new LocalInspectionToolSession(myFile, myStartOffset, myEndOffset);
@@ -240,76 +240,6 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
}
@NotNull
- private static MultiMap<LocalInspectionToolWrapper, String> getToolsForElements(@NotNull List<LocalInspectionToolWrapper> toolWrappers,
- boolean checkDumbAwareness,
- @NotNull List<PsiElement> inside,
- @NotNull List<PsiElement> outside) {
- Set<Language> languages = new SmartHashSet<Language>();
- Map<String, Language> langIds = new SmartHashMap<String, Language>();
- Set<String> dialects = new SmartHashSet<String>();
- calculateDialects(inside, languages, langIds, dialects);
- calculateDialects(outside, languages, langIds, dialects);
- MultiMap<LocalInspectionToolWrapper, String> toolToLanguages = new MultiMap<LocalInspectionToolWrapper, String>() {
- @NotNull
- @Override
- protected Collection<String> createCollection() {
- return new SmartHashSet<String>();
- }
-
- @NotNull
- @Override
- protected Collection<String> createEmptyCollection() {
- return Collections.emptySet();
- }
- };
- for (LocalInspectionToolWrapper wrapper : toolWrappers) {
- ProgressManager.checkCanceled();
- String language = wrapper.getLanguage();
- if (language == null) {
- LocalInspectionTool tool = wrapper.getTool();
- if (!checkDumbAwareness || tool instanceof DumbAware) {
- toolToLanguages.put(wrapper, null);
- }
- continue;
- }
- Language lang = langIds.get(language);
- if (lang != null) {
- LocalInspectionTool tool = wrapper.getTool();
- if (!checkDumbAwareness || tool instanceof DumbAware) {
- toolToLanguages.putValue(wrapper, language);
- if (wrapper.applyToDialects()) {
- for (Language dialect : lang.getDialects()) {
- toolToLanguages.putValue(wrapper, dialect.getID());
- }
- }
- }
- }
- else if (wrapper.applyToDialects() && dialects.contains(language)) {
- LocalInspectionTool tool = wrapper.getTool();
- if (!checkDumbAwareness || tool instanceof DumbAware) {
- toolToLanguages.putValue(wrapper, language);
- }
- }
- }
- return toolToLanguages;
- }
-
- private static void calculateDialects(@NotNull List<PsiElement> inside,
- @NotNull Set<Language> languages,
- @NotNull Map<String, Language> langIds,
- @NotNull Set<String> dialects) {
- for (PsiElement element : inside) {
- Language language = element.getLanguage();
- if (languages.add(language)) {
- langIds.put(language.getID(), language);
- for (Language dialect : language.getDialects()) {
- dialects.add(dialect.getID());
- }
- }
- }
- }
-
- @NotNull
private List<InspectionContext> visitPriorityElementsAndInit(@NotNull MultiMap<LocalInspectionToolWrapper, String> toolToLanguages,
@NotNull final InspectionManagerEx iManager,
final boolean isOnTheFly,
@@ -412,17 +342,16 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
});
}
if (injected.isEmpty()) return;
- if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList<PsiFile>(injected), indicator,
- myFailFastOnAcquireReadAction,
- new Processor<PsiFile>() {
- @Override
- public boolean process(final PsiFile injectedPsi) {
- doInspectInjectedPsi(injectedPsi, onTheFly, indicator, iManager,
- inVisibleRange,
- wrappers, checkDumbAwareness);
- return true;
- }
- })) throw new ProcessCanceledException();
+ Processor<PsiFile> processor = new Processor<PsiFile>() {
+ @Override
+ public boolean process(final PsiFile injectedPsi) {
+ doInspectInjectedPsi(injectedPsi, onTheFly, indicator, iManager, inVisibleRange, wrappers, checkDumbAwareness);
+ return true;
+ }
+ };
+ if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList<PsiFile>(injected), indicator, myFailFastOnAcquireReadAction, processor)) {
+ throw new ProcessCanceledException();
+ }
}
@Nullable
@@ -740,7 +669,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
return;
}
MultiMap<LocalInspectionToolWrapper, String> toolToLanguages =
- getToolsForElements(wrappers, checkDumbAwareness, elements, Collections.<PsiElement>emptyList());
+ InspectionEngine.getToolsForElements(wrappers, checkDumbAwareness, elements, Collections.<PsiElement>emptyList());
for (final Map.Entry<LocalInspectionToolWrapper, Collection<String>> pair : toolToLanguages.entrySet()) {
indicator.checkCanceled();
final LocalInspectionToolWrapper wrapper = pair.getKey();
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java
index 1f47f5c5c69a..57f65283fd2f 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PsiElementListNavigator.java
@@ -33,6 +33,7 @@ import com.intellij.ui.CollectionListModel;
import com.intellij.ui.JBListWithHintProvider;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.AbstractPopup;
+import com.intellij.ui.popup.HintUpdateSupply;
import com.intellij.usages.UsageView;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
@@ -147,8 +148,7 @@ public class PsiElementListNavigator {
setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
- list.hideHint();
-
+ HintUpdateSupply.hideHint(list);
return true;
}
});
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SmartHashMap.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SmartHashMap.java
deleted file mode 100644
index 861df82d5d43..000000000000
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SmartHashMap.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.daemon.impl;
-
-import com.intellij.openapi.util.Comparing;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.SingletonSet;
-import gnu.trove.THashMap;
-import gnu.trove.TObjectFunction;
-import gnu.trove.TObjectObjectProcedure;
-import gnu.trove.TObjectProcedure;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.AbstractMap;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Hash set (based on THashSet) which is fast when contains one or zero elements (avoids to calculate hash codes and call equals whenever possible).
- * For other sizes it delegates to THashSet.
- * Null keys are NOT PERMITTED.
- */
-public class SmartHashMap<K,V> extends THashMap<K,V> {
- private K theKey; // contains the only element if size() == 1
- private V theValue;
-
- @Override
- public boolean containsKey(@NotNull Object key) {
- K theKey = this.theKey;
- if (theKey != null) {
- return eq(theKey, (K)key);
- }
- return !super.isEmpty() && super.containsKey(key);
- }
-
- @Override
- public V put(@NotNull K key, V value) {
- K theKey = this.theKey;
- if (theKey != null) {
- if (eq(theKey, key)) return theValue;
- super.put(theKey, theValue);
- this.theKey = null;
- // fallthrough
- }
- else if (super.isEmpty()) {
- this.theKey = key;
- theValue = value;
- return null;
- }
- return super.put(key, value);
- }
-
- private boolean eq(K obj, K theKey) {
- return theKey == obj || _hashingStrategy.equals(theKey, obj);
- }
-
- @Override
- public boolean equals(@NotNull Object other) {
- K theKey = this.theKey;
- if (theKey != null) {
- if (!(other instanceof Map) || ((Map)other).size() != 1 ) return false;
- Map.Entry<K, V> entry = ((Map<K, V>)other).entrySet().iterator().next();
- return eq(theKey, entry.getKey()) && Comparing.equal(theValue, entry.getValue());
- }
-
- return super.equals(other);
- }
-
- @Override
- public int hashCode() {
- K theKey = this.theKey;
- if (theKey != null) {
- return _hashingStrategy.computeHashCode(theKey);
- }
- return super.hashCode();
- }
-
- @Override
- public void clear() {
- theKey = null;
- theValue = null;
- super.clear();
- }
-
- @Override
- public int size() {
- K theKey = this.theKey;
- if (theKey != null) {
- return 1;
- }
- return super.size();
- }
-
- @Override
- public boolean isEmpty() {
- K theKey = this.theKey;
- return theKey == null && super.isEmpty();
- }
-
- @Override
- public V remove(@NotNull Object obj) {
- K theKey = this.theKey;
- if (theKey != null) {
- if (eq(theKey, (K)obj)) {
- this.theKey = null;
- V value = theValue;
- theValue = null;
- return value;
- }
- return null;
- }
- return super.remove(obj);
- }
-
- @NotNull
- @Override
- public Set<K> keySet() {
- K theKey = this.theKey;
- if (theKey != null) {
- return new SingletonSet<K>(theKey);
- }
- return super.keySet();
- }
-
- @NotNull
- @Override
- public Collection<V> values() {
- K theKey = this.theKey;
- if (theKey != null) {
- return new SingletonSet<V>(theValue);
- }
- return super.values();
- }
-
- @NotNull
- @Override
- public Set<Map.Entry<K, V>> entrySet() {
- K theKey = this.theKey;
- if (theKey != null) {
- return new SingletonSet<Map.Entry<K, V>>(new AbstractMap.SimpleEntry<K, V>(theKey, theValue));
- }
- return super.entrySet();
- }
-
- @Override
- public V get(Object key) {
- K theKey = this.theKey;
- if (theKey != null) {
- return eq(theKey, (K)key) ? theValue : null;
- }
- return super.get(key);
- }
-
- @Override
- public boolean containsValue(Object val) {
- K theKey = this.theKey;
- if (theKey != null) {
- return Comparing.equal(theValue, val);
- }
- return super.containsValue(val);
- }
-
- @Override
- public THashMap<K, V> clone() {
- throw new IncorrectOperationException();
- }
-
- @Override
- public void transformValues(TObjectFunction<V, V> function) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean retainEntries(TObjectObjectProcedure<K, V> procedure) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean forEachEntry(TObjectObjectProcedure<K, V> procedure) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean forEachValue(TObjectProcedure<V> procedure) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean forEachKey(TObjectProcedure<K> procedure) {
- throw new IncorrectOperationException();
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
index 9c4404a21d58..c67af24d8cdc 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,6 @@ import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiFile;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.ArrayUtil;
-import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.UIUtil;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NonNls;
@@ -57,9 +56,7 @@ import java.util.List;
import java.util.Set;
public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
- private static final Icon IN_PROGRESS_ICON = AllIcons.General.ErrorsInProgress;
private static final Icon NO_ANALYSIS_ICON = AllIcons.General.NoAnalysis;
- private static final Icon NO_ICON = new EmptyIcon(IN_PROGRESS_ICON.getIconWidth(), IN_PROGRESS_ICON.getIconHeight());
private static final Icon STARING_EYE_ICON = AllIcons.General.InspectionInProgress;
private final Project myProject;
@@ -162,6 +159,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
public boolean enabled = true;
public int rootsNumber;
+ @Override
public String toString() {
@NonNls String s = "DS: finished=" + errorAnalyzingFinished;
s += "; pass statuses: " + passStati.size() + "; ";
@@ -175,7 +173,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
@Nullable
protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(boolean fillErrorsCount, SeverityRegistrar severityRegistrar) {
- if (myFile == null || myProject.isDisposed() || !myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) return null;
+ if (myFile == null || myProject != null && myProject.isDisposed() || !myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) return null;
List<String> noInspectionRoots = new ArrayList<String>();
List<String> noHighlightingRoots = new ArrayList<String>();
@@ -243,10 +241,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
}
private Icon getIcon(DaemonCodeAnalyzerStatus status) {
- if (status == null) {
- return NO_ICON;
- }
- if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
+ if (status == null || status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
return NO_ANALYSIS_ICON;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java
index 19a958a8bd71..74cfdd9f434e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java
@@ -137,31 +137,33 @@ public class TrafficProgressPanel extends JPanel {
}
}
- private void rebuildPassesPanel(@NotNull TrafficLightRenderer.DaemonCodeAnalyzerStatus status) {
+ private void rebuildPassesPanel(@Nullable TrafficLightRenderer.DaemonCodeAnalyzerStatus status) {
myPassStatuses.removeAll();
myPassStatuses.setLayout(new GridBagLayout());
passes.clear();
GridBagConstraints c = new GridBagConstraints();
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
- for (ProgressableTextEditorHighlightingPass pass : status.passStati) {
- JLabel label = new JLabel(pass.getPresentableName() + ": ");
- label.setHorizontalTextPosition(SwingConstants.RIGHT);
+ if (status != null) {
+ for (ProgressableTextEditorHighlightingPass pass : status.passStati) {
+ JLabel label = new JLabel(pass.getPresentableName() + ": ");
+ label.setHorizontalTextPosition(SwingConstants.RIGHT);
- JProgressBar progressBar = new JProgressBar(0, MAX);
- progressBar.putClientProperty("JComponent.sizeVariant", "mini");
- JLabel percLabel = new JLabel();
- passes.put(pass, Pair.create(progressBar, percLabel));
- myProgressToText.put(progressBar, percLabel);
- c.gridx = 0;
- myPassStatuses.add(label, c);
- c.gridx = 1;
- myPassStatuses.add(progressBar, c);
- c.gridx = 2;
- c.weightx = 1;
- myPassStatuses.add(percLabel, c);
+ JProgressBar progressBar = new JProgressBar(0, MAX);
+ progressBar.putClientProperty("JComponent.sizeVariant", "mini");
+ JLabel percLabel = new JLabel();
+ passes.put(pass, Pair.create(progressBar, percLabel));
+ myProgressToText.put(progressBar, percLabel);
+ c.gridx = 0;
+ myPassStatuses.add(label, c);
+ c.gridx = 1;
+ myPassStatuses.add(progressBar, c);
+ c.gridx = 2;
+ c.weightx = 1;
+ myPassStatuses.add(percLabel, c);
- c.gridy++;
+ c.gridy++;
+ }
}
myHintHint.initStyle(myPassStatuses, true);
@@ -169,7 +171,6 @@ public class TrafficProgressPanel extends JPanel {
}
public void updatePanel(@Nullable TrafficLightRenderer.DaemonCodeAnalyzerStatus status, boolean isFake) {
- if (status == null) return;
boolean isDumb = DumbService.isDumb(myTrafficLightRenderer.getProject());
dumbLabel.setVisible(isDumb);
try {
@@ -178,6 +179,12 @@ public class TrafficProgressPanel extends JPanel {
myPassStatuses.setVisible(false);
statistics.setText("");
}
+ else if (status == null || status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
+ statusLabel.setText(DaemonBundle.message("analysis.hasnot.been.run"));
+ myPassStatuses.setVisible(true);
+ setPassesEnabled(false, Boolean.FALSE);
+ statistics.setText("");
+ }
else if (status.errorAnalyzingFinished) {
if (isDumb) {
statusLabel.setText("Shallow analysis completed");
@@ -194,12 +201,6 @@ public class TrafficProgressPanel extends JPanel {
setPassesEnabled(false, Boolean.FALSE);
statistics.setText("");
}
- else if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) {
- statusLabel.setText(DaemonBundle.message("analysis.hasnot.been.run"));
- myPassStatuses.setVisible(true);
- setPassesEnabled(false, Boolean.FALSE);
- statistics.setText("");
- }
else {
statusLabel.setText(DaemonBundle.message("performing.code.analysis"));
myPassStatuses.setVisible(true);
@@ -207,42 +208,45 @@ public class TrafficProgressPanel extends JPanel {
}
- if (!status.passStati.equals(new ArrayList<ProgressableTextEditorHighlightingPass>(passes.keySet()))) {
+ if (status == null ||
+ !status.passStati.equals(new ArrayList<ProgressableTextEditorHighlightingPass>(passes.keySet()))) {
// passes set has changed
rebuildPassesPanel(status);
}
- for (ProgressableTextEditorHighlightingPass pass : status.passStati) {
- double progress = pass.getProgress();
- Pair<JProgressBar, JLabel> pair = passes.get(pass);
- JProgressBar progressBar = pair.first;
- int percent = (int)Math.round(progress * MAX);
- progressBar.setValue(percent);
- JLabel percentage = pair.second;
- percentage.setText(percent + "%");
- }
+ if (status != null) {
+ for (ProgressableTextEditorHighlightingPass pass : status.passStati) {
+ double progress = pass.getProgress();
+ Pair<JProgressBar, JLabel> pair = passes.get(pass);
+ JProgressBar progressBar = pair.first;
+ int percent = (int)Math.round(progress * MAX);
+ progressBar.setValue(percent);
+ JLabel percentage = pair.second;
+ percentage.setText(percent + "%");
+ }
- int currentSeverityErrors = 0;
- @Language("HTML")
- String text = "";
- for (int i = status.errorCount.length - 1; i >= 0; i--) {
- if (status.errorCount[i] > 0) {
- final HighlightSeverity severity = SeverityRegistrar.getSeverityRegistrar(myTrafficLightRenderer.getProject()).getSeverityByIndex(i);
- String name =
- status.errorCount[i] > 1 ? StringUtil.pluralize(severity.getName().toLowerCase()) : severity.getName().toLowerCase();
+ int currentSeverityErrors = 0;
+ @Language("HTML")
+ String text = "";
+ for (int i = status.errorCount.length - 1; i >= 0; i--) {
+ if (status.errorCount[i] > 0) {
+ final HighlightSeverity severity = SeverityRegistrar.getSeverityRegistrar(myTrafficLightRenderer.getProject()).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("errors.found", status.errorCount[i], name)
- : DaemonBundle.message("errors.found.so.far", status.errorCount[i], name);
- text += "<br>";
- currentSeverityErrors += status.errorCount[i];
+ ? DaemonBundle.message("no.errors.or.warnings.found")
+ : DaemonBundle.message("no.errors.or.warnings.found.so.far") + "<br>";
}
+ statistics.setText(XmlStringUtil.wrapInHtml(text));
}
- if (currentSeverityErrors == 0) {
- text += status.errorAnalyzingFinished
- ? DaemonBundle.message("no.errors.or.warnings.found")
- : DaemonBundle.message("no.errors.or.warnings.found.so.far") + "<br>";
- }
- statistics.setText(XmlStringUtil.wrapInHtml(text));
}
finally {
if (isFake) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java
index 40a798c6af48..a1d95d51d7b4 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java
@@ -76,7 +76,7 @@ public class WholeFileLocalInspectionsPassFactory extends AbstractProjectCompone
}
@Override
- public void profileActivated(@NotNull Profile oldProfile, Profile profile) {
+ public void profileActivated(Profile oldProfile, Profile profile) {
myFileTools.clear();
}
};