EA-72540 - AIOOBE: ExtractMethodSignatureSuggester.detectTopLevelExpressionsToReplace...
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Thu, 3 Sep 2015 09:10:21 +0000 (12:10 +0300)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Thu, 3 Sep 2015 14:22:20 +0000 (17:22 +0300)
java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSignatureSuggester.java

index 3ad037b7a5c74fdc20db8ac78e98cd5d98a8ce62..305536f441b0f6bfc0a5fe70458cb3b5c5c5bddc 100644 (file)
@@ -345,7 +345,8 @@ public class ExtractMethodSignatureSuggester {
         copies.add(myElementFactory.createExpressionFromText(expr.getText(), body));
 
         final SuggestedNameInfo info = JavaCodeStyleManager.getInstance(myProject).suggestVariableName(VariableKind.PARAMETER, null, expr, null);
         copies.add(myElementFactory.createExpressionFromText(expr.getText(), body));
 
         final SuggestedNameInfo info = JavaCodeStyleManager.getInstance(myProject).suggestVariableName(VariableKind.PARAMETER, null, expr, null);
-        name = uniqueNameGenerator.generateUniqueName(info.names[0]);
+        final String paramName = info.names.length > 0 ? info.names[0] : "p";
+        name = uniqueNameGenerator.generateUniqueName(paramName);
 
         final PsiParameter parameter = (PsiParameter)myExtractedMethod.getParameterList().add(myElementFactory.createParameter(name, type));
         inputVariables.add(parameter);
 
         final PsiParameter parameter = (PsiParameter)myExtractedMethod.getParameterList().add(myElementFactory.createParameter(name, type));
         inputVariables.add(parameter);