EA-72540 - AIOOBE: ExtractMethodSignatureSuggester.detectTopLevelExpressionsToReplace...
[idea/community.git] / 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);
-        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);