diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/impl/DaemonRespondToChangesTest.java index 405012b73a74..32347d53f58c 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/impl/DaemonRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/impl/DaemonRespondToChangesTest.java @@ -27,7 +27,6 @@ import com.intellij.codeInsight.folding.JavaCodeFoldingSettings; import com.intellij.codeInsight.hint.EditorHintListener; import com.intellij.codeInsight.intention.AbstractIntentionAction; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInsight.intention.IntentionActionDelegate; import com.intellij.codeInsight.intention.IntentionManager; import com.intellij.codeInsight.intention.impl.IntentionHintComponent; import com.intellij.codeInspection.*; @@ -37,7 +36,6 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase; import com.intellij.codeInspection.ex.InspectionToolRegistrar; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.codeInspection.ex.QuickFixWrapper; import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspectionBase; import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection; import com.intellij.configurationStore.StorageUtilKt; @@ -2653,32 +2651,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { assertEmpty(fixes); } - public void testStupidQuickFixIsStillVisibleAfterAppliedButDidNothing() { - MyInspection tool = new MyInspection(); - enableInspectionTool(tool); - disposeOnTearDown(() -> disableInspectionTool(tool.getShortName())); - - @Language("JAVA") - String text = "class X { void f() { if (this == null) {} else return; } }"; - configureByText(JavaFileType.INSTANCE, text); - WriteCommandAction.runWriteCommandAction(getProject(), () -> myEditor.getDocument().setText(text)); - getEditor().getCaretModel().moveToOffset(getFile().getText().indexOf("if (") + 1); - assertEmpty(doHighlighting(HighlightSeverity.ERROR)); - List fixes = findStupidFixes(); - IntentionAction fix = assertOneElement(fixes); - ((MyInspection.StupidQuickFixWhichDoesntCheckItsOwnApplicability)((QuickFixWrapper)((IntentionActionDelegate)fix).getDelegate()).getFix()).doFix = false; - fix.invoke(getProject(), getEditor(), getFile()); // did nothing - - fixes = findStupidFixes(); - assertOneElement(fixes); - - assertEmpty(doHighlighting(HighlightSeverity.ERROR)); - fixes = findStupidFixes(); - assertOneElement(fixes); - } - private List findStupidFixes() { - UIUtil.dispatchAllInvocationEvents(); return CodeInsightTestFixtureImpl.getAvailableIntentions(getEditor(), getFile()) .stream().filter(f->f.getFamilyName().equals(new MyInspection.StupidQuickFixWhichDoesntCheckItsOwnApplicability().getFamilyName())) .collect(Collectors.toList()); @@ -2719,7 +2692,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { }; } private static class StupidQuickFixWhichDoesntCheckItsOwnApplicability implements LocalQuickFix { - private boolean doFix = true; @Nls @NotNull @Override @@ -2736,9 +2708,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - if (doFix) { - WriteCommandAction.runWriteCommandAction(project, () -> ((PsiIfStatement)descriptor.getPsiElement().getParent()).getElseBranch().delete()); - } + WriteCommandAction.runWriteCommandAction(project, () -> ((PsiIfStatement)descriptor.getPsiElement().getParent()).getElseBranch().delete()); } } } 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 b0fcc05c0fe8..fe07f250f5e7 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 @@ -59,12 +59,14 @@ import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.ModuleRootListener; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.util.UserDataHolderEx; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileListener; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.VirtualFilePropertyEvent; import com.intellij.openapi.wm.StatusBar; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.impl.status.TogglePopupHintsPanel; @@ -92,10 +94,7 @@ import java.util.List; /** * @author cdr */ -public class DaemonListeners - extends SimpleModificationTracker // modCount will change whenever daemon-worthy event happens - implements Disposable { - +public class DaemonListeners implements Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonListeners"); private final Project myProject; @@ -281,7 +280,7 @@ public class DaemonListeners }); connection.subscribe(PowerSaveMode.TOPIC, () -> stopDaemon(true, "Power save mode change")); - connection.subscribe(EditorColorsManager.TOPIC, __ -> stopDaemonAndRestartAllFiles("Editor color scheme changed")); + connection.subscribe(EditorColorsManager.TOPIC, scheme -> stopDaemonAndRestartAllFiles("Editor color scheme changed")); commandProcessor.addCommandListener(new MyCommandListener(), this); application.addApplicationListener(new MyApplicationListener(), this); @@ -292,7 +291,6 @@ public class DaemonListeners virtualFileManager.addVirtualFileListener(new VirtualFileListener() { @Override public void propertyChanged(@NotNull VirtualFilePropertyEvent event) { - incModificationCount(); String propertyName = event.getPropertyName(); if (VirtualFile.PROP_NAME.equals(propertyName)) { stopDaemonAndRestartAllFiles("Virtual file name changed"); @@ -320,31 +318,6 @@ public class DaemonListeners stopDaemon(true, "Virtual file property change"); } } - - @Override - public void fileCreated(@NotNull VirtualFileEvent event) { - incModificationCount(); - } - - @Override - public void beforePropertyChange(@NotNull VirtualFilePropertyEvent event) { - incModificationCount(); - } - - @Override - public void beforeContentsChange(@NotNull VirtualFileEvent event) { - incModificationCount(); - } - - @Override - public void beforeFileDeletion(@NotNull VirtualFileEvent event) { - incModificationCount(); - } - - @Override - public void beforeFileMovement(@NotNull VirtualFileMoveEvent event) { - incModificationCount(); - } }, this); ((EditorEventMulticasterEx)eventMulticaster).addErrorStripeListener(new ErrorStripeHandler(myProject), this); @@ -641,14 +614,12 @@ public class DaemonListeners } private void stopDaemon(boolean toRestartAlarm, @NonNls @NotNull String reason) { - incModificationCount(); if (myDaemonCodeAnalyzer.stopProcess(toRestartAlarm, reason)) { myDaemonEventPublisher.daemonCancelEventOccurred(reason); } } private void stopDaemonAndRestartAllFiles(@NotNull String reason) { - incModificationCount(); if (myDaemonCodeAnalyzer.doRestart()) { myDaemonEventPublisher.daemonCancelEventOccurred(reason); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionActionWithTextCaching.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionActionWithTextCaching.java index 8341d4f61615..68f779060535 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionActionWithTextCaching.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionActionWithTextCaching.java @@ -16,13 +16,11 @@ package com.intellij.codeInsight.intention.impl; -import com.intellij.codeInsight.daemon.impl.DaemonListeners; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionActionDelegate; import com.intellij.openapi.actionSystem.ShortcutProvider; import com.intellij.openapi.actionSystem.ShortcutSet; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.DumbService; @@ -180,19 +178,12 @@ public class IntentionActionWithTextCaching implements Comparable { - if (startModificationCount != DaemonListeners.getInstance(project).getModificationCount()) { - myMarkInvoked.accept(IntentionActionWithTextCaching.this, myAction); - } - }, project.getDisposed()); + myMarkInvoked.accept(IntentionActionWithTextCaching.this, myAction); } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java index 80a3e1388059..91b14b0c5c80 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java @@ -63,7 +63,6 @@ public class IntentionListStep implements ListPopupStep ACTION_TEXT_AND_CLASS_EQUALS = new TObjectHashingStrategy() { @Override @@ -285,7 +284,7 @@ public class IntentionListStep implements ListPopupStep