mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
create constructor params from field: do not reject next constructors if current one is chained (IDEA-131746)
This commit is contained in:
+7
-3
@@ -144,7 +144,9 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
}
|
||||
|
||||
for (PsiMethodMember member : elements) {
|
||||
if (!addParameterToConstructor(project, file, editor, member.getElement(), new PsiField[] {getField()}, cleanupElements)) break;
|
||||
if (!addParameterToConstructor(project, file, editor, member.getElement(), new PsiField[] {getField()}, cleanupElements)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!constrs.isEmpty()) {
|
||||
@@ -317,9 +319,9 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
assert constructor != null;
|
||||
PsiParameter[] newParameters = constructor.getParameterList().getParameters();
|
||||
if (newParameters == parameters) return false; //user must have canceled dialog
|
||||
boolean created = false;
|
||||
// do not introduce assignment in chanined constructor
|
||||
if (JavaHighlightUtil.getChainedConstructors(constructor) == null) {
|
||||
boolean created = false;
|
||||
for (PsiField field : fields.keySet()) {
|
||||
final String defaultParamName = fields.get(field);
|
||||
PsiParameter parameter = findParamByName(defaultParamName, field.getType(), newParameters, parameterInfos);
|
||||
@@ -334,8 +336,10 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
|
||||
}
|
||||
created = true;
|
||||
}
|
||||
return created;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
private static void notNull(PsiField field, PsiParameter parameter) {
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Add constructor parameter" "true"
|
||||
abstract class FooBar {
|
||||
protected final String myFoo;
|
||||
|
||||
public FooBar(String myFoo) {
|
||||
this.myFoo = myFoo;
|
||||
}
|
||||
|
||||
public FooBar(Integer interestingType, String myFoo) {
|
||||
this(myFoo);
|
||||
}
|
||||
|
||||
public FooBar(int i, String myFoo) {
|
||||
this(myFoo);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Add constructor parameter" "true"
|
||||
abstract class FooBar {
|
||||
protected final String my<caret>Foo;
|
||||
|
||||
public FooBar() {
|
||||
}
|
||||
|
||||
public FooBar(Integer interestingType) {
|
||||
this();
|
||||
}
|
||||
|
||||
public FooBar(int i) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user