diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/CreateParameterForFieldIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/CreateParameterForFieldIntention.java index f14d383dbff0..da4dbf8a7542 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/CreateParameterForFieldIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/CreateParameterForFieldIntention.java @@ -17,9 +17,7 @@ package org.jetbrains.plugins.groovy.intentions.control; import com.intellij.ide.util.DefaultPsiElementCellRenderer; import com.intellij.ide.util.MethodCellRenderer; -import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; @@ -118,15 +116,9 @@ public class CreateParameterForFieldIntention extends Intention { CommandProcessor.getInstance().executeCommand(project, new Runnable() { @Override public void run() { - AccessToken accessToken = WriteAction.start(); - try{ - for (Object selectedValue : selectedValues) { - LOG.assertTrue(((GrMethod)selectedValue).isValid()); - addParameter(field, ((GrMethod)selectedValue), project); - } - } - finally { - accessToken.finish(); + for (Object selectedValue : selectedValues) { + LOG.assertTrue(((GrMethod)selectedValue).isValid()); + addParameter(field, ((GrMethod)selectedValue), project); } } }, GroovyIntentionsBundle.message("create.parameter.for.field.intention.name"), null); @@ -155,15 +147,9 @@ public class CreateParameterForFieldIntention extends Intention { CommandProcessor.getInstance().executeCommand(project, new Runnable() { @Override public void run() { - AccessToken accessToken = WriteAction.start(); - try { - for (Object selectedValue : selectedValues) { - LOG.assertTrue(((GrField)selectedValue).isValid()); - addParameter(((GrField)selectedValue), constructor, project); - } - } - finally { - accessToken.finish(); + for (Object selectedValue : selectedValues) { + LOG.assertTrue(((GrField)selectedValue).isValid()); + addParameter(((GrField)selectedValue), constructor, project); } } }, GroovyIntentionsBundle.message("create.parameter.for.field.intention.name"), null); @@ -233,6 +219,11 @@ public class CreateParameterForFieldIntention extends Intention { } + @Override + public boolean startInWriteAction() { + return false; + } + @NotNull @Override protected PsiElementPredicate getElementPredicate() { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy index 61296348c617..7796a5a042c1 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy @@ -15,7 +15,6 @@ */ package org.jetbrains.plugins.groovy.refactoring.introduceParameter -import com.intellij.openapi.command.WriteCommandAction import com.intellij.refactoring.IntroduceParameterRefactoring import gnu.trove.TIntArrayList import org.jetbrains.plugins.groovy.LightGroovyTestCase @@ -27,7 +26,6 @@ import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GrIntroduceP import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GrIntroduceParameterSettings import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.IntroduceParameterInfo import org.jetbrains.plugins.groovy.util.TestUtils - /** * @author Max Medvedev */ @@ -59,11 +57,9 @@ public abstract class ExtractClosureTest extends LightGroovyTestCase { } } } + handler.invoke myFixture.project, myFixture.editor, myFixture.file, null + doPostponedFormatting(myFixture.project) - WriteCommandAction.runWriteCommandAction project, { - handler.invoke myFixture.project, myFixture.editor, myFixture.file, null - doPostponedFormatting(myFixture.project) - } myFixture.checkResult after } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy index 65c3650a5533..b0550f1148b2 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy @@ -15,8 +15,6 @@ */ package org.jetbrains.plugins.groovy.refactoring.introduceParameter -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile @@ -37,7 +35,6 @@ import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.* import org.jetbrains.plugins.groovy.util.TestUtils import org.junit.Assert - /** * @author Maxim.Medvedev */ @@ -123,34 +120,30 @@ public class GrIntroduceParameterTest extends LightGroovyTestCase { final Project project, final Editor editor, final PsiFile file) { - CommandProcessor.instance.executeCommand(project, { - ApplicationManager.application.runWriteAction { - try { - final GrIntroduceParameterHandler hackedHandler = new GrIntroduceParameterHandler() { - @Override - protected void showDialog(IntroduceParameterInfo info) { - final GrIntroduceParameterSettings hackedSettings = - getSettings(info, removeUnusedParameters, replaceFieldsWithGetters, declareFinal, generateDelegate); - if (info.getToReplaceIn() instanceof GrMethod) { - new GrIntroduceParameterProcessor(hackedSettings).run(); - } - else { - new GrIntroduceClosureParameterProcessor(hackedSettings).run(); - } - } - }; - hackedHandler.invoke(project, editor, file, null); - if (conflicts != null) fail("Conflicts were expected"); - } - catch (Exception e) { - if (conflicts == null) { - e.printStackTrace(); - fail("Conflicts were not expected"); + try { + final GrIntroduceParameterHandler hackedHandler = new GrIntroduceParameterHandler() { + @Override + protected void showDialog(IntroduceParameterInfo info) { + final GrIntroduceParameterSettings hackedSettings = + getSettings(info, removeUnusedParameters, replaceFieldsWithGetters, declareFinal, generateDelegate); + if (info.getToReplaceIn() instanceof GrMethod) { + new GrIntroduceParameterProcessor(hackedSettings).run(); + } + else { + new GrIntroduceClosureParameterProcessor(hackedSettings).run(); } - Assert.assertEquals(conflicts, e.getMessage()); } + }; + hackedHandler.invoke(project, editor, file, null); + if (conflicts != null) fail("Conflicts were expected"); + } + catch (Exception e) { + if (conflicts == null) { + e.printStackTrace(); + fail("Conflicts were not expected"); } - }, "introduce Parameter", null); + Assert.assertEquals(conflicts, e.getMessage()); + } } private static GrIntroduceParameterSettings getSettings(final IntroduceParameterInfo context, diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/IntroduceParameterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/IntroduceParameterTest.groovy index fe8cfe083d46..7a6bff8d5edb 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/IntroduceParameterTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/IntroduceParameterTest.groovy @@ -15,8 +15,7 @@ */ package org.jetbrains.plugins.groovy.refactoring.introduceParameter -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.command.CommandProcessor + import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.* @@ -103,28 +102,17 @@ public class IntroduceParameterTest extends LightCodeInsightFixtureTestCase { replaceAllOccurrences, replaceFieldsWithGetters, declareFinal, generateDelegate, null, parametersToRemove); - CommandProcessor.instance.executeCommand(project, new Runnable() { - @Override - public void run() { - ApplicationManager.application.runWriteAction(new Runnable() { - @Override - public void run() { - try { - processor.run(); - if (conflicts != null) fail("Conflicts were expected"); - } - catch (Exception e) { - if (conflicts == null){ - e.printStackTrace(); - fail("Conflicts were not expected"); - } - assertEquals(conflicts, e.message); - } - } - }); + try { + processor.run(); + if (conflicts != null) fail("Conflicts were expected"); + } + catch (Exception e) { + if (conflicts == null){ + e.printStackTrace(); + fail("Conflicts were not expected"); } - }, "introduce Parameter", null); - + assertEquals(conflicts, e.message); + } editor.selectionModel.removeSelection(); return true;