From b3c32c0732c34bb44cce5654cae6eee64b010fc5 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 12 Jul 2012 17:52:13 +0400 Subject: [PATCH] use regular indicator for CodeSmell to work --- .../daemon/impl/PostHighlightingPass.java | 2 +- .../codeInsight/daemon/impl/RefCountHolder.java | 15 ++++++++------- .../impl/analysis/HighlightVisitorImpl.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java index 8b73ad6dd4ca..edabe3778870 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java @@ -143,7 +143,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { myInLibrary = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile); myRefCountHolder = RefCountHolder.endUsing(myFile); - if (myRefCountHolder == null || !myRefCountHolder.retrieveUnusedReferencesInfo((DaemonProgressIndicator)progress, new Runnable() { + if (myRefCountHolder == null || !myRefCountHolder.retrieveUnusedReferencesInfo(progress, new Runnable() { @Override public void run() { boolean errorFound = collectHighlights(elementSet, highlights, progress); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java index b763e4e6c9a8..373b6a9d0b36 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -47,9 +48,9 @@ public class RefCountHolder { private final Map myDclsUsedMap = new ConcurrentHashMap(); private final Map myImportStatements = new ConcurrentHashMap(); private final Map myPossiblyDuplicateElements = new ConcurrentHashMap(); - private final AtomicReference myState = new AtomicReference(VIRGIN); - private static final DaemonProgressIndicator VIRGIN = new DaemonProgressIndicator(); // just created or cleared - private static final DaemonProgressIndicator READY = new DaemonProgressIndicator(); + private final AtomicReference myState = new AtomicReference(VIRGIN); + private static final ProgressIndicator VIRGIN = new DaemonProgressIndicator(); // just created or cleared + private static final ProgressIndicator READY = new DaemonProgressIndicator(); private static class HolderReference extends SoftReference { @SuppressWarnings("UnusedDeclaration") @@ -271,8 +272,8 @@ public class RefCountHolder { return false; } - public boolean analyze(@NotNull PsiFile file, TextRange dirtyScope, @NotNull Runnable analyze, @NotNull DaemonProgressIndicator indicator) { - DaemonProgressIndicator old = myState.get(); + public boolean analyze(@NotNull PsiFile file, TextRange dirtyScope, @NotNull Runnable analyze, @NotNull ProgressIndicator indicator) { + ProgressIndicator old = myState.get(); if (old != VIRGIN && old != READY) return false; if (!myState.compareAndSet(old, indicator)) { log("a: failed to change " + old + "->" + indicator); @@ -305,8 +306,8 @@ public class RefCountHolder { //System.err.println("RFC: "+s); } - public boolean retrieveUnusedReferencesInfo(@NotNull DaemonProgressIndicator indicator, @NotNull Runnable analyze) { - DaemonProgressIndicator old = myState.get(); + public boolean retrieveUnusedReferencesInfo(@NotNull ProgressIndicator indicator, @NotNull Runnable analyze) { + ProgressIndicator old = myState.get(); if (!myState.compareAndSet(READY, indicator)) { log("r: failed to change " + old + "->" + indicator); return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 6924f7ab438c..64d6da201569 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -133,7 +133,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh Document document = PsiDocumentManager.getInstance(project).getDocument(file); TextRange dirtyScope = document == null ? file.getTextRange() : fileStatusMap.getFileDirtyScope(document, Pass.UPDATE_ALL); ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); - success = indicator instanceof DaemonProgressIndicator && refCountHolder.analyze(file, dirtyScope, action, (DaemonProgressIndicator)indicator); + success = indicator != null && refCountHolder.analyze(file, dirtyScope, action, indicator); } else { myRefCountHolder = null;