From 162d79c3edfcdae01f2de9d75252cc6782745050 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Thu, 10 Mar 2011 11:46:52 +0300 Subject: [PATCH] tests for introduce parameter --- .../GrIntroduceParameterTest.java | 292 ++++++++++++++++++ .../FieldWithGetterReplacementAfter.groovy | 2 +- ...hInaccessibleGetterReplacementAfter.groovy | 2 +- .../ConflictingFieldAfter.groovy | 27 ++ .../ConflictingFieldBefore.groovy | 27 ++ .../ConflictingFieldMyClass.groovy | 27 ++ .../fieldAccess/FieldAccessAfter.groovy | 22 ++ .../fieldAccess/FieldAccessBefore.groovy | 22 ++ .../fieldAccess/FieldAccessMyClass.groovy | 21 ++ .../FieldWithGetterReplacementAfter.groovy | 21 ++ .../FieldWithGetterReplacementBefore.groovy | 21 ++ .../FieldWithGetterReplacementMyClass.groovy | 24 ++ ...hInaccessibleGetterReplacementAfter.groovy | 21 ++ ...InaccessibleGetterReplacementBefore.groovy | 21 ++ ...naccessibleGetterReplacementMyClass.groovy | 24 ++ .../ImplicitDefaultConstructorAfter.groovy | 24 ++ .../ImplicitDefaultConstructorBefore.groovy | 20 ++ .../ImplicitDefaultConstructorMyClass.groovy | 21 ++ .../ImplicitSuperCallAfter.groovy | 27 ++ .../ImplicitSuperCallBefore.groovy | 26 ++ .../ImplicitSuperCallMyClass.groovy | 6 + .../IncorrectArgumentListAfter.groovy | 1 + .../IncorrectArgumentListBefore.groovy | 1 + .../IncorrectArgumentListMyClass.groovy | 6 + .../InternalSideEffectAfter.groovy | 32 ++ .../InternalSideEffectBefore.groovy | 30 ++ .../InternalSideEffectMyClass.groovy | 22 ++ .../methodAccess/MethodAccessAfter.groovy | 22 ++ .../methodAccess/MethodAccessBefore.groovy | 22 ++ .../methodAccess/MethodAccessMyClass.groovy | 25 ++ ...thodUsageInThisMethodInheritorAfter.groovy | 20 ++ ...hodUsageInThisMethodInheritorBefore.groovy | 20 ++ ...odUsageInThisMethodInheritorMyClass.groovy | 20 ++ .../MethodWithoutParamsAfter.groovy | 21 ++ .../MethodWithoutParamsBefore.groovy | 21 ++ .../MethodWithoutParamsMyClass.groovy | 20 ++ ...thodWithRemoveUnusedParametersAfter.groovy | 20 ++ ...hodWithRemoveUnusedParametersBefore.groovy | 20 ++ ...odWithRemoveUnusedParametersMyClass.groovy | 20 ++ .../ParameterSubstitutionAfter.groovy | 22 ++ .../ParameterSubstitutionBefore.groovy | 22 ++ .../ParameterSubstitutionMyClass.groovy | 20 ++ .../RemoveParameterInHierarchyAfter.groovy | 20 ++ .../RemoveParameterInHierarchyBefore.groovy | 20 ++ .../RemoveParameterInHierarchyMyClass.groovy | 20 ++ .../SimpleOverridedMethodAfter.groovy | 20 ++ .../SimpleOverridedMethodBefore.groovy | 20 ++ .../SimpleOverridedMethodMyClass.groovy | 20 ++ .../simpleUsage/SimpleUsageAfter.groovy | 20 ++ .../simpleUsage/SimpleUsageBefore.groovy | 20 ++ .../simpleUsage/SimpleUsageMyClass.groovy | 21 ++ .../StaticFieldAccessAfter.groovy | 23 ++ .../StaticFieldAccessBefore.groovy | 23 ++ .../StaticFieldAccessMyClass.groovy | 22 ++ .../SuperInExpressionAfter.groovy | 21 ++ .../SuperInExpressionBefore.groovy | 21 ++ .../SuperInExpressionMyClass.groovy | 26 ++ .../SuperWithSideEffectAfter.groovy | 20 ++ .../SuperWithSideEffectBefore.groovy | 20 ++ .../SuperWithSideEffectMyClass.groovy | 26 ++ .../ThisSubstitutionAfter.groovy | 22 ++ .../ThisSubstitutionBefore.groovy | 22 ++ .../ThisSubstitutionMyClass.groovy | 21 ++ .../ThisSubstitutionInQualifierAfter.groovy | 22 ++ .../ThisSubstitutionInQualifierBefore.groovy | 22 ++ .../ThisSubstitutionInQualifierMyClass.groovy | 21 ++ .../varargs/VarargsAfter.groovy | 22 ++ .../varargs/VarargsBefore.groovy | 22 ++ .../varargs/VarargsMyClass.groovy | 25 ++ .../weirdQualifier/WeirdQualifierAfter.groovy | 21 ++ .../WeirdQualifierBefore.groovy | 20 ++ .../WeirdQualifierMyClass.groovy | 24 ++ .../WeirdQualifierAndParameterAfter.groovy | 21 ++ .../WeirdQualifierAndParameterBefore.groovy | 20 ++ .../WeirdQualifierAndParameterMyClass.groovy | 24 ++ 75 files changed, 1815 insertions(+), 2 deletions(-) create mode 100644 plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.java create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierMyClass.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterBefore.groovy create mode 100644 plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterMyClass.groovy diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.java new file mode 100644 index 000000000000..31ca9497a12a --- /dev/null +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.java @@ -0,0 +1,292 @@ +/* + * Copyright 2000-2011 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 org.jetbrains.plugins.groovy.refactoring.introduceParameter; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.CommandProcessor; +import com.intellij.psi.PsiType; +import com.intellij.psi.impl.source.PostprocessReformattingAspect; +import com.intellij.refactoring.IntroduceParameterRefactoring; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import gnu.trove.TIntArrayList; +import gnu.trove.TObjectIntHashMap; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; +import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; +import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext; +import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceDialog; +import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.*; +import org.jetbrains.plugins.groovy.util.TestUtils; + +/** + * @author Maxim.Medvedev + */ +public class GrIntroduceParameterTest extends LightCodeInsightFixtureTestCase { + + protected String getBasePath() { + return TestUtils.getTestDataPath() + "refactoring/introduceParameterGroovy/" + getTestName(true) + '/'; + } + + private boolean doTest(int replaceFieldsWithGetters, boolean removeUnusedParameters, boolean searchForSuper, boolean declareFinal) { + return doTest(replaceFieldsWithGetters, removeUnusedParameters, searchForSuper, declareFinal, null); + } + + private boolean doTest(final int replaceFieldsWithGetters, + final boolean removeUnusedParameters, + boolean searchForSuper, + final boolean declareFinal, + final String conflicts) { + final String beforeGroovy = getTestName(false)+"Before.groovy"; + final String afterGroovy = getTestName(false) + "After.groovy"; + final String clazz = getTestName(false) + "MyClass.groovy"; + myFixture.configureByFiles(clazz, beforeGroovy); + + execute(replaceFieldsWithGetters, removeUnusedParameters, declareFinal, conflicts); + + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); + myFixture.getEditor().getSelectionModel().removeSelection(); + myFixture.checkResultByFile(beforeGroovy, afterGroovy, true); + return true; + } + + private void execute(final int replaceFieldsWithGetters, + final boolean removeUnusedParameters, + final boolean declareFinal, + final String conflicts) { + CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { + @Override + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + try { + final GrIntroduceParameterHandler hackedHandler = new GrIntroduceParameterHandler() { + @Override + protected GrIntroduceDialog getDialog(final GrIntroduceContext context) { + final GrIntroduceParameterSettings hackedSettings = + getSettings(context, removeUnusedParameters, replaceFieldsWithGetters, declareFinal); + + + return new GrIntroduceDialog() { + @Override + public GrIntroduceParameterSettings getSettings() { + return null; + } + + @Override + public void show() { + new GrIntroduceParameterProcessor(hackedSettings, (GrIntroduceParameterContext)context).run(); + } + + @Override + public boolean isOK() { + return false; + } + }; + } + }; + hackedHandler.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), null); + if (conflicts != null) fail("Conflicts were expected"); + } + catch (Exception e) { + if (conflicts == null) { + e.printStackTrace(); + fail("Conflicts were not expected"); + } + assertEquals(conflicts, e.getMessage()); + } + } + }); + } + }, "introduce Parameter", null); + } + + private GrIntroduceParameterSettings getSettings(final GrIntroduceContext context, + final boolean removeUnusedParameters, + final int replaceFieldsWithGetters, + final boolean declareFinal) { + return new GrIntroduceParameterSettings() { + @Override + public boolean generateDelegate() { + return false; + } + + @Override + public TIntArrayList parametersToRemove() { + if (removeUnusedParameters) { + final TObjectIntHashMap parametersToRemove = GroovyIntroduceParameterUtil.findParametersToRemove(context); + TIntArrayList list = new TIntArrayList(parametersToRemove.size()); + for (Object o : parametersToRemove.keys()) { + list.add(parametersToRemove.get((GrParameter)o)); + } + return list; + } + return new TIntArrayList(0); + } + + @Override + public int replaceFieldsWithGetters() { + return replaceFieldsWithGetters; + } + + @Override + public boolean declareFinal() { + return declareFinal; + } + + @Override + public boolean removeLocalVariable() { + return false; + } + + @Override + public String getName() { + return "anObject"; + } + + @Override + public boolean replaceAllOccurrences() { + return true; + } + + @Override + public PsiType getSelectedType() { + PsiType type = context.var == null ? context.expression.getType() : context.var.getDeclaredType(); + return TypesUtil.unboxPrimitiveTypeWrapper(type); + } + }; + } + + + public void testSimpleOverridedMethod() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testOverridedMethodWithRemoveUnusedParameters() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false); + } + + public void testSimpleUsage() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testMethodWithoutParams() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testParameterSubstitution() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testThisSubstitution() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testThisSubstitutionInQualifier() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, "field Test.i is not accessible from method XTest.n(). Value for introduced parameter in that method call will be incorrect."); + } + + public void testFieldAccess() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testMethodAccess() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testStaticFieldAccess() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testFieldWithGetterReplacement() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, false, false, false); + } + + public void testFieldWithInaccessibleGetterReplacement() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + + public void testWeirdQualifier() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + + public void testSuperInExpression() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, "Parameter initializer contains super, but not all calls to method are in its class."); + } + + public void testWeirdQualifierAndParameter() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + + public void testImplicitSuperCall() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + + public void testImplicitDefaultConstructor() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + + public void testInternalSideEffect() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + } + +/* public void testAnonymousClass() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false); + }*/ + + public void testSuperWithSideEffect() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, "Parameter initializer contains super, but not all calls to method are in its class."); + } + + public void testConflictingField() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, true, false); + } + + /*public void testParameterJavaDoc1() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true); + } + + public void testParameterJavaDoc2() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true); + } + + public void testParameterJavaDoc3() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true); + } + + public void testParameterJavaDocBeforeVararg() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true); + }*/ + + public void testRemoveParameterInHierarchy() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false); + } + + /*public void testRemoveParameterWithJavadoc() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false); + }*/ + + public void testVarargs() { // IDEADEV-16828 + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testMethodUsageInThisMethodInheritor() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false); + } + + public void testIncorrectArgumentList() { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, true); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy index bd06a9987e25..318a1c228b41 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy @@ -1,6 +1,6 @@ class XXX { public int m() { Test t; - return t.method(1, 1 + t.getI()); + return t.method(1, 1 + t.i); } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy index 318a1c228b41..dd4f98b4e8a6 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy @@ -1,6 +1,6 @@ class XXX { public int m() { Test t; - return t.method(1, 1 + t.i); + return t.method(1, 1 + t.@i); } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldAfter.groovy new file mode 100644 index 000000000000..4b4890efd086 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldAfter.groovy @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2011 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. + */ +public class Test2 extends Test1 { + public void method(int anObject) { + System.out.println(this.anObject); + } +} + +public class Usage { + { + Test t = new Test2(); + t.method(1 + 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldBefore.groovy new file mode 100644 index 000000000000..294c227cd00e --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldBefore.groovy @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2011 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. + */ +public class Test2 extends Test1 { + public void method() { + System.out.println(anObject); + } +} + +public class Usage { + { + Test t = new Test2(); + t.method(); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldMyClass.groovy new file mode 100644 index 000000000000..0521ccf4370c --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/conflictingField/ConflictingFieldMyClass.groovy @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2011 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. + */ +public class Test { + public int anObject; + public void method() { + } +} + +public class Test1 extends Test { + public void method() { + System.out.println(1 + 2); + System.out.println(anObject); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessAfter.groovy new file mode 100644 index 000000000000..89021e58c974 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2, t.i); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessBefore.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessMyClass.groovy new file mode 100644 index 000000000000..0d8df5e1dd94 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldAccess/FieldAccessMyClass.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int method(int a, int b) { + return i; + } + public int i; +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy new file mode 100644 index 000000000000..5677fbbd13ac --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class XXX { + public int m() { + Test t; + return t.method(1, 1 + t.i); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementBefore.groovy new file mode 100644 index 000000000000..14e7a3ed67e6 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementBefore.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class XXX { + public int m() { + Test t; + return t.method(1); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementMyClass.groovy new file mode 100644 index 000000000000..ee903e5f7693 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithGetterReplacement/FieldWithGetterReplacementMyClass.groovy @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int i; + + public int getI() { return i; } + + int method(int a) { + return a + i; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy new file mode 100644 index 000000000000..1fa4acf9e153 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class XXX { + public int m() { + Test t; + return t.method(1, 1 + t.@i); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementBefore.groovy new file mode 100644 index 000000000000..14e7a3ed67e6 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementBefore.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class XXX { + public int m() { + Test t; + return t.method(1); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementMyClass.groovy new file mode 100644 index 000000000000..f1dc0dde4f7e --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/fieldWithInaccessibleGetterReplacement/FieldWithInaccessibleGetterReplacementMyClass.groovy @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + public int i; + + public int getI() { return i; } + + int method(int a) { + return a + i; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy new file mode 100644 index 000000000000..2a2274e9f765 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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. + */ +class B extends A { + B() { + super(27) + } +} + +class Usage { + A a = new B(); +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorBefore.groovy new file mode 100644 index 000000000000..3b77f1f992f4 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class B extends A {} + +class Usage { + A a = new B(); +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorMyClass.groovy new file mode 100644 index 000000000000..06ae3a9092ef --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitDefaultConstructor/ImplicitDefaultConstructorMyClass.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class A { + int i; + public A() { + i = 27; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallAfter.groovy new file mode 100644 index 000000000000..570de9e69f63 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallAfter.groovy @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2011 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. + */ +class B extends A { + int k; + + public B() { + super(27) + k = 10; + } +} + +class Usage { + A a = new B(); +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallBefore.groovy new file mode 100644 index 000000000000..950a9b9bd356 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallBefore.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 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. + */ +class B extends A { + int k; + + public B() { + k = 10; + } +} + +class Usage { + A a = new B(); +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallMyClass.groovy new file mode 100644 index 000000000000..5983cfed77cf --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/implicitSuperCall/ImplicitSuperCallMyClass.groovy @@ -0,0 +1,6 @@ +class A { + int i; + public A() { + i = 27; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListAfter.groovy new file mode 100644 index 000000000000..853f4929faec --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListAfter.groovy @@ -0,0 +1 @@ +new A().foo(27 + 4.5) \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListBefore.groovy new file mode 100644 index 000000000000..2ed39c63b33a --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListBefore.groovy @@ -0,0 +1 @@ +new A().foo("dsf", 4.5) \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListMyClass.groovy new file mode 100644 index 000000000000..d75235e907d0 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/incorrectArgumentList/IncorrectArgumentListMyClass.groovy @@ -0,0 +1,6 @@ +class A { + int i; + def foo(int x, double y) { + i = 27+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectAfter.groovy new file mode 100644 index 000000000000..f8e457a132e2 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectAfter.groovy @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2011 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. + */ +public class Usage { + int usage(Test[] tests) { + int sum = 0; + int i = 0; + while (i < tests.length) { + final Test test = tests[i++] + sum += test.method(test.field); + } + + List list = Arrays.asList(tests); + i = 0; + while (i < list.size()) { + final Test test = (Test) list.get(i++) + sum += test.method(test.field); + } + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectBefore.groovy new file mode 100644 index 000000000000..b315ddf84366 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectBefore.groovy @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2011 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. + */ +public class Usage { + int usage(Test[] tests) { + int sum = 0; + int i = 0; + while (i < tests.length) { + sum += tests[i++].method(); + } + + List list = Arrays.asList(tests); + i = 0; + while (i < list.size()) { + sum += ((Test) list.get(i++)).method(); + } + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectMyClass.groovy new file mode 100644 index 000000000000..efe8dd90f2ba --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/internalSideEffect/InternalSideEffectMyClass.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ + +public class Test { + int field; + int method() { + return field; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessAfter.groovy new file mode 100644 index 000000000000..00200697a8f8 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2, t.anotherMethod(1 + 2)); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessBefore.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessMyClass.groovy new file mode 100644 index 000000000000..17ef9dc56302 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodAccess/MethodAccessMyClass.groovy @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int method(int a, int b) { + return anotherMethod(a + b); + } + int i; + + int anotherMethod(int x) { + return x; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorAfter.groovy new file mode 100644 index 000000000000..01ae467b1fad --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class D extends C { + int foo(int x, int anObject) { + return super.foo(x, anObject); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorBefore.groovy new file mode 100644 index 000000000000..9fc0a41b1c1f --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class D extends C { + int foo(int x) { + return super.foo(x); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorMyClass.groovy new file mode 100644 index 000000000000..67532a1f5adf --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodUsageInThisMethodInheritor/MethodUsageInThisMethodInheritorMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class C { + int foo(int x) { + return x+1; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsAfter.groovy new file mode 100644 index 000000000000..badf46b4e5fb --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class X3 { + int n() { + Test t; + return t.m(0); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsBefore.groovy new file mode 100644 index 000000000000..52af5daa86d2 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsBefore.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class X3 { + int n() { + Test t; + return t.m(); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsMyClass.groovy new file mode 100644 index 000000000000..d811fa11b7dc --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/methodWithoutParams/MethodWithoutParamsMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int m() { + return 0; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersAfter.groovy new file mode 100644 index 000000000000..af032f2c0f63 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass extends MyClass { + public int m(int y, int anObject) { + return 1; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersBefore.groovy new file mode 100644 index 000000000000..bb9a13184658 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass extends MyClass { + public int m(int x, int y) { + return 1; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersMyClass.groovy new file mode 100644 index 000000000000..ce2da355e4e4 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/overridedMethodWithRemoveUnusedParameters/OverridedMethodWithRemoveUnusedParametersMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +public class MyClass { + public int m(int x, int y) { + return x+1+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionAfter.groovy new file mode 100644 index 000000000000..e849427aa36d --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2, 1 + 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionBefore.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionMyClass.groovy new file mode 100644 index 000000000000..e29f0a349972 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/parameterSubstitution/ParameterSubstitutionMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int method(int a, int b) { + return a + b; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyAfter.groovy new file mode 100644 index 000000000000..39b870a191e4 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class S extends Bar { + public int baz(int anObject) { + return super.baz(anObject); //To change body of overridden methods use File | Settings | File Templates. + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyBefore.groovy new file mode 100644 index 000000000000..5eb13a318a9f --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class S extends Bar { + public int baz(byte blah) { + return super.baz((byte) 0); //To change body of overridden methods use File | Settings | File Templates. + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyMyClass.groovy new file mode 100644 index 000000000000..dbd4db7cfa95 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/removeParameterInHierarchy/RemoveParameterInHierarchyMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +public class Bar { + public int baz(byte blah) { + return blah + 3; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodAfter.groovy new file mode 100644 index 000000000000..7d5e98f280d1 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass extends MyClass { + public int m(int x, int y, int anObject) { + return x+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodBefore.groovy new file mode 100644 index 000000000000..d0ec66647176 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass extends MyClass { + public int m(int x, int y) { + return x+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodMyClass.groovy new file mode 100644 index 000000000000..ce2da355e4e4 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleOverridedMethod/SimpleOverridedMethodMyClass.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +public class MyClass { + public int m(int x, int y) { + return x+1+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageAfter.groovy new file mode 100644 index 000000000000..2a92d6c4da9c --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass { + public void exec() { + new MyClass().foo(x, y, x + y); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageBefore.groovy new file mode 100644 index 000000000000..3bcd57af6858 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class GrClass { + public void exec() { + new MyClass().foo(x, y); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageMyClass.groovy new file mode 100644 index 000000000000..4758f0b5bfa1 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/simpleUsage/SimpleUsageMyClass.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +public class MyClass { + public void foo(int x, int y) { + System.out.println(x+y); + return x+1+y; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessAfter.groovy new file mode 100644 index 000000000000..969b38d6b522 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessAfter.groovy @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public static int i; + + int yyy(int z) { + Test t; + return t.method(z, z + Test.i); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessBefore.groovy new file mode 100644 index 000000000000..a3b4ed362556 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessBefore.groovy @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public static int i; + + int yyy(int z) { + Test t; + return t.method(z); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessMyClass.groovy new file mode 100644 index 000000000000..2c95c5a38f15 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/staticFieldAccess/StaticFieldAccessMyClass.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + public static int i; + + int method(int a) { + return a + i; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionAfter.groovy new file mode 100644 index 000000000000..d6ec83ea914b --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class Usage { + int m() { + T2 test; + return test.method(0); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionBefore.groovy new file mode 100644 index 000000000000..d6ec83ea914b --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionBefore.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class Usage { + int m() { + T2 test; + return test.method(0); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionMyClass.groovy new file mode 100644 index 000000000000..77517cb9475d --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superInExpression/SuperInExpressionMyClass.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 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. + */ +class T1 { + int method(int i) { + return 0; + } +} + +class T2 extends T1 { + int method(int i) { + return super.method(i) + 1; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectAfter.groovy new file mode 100644 index 000000000000..f8ad1fdd4c31 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectAfter.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class Usage { + int m() { + return new T2().method(0); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectBefore.groovy new file mode 100644 index 000000000000..f8ad1fdd4c31 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class Usage { + int m() { + return new T2().method(0); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectMyClass.groovy new file mode 100644 index 000000000000..77517cb9475d --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/superWithSideEffect/SuperWithSideEffectMyClass.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 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. + */ +class T1 { + int method(int i) { + return 0; + } +} + +class T2 extends T1 { + int method(int i) { + return super.method(i) + 1; + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionAfter.groovy new file mode 100644 index 000000000000..621479b99872 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2, t); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionBefore.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionMyClass.groovy new file mode 100644 index 000000000000..ef5601fb93a1 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitution/ThisSubstitutionMyClass.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int method(int a, int b) { + return this.i; + } + private int i; +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierAfter.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierBefore.groovy new file mode 100644 index 000000000000..ff06d1706798 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class XTest { + int n() { + Test t; + + return t.method(1, 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierMyClass.groovy new file mode 100644 index 000000000000..fdafbc69be88 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/thisSubstitutionInQualifier/ThisSubstitutionInQualifierMyClass.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + int method(int a, int b) { + return this.i; + } + private int i; +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsAfter.groovy new file mode 100644 index 000000000000..2ace9b55c609 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsAfter.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class Test1 { + Test t; + + public int n(int v) { + return t.m(v, 0, 1); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsBefore.groovy new file mode 100644 index 000000000000..564a687d5b6f --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsBefore.groovy @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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. + */ +class Test1 { + Test t; + + public int n(int v) { + return t.m(v, 1); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsMyClass.groovy new file mode 100644 index 000000000000..9f870bbcd65a --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/varargs/VarargsMyClass.groovy @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2011 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. + */ +class Test { + public int m(int a, int... values) { + if(a > values.length) { + return 0; + } + else { + return 0; + } + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierAfter.groovy new file mode 100644 index 000000000000..227d5c860bb1 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public int n(int a) { + final Test test = new Test() + return test.m(a, a * 2, test.method(a * 2)); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierBefore.groovy new file mode 100644 index 000000000000..7e63cca9739b --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public int n(int a) { + return (new Test()).m(a, a * 2); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierMyClass.groovy new file mode 100644 index 000000000000..c7078798aae7 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifier/WeirdQualifierMyClass.groovy @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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. + */ +public class Test { + int method(int i) { + return 0; + } + + int m(int i, int j) { + return i + method(j); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy new file mode 100644 index 000000000000..3ba2f6eb0afd --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public int n(int a) { + final Test test = new Test() + return (new Test()).m(a, a * 2, test, test.method(a * 2)); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterBefore.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterBefore.groovy new file mode 100644 index 000000000000..1d8c438c17fd --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterBefore.groovy @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2011 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. + */ +class X { + public int n(int a) { + return (new Test()).m(a, a * 2, new Test()); + } +} diff --git a/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterMyClass.groovy b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterMyClass.groovy new file mode 100644 index 000000000000..70c3dc915d8d --- /dev/null +++ b/plugins/groovy/testdata/refactoring/introduceParameterGroovy/weirdQualifierAndParameter/WeirdQualifierAndParameterMyClass.groovy @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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. + */ +public class Test { + int method(int i) { + return 0; + } + + int m(int i, int j, Test t) { + return i + t.method(j); + } +}