From b205caf9f362241d895ee6d2f5f08bcbb184875f Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 6 Mar 2015 16:46:55 +0300 Subject: [PATCH] more diagnostics for daemon cancel event --- .../daemon/DaemonCodeAnalyzer.java | 14 +++++--- .../daemon/impl/DaemonListeners.java | 34 ++++++++++--------- .../injected/InjectedLanguageManagerImpl.java | 2 +- .../ui/playback/util/EditorPlaybackCall.java | 5 +-- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java index 6c25a8d49bc4..282fc839ecd4 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,10 +65,16 @@ public abstract class DaemonCodeAnalyzer { public interface DaemonListener { void daemonFinished(); - void daemonCancelEventOccurred(); + void daemonCancelEventOccurred(@NotNull String reason); } + public abstract static class DaemonListenerAdapter implements DaemonListener { - @Override public void daemonFinished() {} - @Override public void daemonCancelEventOccurred() {} + @Override + public void daemonFinished() { + } + + @Override + public void daemonCancelEventOccurred(@NotNull String reason) { + } } } 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 6dfc2cb1079e..b3946d93be9e 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 @@ -129,7 +129,9 @@ public class DaemonListeners implements Disposable { @NotNull TodoConfiguration todoConfiguration, @NotNull ActionManagerEx actionManagerEx, @NotNull VirtualFileManager virtualFileManager, + @SuppressWarnings("UnusedParameters") // for dependency order @NotNull final NamedScopeManager namedScopeManager, + @SuppressWarnings("UnusedParameters") // for dependency order @NotNull final DependencyValidationManager dependencyValidationManager, @NotNull final FileDocumentManager fileDocumentManager, @NotNull final PsiManager psiManager, @@ -260,19 +262,19 @@ public class DaemonListeners implements Disposable { connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Project roots changed"); } }); connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { @Override public void enteredDumbMode() { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Dumb mode started"); } @Override public void exitDumbMode() { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Dumb mode finished"); } }); @@ -286,7 +288,7 @@ public class DaemonListeners implements Disposable { colorsManager.addEditorColorsListener(new EditorColorsListener() { @Override public void globalSchemeChange(EditorColorsScheme scheme) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Global color scheme changed"); } }, this); @@ -303,7 +305,7 @@ public class DaemonListeners implements Disposable { public void propertyChanged(@NotNull VirtualFilePropertyEvent event) { String propertyName = event.getPropertyName(); if (VirtualFile.PROP_NAME.equals(propertyName)) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Virtual file name changed"); VirtualFile virtualFile = event.getFile(); PsiFile psiFile = !virtualFile.isValid() ? null : ((PsiManagerEx)psiManager).getFileManager().getCachedPsiFile(virtualFile); if (psiFile != null && !myDaemonCodeAnalyzer.isHighlightingAvailable(psiFile)) { @@ -346,7 +348,7 @@ public class DaemonListeners implements Disposable { messageBus.connect().subscribe(SeverityRegistrar.SEVERITIES_CHANGED_TOPIC, new Runnable() { @Override public void run() { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Severities changed"); } }); @@ -377,7 +379,7 @@ public class DaemonListeners implements Disposable { @Override public void dispose() { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Project closed"); boolean replaced = ((UserDataHolderEx)myProject).replace(DAEMON_INITIALIZED, Boolean.TRUE, Boolean.FALSE); LOG.assertTrue(replaced, "Daemon listeners already disposed for the project "+myProject); } @@ -496,7 +498,7 @@ public class DaemonListeners implements Disposable { @Override public void globalSchemeChange(EditorColorsScheme scheme) { TodoConfiguration.getInstance().colorSettingsChanged(); - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Editor color scheme changed"); } } @@ -504,7 +506,7 @@ public class DaemonListeners implements Disposable { @Override public void propertyChange(PropertyChangeEvent evt) { if (TodoConfiguration.PROP_TODO_PATTERNS.equals(evt.getPropertyName())) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Todo patterns changed"); } } } @@ -512,12 +514,12 @@ public class DaemonListeners implements Disposable { private class MyProfileChangeListener extends ProfileChangeAdapter { @Override public void profileChanged(Profile profile) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Profile changed"); } @Override public void profileActivated(Profile oldProfile, Profile profile) { - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Profile activated"); } @Override @@ -537,7 +539,7 @@ public class DaemonListeners implements Disposable { statusBar.addWidget(myTogglePopupHintsPanel, myProject); updateStatusBar(); - stopDaemonAndRestartAllFiles(); + stopDaemonAndRestartAllFiles("Inspection profiles activated"); } }); } @@ -620,13 +622,13 @@ public class DaemonListeners implements Disposable { } } - private void stopDaemon(boolean toRestartAlarm, @NonNls String reason) { - myDaemonEventPublisher.daemonCancelEventOccurred(); + private void stopDaemon(boolean toRestartAlarm, @NonNls @NotNull String reason) { + myDaemonEventPublisher.daemonCancelEventOccurred(reason); myDaemonCodeAnalyzer.stopProcess(toRestartAlarm, reason); } - private void stopDaemonAndRestartAllFiles() { - myDaemonEventPublisher.daemonCancelEventOccurred(); + private void stopDaemonAndRestartAllFiles(@NotNull String reason) { + myDaemonEventPublisher.daemonCancelEventOccurred(reason); myDaemonCodeAnalyzer.restart(); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index 5d087898ab66..9e6f70daa6f1 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -105,7 +105,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme myProgress = new DaemonProgressIndicator(); project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { @Override - public void daemonCancelEventOccurred() { + public void daemonCancelEventOccurred(@NotNull String reason) { myProgress.cancel(); } }); diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java index 53b8599ab864..f486d0469745 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.TextRange; import com.intellij.util.Consumer; import com.intellij.util.messages.MessageBusConnection; +import org.jetbrains.annotations.NotNull; public class EditorPlaybackCall { @@ -87,7 +88,7 @@ public class EditorPlaybackCall { } @Override - public void daemonCancelEventOccurred() { + public void daemonCancelEventOccurred(@NotNull String reason) { result.setDone(); } });