mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
preinstantiate inspection tools revert
This commit is contained in:
+4
-5
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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<FileEditor> 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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user