From c8d38ec0d9fd53628166f5ff7e22182b1d4b2b53 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 18 Jul 2012 17:27:43 +0400 Subject: [PATCH] preinstantiate inspection tools revert --- .../daemon/impl/DaemonCodeAnalyzerImpl.java | 9 +++--- .../daemon/impl/DaemonListeners.java | 30 ------------------- .../ex/InspectionProfileWrapper.java | 17 ----------- 3 files changed, 4 insertions(+), 52 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 eab96739beee..b8e74f01806a 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 @@ -711,6 +711,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx if (PowerSaveMode.isEnabled()) return; Editor activeEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor(); + final PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject); Runnable runnable = new Runnable() { @Override public void run() { @@ -728,9 +729,8 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx // we'll restart when write action finish return; } - if (PsiDocumentManager.getInstance(myProject).hasUncommitedDocuments()) { - ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject)).cancelAndRunWhenAllCommitted( - "restart daemon when all committed", this); + if (documentManager.hasUncommitedDocuments()) { + documentManager.cancelAndRunWhenAllCommitted("restart daemon when all committed", this); return; } @@ -755,8 +755,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx runnable.run(); } else { - ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject)).cancelAndRunWhenAllCommitted( - "start daemon when all committed", runnable); + documentManager.cancelAndRunWhenAllCommitted("start daemon when all committed", runnable); } } }; 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 78d294258eb6..5480d1a4b3f1 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 @@ -20,7 +20,6 @@ import com.intellij.ProjectTopics; import com.intellij.codeHighlighting.Pass; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.hint.TooltipController; -import com.intellij.codeInspection.ex.InspectionProfileWrapper; import com.intellij.ide.PowerSaveMode; import com.intellij.ide.todo.TodoConfiguration; import com.intellij.openapi.Disposable; @@ -160,7 +159,6 @@ class DaemonListeners implements Disposable { // editor appear in modal context, re-enable the daemon myDaemonCodeAnalyzer.setUpdateByTimerEnabled(true); } - preInstantiateTools(); } }; myEditorTracker.addEditorTrackerListener(editorTrackerListener, this); @@ -298,34 +296,6 @@ class DaemonListeners implements Disposable { LaterInvocator.addModalityStateListener(modalityStateListener,this); } - private void preInstantiateTools() { - final InspectionProfileWrapper profile = InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper(); - if (profile == null || profile.areToolsInstantiated()) return; - Collection editors = getSelectedEditors(); - for (FileEditor fe : editors) { - if (!(fe instanceof TextEditor)) continue; - Editor editor = ((TextEditor)fe).getEditor(); - if (editor.getProject() != myProject) continue; - final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); - if (psiFile == null) continue; - // optimization: do expensive classloading outside readaction - ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { - @Override - public void run() { - if (!psiFile.getManager().isDisposed() && !profile.areToolsInstantiated()) { - try { - profile.preInstantiateTools(psiFile); - } - catch (Throwable ignored) { - // app still can be disposed in the middle, ignore - } - } - } - }); - break; - } - } - static boolean isUnderIgnoredAction(@Nullable Object action) { return action instanceof DocumentRunnable.IgnoreDocumentRunnable || ApplicationManager.getApplication().hasWriteAction(DocumentRunnable.IgnoreDocumentRunnable.class); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java index 35a5ee5873bb..ecb2d14c9e83 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java @@ -22,7 +22,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.util.Function; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; @@ -81,22 +80,6 @@ public class InspectionProfileWrapper { } } - private volatile boolean toolsInstantiated; - public void preInstantiateTools(PsiFile psiFile) { - if (toolsInstantiated) return; - toolsInstantiated = true; - InspectionTool[] tools = getInspectionTools(psiFile); - for (InspectionTool tool : tools) { - if (tool instanceof InspectionToolWrapper) { - ((InspectionToolWrapper)tool).getTool(); - } - } - } - - public boolean areToolsInstantiated() { - return toolsInstantiated; - } - public String getName() { return myProfile.getName(); }