Change Signature: Retain parameter modifier list
This commit is contained in:
+3
-1
@@ -73,13 +73,15 @@ public final class JetChangeSignatureData implements JetMethodDescriptor {
|
|||||||
@Override
|
@Override
|
||||||
public JetParameterInfo fun(ValueParameterDescriptor param) {
|
public JetParameterInfo fun(ValueParameterDescriptor param) {
|
||||||
JetParameter parameter = valueParameters != null ? valueParameters.get(param.getIndex()) : null;
|
JetParameter parameter = valueParameters != null ? valueParameters.get(param.getIndex()) : null;
|
||||||
return new JetParameterInfo(
|
JetParameterInfo parameterInfo = new JetParameterInfo(
|
||||||
param.getIndex(),
|
param.getIndex(),
|
||||||
param.getName().asString(),
|
param.getName().asString(),
|
||||||
param.getType(),
|
param.getType(),
|
||||||
parameter != null ? parameter.getDefaultValue() : null,
|
parameter != null ? parameter.getDefaultValue() : null,
|
||||||
parameter != null ? parameter.getValOrVarNode() : null
|
parameter != null ? parameter.getValOrVarNode() : null
|
||||||
);
|
);
|
||||||
|
parameterInfo.setModifierList(parameter != null ? parameter.getModifierList() : null);
|
||||||
|
return parameterInfo;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetModifierList;
|
||||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
@@ -42,6 +43,7 @@ public class JetParameterInfo implements ParameterInfo {
|
|||||||
private String defaultValueText = "";
|
private String defaultValueText = "";
|
||||||
private JetValVar valOrVar;
|
private JetValVar valOrVar;
|
||||||
@Nullable private JetExpression defaultValue;
|
@Nullable private JetExpression defaultValue;
|
||||||
|
@Nullable JetModifierList modifierList;
|
||||||
|
|
||||||
public JetParameterInfo(int oldIndex, String name, JetType type, @Nullable JetExpression defaultValue, @Nullable ASTNode valOrVar) {
|
public JetParameterInfo(int oldIndex, String name, JetType type, @Nullable JetExpression defaultValue, @Nullable ASTNode valOrVar) {
|
||||||
this.oldIndex = oldIndex;
|
this.oldIndex = oldIndex;
|
||||||
@@ -174,6 +176,15 @@ public class JetParameterInfo implements ParameterInfo {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public JetModifierList getModifierList() {
|
||||||
|
return modifierList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifierList(@Nullable JetModifierList modifierList) {
|
||||||
|
this.modifierList = modifierList;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean requiresExplicitType(@NotNull JetFunctionDefinitionUsage inheritedFunction) {
|
public boolean requiresExplicitType(@NotNull JetFunctionDefinitionUsage inheritedFunction) {
|
||||||
FunctionDescriptor inheritedFunctionDescriptor = inheritedFunction.getOriginalFunctionDescriptor();
|
FunctionDescriptor inheritedFunctionDescriptor = inheritedFunction.getOriginalFunctionDescriptor();
|
||||||
if (!(inheritedFunctionDescriptor instanceof AnonymousFunctionDescriptor)) return true;
|
if (!(inheritedFunctionDescriptor instanceof AnonymousFunctionDescriptor)) return true;
|
||||||
@@ -189,8 +200,12 @@ public class JetParameterInfo implements ParameterInfo {
|
|||||||
|
|
||||||
public String getDeclarationSignature(int parameterIndex, @NotNull JetFunctionDefinitionUsage inheritedFunction) {
|
public String getDeclarationSignature(int parameterIndex, @NotNull JetFunctionDefinitionUsage inheritedFunction) {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
JetValVar valVar = getValOrVar();
|
|
||||||
|
|
||||||
|
if (modifierList != null) {
|
||||||
|
buffer.append(modifierList.getText()).append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
JetValVar valVar = getValOrVar();
|
||||||
if (valVar != JetValVar.None) {
|
if (valVar != JetValVar.None) {
|
||||||
buffer.append(valVar.toString()).append(' ');
|
buffer.append(valVar.toString()).append(' ');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
annotation class foo(val n: Int)
|
||||||
|
|
||||||
|
class Test([foo(1) foo(2)] [foo(3)] private val s: String, n: Int)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
annotation class foo(val n: Int)
|
||||||
|
|
||||||
|
class <caret>Test([foo(1) foo(2)] [foo(3)] private val s: String)
|
||||||
+6
@@ -553,6 +553,12 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
|||||||
doTest(changeInfo);
|
doTest(changeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testParameterModifiers() throws Exception {
|
||||||
|
JetChangeInfo changeInfo = getChangeInfo();
|
||||||
|
changeInfo.addParameter(new JetParameterInfo("n", KotlinBuiltIns.getInstance().getIntType()));
|
||||||
|
doTest(changeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected String getTestDataPath() {
|
protected String getTestDataPath() {
|
||||||
|
|||||||
Reference in New Issue
Block a user