replace constructor with builder: skip default constructor to use in builder create method when chained constructor was not detected (IDEA-82412)

This commit is contained in:
anna
2012-03-12 12:43:06 +01:00
parent 3c5d7a568d
commit 19c21b657b
@@ -222,7 +222,12 @@ public class ReplaceConstructorWithBuilderProcessor extends FixableUsagesRefacto
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(myProject);
final StringBuffer buf = new StringBuffer();
PsiMethod constructor = getMostCommonConstructor();
if (constructor == null) constructor = myConstructors[0];
if (constructor == null){
constructor = myConstructors[0];
if (constructor.getParameterList().getParametersCount() == 0) {
constructor = myConstructors[1];
}
}
for (PsiParameter parameter : constructor.getParameterList().getParameters()) {
final String pureParamName = styleManager.variableNameToPropertyName(parameter.getName(), VariableKind.PARAMETER);
if (buf.length() > 0) buf.append(", ");