From 19c21b657b2c2bc6cbafd7dfeb571a6a86e3c448 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 12 Mar 2012 12:14:16 +0100 Subject: [PATCH] replace constructor with builder: skip default constructor to use in builder create method when chained constructor was not detected (IDEA-82412) --- .../ReplaceConstructorWithBuilderProcessor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderProcessor.java b/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderProcessor.java index 00bd320e2fca..32f5489fa54a 100644 --- a/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/replaceConstructorWithBuilder/ReplaceConstructorWithBuilderProcessor.java @@ -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(", ");