From 2af787934505fac694b41ee651ab595e24bf6d68 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Mon, 31 Jan 2011 17:26:01 +0300 Subject: [PATCH] IDEA-64819 improve 'Extract method' refactoring for Groovy: support multiple output parameters --- .../psi/impl/GroovyPsiElementFactoryImpl.java | 8 + .../ExtractMethodInfoHelper.java | 30 ++-- .../extractMethod/ExtractMethodUtil.java | 159 ++++++++++++++---- .../GroovyExtractMethodHandler.java | 13 +- .../extractMethod/ExtractMethodTest.java | 8 +- .../refactoring/extractMethod/err1.test | 22 ++- .../extractMethod/multiOutput1.test | 25 +++ .../extractMethod/multiOutput2.test | 25 +++ .../extractMethod/multiOutput3.test | 25 +++ .../extractMethod/multiOutput4.test | 20 +++ .../extractMethod/multiOutput5.test | 21 +++ .../highlighting/ResolveMetaClass.groovy | 2 +- 12 files changed, 303 insertions(+), 55 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test create mode 100644 plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test create mode 100644 plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test create mode 100644 plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test create mode 100644 plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 6f8e9d3159d4..ecd2d8f70787 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -149,11 +149,19 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { text.append(typeText).append(" "); } + if (identifiers.length > 1 && initializer != null) { + text.append('('); + } for (int i = 0; i < identifiers.length; i++) { if (i > 0) text.append(", "); String identifier = identifiers[i]; text.append(identifier); } + + if (identifiers.length > 1 && initializer != null) { + text.append(')'); + } + GrExpression expr; if (initializer != null) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodInfoHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodInfoHelper.java index 5f223f020897..827f4b35a2cc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodInfoHelper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodInfoHelper.java @@ -18,12 +18,9 @@ package org.jetbrains.plugins.groovy.refactoring.extractMethod; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiModifier; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement; @@ -40,7 +37,7 @@ import java.util.*; public class ExtractMethodInfoHelper { private final Map myInputNamesMap = new HashMap(); - private final String myOutputName; + private final VariableInfo[] myOutputNames; private final PsiType myOutputType; private final GrMemberOwner myTargetClass; private final boolean myIsStatic; @@ -52,7 +49,7 @@ public class ExtractMethodInfoHelper { private final GrStatement[] myStatements; public ExtractMethodInfoHelper(VariableInfo[] inputInfos, - VariableInfo outputInfo, + VariableInfo[] outputInfos, PsiElement[] innerElements, GrStatement[] statements, GrMemberOwner targetClass, @@ -80,19 +77,22 @@ public class ExtractMethodInfoHelper { } PsiType outputType = PsiType.VOID; - if (outputInfo != null) { - myOutputName = outputInfo.getName(); - outputType = outputInfo.getType(); + myOutputNames = outputInfos; + if (outputInfos.length > 0) { + if (outputInfos.length == 1) { + outputType = outputInfos[0].getType(); + } + else { + outputType = JavaPsiFacade.getElementFactory(myProject).createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, myTargetClass); + } } else if (ExtractMethodUtil.isSingleExpression(statements)) { final GrStatement lastExpr = statements[statements.length - 1]; if (!(lastExpr.getParent() instanceof GrCodeBlock)) { outputType = ((GrExpression)lastExpr).getType(); } - myOutputName = null; } else { - myOutputName = null; if (myIsReturnStatement) { assert returnStatements.size() > 0; List types = new ArrayList(returnStatements.size()); @@ -103,7 +103,7 @@ public class ExtractMethodInfoHelper { types.add(returnValue.getType()); } } - else if (statement instanceof GrExpression){ + else if (statement instanceof GrExpression) { types.add(((GrExpression)statement).getType()); } } @@ -130,9 +130,9 @@ public class ExtractMethodInfoHelper { return infos; } - @Nullable - public String getOutputName() { - return myOutputName; + @NotNull + public VariableInfo[] getOutputNames() { + return myOutputNames; } /** diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodUtil.java index 44c2a9fdf92a..da9476df9e9d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodUtil.java @@ -22,6 +22,7 @@ import com.intellij.refactoring.ui.ConflictsDialog; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.containers.HashMap; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,6 +47,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefini import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner; import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner; +import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo; +import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; @@ -53,10 +56,7 @@ import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil; import org.jetbrains.plugins.groovy.refactoring.inline.GroovyInlineMethodUtil; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author ilyas @@ -91,21 +91,84 @@ public class ExtractMethodUtil { } @NotNull - static GrStatement createResultStatement(ExtractMethodInfoHelper helper, @NotNull String methodName) { - String name = helper.getOutputName(); + static GrStatement[] createResultStatement(ExtractMethodInfoHelper helper, @NotNull String methodName) { + VariableInfo[] outputVars = helper.getOutputNames(); + PsiType type = helper.getOutputType(); GrStatement[] statements = helper.getStatements(); GrMethodCallExpression callExpression = createMethodCallByHelper(methodName, helper); - if ((name == null || PsiType.VOID.equals(type)) && !helper.isReturnStatement()) return callExpression; + + if ((outputVars.length == 0 || PsiType.VOID.equals(type)) && !helper.isReturnStatement()) return new GrStatement[]{callExpression}; GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(helper.getProject()); if (helper.isReturnStatement()) { - return factory.createStatementFromText("return " + callExpression.getText()); - } else if (name != null && mustAddVariableDeclaration(statements, name)) { - return factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, callExpression, - type.equalsToText("java.lang.Object") ? null : type, name); - } else { - return factory.createExpressionFromText(name + "= " + callExpression.getText()); + return new GrStatement[]{factory.createStatementFromText("return " + callExpression.getText())}; } + + assert outputVars.length > 0; + + final List mustAdd = mustAddVariableDeclaration(statements, outputVars); + if (mustAdd.size() == 0) { + return new GrStatement[]{createAssignment(outputVars, callExpression, helper)}; + } + if (mustAdd.size() == outputVars.length && outputVars.length == 1) { + final GrVariableDeclaration decl = factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, callExpression, + outputVars[0].getType(), outputVars[0].getName()); + return new GrVariableDeclaration[]{decl}; + } + List result = generateVarDeclarations(mustAdd, helper.getProject(), null); + result.add(createAssignment(outputVars, callExpression, helper)); + + return result.toArray(new GrStatement[result.size()]); + } + + private static List generateVarDeclarations(List varInfos, + Project project, + @Nullable GrExpression initializer) { + List result = new ArrayList(); + if (varInfos.size() == 0) return result; + + GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); + boolean distinctDeclaration = haveDifferentTypes(varInfos); + + if (distinctDeclaration) { + for (VariableInfo info : varInfos) { + result.add(factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, null, info.getType(), info.getName())); + } + } + else { + String[] names = new String[varInfos.size()]; + for (int i = 0, mustAddLength = varInfos.size(); i < mustAddLength; i++) { + names[i] = varInfos.get(i).getName(); + } + result.add(factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, initializer, varInfos.get(0).getType(), names)); + } + return result; + } + + private static boolean haveDifferentTypes(List varInfos) { + if (varInfos.size() < 2) return true; + Set diffTypes = new com.intellij.util.containers.hash.HashSet(); + for (VariableInfo info : varInfos) { + final PsiType t = info.getType(); + diffTypes.add(t == null ? null : TypesUtil.unboxPrimitiveTypeWrapper(t).getCanonicalText()); + } + return diffTypes.size() > 1; + } + + private static GrStatement createAssignment(VariableInfo[] infos, GrMethodCallExpression callExpression, ExtractMethodInfoHelper helper) { + StringBuilder text = new StringBuilder(); + if (infos.length > 1) text.append('('); + for (VariableInfo info : infos) { + text.append(info.getName()).append(", "); + } + if (infos.length > 1) { + text.replace(text.length() - 2, text.length(), ") ="); + } + else { + text.replace(text.length() - 2, text.length(), " = "); + } + text.append(callExpression.getText()); + return GroovyPsiElementFactory.getInstance(helper.getProject()).createExpressionFromText(text.toString()); } static boolean validateMethod(GrMethod method, ExtractMethodInfoHelper helper) { @@ -154,16 +217,31 @@ public class ExtractMethodUtil { /* To declare or not a variable to which method call result will be assigned. */ - private static boolean mustAddVariableDeclaration(@NotNull GrStatement[] statements, @NotNull String varName) { + private static List mustAddVariableDeclaration(@NotNull GrStatement[] statements, @NotNull VariableInfo[] vars) { + Map names = new HashMap(); + for (VariableInfo var : vars) { + names.put(var.getName(), var); + } + List result = new ArrayList(); + for (GrStatement statement : statements) { if (statement instanceof GrVariableDeclaration) { - GrVariableDeclaration declaration = (GrVariableDeclaration) statement; + GrVariableDeclaration declaration = (GrVariableDeclaration)statement; for (GrVariable variable : declaration.getVariables()) { - if (varName.equals(variable.getName())) return true; + final VariableInfo removed = names.remove(variable.getName()); + if (removed != null) { + result.add(removed); + } } } } - return ResolveUtil.resolveProperty(statements[0], varName) == null; + for (String varName : names.keySet()) { + if (ResolveUtil.resolveProperty(statements[0], varName) == null) { + result.add(names.get(varName)); + } + } + + return result; } private static boolean containVariableDeclaration(@NotNull GrStatement[] statements, @NotNull String varName) { @@ -226,33 +304,50 @@ public class ExtractMethodUtil { buffer.append(") { \n"); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(helper.getProject()); - String outputName = helper.getOutputName(); + VariableInfo[] outputInfos = helper.getOutputNames(); ParameterInfo[] infos = helper.getParameterInfos(); - boolean outputIsParameter = false; - if (outputName != null) { - for (ParameterInfo info : infos) { - if (outputName.equals(info.getOldName())) { - outputIsParameter = true; + boolean[] outputIsParameter = new boolean[outputInfos.length]; + for (VariableInfo outputName : outputInfos) { + for (int i = 0; i < infos.length; i++) { + if (outputName.getName().equals(infos[i].getOldName())) { + outputIsParameter[i] = true; } } } - if (type != PsiType.VOID && outputName != null && !outputIsParameter && - !mustAddVariableDeclaration(helper.getStatements(), outputName) && - !containVariableDeclaration(helper.getStatements(), outputName)) { - GrVariableDeclaration decl = factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, null, type, outputName); - buffer.append(decl.getText()).append("\n"); + + final Set mustAdd = new HashSet(mustAddVariableDeclaration(helper.getStatements(), outputInfos)); + + List genDecl = new ArrayList(); + for (int i = 0; i < outputInfos.length; i++) { + VariableInfo info = outputInfos[i]; + if (type != PsiType.VOID && !outputIsParameter[i] && + !mustAdd.contains(info) && + !containVariableDeclaration(helper.getStatements(), info.getName())) { + genDecl.add(info); + } } - if (!ExtractMethodUtil.isSingleExpression(helper.getStatements())) { + final List statements = generateVarDeclarations(genDecl, helper.getProject(), null); + for (GrStatement statement : statements) { + buffer.append(statement.getText()).append('\n'); + } + + if (!isSingleExpression(helper.getStatements())) { for (PsiElement element : helper.getInnerElements()) { buffer.append(element.getText()); } //append return statement - if (type != PsiType.VOID && outputName != null) { + if (type != PsiType.VOID && outputInfos.length > 0) { buffer.append("\n return "); - buffer.append(outputName); + if (outputInfos.length > 1) buffer.append('['); + for (VariableInfo info : outputInfos) { + buffer.append(info.getName()).append(", "); + } + buffer.delete(buffer.length() - 2, buffer.length()); + if (outputInfos.length > 1) buffer.append(']'); } - } else { + } + else { GrExpression expr = (GrExpression)PsiUtil.skipParentheses((GrExpression)helper.getStatements()[0], false); buffer.append(PsiType.VOID.equals(type) ? "" : "return ").append(expr != null ? expr.getText() : ""); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/GroovyExtractMethodHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/GroovyExtractMethodHandler.java index 29a9accdcfc9..298eb237c02e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/GroovyExtractMethodHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extractMethod/GroovyExtractMethodHandler.java @@ -160,7 +160,7 @@ public class GroovyExtractMethodHandler implements RefactoringActionHandler { FragmentVariableInfos fragmentVariableInfos = ReachingDefinitionsCollector.obtainVariableFlowInformation(statement0, statements[statements.length - 1]); VariableInfo[] inputInfos = fragmentVariableInfos.getInputVariableNames(); VariableInfo[] outputInfos = fragmentVariableInfos.getOutputVariableNames(); - if (outputInfos.length > 1 || + if (/*outputInfos.length > 1 ||*/ outputInfos.length == 1 && returnStatements.size() > 0) { String message = GroovyRefactoringBundle.message("multiple.output.values"); showErrorMessage(message, project, editor); @@ -187,10 +187,9 @@ public class GroovyExtractMethodHandler implements RefactoringActionHandler { return false; } - VariableInfo outputInfo = outputInfos.length == 0 ? null : outputInfos[0]; boolean canBeStatic = ExtractMethodUtil.canBeStatic(statement0); - ExtractMethodInfoHelper helper = new ExtractMethodInfoHelper(inputInfos, outputInfo, elements, statements, owner, canBeStatic, returnStatements); + ExtractMethodInfoHelper helper = new ExtractMethodInfoHelper(inputInfos, outputInfos, elements, statements, owner, canBeStatic, returnStatements); final String methodName; if (!ApplicationManager.getApplication().isUnitTestMode()) { @@ -230,11 +229,15 @@ public class GroovyExtractMethodHandler implements RefactoringActionHandler { if (declarationOwner != null && !ExtractMethodUtil.isSingleExpression(helper.getStatements())) { // Replace set of statements - final GrStatement newStatement = ExtractMethodUtil.createResultStatement(helper, methodName); + final GrStatement[] newStatement = ExtractMethodUtil.createResultStatement(helper, methodName); // add call statement final GrStatement[] statements = helper.getStatements(); assert statements.length > 0; - realStatement = declarationOwner.addStatementBefore(newStatement, statements[0]); + realStatement = null; + for (GrStatement statement : newStatement) { + realStatement = declarationOwner.addStatementBefore(statement, statements[0]); + } + assert realStatement != null; // remove old statements ExtractMethodUtil.removeOldStatements(declarationOwner, helper); PsiImplUtil.removeNewLineAfter(realStatement); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodTest.java index 9507d3462df8..6697a9d1f111 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extractMethod/ExtractMethodTest.java @@ -63,7 +63,7 @@ public class ExtractMethodTest extends LightGroovyTestCase { public void testClos_em() throws Throwable { doTest(); } public void testEm1() throws Throwable { doTest(); } public void testEnum1() throws Throwable { doTest(); } - public void testErr1() throws Throwable { doAntiTest("There are multiple output values for the selected code fragment"); } + public void testErr1() throws Throwable { doTest(); } public void testExpr1() throws Throwable { doTest(); } public void testExpr2() throws Throwable { doTest(); } public void testExpr3() throws Throwable { doTest(); } @@ -90,4 +90,10 @@ public class ExtractMethodTest extends LightGroovyTestCase { public void testClosureIt() throws Throwable { doTest(); } public void testImplicitReturn() {doTest();} + public void testMultiOutput1() {doTest();} + public void testMultiOutput2() {doTest();} + public void testMultiOutput3() {doTest();} + public void testMultiOutput4() {doTest();} + public void testMultiOutput5() {doTest();} + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test index cd4365f56ad2..34c280191bd5 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test @@ -12,4 +12,24 @@ www = kkk + 3 println(yyy) println(www) ----- -FAILED: There are multiple output values for the selected code fragment \ No newline at end of file +iii = 6 +int kkk = 5 +def vv = 6 +def gg = 7 + + +int www, yyy +(yyy, www) = testMethod(kkk, vv, gg) + +private List testMethod(int kkk, int vv, int gg) { + println(kkk + iii + (vv + gg)) + yyy = kkk + 2 + www = kkk + 3 + return [yyy, www] +} + + + + +println(yyy) +println(www) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test new file mode 100644 index 000000000000..e6f4ce20b06c --- /dev/null +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test @@ -0,0 +1,25 @@ +def a = 5 + +print a +def b = 6; +a++ +print a+b + +print a+b +----- +def a = 5 + +int b +(a, b) = testMethod(a) + +private List testMethod(int a) { + print a + def b = 6; + a++ + print a + b + return [a, b] +} + + + +print a+b \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test new file mode 100644 index 000000000000..7173372f16ff --- /dev/null +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test @@ -0,0 +1,25 @@ +def a = 5 + +print a +int b = 6; +int c = 7 +print a+b + +print a+b+c +----- +def a = 5 + +int b, c +(b, c) = testMethod(a) + +private List testMethod(int a) { + print a + int b = 6; + int c = 7 + print a + b + return [b, c] +} + + + +print a+b+c \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test new file mode 100644 index 000000000000..cdd2dcc323e3 --- /dev/null +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test @@ -0,0 +1,25 @@ +def a = 5 + +print a +def b = 6; +def c = 7 +print a+b + +print a+b+c +----- +def a = 5 + +int b, c +(b, c) = testMethod(a) + +private List testMethod(int a) { + print a + def b = 6; + def c = 7 + print a + b + return [b, c] +} + + + +print a+b+c \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test new file mode 100644 index 000000000000..f3438ba0ed32 --- /dev/null +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test @@ -0,0 +1,20 @@ +def a = 5 + +def b = 6 +print a+b + +print a+b +----- +def a = 5 + +int b = testMethod(a) + +private int testMethod(int a) { + def b = 6 + print a + b + return b +} + + + +print a+b \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test new file mode 100644 index 000000000000..4cb92920cac3 --- /dev/null +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test @@ -0,0 +1,21 @@ +def a = 5 + +def b = 6 +print a+b +a = 5 +print a+b +----- +def a = 5 + +int b +(a, b) = testMethod(a) + +private List testMethod(int a) { + def b = 6 + print a + b + a = 5 + return [a, b] +} + + +print a+b \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/ResolveMetaClass.groovy b/plugins/groovy/testdata/highlighting/ResolveMetaClass.groovy index 0eaa5b023193..23f6a58aaf42 100644 --- a/plugins/groovy/testdata/highlighting/ResolveMetaClass.groovy +++ b/plugins/groovy/testdata/highlighting/ResolveMetaClass.groovy @@ -3,4 +3,4 @@ class MyClass { } print MyClass.metaClass.getMethods() -print MyClass.field \ No newline at end of file +print MyClass.field \ No newline at end of file