mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more correct preloading tools
This commit is contained in:
-19
@@ -757,25 +757,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
final InspectionProfileWrapper profile = InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper();
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(activeEditor.getDocument());
|
||||
if (psiFile != null && profile != null && !profile.areToolsInstantiated()) {
|
||||
// optimization: do expensive classloading outside readaction
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!psiFile.getManager().isDisposed() && !profile.areToolsInstantiated()) {
|
||||
profile.preInstantiateTools(psiFile);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(myProject)).cancelAndRunWhenAllCommitted(
|
||||
"start daemon when all committed", runnable);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ 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;
|
||||
@@ -130,7 +131,7 @@ class DaemonListeners implements Disposable {
|
||||
@Override
|
||||
public void caretPositionChanged(CaretEvent e) {
|
||||
Editor editor = e.getEditor();
|
||||
if ((!editor.getComponent().isShowing() && !ApplicationManager.getApplication().isUnitTestMode()) ||
|
||||
if (!editor.getComponent().isShowing() && !ApplicationManager.getApplication().isUnitTestMode() ||
|
||||
!worthBothering(editor.getDocument(), editor.getProject())) {
|
||||
return; //no need to stop daemon if something happened in the console
|
||||
}
|
||||
@@ -158,6 +159,7 @@ class DaemonListeners implements Disposable {
|
||||
// editor appear in modal context, re-enable the daemon
|
||||
myDaemonCodeAnalyzer.setUpdateByTimerEnabled(true);
|
||||
}
|
||||
preInstantiateTools();
|
||||
}
|
||||
};
|
||||
myEditorTracker.addEditorTrackerListener(editorTrackerListener, this);
|
||||
@@ -294,6 +296,33 @@ 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();
|
||||
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);
|
||||
@@ -532,6 +561,7 @@ class DaemonListeners implements Disposable {
|
||||
myDaemonCodeAnalyzer.restart();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Collection<FileEditor> getSelectedEditors() {
|
||||
// Editors in modal context
|
||||
List<Editor> editors = getActiveEditors();
|
||||
|
||||
Reference in New Issue
Block a user