diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java index 653d92c33574..265cdfe29218 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java @@ -20,9 +20,9 @@ import com.intellij.codeInsight.daemon.impl.DaemonListeners; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFix; import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase; -import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.WriteCommandAction; @@ -306,8 +306,7 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase { assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements()); - CommentByBlockCommentAction action = new CommentByBlockCommentAction(); - action.actionPerformedImpl(getProject(), getEditor()); + EditorTestUtil.executeAction(getEditor(), IdeActions.ACTION_COMMENT_BLOCK); assertEmpty(highlightErrors()); 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 6638c9c1fa68..cc58bae66f28 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 @@ -22,7 +22,6 @@ import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.daemon.impl.quickfix.DeleteCatchFix; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; import com.intellij.codeInsight.folding.CodeFoldingManager; -import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; import com.intellij.codeInsight.hint.EditorHintListener; import com.intellij.codeInsight.intention.AbstractIntentionAction; import com.intellij.codeInsight.intention.IntentionAction; @@ -58,7 +57,6 @@ import com.intellij.lang.annotation.ExternalAnnotator; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.IdeActions; @@ -337,7 +335,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { List infos = doHighlighting(HighlightSeverity.WARNING); assertEmpty(infos); - commentLine(); + PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); infos = doHighlighting(HighlightSeverity.WARNING); assertEquals(1, infos.size()); @@ -626,14 +624,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { assertEquals(markers.toString(), 3, markers.size()); } - private static void commentLine() { - WriteCommandAction.runWriteCommandAction(null, () -> { - CommentByLineCommentAction action = new CommentByLineCommentAction(); - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); - }); - } - public void testChangeXmlIncludeLeadsToRehighlight() throws Exception { LanguageFilter[] extensions = ((CompositeLanguage)StdLanguages.XML).getLanguageExtensions(); for (LanguageFilter extension : extensions) { diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCaseUtil.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCaseUtil.java deleted file mode 100644 index 54800684e3c6..000000000000 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCaseUtil.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight; - -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; - -public class CodeInsightTestCaseUtil { - public static void doAction(CodeInsightTestCase testCase, AnAction action, String testName, String ext) throws Exception { - testCase.configureByFile(testName + "." + ext); - - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); - - testCase.checkResultByFile(testName + "_after." + ext); - } - -} diff --git a/platform/platform-tests/testSrc/com/intellij/codeInsight/CommentInCustomFileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/codeInsight/CommentInCustomFileTypesTest.java index e1c03d25acd3..4602ad456d45 100644 --- a/platform/platform-tests/testSrc/com/intellij/codeInsight/CommentInCustomFileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/codeInsight/CommentInCustomFileTypesTest.java @@ -15,10 +15,7 @@ */ package com.intellij.codeInsight; -import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction; -import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; import com.intellij.testFramework.PlatformTestUtil; import org.jetbrains.annotations.NotNull; @@ -51,13 +48,11 @@ public class CommentInCustomFileTypesTest extends LightPlatformCodeInsightTestCa checkResultByFile("/codeInsight/commentInCustomFileType/line2_after.cs"); } - private void performBlockCommentAction() { - CommentByBlockCommentAction action = new CommentByBlockCommentAction(); - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); + private static void performBlockCommentAction() { + PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_BLOCK); } - private void performLineCommentAction() { - CommentByLineCommentAction action = new CommentByLineCommentAction(); - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); + private static void performLineCommentAction() { + PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); } } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 607dc548291d..7af47f619277 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -16,7 +16,6 @@ package com.intellij.testFramework; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; import com.intellij.ide.DataManager; import com.intellij.injected.editor.DocumentWindow; @@ -621,7 +620,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest } protected static void lineComment() { - new CommentByLineCommentAction().actionPerformedImpl(getProject(), getEditor()); + executeAction(IdeActions.ACTION_COMMENT_LINE); } protected static void executeAction(@NonNls @NotNull final String actionId) { diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 59c5b9c5f18c..7a55ea8dde42 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -436,7 +436,7 @@ public class PlatformTestUtil { final Presentation presentation = new Presentation(); @SuppressWarnings("deprecation") final DataContext context = DataManager.getInstance().getDataContext(); final AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", context); - action.update(event); + action.beforeActionPerformedUpdate(event); Assert.assertTrue(presentation.isEnabled()); action.actionPerformed(event); } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 58cee3f88261..f1331aa37939 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -830,7 +830,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return WriteCommandAction.runWriteCommandAction(getProject(), new Computable() { @Override public Boolean compute() { - action.update(event); + action.beforeActionPerformedUpdate(event); if (!event.getPresentation().isEnabled()) { return false; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy index fff09b2524a6..bfb857f12b96 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy @@ -17,13 +17,9 @@ package org.jetbrains.plugins.groovy import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction -import com.intellij.ide.DataManager import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.DataContext import org.jetbrains.annotations.NotNull import org.jetbrains.plugins.groovy.util.TestUtils - /** * @author Max Medvedev */ @@ -101,8 +97,7 @@ print 2 private void doTest(@NotNull String before, @NotNull String after, final AnAction action) { myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before) - final DataContext dataContext = DataManager.instance.dataContextFromFocus.result - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", dataContext)) + myFixture.testAction(action) myFixture.checkResult(after) } } diff --git a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesCommenterTest.java b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesCommenterTest.java index 60cbd88195a7..5db0f511ef74 100644 --- a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesCommenterTest.java +++ b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesCommenterTest.java @@ -15,11 +15,10 @@ */ package com.intellij.lang.properties; -import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.PluginPathManager; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; +import com.intellij.testFramework.PlatformTestUtil; import org.jetbrains.annotations.NotNull; /** @@ -37,12 +36,7 @@ public class PropertiesCommenterTest extends LightPlatformCodeInsightTestCase { private void doTest() { configureByFile("/propertiesFile/comment/before" + getTestName(false) + ".properties"); - performAction(); + PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); checkResultByFile("/propertiesFile/comment/after" + getTestName(false) + ".properties"); } - - private static void performAction() { - CommentByLineCommentAction action = new CommentByLineCommentAction(); - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); - } } diff --git a/python/testSrc/com/jetbrains/python/PyEditingTest.java b/python/testSrc/com/jetbrains/python/PyEditingTest.java index 1c177ba67752..ea9caf885adb 100644 --- a/python/testSrc/com/jetbrains/python/PyEditingTest.java +++ b/python/testSrc/com/jetbrains/python/PyEditingTest.java @@ -15,16 +15,13 @@ */ package com.jetbrains.python; -import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.IdeActions; -import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiFile; +import com.intellij.testFramework.PlatformTestUtil; import com.jetbrains.python.codeInsight.PyCodeInsightSettings; import com.jetbrains.python.documentation.docstrings.DocStringFormat; import com.jetbrains.python.fixtures.PyTestCase; @@ -124,10 +121,7 @@ public class PyEditingTest extends PyTestCase { public void testUncommentWithSpace() throws Exception { // PY-980 myFixture.configureByFile("/editing/uncommentWithSpace.before.py"); myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(0, 1)); - CommandProcessor.getInstance().executeCommand(myFixture.getProject(), () -> { - CommentByLineCommentAction action = new CommentByLineCommentAction(); - action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); - }, "", null); + PlatformTestUtil.invokeNamedAction(IdeActions.ACTION_COMMENT_LINE); myFixture.checkResultByFile("/editing/uncommentWithSpace.after.py", true); }