IDEA-91393 IDE freezes

This commit is contained in:
Alexey Kudravtsev
2012-09-14 16:19:57 +04:00
parent 0b68aa1d4b
commit 88b128faf3
2 changed files with 33 additions and 29 deletions
@@ -100,7 +100,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
private final FileStatusMap myFileStatusMap;
private DaemonCodeAnalyzerSettings myLastSettings;
private IntentionHintComponent myLastIntentionHint; //guarded by this
private volatile IntentionHintComponent myLastIntentionHint;
private volatile boolean myDisposed; // the only possible transition: false -> true
private volatile boolean myInitialized; // the only possible transition: false -> true
@@ -109,7 +109,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
@NonNls private static final String URL_ATT = "url";
private DaemonListeners myDaemonListeners;
private final PassExecutorService myPassExecutorService;
private int myModificationCount = 0;
private volatile boolean allowToInterrupt = true;
private StatusBarUpdater myStatusBarUpdater;
@@ -456,7 +455,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
}
@NotNull
public List<TextEditorHighlightingPass> getPassesToShowProgressFor(Document document) {
List<TextEditorHighlightingPass> getPassesToShowProgressFor(Document document) {
List<TextEditorHighlightingPass> allPasses = myPassExecutorService.getAllSubmittedPasses();
List<TextEditorHighlightingPass> result = new ArrayList<TextEditorHighlightingPass>(allPasses.size());
for (TextEditorHighlightingPass pass : allPasses) {
@@ -467,7 +466,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return result;
}
public boolean isAllAnalysisFinished(@NotNull PsiFile file) {
boolean isAllAnalysisFinished(@NotNull PsiFile file) {
if (myDisposed) return false;
Document document = PsiDocumentManager.getInstance(myProject).getCachedDocument(file);
return document != null &&
@@ -488,11 +487,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return myFileStatusMap;
}
public synchronized int getModificationCount() {
return myModificationCount;
}
public synchronized boolean isRunning() {
synchronized boolean isRunning() {
return myUpdateProgress != null && !myUpdateProgress.isCanceled();
}
@@ -509,7 +504,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
private synchronized void cancelUpdateProgress(final boolean start, @NonNls String reason) {
PassExecutorService.log(myUpdateProgress, null, reason, start);
myModificationCount++;
if (myUpdateProgress != null) {
myUpdateProgress.cancel();
@@ -541,12 +535,12 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
});
}
public static boolean processHighlightsOverlappingOutside(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
static boolean processHighlightsOverlappingOutside(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
@@ -634,13 +628,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
return markup.getUserData(MARKERS_IN_EDITOR_DOCUMENT_KEY);
}
public static void setLineMarkers(@NotNull Document document, List<LineMarkerInfo> lineMarkers, Project project) {
static void setLineMarkers(@NotNull Document document, List<LineMarkerInfo> lineMarkers, Project project) {
ApplicationManager.getApplication().assertIsDispatchThread();
MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true);
markup.putUserData(MARKERS_IN_EDITOR_DOCUMENT_KEY, lineMarkers);
}
public synchronized void setLastIntentionHint(@NotNull Project project, @NotNull PsiFile file, @NotNull Editor editor, @NotNull ShowIntentionsPass.IntentionsInfo intentions, boolean hasToRecreate) {
void setLastIntentionHint(@NotNull Project project,
@NotNull PsiFile file,
@NotNull Editor editor,
@NotNull ShowIntentionsPass.IntentionsInfo intentions,
boolean hasToRecreate) {
ApplicationManager.getApplication().assertIsDispatchThread();
hideLastIntentionHint();
IntentionHintComponent hintComponent = IntentionHintComponent.showIntentionHint(project, file, editor, intentions, false);
@@ -650,15 +648,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myLastIntentionHint = hintComponent;
}
public synchronized void hideLastIntentionHint() {
if (myLastIntentionHint != null && myLastIntentionHint.isVisible()) {
myLastIntentionHint.hide();
void hideLastIntentionHint() {
ApplicationManager.getApplication().assertIsDispatchThread();
IntentionHintComponent hint = myLastIntentionHint;
if (hint != null && hint.isVisible()) {
hint.hide();
myLastIntentionHint = null;
}
}
@Nullable
public synchronized IntentionHintComponent getLastIntentionHint() {
IntentionHintComponent getLastIntentionHint() {
return myLastIntentionHint;
}
@@ -715,7 +715,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
Runnable runnable = new Runnable() {
@Override
public void run() {
PassExecutorService.log(myUpdateProgress, null, "Update Runnable. myUpdateByTimerEnabled:",myUpdateByTimerEnabled," something disposed:",PowerSaveMode.isEnabled() || myDisposed || !myProject.isInitialized()," activeEditors:",myProject.isDisposed() ? null : myDaemonListeners.getSelectedEditors());
PassExecutorService.log(getUpdateProgress(), null, "Update Runnable. myUpdateByTimerEnabled:",myUpdateByTimerEnabled," something disposed:",PowerSaveMode.isEnabled() || myDisposed || !myProject.isInitialized()," activeEditors:",myProject.isDisposed() ? null : myDaemonListeners.getSelectedEditors());
if (!myUpdateByTimerEnabled) return;
if (myDisposed) return;
ApplicationManager.getApplication().assertIsDispatchThread();
@@ -786,6 +786,10 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
}
}
synchronized DaemonProgressIndicator getUpdateProgress() {
return myUpdateProgress;
}
@NotNull
@TestOnly
public static List<HighlightInfo> getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file ) {
@@ -796,9 +800,4 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
public void allowToInterrupt(boolean can) {
allowToInterrupt = can;
}
@TestOnly
public synchronized DaemonProgressIndicator getUpdateProgress() {
return myUpdateProgress;
}
}
@@ -181,7 +181,12 @@ class DaemonListeners implements Disposable {
@Override
public void editorReleased(@NotNull EditorFactoryEvent event) {
// mem leak after closing last editor otherwise
myDaemonCodeAnalyzer.hideLastIntentionHint();
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
myDaemonCodeAnalyzer.hideLastIntentionHint();
}
});
}
};
EditorFactory.getInstance().addEditorFactoryListener(editorFactoryListener, this);