diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
index 123463734811..41bbe91ca43d 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2012 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.
@@ -762,12 +762,11 @@ public class ExtractMethodProcessor implements MatchProvider {
}
adjustFinalParameters(newMethod);
-
- for (int i = 0, length = myVariableDatum.length; i < length; i++) {
- ParameterTablePanel.VariableData data = myVariableDatum[i];
+ int i = 0;
+ for (ParameterTablePanel.VariableData data : myVariableDatum) {
if (!data.passAsParameter) continue;
final PsiVariable variable = data.variable;
- final PsiParameter psiParameter = newMethod.getParameterList().getParameters()[i];
+ final PsiParameter psiParameter = newMethod.getParameterList().getParameters()[i++];
if (!TypeConversionUtil.isAssignable(variable.getType(), psiParameter.getType())) {
for (PsiReference reference : ReferencesSearch.search(psiParameter, new LocalSearchScope(body))){
final PsiElement element = reference.getElement();
diff --git a/java/java-tests/testData/refactoring/extractMethod/DisabledParam.java b/java/java-tests/testData/refactoring/extractMethod/DisabledParam.java
index 64406a7febeb..a64da7565d1e 100644
--- a/java/java-tests/testData/refactoring/extractMethod/DisabledParam.java
+++ b/java/java-tests/testData/refactoring/extractMethod/DisabledParam.java
@@ -1,6 +1,22 @@
+/*
+ * Copyright 2000-2012 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 Fest {
public static void main(String[] args) {
String f = "";
- System.out.println(f);
+ String bar = ""
+ System.out.println(f + ";" + bar);
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractMethod/DisabledParam_after.java b/java/java-tests/testData/refactoring/extractMethod/DisabledParam_after.java
index c25ade46e4d5..c83eb274a692 100644
--- a/java/java-tests/testData/refactoring/extractMethod/DisabledParam_after.java
+++ b/java/java-tests/testData/refactoring/extractMethod/DisabledParam_after.java
@@ -1,11 +1,27 @@
+/*
+ * Copyright 2000-2012 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 Fest {
public static void main(String[] args) {
String f = "";
- newMethod();
+ String bar = ""
+ newMethod(bar);
}
- private static void newMethod() {
+ private static void newMethod(String bar) {
String f = ;
- System.out.println(f);
+ System.out.println(f + ";" + bar);
}
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
index dd534625c829..fba5f90a20fa 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
@@ -503,6 +518,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
}
public void testDisabledParam() throws Exception {
+ doTestDisabledParam();
+ }
+
+ private void doTestDisabledParam() throws PrepareFailedException {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
settings.ELSE_ON_NEW_LINE = true;
settings.CATCH_ON_NEW_LINE = myCatchOnNewLine;