From e1d39a85f4600d8e1b9f7aad14b0d60fe834925d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 11 Sep 2025 17:22:36 +0200 Subject: [PATCH] introduce DCA."restart" methods with "reason" parameter, port old "restart"s to the new ones, to fix IJPL-207110 make daemon restart explicit and visible in logs GitOrigin-RevId: 23e8c9ea47b272be73814849fb0648caf1a317eb --- .../compiler/JavaCompilerConfiguration.java | 2 +- .../options/editor/JavaAutoImportOptions.kt | 2 +- ...nHighlightVisitorRespondToChangesTest.java | 2 +- .../impl/DaemonRespondToChangesTest.java | 2 +- .../impl/HighlightingMarkupGraveTest.java | 2 +- .../daemon/impl/LazyQuickFixTest.java | 2 +- .../daemon/impl/LightBulbTest.java | 2 +- .../jsonSchema/JsonSchemaVfsListener.java | 2 +- .../impl/JsonSchemaServiceImpl.java | 2 +- .../JsonSchemaMappingsConfigurable.java | 2 +- platform/analysis-api/api-dump-unreviewed.txt | 2 -- platform/analysis-api/api-dump.txt | 5 +++ .../daemon/DaemonCodeAnalyzer.java | 35 ++++++++++++++++--- .../codeInspection/ex/QuickFixWrapper.java | 2 +- .../daemon/impl/DaemonCodeAnalyzerEx.java | 3 -- .../util/DiffEditorHighlighterUpdater.java | 4 +-- .../codeInsight/hints/InlayHintsSwitch.kt | 2 +- .../codeInsight/codeVision/CodeVisionHost.kt | 2 +- .../daemon/impl/DaemonCodeAnalyzerImpl.java | 17 ++++----- .../quickFix/AbstractCreateFileFix.java | 2 +- .../codeInsight/hints/PopupActions.kt | 2 +- .../codeVision/CodeVisionProjectSettings.kt | 6 ++-- .../console/UseConsoleInputAction.java | 2 +- .../colors/RainbowColorsInSchemeState.java | 6 ++-- .../ide/errorTreeView/ErrorViewStructure.java | 2 +- .../daemon/impl/DaemonCodeAnalyzerTest.kt | 2 +- .../context/impl/PolyContextDiscovery.kt | 2 +- .../sm/runner/ui/SMTestRunnerResultsForm.java | 2 +- .../ant/config/impl/AntBuildFileImpl.java | 2 +- .../ant/config/impl/AntConfigurationImpl.java | 2 +- .../editor/EditorConfigStatusListener.java | 2 +- .../com/intellij/grazie/GrazieConfig.kt | 2 +- .../com/intellij/grazie/GraziePlugin.kt | 2 +- .../groovy/dsl/GroovyDslAnnotator.java | 2 +- .../intentions/dynamic/ui/DynamicDialog.java | 2 +- .../resources/TypeCustomizerInspection.java | 2 +- .../jsonpath/ui/JsonPathEvaluateView.kt | 2 +- .../core/script/k1/IdeScriptReportSink.kt | 2 +- .../core/script/k1/ScriptClassRootsUpdater.kt | 2 +- .../DefaultScriptResolutionStrategy.kt | 2 +- .../k1/roots/GradleBuildRootsLocatorImpl.kt | 2 +- .../ui/KotlinChangeSignatureDialog.kt | 2 +- .../InvalidateK2CachesInternalAction.kt | 2 +- .../k1/scratch/K1ScratchFileEditorProvider.kt | 2 +- .../scratch/ScratchFileModuleInfoProvider.kt | 2 +- ...downCodeFenceErrorHighlightingIntention.kt | 2 +- .../settings/MarkdownSmartKeysConfigurable.kt | 2 +- .../maven/utils/MavenHighlightingUpdater.kt | 2 +- .../commands/CodeAnalysisCommand.kt | 2 +- .../commands/DoLocalInspection.kt | 2 +- .../ShellcheckSetupNotificationProvider.java | 2 +- .../ShDisableInspectionIntention.java | 2 +- .../youtrack/YouTrackRepositoryEditor.java | 2 +- .../uiDesigner/designSurface/GuiEditor.java | 2 +- .../quickFixes/QuickFixManager.java | 2 +- .../lang/xpath/context/ContextProvider.java | 4 +-- .../impl/AddAssociationAction.java | 2 +- .../impl/FileAssociationsConfigurable.java | 2 +- .../impl/ToggleAssociationAction.java | 2 +- .../xpath/xslt/quickfix/AddParamBase.java | 2 +- .../xpathView/ui/InputExpressionDialog.java | 4 +-- .../backend/src/YAMLlInspectionSuppressor.kt | 2 +- .../PyIntegratedToolsConfigurable.java | 6 ++-- .../quickfix/SyncProjectQuickFix.kt | 2 +- .../PyNamespacePackagesService.java | 2 +- .../PyV3ProjectBaseGenerator.kt | 2 +- .../management/PythonPackageManagerAction.kt | 2 +- .../src/com/jetbrains/python/sdk/PySdkExt.kt | 2 +- .../sdk/PythonSdkUpdateProjectActivity.kt | 8 ++--- .../python/sdk/PythonSdkUpdater.java | 2 +- .../PyInterpreterInspectionSuppressor.kt | 2 +- .../sdk/skeletons/PySkeletonRefresher.java | 2 +- .../spellchecker/SpellCheckerManager.kt | 20 +++++------ .../spellchecker/grazie/async/AsyncUtils.kt | 6 ++-- .../grazie/async/WordListLoader.kt | 2 +- .../settings/SpellCheckerSettingsPane.java | 2 +- .../ui/SpellCheckingEditorCustomization.java | 2 +- .../impl/quickfix/FetchExtResourceAction.java | 2 +- .../impl/PsiExternalResourceChangeListener.kt | 2 +- .../htmlInspections/SwitchToHtml5Action.java | 2 +- 80 files changed, 139 insertions(+), 119 deletions(-) diff --git a/java/compiler/openapi/src/com/intellij/compiler/JavaCompilerConfiguration.java b/java/compiler/openapi/src/com/intellij/compiler/JavaCompilerConfiguration.java index b98a03106ad6..3b5d94e5e148 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/JavaCompilerConfiguration.java +++ b/java/compiler/openapi/src/com/intellij/compiler/JavaCompilerConfiguration.java @@ -45,7 +45,7 @@ final class JavaCompilerConfiguration extends JavaCompilerConfigurationProxy { value -> { setAdditionalOptions(project, module, value); PsiManager.getInstance(project).dropPsiCaches(); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart("JavaCompilerConfiguration.additionalOptions " +value); }) .withRootPane(() -> OptPane.pane(OptPane.stringList(bindId, JavaCompilerBundle.message("settings.override.compilation.options.column")))); } diff --git a/java/java-impl/src/com/intellij/application/options/editor/JavaAutoImportOptions.kt b/java/java-impl/src/com/intellij/application/options/editor/JavaAutoImportOptions.kt index c4ce6395e795..9e7a3cf37280 100644 --- a/java/java-impl/src/com/intellij/application/options/editor/JavaAutoImportOptions.kt +++ b/java/java-impl/src/com/intellij/application/options/editor/JavaAutoImportOptions.kt @@ -143,7 +143,7 @@ public class JavaAutoImportOptions(public val project: Project) : UiDslUnnamedCo } onApply { for (project in ProjectManager.getInstance().openProjects) { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("JavaAutoImportOptions.update") } } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonHighlightVisitorRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonHighlightVisitorRespondToChangesTest.java index 87c2fdde47da..3bf1e833f59b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonHighlightVisitorRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonHighlightVisitorRespondToChangesTest.java @@ -659,7 +659,7 @@ public class DaemonHighlightVisitorRespondToChangesTest extends DaemonAnalyzerTe HighlightingSettingsPerFile.getInstance(myProject).setHighlightingSettingForRoot(myFile, FileHighlightingSetting.SKIP_HIGHLIGHTING); MyCheckingCallsVisitor.VISIT_CALLED = false; MyCheckingCallsVisitor.ANALYZE_CALLED = false; - myDaemonCodeAnalyzer.restart(); + myDaemonCodeAnalyzer.restart(this); doHighlighting(); assertFalse(MyCheckingCallsVisitor.VISIT_CALLED); assertFalse(MyCheckingCallsVisitor.ANALYZE_CALLED); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java index dc79de0ecd8a..c9669d9b453f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java @@ -2159,7 +2159,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { } }); //updater.assertNoDuplicates(myFile, getErrorsFromMarkup(markupModel), "errors from markup "); - myDaemonCodeAnalyzer.restart(myFile); + myDaemonCodeAnalyzer.restart(myFile, this); List errorsFromMarkup = getErrorsFromMarkup(markupModel); //updater.assertNoDuplicates(myFile, errorsFromMarkup, "errors from markup "); //((HighlightInfoUpdaterImpl)HighlightInfoUpdater.getInstance(getProject())).assertMarkupDataConsistent(myFile); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/HighlightingMarkupGraveTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/HighlightingMarkupGraveTest.java index 5f74bb52edab..0b1c8ad19f64 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/HighlightingMarkupGraveTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/HighlightingMarkupGraveTest.java @@ -129,7 +129,7 @@ public class HighlightingMarkupGraveTest extends DaemonAnalyzerTestCase { CoroutineKt.executeSomeCoroutineTasksAndDispatchAllInvocationEvents(myProject); LaterInvocator.purgeExpiredItems(); LaterInvocator.dispatchPendingFlushes(); - DaemonCodeAnalyzer.getInstance(getProject()).restart(); + DaemonCodeAnalyzer.getInstance(getProject()).restart(this); } try { GCWatcher.tracking(FileDocumentManager.getInstance().getDocument(virtualFile)).ensureCollected(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LazyQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LazyQuickFixTest.java index 36e60e60de4a..91d9651be8ab 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LazyQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LazyQuickFixTest.java @@ -243,7 +243,7 @@ public class LazyQuickFixTest extends LightQuickFixTestCase { MyLazyFixHighlightVisitor.infoCreated = false; MyLazyFixHighlightVisitor.fixComputed = false; - DaemonCodeAnalyzerImpl.getInstance(getProject()).restart(); + DaemonCodeAnalyzerImpl.getInstance(getProject()).restart(this); doHighlighting(); assertTrue(MyLazyFixHighlightVisitor.infoCreated); assertFalse(MyLazyFixHighlightVisitor.fixComputed); // must not recompute on each restart diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LightBulbTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LightBulbTest.java index f5bfd54d7e98..4790aed3580c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LightBulbTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LightBulbTest.java @@ -265,7 +265,7 @@ public class LightBulbTest extends DaemonAnalyzerTestCase { caretRight(); UIUtil.dispatchAllInvocationEvents(); caretLeft(); - myDaemonCodeAnalyzer.restart(); + myDaemonCodeAnalyzer.restart(this); assertFalse(myDaemonCodeAnalyzer.getFileStatusMap().allDirtyScopesAreNull(myEditor.getDocument(), EditorContextManager.getEditorContext(myEditor, myProject))); long daemonStartDeadline = System.currentTimeMillis() + 5000; while (!myDaemonCodeAnalyzer.isRunning() && !myDaemonCodeAnalyzer.getFileStatusMap().allDirtyScopesAreNull(myEditor.getDocument(), EditorContextManager.getEditorContext(myEditor, myProject)) && System.currentTimeMillis() < daemonStartDeadline) { // wait until the daemon started diff --git a/json/backend/src/com/jetbrains/jsonSchema/JsonSchemaVfsListener.java b/json/backend/src/com/jetbrains/jsonSchema/JsonSchemaVfsListener.java index 9c85e55bb7aa..0d333a79ed95 100644 --- a/json/backend/src/com/jetbrains/jsonSchema/JsonSchemaVfsListener.java +++ b/json/backend/src/com/jetbrains/jsonSchema/JsonSchemaVfsListener.java @@ -124,7 +124,7 @@ public final class JsonSchemaVfsListener extends BulkVirtualFileListenerAdapter private static void restartAnalyzer(@NotNull DaemonCodeAnalyzer analyzer, @NotNull PsiManager psiManager, @NotNull VirtualFile file) { PsiFile psiFile = !psiManager.isDisposed() && file.isValid() ? psiManager.findFile(file) : null; - if (psiFile != null) analyzer.restart(psiFile); + if (psiFile != null) analyzer.restart(psiFile, "JsonSchemaUpdater"); } private void onFileChange(final @NotNull VirtualFile schemaFile) { diff --git a/json/backend/src/com/jetbrains/jsonSchema/impl/JsonSchemaServiceImpl.java b/json/backend/src/com/jetbrains/jsonSchema/impl/JsonSchemaServiceImpl.java index 0400dbfae83e..e635649bde07 100644 --- a/json/backend/src/com/jetbrains/jsonSchema/impl/JsonSchemaServiceImpl.java +++ b/json/backend/src/com/jetbrains/jsonSchema/impl/JsonSchemaServiceImpl.java @@ -120,7 +120,7 @@ public class JsonSchemaServiceImpl implements JsonSchemaService, ModificationTra for (Runnable action : myResetActions) { action.run(); } - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); } @Override diff --git a/json/backend/src/com/jetbrains/jsonSchema/settings/mappings/JsonSchemaMappingsConfigurable.java b/json/backend/src/com/jetbrains/jsonSchema/settings/mappings/JsonSchemaMappingsConfigurable.java index b5b21671e329..5aaa53132d81 100644 --- a/json/backend/src/com/jetbrains/jsonSchema/settings/mappings/JsonSchemaMappingsConfigurable.java +++ b/json/backend/src/com/jetbrains/jsonSchema/settings/mappings/JsonSchemaMappingsConfigurable.java @@ -180,7 +180,7 @@ public final class JsonSchemaMappingsConfigurable extends MasterDetailsComponent final JsonSchemaService service = JsonSchemaService.Impl.get(project); if (service != null) service.reset(); } - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); EditorNotifications.getInstance(myProject).updateAllNotifications(); } diff --git a/platform/analysis-api/api-dump-unreviewed.txt b/platform/analysis-api/api-dump-unreviewed.txt index e0aaa7cd9ac4..ebd6c5f3820e 100644 --- a/platform/analysis-api/api-dump-unreviewed.txt +++ b/platform/analysis-api/api-dump-unreviewed.txt @@ -409,8 +409,6 @@ a:com.intellij.codeInsight.daemon.DaemonCodeAnalyzer - a:isAutohintsAvailable(com.intellij.psi.PsiFile):Z - a:isHighlightingAvailable(com.intellij.psi.PsiFile):Z - a:isImportHintsEnabled(com.intellij.psi.PsiFile):Z -- a:restart():V -- a:restart(com.intellij.psi.PsiFile):V - a:setHighlightingEnabled(com.intellij.psi.PsiFile,Z):V - a:setImportHintsEnabled(com.intellij.psi.PsiFile,Z):V - a:settingsChanged():V diff --git a/platform/analysis-api/api-dump.txt b/platform/analysis-api/api-dump.txt index 12a091fde278..9b7d41f388cf 100644 --- a/platform/analysis-api/api-dump.txt +++ b/platform/analysis-api/api-dump.txt @@ -22,6 +22,11 @@ a:com.intellij.codeInsight.completion.PrefixMatcher - getMatchingFragments(java.lang.String):java.util.List com.intellij.codeInsight.daemon.ChangeLocalityDetector - a:getChangeHighlightingDirtyScopeFor(com.intellij.psi.PsiElement):com.intellij.psi.PsiElement +a:com.intellij.codeInsight.daemon.DaemonCodeAnalyzer +- restart():V +- restart(com.intellij.psi.PsiFile):V +- restart(com.intellij.psi.PsiFile,java.lang.Object):V +- restart(java.lang.Object):V com.intellij.codeInsight.daemon.DaemonCodeAnalyzer$DaemonListener - daemonCancelEventOccurred(java.lang.String):V - daemonCanceled(java.lang.String,java.util.Collection):V 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 cff15818489f..6348ab0020e7 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java @@ -13,6 +13,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.messages.Topic; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -48,17 +49,41 @@ public abstract class DaemonCodeAnalyzer { /** * Force re-highlighting for all files. - * - * @see #restart(PsiFile) + * @deprecated use {@link #restart(Object)} */ - public abstract void restart(); + @Deprecated + public void restart() { + restart("Global restart"); + } + + /** + * Force re-highlighting for all files, for the {@code reason}. + * @param reason some object which {@code .toString()} will be written to the log file, to identify the source of the daemon restart. + * E.g. it could be a string {@code "project roots changed"}, or an instance of quick fix class, etc. + */ + public void restart(@NotNull @NonNls Object reason) { + throw new AbstractMethodError(); + } /** * Force re-highlighting for a specific file. * - * @param psiFile the file to rehighlight. + * @deprecated use {@link #restart(PsiFile, Object)} */ - public abstract void restart(@NotNull PsiFile psiFile); + @Deprecated + public void restart(@NotNull PsiFile psiFile) { + restart(psiFile, "Global restart"); + } + /** + * Force re-highlighting of this particular {@code psiFile}. + * + * @param psiFile the file to rehighlight. + * @param reason some object which {@code .toString()} will be written to the log file, to identify the source of the daemon restart. + * E.g. it could be a string {@code "project roots changed"}, or an instance of quick fix class, etc. + */ + public void restart(@NotNull PsiFile psiFile, @NotNull @NonNls Object reason) { + throw new AbstractMethodError(); + } public abstract void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile psiFile); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/QuickFixWrapper.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/QuickFixWrapper.java index 1dd6c6b1fccb..3088ec2d940a 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ex/QuickFixWrapper.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/QuickFixWrapper.java @@ -158,7 +158,7 @@ public final class QuickFixWrapper implements IntentionAction, PriorityAction, C final PsiElement element = myDescriptor.getPsiElement(); final PsiFile fileForUndo = element == null ? null : element.getContainingFile(); myFix.applyFix(project, myDescriptor); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart(this); if (fileForUndo != null && !fileForUndo.equals(psiFile)) { UndoUtil.markPsiFileForUndo(fileForUndo); } diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java index 8eb5e4526d08..2e9613a0926a 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java @@ -36,9 +36,6 @@ public abstract class DaemonCodeAnalyzerEx extends DaemonCodeAnalyzer { return (DaemonCodeAnalyzerEx)getInstance(project); } - @ApiStatus.Internal - public abstract void restart(@NotNull Object reason); - // todo IJPL-339 mark deprecated /** * Do not perform any meaningful work inside the processor because iteration is performed under MarkupModel lock diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffEditorHighlighterUpdater.java b/platform/diff-impl/src/com/intellij/diff/util/DiffEditorHighlighterUpdater.java index 655b0e247349..edc75929cdbf 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffEditorHighlighterUpdater.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffEditorHighlighterUpdater.java @@ -57,7 +57,7 @@ public class DiffEditorHighlighterUpdater extends EditorHighlighterUpdater { * @see com.intellij.codeInsight.daemon.impl.EditorTrackerImpl#activeWindow * @see com.intellij.openapi.fileEditor.FileEditorWithTextEditors */ - private static void restartHighlighterFor(@Nullable Project project, @NotNull Editor editor) { + private void restartHighlighterFor(@Nullable Project project, @NotNull Editor editor) { if (project == null) return; // Rely on com.intellij.codeInsight.daemon.impl.EditorTracker and EditorTrackerListener.TOPIC in a focused window @@ -76,7 +76,7 @@ public class DiffEditorHighlighterUpdater extends EditorHighlighterUpdater { .submit(NonUrgentExecutor.getInstance()) .onSuccess(psiFile -> { if (psiFile != null) { - DaemonCodeAnalyzer.getInstance(project).restart(psiFile); + DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this); } }); } diff --git a/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsSwitch.kt b/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsSwitch.kt index 2c710e92b40d..790161374aa2 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsSwitch.kt +++ b/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsSwitch.kt @@ -22,7 +22,7 @@ interface InlayHintsSwitch { for (switch in EP.extensionList) { switch.setEnabled(project, value) } - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("InlayHintsSwitch enabled=$value") } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/codeVision/CodeVisionHost.kt b/platform/lang-impl/src/com/intellij/codeInsight/codeVision/CodeVisionHost.kt index 0867f8c3cb67..6038d0f0843e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/codeVision/CodeVisionHost.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/codeVision/CodeVisionHost.kt @@ -303,7 +303,7 @@ open class CodeVisionHost(val project: Project) { for (editor in EditorFactory.getInstance().allEditors) { ModificationStampUtil.clearModificationStamp(editor) } - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("CodeVisionHost.providerAvailabilityChanged $id") invalidateProviderSignal.fire(LensInvalidateSignal(null)) } }) 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 42571012972b..2d64798bf086 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 @@ -444,6 +444,7 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx @Override protected void progressIsAdvanced(@NotNull HighlightingSession session, Editor editor, double progress) { + assertFileFromMyProject(session.getProject(),session.getPsiFile()); if (editor != null) { repaintIconHelper.repaintTrafficIcon(session.getPsiFile(), editor, progress); } @@ -855,11 +856,6 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx return isHighlightingAvailable(psiFile) && !(psiFile instanceof PsiCompiledElement); } - @Override - public void restart() { - restart("Global restart"); - } - @NotNull private static List getFileLevelHighlights(@NotNull FileEditor textEditor) { List highlights = textEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); @@ -873,15 +869,14 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx } @Override - public void restart(@NotNull PsiFile psiFile) { + public void restart(@NotNull PsiFile psiFile, @NotNull Object reason) { assertFileFromMyProject(psiFile.getProject(), psiFile); Document document = psiFile.getViewProvider().getDocument(); - if (document == null) { - return; + if (document != null) { + String r = "Psi file restart: " + psiFile.getName() + ": " + reason; + myFileStatusMap.markWholeFileScopeDirty(document, r); + stopProcess(true, r); } - String reason = "Psi file restart: " + psiFile.getName(); - myFileStatusMap.markWholeFileScopeDirty(document, reason); - stopProcess(true, reason); } public @NotNull List getPassesToShowProgressFor(@NotNull Document document) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/AbstractCreateFileFix.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/AbstractCreateFileFix.java index 3ebe4d3757c6..f8cd1d227641 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/AbstractCreateFileFix.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/AbstractCreateFileFix.java @@ -285,7 +285,7 @@ public abstract class AbstractCreateFileFix extends LocalQuickFixAndIntentionAct // rerun code-insight after popup close PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile != null) { - DaemonCodeAnalyzer.getInstance(project).restart(psiFile); + DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this); } } }) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt index 09f2d72d936d..5d49b86b78a1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/PopupActions.kt @@ -342,7 +342,7 @@ private fun refreshAllOpenEditors(project: Project) { val fileEditorManager = FileEditorManager.getInstance(project) fileEditorManager.selectedFiles.forEach { file -> - psiManager.findFile(file)?.let { daemonCodeAnalyzer.restart(it) } + psiManager.findFile(file)?.let { daemonCodeAnalyzer.restart(it, "PopupActionsKt.refreshAllOpenEditors") } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/CodeVisionProjectSettings.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/CodeVisionProjectSettings.kt index af62b92d6fd4..ccbef5db333f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/CodeVisionProjectSettings.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/CodeVisionProjectSettings.kt @@ -33,7 +33,7 @@ internal class CodeVisionProjectSettings( } } if (changed) { - forceCodeVisionPass() + forceCodeVisionPass("CodeVisionProjectSettings.enabled=$isEnabled") } } @@ -47,9 +47,9 @@ internal class CodeVisionProjectSettings( var isEnabledForProject: Boolean by property(true) } - private fun forceCodeVisionPass() { + private fun forceCodeVisionPass(reason: Any) { ModificationStampUtil.clearModificationStamp() - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(reason) project.service().invalidateProviderSignal.fire(CodeVisionHost.LensInvalidateSignal(null)) } diff --git a/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java b/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java index 82c3db213bbe..21b84a634365 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java +++ b/platform/lang-impl/src/com/intellij/execution/console/UseConsoleInputAction.java @@ -44,7 +44,7 @@ final class UseConsoleInputAction extends ToggleAction implements DumbAware { DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject()); PsiFile file = consoleView.getFile(); daemonCodeAnalyzer.setHighlightingEnabled(file, state); - daemonCodeAnalyzer.restart(file); + daemonCodeAnalyzer.restart(file, this); PropertiesComponent.getInstance().setValue(processInputStateKey, useProcessStdIn); List actions = ActionUtil.getActions(consoleView.getConsoleEditor().getComponent()); diff --git a/platform/platform-impl/src/com/intellij/application/options/colors/RainbowColorsInSchemeState.java b/platform/platform-impl/src/com/intellij/application/options/colors/RainbowColorsInSchemeState.java index 21e0ba015aaf..34d2f2b5bc9e 100644 --- a/platform/platform-impl/src/com/intellij/application/options/colors/RainbowColorsInSchemeState.java +++ b/platform/platform-impl/src/com/intellij/application/options/colors/RainbowColorsInSchemeState.java @@ -45,12 +45,12 @@ public final class RainbowColorsInSchemeState { scheme.setAttributes(key, RainbowHighlighter.createRainbowAttribute(color)); } } - updateRainbowMarkup(scheme); + updateRainbowMarkup(scheme, this); } } @ApiStatus.Internal - public static void updateRainbowMarkup(@NotNull EditorColorsScheme scheme) { + public static void updateRainbowMarkup(@NotNull EditorColorsScheme scheme, @NotNull Object reason) { Set languagesWithRainbowHighlighting = getRainbowOnLanguageIds(scheme); reportStatistic(languagesWithRainbowHighlighting); @@ -67,7 +67,7 @@ public final class RainbowColorsInSchemeState { if (project != null) { PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file != null) { - DaemonCodeAnalyzer.getInstance(project).restart(file); + DaemonCodeAnalyzer.getInstance(project).restart(file, reason); } } } diff --git a/platform/platform-impl/src/com/intellij/ide/errorTreeView/ErrorViewStructure.java b/platform/platform-impl/src/com/intellij/ide/errorTreeView/ErrorViewStructure.java index 96866e8c0991..e7b2bfc3a82f 100644 --- a/platform/platform-impl/src/com/intellij/ide/errorTreeView/ErrorViewStructure.java +++ b/platform/platform-impl/src/com/intellij/ide/errorTreeView/ErrorViewStructure.java @@ -474,7 +474,7 @@ public class ErrorViewStructure extends AbstractTreeStructure { ApplicationManager.getApplication().runReadAction(() -> { final PsiFile psiFile = virtualFile.isValid()? PsiManager.getInstance(myProject).findFile(virtualFile) : null; if (psiFile != null) { - DaemonCodeAnalyzer.getInstance(myProject).restart(psiFile); // urge the daemon to re-highlight the file despite no modification has been made + DaemonCodeAnalyzer.getInstance(myProject).restart(psiFile, this); // urge the daemon to re-highlight the file despite no modification has been made } }); } diff --git a/platform/platform-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerTest.kt b/platform/platform-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerTest.kt index a032d79a27bc..2c909b3faeed 100644 --- a/platform/platform-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerTest.kt @@ -52,7 +52,7 @@ class DaemonCodeAnalyzerTest { while (!ApplicationManagerEx.getApplicationEx().isWriteActionPending) { Thread.sleep(10) } - analyzer.restart() + analyzer.restart(this) Thread.sleep(DaemonCodeAnalyzerSettings.getInstance().autoReparseDelay.times(2).toLong()) UIUtil.dispatchAllInvocationEvents() assertFalse(listenerInvoked.get()) diff --git a/platform/polySymbols/src/com/intellij/polySymbols/context/impl/PolyContextDiscovery.kt b/platform/polySymbols/src/com/intellij/polySymbols/context/impl/PolyContextDiscovery.kt index 8ff9c083d4c8..48dbb5a2b48c 100644 --- a/platform/polySymbols/src/com/intellij/polySymbols/context/impl/PolyContextDiscovery.kt +++ b/platform/polySymbols/src/com/intellij/polySymbols/context/impl/PolyContextDiscovery.kt @@ -444,7 +444,7 @@ private class PolyContextDiscoveryInfo(private val project: Project, private val } }) messageBus.subscribe(PolyContextChangeListener.TOPIC, PolyContextChangeListener { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("PolyContextDiscoveryInfo.PolyContextChangeListener") }) messageBus.subscribe(VFS_CHANGES, object : BulkFileListener { override fun after(events: MutableList) { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java index 0d69883c99e2..c393dd5e3c56 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java @@ -884,7 +884,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel @Override public void run(@NotNull ProgressIndicator indicator) { writeState(); - DaemonCodeAnalyzer.getInstance(getProject()).restart(); + DaemonCodeAnalyzer.getInstance(getProject()).restart(this); try { SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newDefaultInstance(); TransformerHandler handler = transformerFactory.newTransformerHandler(); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildFileImpl.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildFileImpl.java index cc9e4e35c72a..40d040ee7f36 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildFileImpl.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildFileImpl.java @@ -331,7 +331,7 @@ public final class AntBuildFileImpl implements AntBuildFileBase { @Override public void updateConfig() { basicUpdateConfig(); - DaemonCodeAnalyzer.getInstance(getProject()).restart(); + DaemonCodeAnalyzer.getInstance(getProject()).restart(this); } public void setTreeViewAnsiColor(final boolean value) { diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java index f4eca36afabe..24653a42d03b 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java @@ -143,7 +143,7 @@ public final class AntConfigurationImpl extends AntConfigurationBase implements ModalityUiUtil.invokeLaterIfNeeded(ModalityState.any(), () -> { if (project.isDisposed()) return; - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart(AntConfigurationImpl.this); }); } }); diff --git a/plugins/editorconfig/backend/src/configmanagement/editor/EditorConfigStatusListener.java b/plugins/editorconfig/backend/src/configmanagement/editor/EditorConfigStatusListener.java index de6314c97a96..c1d22d236309 100644 --- a/plugins/editorconfig/backend/src/configmanagement/editor/EditorConfigStatusListener.java +++ b/plugins/editorconfig/backend/src/configmanagement/editor/EditorConfigStatusListener.java @@ -73,7 +73,7 @@ final class EditorConfigStatusListener implements CodeStyleSettingsListener { Document document = FileDocumentManager.getInstance().getDocument(myVirtualFile); PsiFile psiFile = document == null ? null : PsiDocumentManager.getInstance(myProject).getPsiFile(document); if (psiFile != null) { - DaemonCodeAnalyzer.getInstance(myProject).restart(psiFile); + DaemonCodeAnalyzer.getInstance(myProject).restart(psiFile, this); } } diff --git a/plugins/grazie/src/main/kotlin/com/intellij/grazie/GrazieConfig.kt b/plugins/grazie/src/main/kotlin/com/intellij/grazie/GrazieConfig.kt index ea3e5985e358..7653e175dd16 100644 --- a/plugins/grazie/src/main/kotlin/com/intellij/grazie/GrazieConfig.kt +++ b/plugins/grazie/src/main/kotlin/com/intellij/grazie/GrazieConfig.kt @@ -189,7 +189,7 @@ class GrazieConfig : PersistentStateComponent, ModificationT service().publisher.update(prevState, newState) ProjectManager.getInstance().openProjects.forEach { - DaemonCodeAnalyzer.getInstance(it).restart() + DaemonCodeAnalyzer.getInstance(it).restart("GrazieConfig") } } } diff --git a/plugins/grazie/src/main/kotlin/com/intellij/grazie/GraziePlugin.kt b/plugins/grazie/src/main/kotlin/com/intellij/grazie/GraziePlugin.kt index 05dae7fa1e3d..bc4d478e6109 100644 --- a/plugins/grazie/src/main/kotlin/com/intellij/grazie/GraziePlugin.kt +++ b/plugins/grazie/src/main/kotlin/com/intellij/grazie/GraziePlugin.kt @@ -48,7 +48,7 @@ object GraziePlugin { } if (project.isInitialized && project.isOpen) { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("Hunspell.update") } } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslAnnotator.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslAnnotator.java index 41aadce25bb6..32853f514ed2 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslAnnotator.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslAnnotator.java @@ -78,7 +78,7 @@ public final class GroovyDslAnnotator implements Annotator { public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException { FileDocumentManager.getInstance().saveAllDocuments(); GroovyDslFileIndex.activate(myVfile); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart(this); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java index 4155b63b4325..24e5309ef076 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/ui/DynamicDialog.java @@ -250,7 +250,7 @@ public abstract class DynamicDialog extends DialogWrapper { public void doCancelAction() { super.doCancelAction(); - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/resources/TypeCustomizerInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/resources/TypeCustomizerInspection.java index 3f4f764a3014..92e3c80991fd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/resources/TypeCustomizerInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/resources/TypeCustomizerInspection.java @@ -121,7 +121,7 @@ public final class TypeCustomizerInspection extends BaseInspection { final String sourceRootPath = VfsUtilCore.getRelativePath(sourceRoot, contentRoot, '/'); CompilerConfiguration.getInstance(project).addResourceFilePattern(sourceRootPath + ':' + path); } - DaemonCodeAnalyzer.getInstance(project).restart(file); + DaemonCodeAnalyzer.getInstance(project).restart(file, this); } } } diff --git a/plugins/jsonpath/src/com/intellij/jsonpath/ui/JsonPathEvaluateView.kt b/plugins/jsonpath/src/com/intellij/jsonpath/ui/JsonPathEvaluateView.kt index a33abde8d1a0..d26351c9b583 100644 --- a/plugins/jsonpath/src/com/intellij/jsonpath/ui/JsonPathEvaluateView.kt +++ b/plugins/jsonpath/src/com/intellij/jsonpath/ui/JsonPathEvaluateView.kt @@ -158,7 +158,7 @@ internal abstract class JsonPathEvaluateView(protected val project: Project) : S val jsonPathFile = PsiDocumentManager.getInstance(project).getPsiFile(searchTextField.document) if (jsonPathFile != null) { // reset inspections in expression - DaemonCodeAnalyzer.getInstance(project).restart(jsonPathFile) + DaemonCodeAnalyzer.getInstance(project).restart(jsonPathFile, this) } } diff --git a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/IdeScriptReportSink.kt b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/IdeScriptReportSink.kt index 4181828382c1..cc8cf407fca0 100644 --- a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/IdeScriptReportSink.kt +++ b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/IdeScriptReportSink.kt @@ -27,7 +27,7 @@ class IdeScriptReportSink( coroutineScope.launch { readAction { PsiManager.getInstance(project).findFile(scriptFile)?.let { - DaemonCodeAnalyzer.getInstance(project).restart(it) + DaemonCodeAnalyzer.getInstance(project).restart(it, this) } EditorNotifications.getInstance(project).updateAllNotifications() diff --git a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/ScriptClassRootsUpdater.kt b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/ScriptClassRootsUpdater.kt index d5e07532f58c..532f232d2afd 100644 --- a/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/ScriptClassRootsUpdater.kt +++ b/plugins/kotlin/base/scripting/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/ScriptClassRootsUpdater.kt @@ -418,7 +418,7 @@ abstract class ScriptClassRootsUpdater( openedScripts.forEach { if (it.isValid) { - (PsiManager.getInstance(project).findFile(it) as? KtFile)?.let { ktFile -> DaemonCodeAnalyzer.getInstance(project).restart(ktFile) } + (PsiManager.getInstance(project).findFile(it) as? KtFile)?.let { ktFile -> DaemonCodeAnalyzer.getInstance(project).restart(ktFile, this) } } } } diff --git a/plugins/kotlin/base/scripting/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/highlighting/DefaultScriptResolutionStrategy.kt b/plugins/kotlin/base/scripting/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/highlighting/DefaultScriptResolutionStrategy.kt index b6ac0b0129ef..f307b1582179 100644 --- a/plugins/kotlin/base/scripting/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/highlighting/DefaultScriptResolutionStrategy.kt +++ b/plugins/kotlin/base/scripting/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/highlighting/DefaultScriptResolutionStrategy.kt @@ -106,7 +106,7 @@ class DefaultScriptResolutionStrategy(val project: Project, val coroutineScope: if (ktFile.alwaysVirtualFile !in filesInEditors) continue if (project.isOpen && !project.isDisposed) { readAction { - DaemonCodeAnalyzer.getInstance(project).restart(ktFile) + DaemonCodeAnalyzer.getInstance(project).restart(ktFile, this) } } } diff --git a/plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.k1/src/org/jetbrains/kotlin/gradle/scripting/k1/roots/GradleBuildRootsLocatorImpl.kt b/plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.k1/src/org/jetbrains/kotlin/gradle/scripting/k1/roots/GradleBuildRootsLocatorImpl.kt index c3b2658db94c..3ba9d4b26988 100644 --- a/plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.k1/src/org/jetbrains/kotlin/gradle/scripting/k1/roots/GradleBuildRootsLocatorImpl.kt +++ b/plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.k1/src/org/jetbrains/kotlin/gradle/scripting/k1/roots/GradleBuildRootsLocatorImpl.kt @@ -174,7 +174,7 @@ class GradleBuildRootsLocatorImpl(val project: Project, private val coroutineSco // this required only for "pause" state PsiManager.getInstance(project).findFile(it)?.let { ktFile -> - DaemonCodeAnalyzer.getInstance(project).restart(ktFile) + DaemonCodeAnalyzer.getInstance(project).restart(ktFile, this) } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt index 3c342fb213f2..3e3b281f36b2 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt @@ -173,7 +173,7 @@ class KotlinChangeSignatureDialog ( val codeFragment = parameter.defaultValueCodeFragment as KtExpressionCodeFragment if (newKotlinType != oldKotlinType && codeFragment.getContentElement() != null) { codeFragment.putUserData(CodeFragmentAnalyzer.EXPECTED_TYPE_KEY, kotlinTypeInfo.type) - DaemonCodeAnalyzer.getInstance(codeFragment.project).restart(codeFragment) + DaemonCodeAnalyzer.getInstance(codeFragment.project).restart(codeFragment, this) } if (!forPreview) AddFullQualifierIntention.Holder.addQualifiersRecursively(codeFragment) diff --git a/plugins/kotlin/internal/src/org/jetbrains/kotlin/idea/internal/actions/InvalidateK2CachesInternalAction.kt b/plugins/kotlin/internal/src/org/jetbrains/kotlin/idea/internal/actions/InvalidateK2CachesInternalAction.kt index ddfd78ffe96f..ea629e415850 100644 --- a/plugins/kotlin/internal/src/org/jetbrains/kotlin/idea/internal/actions/InvalidateK2CachesInternalAction.kt +++ b/plugins/kotlin/internal/src/org/jetbrains/kotlin/idea/internal/actions/InvalidateK2CachesInternalAction.kt @@ -31,7 +31,7 @@ internal class InvalidateK2CachesInternalAction : AnAction() { val project = e.project ?: return val invalidationMode = InvalidateCachesDialog.show() ?: return invalidateCaches(project, invalidationMode) - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(this) showNotificationAboutInvalidatedCaches(project, invalidationMode) } diff --git a/plugins/kotlin/jvm/k1/src/org/jetbrains/kotlin/idea/jvm/k1/scratch/K1ScratchFileEditorProvider.kt b/plugins/kotlin/jvm/k1/src/org/jetbrains/kotlin/idea/jvm/k1/scratch/K1ScratchFileEditorProvider.kt index c8390f4500f4..cf44cfec18c4 100644 --- a/plugins/kotlin/jvm/k1/src/org/jetbrains/kotlin/idea/jvm/k1/scratch/K1ScratchFileEditorProvider.kt +++ b/plugins/kotlin/jvm/k1/src/org/jetbrains/kotlin/idea/jvm/k1/scratch/K1ScratchFileEditorProvider.kt @@ -89,7 +89,7 @@ internal class K1ScratchFileEditorProvider : KtScratchFileEditorProvider() { if (!file.project.isDisposed) { val scratch = file.getPsiFile() if (scratch?.isValid == true) { - DaemonCodeAnalyzer.getInstance(project).restart(scratch) + DaemonCodeAnalyzer.getInstance(project).restart(scratch, this) } } } diff --git a/plugins/kotlin/jvm/shared/src/org/jetbrains/kotlin/idea/jvm/shared/scratch/ScratchFileModuleInfoProvider.kt b/plugins/kotlin/jvm/shared/src/org/jetbrains/kotlin/idea/jvm/shared/scratch/ScratchFileModuleInfoProvider.kt index 61924c242bd9..0a2ecaece1db 100644 --- a/plugins/kotlin/jvm/shared/src/org/jetbrains/kotlin/idea/jvm/shared/scratch/ScratchFileModuleInfoProvider.kt +++ b/plugins/kotlin/jvm/shared/src/org/jetbrains/kotlin/idea/jvm/shared/scratch/ScratchFileModuleInfoProvider.kt @@ -32,7 +32,7 @@ class ScratchFileModuleInfoProvider : ScratchFileListener { // Drop caches for old module ScriptDependenciesModificationTracker.getInstance(project).incModificationCount() // Force re-highlighting - runReadAction { DaemonCodeAnalyzer.getInstance(project).restart(psiFile) } + runReadAction { DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this) } } val module = ScriptRelatedModuleNameFile[project, virtualFile]?.let { ModuleManager.getInstance(project).findModuleByName(it) } ?: return diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/injection/MarkdownCodeFenceErrorHighlightingIntention.kt b/plugins/markdown/core/src/org/intellij/plugins/markdown/injection/MarkdownCodeFenceErrorHighlightingIntention.kt index 45d612096a19..501fc5ac1168 100644 --- a/plugins/markdown/core/src/org/intellij/plugins/markdown/injection/MarkdownCodeFenceErrorHighlightingIntention.kt +++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/injection/MarkdownCodeFenceErrorHighlightingIntention.kt @@ -42,7 +42,7 @@ internal class MarkdownCodeFenceErrorHighlightingIntention : IntentionAction { continue } val psi = psiManager.findFile(file) ?: continue - codeAnalyzer.restart(psi) + codeAnalyzer.restart(psi, this) } } } diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/settings/MarkdownSmartKeysConfigurable.kt b/plugins/markdown/core/src/org/intellij/plugins/markdown/settings/MarkdownSmartKeysConfigurable.kt index 1ab83440acd2..eb57d02420f4 100644 --- a/plugins/markdown/core/src/org/intellij/plugins/markdown/settings/MarkdownSmartKeysConfigurable.kt +++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/settings/MarkdownSmartKeysConfigurable.kt @@ -97,7 +97,7 @@ internal class MarkdownSmartKeysConfigurable: UiDslUnnamedConfigurable.Simple(), coroutineScope.launch { readAction { ProjectUtil.getOpenProjects().forEach { project -> - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("MarkdownSmartKeysConfigurable.create") } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenHighlightingUpdater.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenHighlightingUpdater.kt index ba6490956f97..69e0de4d1063 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenHighlightingUpdater.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenHighlightingUpdater.kt @@ -104,7 +104,7 @@ internal class MavenHighlightingUpdater( if (!MavenDomUtil.isMavenFile(psiFile)) return@readAction null - DaemonCodeAnalyzer.getInstance(project).restart(psiFile) + DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this) } } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/CodeAnalysisCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/CodeAnalysisCommand.kt index ad6a3a8de886..89c763949015 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/CodeAnalysisCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/CodeAnalysisCommand.kt @@ -118,7 +118,7 @@ class CodeAnalysisCommand(text: String, line: Int) : AbstractCommand(text, line) DumbService.getInstance(project).smartInvokeLater { PsiManager.getInstance(project).dropPsiCaches() context.message("Code highlighting started", line) - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(this) } return actionCallback.toPromise() } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/DoLocalInspection.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/DoLocalInspection.kt index e30ba7b0ff59..47d3dc78172d 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/DoLocalInspection.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/DoLocalInspection.kt @@ -115,7 +115,7 @@ class DoLocalInspection(text: String, line: Int) : PlaybackCommandCoroutineAdapt val document = FileEditorManager.getInstance(project).selectedTextEditor!!.document val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document)!! - DaemonCodeAnalyzer.getInstance(project).restart(psiFile) + DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this) } } } diff --git a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckSetupNotificationProvider.java b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckSetupNotificationProvider.java index 5ee465e252fb..c96e1191e9cd 100644 --- a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckSetupNotificationProvider.java +++ b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/ShellcheckSetupNotificationProvider.java @@ -36,7 +36,7 @@ public class ShellcheckSetupNotificationProvider implements EditorNotificationPr Runnable onSuccess = () -> { EditorNotifications.getInstance(project).updateAllNotifications(); PsiFile psiFile = PsiManager.getInstance(project).findFile(file); - if (psiFile != null) DaemonCodeAnalyzer.getInstance(project).restart(psiFile); + if (psiFile != null) DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this); NOTIFICATION_GROUP.createNotification(message("sh.shell.script"), message("sh.shellcheck.success.install"), NotificationType.INFORMATION).notify(project); diff --git a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/intention/ShDisableInspectionIntention.java b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/intention/ShDisableInspectionIntention.java index 84887b6a3fef..245d91aebe50 100644 --- a/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/intention/ShDisableInspectionIntention.java +++ b/plugins/sh/backend/src/com/intellij/sh/backend/shellcheck/intention/ShDisableInspectionIntention.java @@ -53,7 +53,7 @@ public class ShDisableInspectionIntention implements IntentionAction, LowPriorit tool.disableInspection(myInspectionCode); } }); - DaemonCodeAnalyzer.getInstance(project).restart(psiFile); + DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this); } @Override diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepositoryEditor.java index 8a12d1b1ad07..7c400d8f2ca6 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackRepositoryEditor.java @@ -39,7 +39,7 @@ public class YouTrackRepositoryEditor extends BaseRepositoryEditor{ if (!myEditor.ensureEditable()) return; myEditor.getRootContainer().suppressInspection(myInspectionId, myComponent); myEditor.refreshAndSave(true); - DaemonCodeAnalyzer.getInstance(myEditor.getProject()).restart(); + DaemonCodeAnalyzer.getInstance(myEditor.getProject()).restart(this); } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/context/ContextProvider.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/context/ContextProvider.java index aab27ccb312d..65a195657429 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/context/ContextProvider.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/context/ContextProvider.java @@ -212,7 +212,7 @@ public abstract class ContextProvider { } } - private static void setXPathInjected(final PsiFile file) { + private void setXPathInjected(final PsiFile file) { final Boolean flag = file.getUserData(XML_FILE_WITH_XPATH_INJECTTION); // This is a very ugly hack, but it is required to make the implicit usages provider recognize namespace declarations used from @@ -226,7 +226,7 @@ public abstract class ContextProvider { file.putUserData(XML_FILE_WITH_XPATH_INJECTTION, Boolean.TRUE); // TODO workaround for highlighting tests if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - DaemonCodeAnalyzer.getInstance(file.getProject()).restart(file); + DaemonCodeAnalyzer.getInstance(file.getProject()).restart(file, this); } } }); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java index 4be0038ca6b3..938f80893ebf 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java @@ -49,7 +49,7 @@ class AddAssociationAction extends AnAction { if (psiFile == null) return; addAssociation(psiFile); - DaemonCodeAnalyzer.getInstance(psiFile.getProject()).restart(psiFile); + DaemonCodeAnalyzer.getInstance(psiFile.getProject()).restart(psiFile, this); } protected void addAssociation(final PsiFile psiFile) { diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/FileAssociationsConfigurable.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/FileAssociationsConfigurable.java index 3d8de69acd3e..c1e6ef1bd1ff 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/FileAssociationsConfigurable.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/FileAssociationsConfigurable.java @@ -70,7 +70,7 @@ public final class FileAssociationsConfigurable implements SearchableConfigurabl @Override public void apply() { myEditor.apply(); - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); } @Override diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/ToggleAssociationAction.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/ToggleAssociationAction.java index e582b30bbd3b..63103135b1aa 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/ToggleAssociationAction.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/ToggleAssociationAction.java @@ -69,6 +69,6 @@ class ToggleAssociationAction extends ToggleAction { public void setSelected(@NotNull AnActionEvent e, boolean state) { assert !state; myFileAssociationsManager.removeAssociation(myPsiFile, myAssoc); - DaemonCodeAnalyzer.getInstance(AnAction.getEventProject(e)).restart(); + DaemonCodeAnalyzer.getInstance(AnAction.getEventProject(e)).restart(this); } } \ No newline at end of file diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/quickfix/AddParamBase.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/quickfix/AddParamBase.java index 49e15abb7134..acb5e790b45a 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/quickfix/AddParamBase.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/quickfix/AddParamBase.java @@ -47,6 +47,6 @@ public abstract class AddParamBase extends AbstractFix { RefactoringUtil.addParameter(templateTag, paramTag); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart(this); } } \ No newline at end of file diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputExpressionDialog.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputExpressionDialog.java index d333f80f35b6..ea83c7919248 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputExpressionDialog.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/InputExpressionDialog.java @@ -112,7 +112,7 @@ public abstract class InputExpressionDialog extends if (item != null) { myContextProvider.getNamespaceContext().setMap(asMap(item.namespaces)); if (myXPathFile != null) { - analyzer.restart(myXPathFile); + analyzer.restart(myXPathFile, this); } } } @@ -202,7 +202,7 @@ public abstract class InputExpressionDialog extends } final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myProject); - analyzer.restart(myXPathFile); + analyzer.restart(myXPathFile, this); } private Set findUnresolvedPrefixes() { diff --git a/plugins/yaml/backend/src/YAMLlInspectionSuppressor.kt b/plugins/yaml/backend/src/YAMLlInspectionSuppressor.kt index cb5d013480d6..1fedf38a7f17 100644 --- a/plugins/yaml/backend/src/YAMLlInspectionSuppressor.kt +++ b/plugins/yaml/backend/src/YAMLlInspectionSuppressor.kt @@ -132,7 +132,7 @@ private class YAMLSuppressFileQuickFix(ID: String) : if (existingComment != null) { val comment = createNewCommentByPattern(SUPPRESS_IN_FILE_COMMENT_PATTERN, existingComment, myID) existingComment.replace(comment) - DaemonCodeAnalyzer.getInstance(project).restart(container) + DaemonCodeAnalyzer.getInstance(project).restart(container, this) } else { var before = container.firstChild diff --git a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java index 6f313baea5b6..0b99a9f72b16 100644 --- a/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java +++ b/python/src/com/jetbrains/python/configuration/PyIntegratedToolsConfigurable.java @@ -267,7 +267,7 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { @Override public void apply() throws ConfigurationException { if (myDocstringFormatComboBox.getSelectedItem() != myDocumentationSettings.getFormat()) { - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); } if (analyzeDoctest.isSelected() != myDocumentationSettings.isAnalyzeDoctest()) { final List files = new ArrayList<>(); @@ -291,7 +291,7 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { myDocumentationSettings.setAnalyzeDoctest(analyzeDoctest.isSelected()); setRequirementsPath(myRequirementsPathField.getText()); - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); PipenvCommandExecutorKt.setPipEnvPath(PropertiesComponent.getInstance(), StringUtil.nullize(myPipEnvPathField.getText())); for (@NotNull DialogPanel panel : myCustomizePanels) { @@ -311,7 +311,7 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable { PyUiUtil.rehighlightOpenEditors(myProject); - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); } @Override diff --git a/python/src/com/jetbrains/python/inspections/quickfix/SyncProjectQuickFix.kt b/python/src/com/jetbrains/python/inspections/quickfix/SyncProjectQuickFix.kt index 23445fa691c0..4bf6e82af57d 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/SyncProjectQuickFix.kt +++ b/python/src/com/jetbrains/python/inspections/quickfix/SyncProjectQuickFix.kt @@ -33,7 +33,7 @@ internal class SyncProjectQuickFix : LocalQuickFix { } packageManager.sync() } - DaemonCodeAnalyzer.getInstance(project).restart(element.containingFile) + DaemonCodeAnalyzer.getInstance(project).restart(element.containingFile, this) } } } \ No newline at end of file diff --git a/python/src/com/jetbrains/python/namespacePackages/PyNamespacePackagesService.java b/python/src/com/jetbrains/python/namespacePackages/PyNamespacePackagesService.java index 65cb8f8ce20e..bb342edb3638 100644 --- a/python/src/com/jetbrains/python/namespacePackages/PyNamespacePackagesService.java +++ b/python/src/com/jetbrains/python/namespacePackages/PyNamespacePackagesService.java @@ -156,7 +156,7 @@ public final class PyNamespacePackagesService implements PersistentStateComponen Project project = myModule.getProject(); ProjectView.getInstance(project).refresh(); PsiManager.getInstance(project).dropPsiCaches(); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart(this); } @TestOnly diff --git a/python/src/com/jetbrains/python/newProjectWizard/PyV3ProjectBaseGenerator.kt b/python/src/com/jetbrains/python/newProjectWizard/PyV3ProjectBaseGenerator.kt index dd9cdc4b58cb..9e1e605ae7c0 100644 --- a/python/src/com/jetbrains/python/newProjectWizard/PyV3ProjectBaseGenerator.kt +++ b/python/src/com/jetbrains/python/newProjectWizard/PyV3ProjectBaseGenerator.kt @@ -98,7 +98,7 @@ abstract class PyV3ProjectBaseGenerator : DumbAwa PythonPackageManagerUI.forPackageManager(manager).executeCommand(e.presentation.text) { execute(e, manager).mapSuccess { - DaemonCodeAnalyzer.getInstance(psiFile.project).restart(psiFile) + DaemonCodeAnalyzer.getInstance(psiFile.project).restart(psiFile, this) } } } diff --git a/python/src/com/jetbrains/python/sdk/PySdkExt.kt b/python/src/com/jetbrains/python/sdk/PySdkExt.kt index 169f5f018e16..02c8c2a42855 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkExt.kt +++ b/python/src/com/jetbrains/python/sdk/PySdkExt.kt @@ -381,7 +381,7 @@ var Module.pythonSdk: Sdk? thisLogger().info("Setting PythonSDK $newSdk to module $this") ModuleRootModificationUtil.setModuleSdk(this, newSdk) runInEdt { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("Setting PythonSDK $newSdk to module $this") } ApplicationManager.getApplication().messageBus.syncPublisher(PySdkListener.TOPIC).moduleSdkUpdated(this, prevSdk, newSdk) } diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkUpdateProjectActivity.kt b/python/src/com/jetbrains/python/sdk/PythonSdkUpdateProjectActivity.kt index b9910b0c3b6a..195a41e869fb 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkUpdateProjectActivity.kt +++ b/python/src/com/jetbrains/python/sdk/PythonSdkUpdateProjectActivity.kt @@ -28,12 +28,12 @@ class PythonSdkUpdateProjectActivity : ProjectActivity, DumbAware { messageBusConnection.subscribe(PythonPackageManager.PACKAGE_MANAGEMENT_TOPIC, object : PythonPackageManagementListener { override fun packagesChanged(sdk: Sdk) { PyPackageCoroutine.launch(project) { - refreshPaths(project, sdk) + refreshPaths(project, sdk, "PythonSdkUpdateProjectActivity.packagesChanged") }.cancelOnDispose(messageBusConnection) } override fun outdatedPackagesChanged(sdk: Sdk) { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("PythonSdkUpdateProjectActivity.outdatedPackagesChanged") } }) @@ -49,7 +49,7 @@ class PythonSdkUpdateProjectActivity : ProjectActivity, DumbAware { } @ApiStatus.Internal -suspend fun refreshPaths(project: Project, sdk: Sdk): Unit = edtWriteAction { +suspend fun refreshPaths(project: Project, sdk: Sdk, reason: Any): Unit = edtWriteAction { // Background refreshing breaks structured concurrency: there is a some activity in background that locks files. // Temporary folders can't be deleted on Windows due to that. // That breaks tests. @@ -62,7 +62,7 @@ suspend fun refreshPaths(project: Project, sdk: Sdk): Unit = edtWriteAction { sdk.associatedModuleDir?.refresh(true, false) //Restart all inspections because packages are changed - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(reason) PythonSdkUpdater.scheduleUpdate(sdk, project, false) } diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java b/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java index 5cf97b160321..26174fa40f69 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java +++ b/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java @@ -303,7 +303,7 @@ public final class PythonSdkUpdater { ApplicationManager.getApplication().invokeLater(() -> { Disposer.dispose(indicatorDisposable); // restart code analysis - DaemonCodeAnalyzer.getInstance(myProject).restart(); + DaemonCodeAnalyzer.getInstance(myProject).restart(this); }, myProject.getDisposed()); } } diff --git a/python/src/com/jetbrains/python/sdk/configuration/suppressors/PyInterpreterInspectionSuppressor.kt b/python/src/com/jetbrains/python/sdk/configuration/suppressors/PyInterpreterInspectionSuppressor.kt index 3367b2eefebf..7ed1206470b5 100644 --- a/python/src/com/jetbrains/python/sdk/configuration/suppressors/PyInterpreterInspectionSuppressor.kt +++ b/python/src/com/jetbrains/python/sdk/configuration/suppressors/PyInterpreterInspectionSuppressor.kt @@ -30,7 +30,7 @@ internal class PyInterpreterInspectionSuppressor : PyInspectionExtension() { private var suppress = false fun suppress(project: Project): Disposable? { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart("PyInterpreterInspectionSuppressor.Suppress for $project") return if (suppress) null else Suppressor() } } diff --git a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java index 383f89ee8c20..d5a55c824570 100644 --- a/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java +++ b/python/src/com/jetbrains/python/sdk/skeletons/PySkeletonRefresher.java @@ -158,7 +158,7 @@ public class PySkeletonRefresher { cleanUpSkeletons(skeletonsDir); if ((builtinsUpdated || PythonSdkUtil.isRemote(mySdk)) && myProject != null) { - ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(myProject).restart(), myProject.getDisposed()); + ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(myProject).restart(this), myProject.getDisposed()); } return failedModules; diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.kt b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.kt index 5ba86cf396ec..1a967851fb93 100644 --- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.kt +++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.kt @@ -104,12 +104,12 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project, val runtimeDictionaries: List get() = RuntimeDictionaryProvider.EP_NAME.extensionList.flatMap { it.dictionaries.asSequence() } - fun restartInspections() { + fun restartInspections(reason: Any) { ApplicationManager.getApplication().invokeLater { val projects = ProjectManager.getInstance().openProjects for (project in projects) { if (project.isInitialized && project.isOpen) { - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(reason) } } } @@ -165,7 +165,7 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project, } } - restartInspections() + restartInspections("SpellCheckerManager.updateBundledDictionaries") } val userDictionaryWords: Set @@ -197,14 +197,14 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project, private fun initUserDictionaries(spellChecker: SpellCheckerEngine) { val appDictionaryState = AppDictionaryState.getInstance() - appDictionaryState.addAppDictListener({ restartInspections() }, this) + appDictionaryState.addAppDictListener({ restartInspections("SpellCheckerManager.addAppDictListener") }, this) if (appDictionaryState.dictionary == null) { appDictionaryState.dictionary = UserDictionary(AppDictionaryState.DEFAULT_NAME) } appDictionary = appDictionaryState.dictionary spellChecker.addModifiableDictionary(appDictionary!!) val dictionaryState = project.service() - dictionaryState.addProjectDictListener { restartInspections() } + dictionaryState.addProjectDictListener { restartInspections("SpellCheckerManager.addProjectDictListener") } projectDictionary = dictionaryState.projectDictionary projectDictionary!!.setActiveName(getProjectDictionaryName()) @@ -278,7 +278,7 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project, private fun fireDictionaryChanged(dictionary: EditableDictionary) { userDictionaryListenerEventDispatcher.multicaster.dictChanged(dictionary) - restartInspections() + restartInspections("SpellCheckerManager.fireDictionaryChanged") SaveAndSyncHandler.getInstance().scheduleProjectSave(project, forceSavingAllSettings = true) } @@ -309,7 +309,7 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project, if (!deletedFromApplicationWords.isEmpty()) { userDictionaryListenerEventDispatcher.multicaster.dictChanged(appDictionary) } - restartInspections() + restartInspections("SpellCheckerManager.updateUserDictionary") } fun getSuggestions(text: String): List { @@ -369,7 +369,7 @@ private class CustomDictFileListener(private val project: Project, private val m manager.spellChecker!!.removeDictionary(path) manager.loadDictionary(path) - restartInspections() + restartInspections("SpellCheckerManager.contentsChanged") } override fun propertyChanged(event: VirtualFilePropertyEvent) { @@ -396,7 +396,7 @@ private class CustomDictFileListener(private val project: Project, private val m SpellCheckerSettings.getInstance(project).customDictionariesPaths.removeIf { dict: String? -> FileUtil.isAncestor(systemDependentPath, dict!!, false) } - restartInspections() + restartInspections("SpellCheckerManager.removeCustomDictionaries") } } @@ -412,7 +412,7 @@ private class CustomDictFileListener(private val project: Project, private val m val filePath = file.path if (!isDirectory && SpellCheckerSettings.getInstance(project).customDictionariesPaths.contains(filePath)) { manager.loadDictionary(filePath) - restartInspections() + restartInspections("SpellCheckerManager.loadCustomDictionaries") } return isDirectory } diff --git a/spellchecker/src/com/intellij/spellchecker/grazie/async/AsyncUtils.kt b/spellchecker/src/com/intellij/spellchecker/grazie/async/AsyncUtils.kt index 30e5fabdfc28..b516a691b9e7 100644 --- a/spellchecker/src/com/intellij/spellchecker/grazie/async/AsyncUtils.kt +++ b/spellchecker/src/com/intellij/spellchecker/grazie/async/AsyncUtils.kt @@ -19,13 +19,13 @@ internal object AsyncUtils { return ApplicationManager.getApplication().isUnitTestMode } - fun restartInspection(application: Application) { + fun restartInspection(application: Application, reason: Any) { if (application.isDisposed) { return } for (project in ProjectManager.getInstance().openProjects.filter { it.isInitialized && it.isOpen && !it.isDefault }) { - DaemonCodeAnalyzer.getInstance(project)?.restart() + DaemonCodeAnalyzer.getInstance(project)?.restart(reason) } } @@ -42,7 +42,7 @@ internal object AsyncUtils { body() withContext(Dispatchers.EDT) { - restartInspection(ApplicationManager.getApplication()) + restartInspection(ApplicationManager.getApplication(), "AsyncUtils.run") } } } diff --git a/spellchecker/src/com/intellij/spellchecker/grazie/async/WordListLoader.kt b/spellchecker/src/com/intellij/spellchecker/grazie/async/WordListLoader.kt index e7513dd82d6b..c0b5c124bdf0 100644 --- a/spellchecker/src/com/intellij/spellchecker/grazie/async/WordListLoader.kt +++ b/spellchecker/src/com/intellij/spellchecker/grazie/async/WordListLoader.kt @@ -62,7 +62,7 @@ internal class WordListLoader(private val project: Project, private val coroutin isLoadingList.set(false) withContext(Dispatchers.EDT) { - AsyncUtils.restartInspection(ApplicationManager.getApplication()) + AsyncUtils.restartInspection(ApplicationManager.getApplication(), "WordListLoader.load") } } } diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index 19ac9a84490e..ef854a114e6b 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -162,7 +162,7 @@ public final class SpellCheckerSettingsPane implements Disposable { if (myUseSingleDictionary.isSelected() && settings.getDictionaryToSave() != myDictionariesComboBox.getSelectedItem()) { settings.setDictionaryToSave((String)myDictionariesComboBox.getSelectedItem()); } - SpellCheckerManager.Companion.restartInspections(); + SpellCheckerManager.Companion.restartInspections(this); if (!myProvidedDictionariesChooserComponent.isModified() && !myDictionariesPanel.isModified()) { return; } diff --git a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java index 206f00973b7b..031535561f41 100644 --- a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java +++ b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java @@ -108,7 +108,7 @@ public class SpellCheckingEditorCustomization extends SimpleEditorCustomization // Update representation. DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project); if (analyzer != null) { - analyzer.restart(file); + analyzer.restart(file, this); } } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java index 7ebe7b96b297..8bc281566ae9 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/quickfix/FetchExtResourceAction.java @@ -160,7 +160,7 @@ public final class FetchExtResourceAction extends BaseExtResourceAction { try { HttpConfigurable.getInstance().prepareURL(url); fetchDtd(project, uri, url, indicator); - ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(project).restart(psiFile)); + ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(project).restart(psiFile, this)); return; } catch (IOException ex) { diff --git a/xml/impl/src/com/intellij/xml/impl/PsiExternalResourceChangeListener.kt b/xml/impl/src/com/intellij/xml/impl/PsiExternalResourceChangeListener.kt index 0a993aa023d4..b23807ecba36 100644 --- a/xml/impl/src/com/intellij/xml/impl/PsiExternalResourceChangeListener.kt +++ b/xml/impl/src/com/intellij/xml/impl/PsiExternalResourceChangeListener.kt @@ -10,7 +10,7 @@ internal class PsiExternalResourceChangeListener(val project: Project) : Externa override fun externalResourceChanged() { if (!project.isDisposed) { PsiManagerEx.getInstanceEx(project).beforeChange(true) - DaemonCodeAnalyzer.getInstance(project).restart() + DaemonCodeAnalyzer.getInstance(project).restart(this) } } } \ No newline at end of file diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java index 9b55d8f9087d..3784df9506f9 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java @@ -54,6 +54,6 @@ public class SwitchToHtml5Action implements LocalQuickFix, IntentionAction { private static void applyFix(Project project) { ExternalResourceManagerEx.getInstanceEx().setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), project); - DaemonCodeAnalyzer.getInstance(project).restart(); + DaemonCodeAnalyzer.getInstance(project).restart("SwitchToHtml5Action.applyFix"); } }