From 7675839a1fbec50ca056408b674fae655ccbcd8d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 20 Nov 2009 12:25:01 +0300 Subject: [PATCH] diagnostics --- .../daemon/DaemonAnalyzerTestCase.java | 2 +- .../daemon/impl/FileStatusMap.java | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java index 2f294eac3f6c..23b0ab1769e3 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java @@ -294,7 +294,7 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase { if (!canChangeDocumentDuringHighlighting()) { Document document = getDocument(getFile()); - assertTrue(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).getFileStatusMap().allDirtyScopesAreNull(document)); + ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).getFileStatusMap().assertAllDirtyScopesAreNull(document); } List infos = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), getProject()); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java index 9d4c25467330..d1923fd5a48c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java @@ -21,15 +21,15 @@ import com.intellij.codeHighlighting.DirtyScopeTrackingHighlightingPassFactory; import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.openapi.Disposable; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.editor.ex.RangeMarkerEx; import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.ex.RangeMarkerEx; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.Disposable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.util.containers.WeakHashMap; @@ -37,6 +37,7 @@ import gnu.trove.TIntObjectHashMap; import gnu.trove.TIntObjectProcedure; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -131,6 +132,22 @@ public class FileStatusMap implements Disposable { } }); } + + @Override + public String toString() { + final StringBuilder s = new StringBuilder(); + s.append("defensivelyMarked = " + defensivelyMarked); + s.append("; wolfPassFinfished = " + wolfPassFinfished); + s.append("; errorFound = " + errorFound); + s.append("; dirtyScopes: ("); + dirtyScopes.forEachEntry(new TIntObjectProcedure() { + public boolean execute(int passId, RangeMarker rangeMarker) { + s.append(" pass: " + passId + " -> " + rangeMarker + ";"); + return true; + } + }); + return s.toString(); + } } public void markAllFilesDirty() { @@ -262,4 +279,12 @@ public class FileStatusMap implements Disposable { return status != null && !status.defensivelyMarked && status.wolfPassFinfished && status.allDirtyScopesAreNull(); } } + + @TestOnly + public void assertAllDirtyScopesAreNull(@NotNull Document document) { + synchronized (myDocumentToStatusMap) { + FileStatus status = myDocumentToStatusMap.get(document); + assert status != null && !status.defensivelyMarked && status.wolfPassFinfished && status.allDirtyScopesAreNull() : status; + } + } }