mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
create fields from params: fix name for mult params, final modifier fixed (IDEA-84852)
This commit is contained in:
+7
-3
@@ -66,6 +66,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private String myName = "";
|
||||
private boolean myConstructor = false;
|
||||
|
||||
@Nullable
|
||||
private static PsiType[] getTypes(final PsiParameter parameter) {
|
||||
@@ -101,7 +102,9 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
if (myName == null) return CodeInsightBundle.message("intention.create.fields.from.parameters.text");
|
||||
if (myName == null) {
|
||||
return CodeInsightBundle.message("intention.create.fields.from.parameters.text", myConstructor ? "Constructor" : "Method") ;
|
||||
}
|
||||
return CodeInsightBundle.message("intention.create.field.from.parameter.text", myName);
|
||||
}
|
||||
|
||||
@@ -144,6 +147,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
LOG.assertTrue(psiParameter != null);
|
||||
}
|
||||
myName = params.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode() ? null : psiParameter.getName();
|
||||
myConstructor = method.isConstructor();
|
||||
}
|
||||
return isAvailable(psiParameter);
|
||||
}
|
||||
@@ -270,7 +274,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
if (selection != null) {
|
||||
chooser.selectElements(new ClassMember[] {selection});
|
||||
}
|
||||
chooser.setTitle("Choose Constructor Parameters to Generate Fields");
|
||||
chooser.setTitle("Choose " + (method.isConstructor() ? "Constructor" : "Method") + " Parameters to Generate Fields");
|
||||
chooser.setCopyJavadocVisible(false);
|
||||
chooser.show();
|
||||
if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
|
||||
@@ -342,7 +346,7 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
suggestedNameInfo.nameChoosen(fieldNameToCalc);
|
||||
}
|
||||
else {
|
||||
isFinalToCalc = !isMethodStatic;
|
||||
isFinalToCalc = !isMethodStatic && method.isConstructor();
|
||||
fieldNameToCalc = names[0];
|
||||
type= types[0];
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create Field For Parameter 'p1'" "true"
|
||||
|
||||
class Test{
|
||||
private final String[] myP1;
|
||||
private String[] myP1;
|
||||
|
||||
void f(String[] p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import java.util.*;
|
||||
class Test{
|
||||
private final List<String> myP1;
|
||||
private List<String> myP1;
|
||||
|
||||
<T extends String> void f(List<T> p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create Field For Parameter 'p1'" "true"
|
||||
|
||||
class Test{
|
||||
private final String myP1;
|
||||
private String myP1;
|
||||
|
||||
<T extends String> void f(T p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create Field For Parameter 'p1'" "true"
|
||||
|
||||
class Test<T>{
|
||||
private final T myP1;
|
||||
private T myP1;
|
||||
|
||||
void f(T p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import java.util.*;
|
||||
class Test<T>{
|
||||
private final List<T> myP1;
|
||||
private List<T> myP1;
|
||||
|
||||
void f(List<T> p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import java.util.*;
|
||||
class Test{
|
||||
private final List<Object> myP1;
|
||||
private List<Object> myP1;
|
||||
|
||||
<T> void f(List<T> p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create Field For Parameter 'p1'" "true"
|
||||
|
||||
class Test{
|
||||
private final Object myP1;
|
||||
private Object myP1;
|
||||
|
||||
<T> void f(T p1){
|
||||
myP1 = p1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create Field For Parameter 'p1'" "true"
|
||||
|
||||
class Test{
|
||||
private final String myP1;
|
||||
private String myP1;
|
||||
|
||||
<T extends String> void f(T p1){
|
||||
myP1 = p1;
|
||||
|
||||
@@ -191,7 +191,7 @@ intention.error.cannot.create.class.title=Failed to Create Class
|
||||
intention.assign.field.from.parameter.text=Assign Parameter to Field ''{0}''
|
||||
intention.assign.field.from.parameter.family=Assign Parameter to Field
|
||||
intention.create.field.from.parameter.text=Create Field For Parameter ''{0}''
|
||||
intention.create.fields.from.parameters.text=Create Fields For Constructor Parameters
|
||||
intention.create.fields.from.parameters.text=Create Fields For {0} Parameters
|
||||
intention.create.field.from.parameter.family=Create Field for Parameter
|
||||
intention.implement.abstract.method.searching.for.descendants.progress=Searching For Descendants...
|
||||
intention.implement.abstract.method.error.no.classes.message=There are no classes found where this method can be implemented
|
||||
|
||||
Reference in New Issue
Block a user