mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-64581 Groovy: Change Signature Refactoring shouldn't use parameter's initializer as default value
This commit is contained in:
+8
@@ -511,6 +511,10 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
else {
|
||||
if (skipOptionals && isParameterOptional(parameter)) continue;
|
||||
GrExpression fromText = null;
|
||||
if (forceOptional(parameter)) {
|
||||
skipOptionals = true;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
fromText = factory.createExpressionFromText(parameter.getDefaultValue());
|
||||
}
|
||||
@@ -535,6 +539,10 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
}
|
||||
}
|
||||
|
||||
protected static boolean forceOptional(JavaParameterInfo parameter) {
|
||||
return parameter instanceof GrParameterInfo && ((GrParameterInfo)parameter).forceOptional();
|
||||
}
|
||||
|
||||
private static void fixExceptions(PsiElement element, PsiClassType[] exceptions) {
|
||||
if (exceptions.length == 0) return;
|
||||
final GroovyPsiElement context =
|
||||
|
||||
+5
-2
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.changeSignature;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.changeSignature.JavaParameterInfo;
|
||||
import com.intellij.refactoring.util.CanonicalTypes;
|
||||
@@ -37,7 +36,6 @@ public class GrParameterInfo implements JavaParameterInfo {
|
||||
|
||||
public GrParameterInfo(GrParameter parameter, int position) {
|
||||
myPosition = position;
|
||||
final Project project = parameter.getProject();
|
||||
myName = parameter.getName();
|
||||
final PsiType type = parameter.getDeclaredType();
|
||||
if (type != null) {
|
||||
@@ -82,6 +80,7 @@ public class GrParameterInfo implements JavaParameterInfo {
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
if (forceOptional()) return getDefaultInitializer();
|
||||
return myDefaultValue;
|
||||
}
|
||||
|
||||
@@ -133,6 +132,10 @@ public class GrParameterInfo implements JavaParameterInfo {
|
||||
return getTypeText().length() == 0;
|
||||
}
|
||||
|
||||
public boolean forceOptional() {
|
||||
return myPosition < 0 && myDefaultValue.length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* for testing only
|
||||
*/
|
||||
|
||||
-3
@@ -119,9 +119,6 @@ public class GrTableParameterInfo {
|
||||
type = null;
|
||||
}
|
||||
String defaultValue = getDefaultValue();
|
||||
if (defaultValue.length() == 0) {
|
||||
defaultValue = defaultInitializer;
|
||||
}
|
||||
return new GrParameterInfo(getName(), defaultValue, defaultInitializer, type, myPosition);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user