change signature: refresh type element after normalizeDeclaration for old style arrays

This commit is contained in:
Anna.Kozlova
2016-11-15 18:11:31 +01:00
parent 971c0fe60a
commit 12542833ff
4 changed files with 14 additions and 3 deletions
@@ -827,11 +827,12 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
parameter.getNameIdentifier().replace(newIdentifier);
}
final PsiTypeElement typeElement = parameter.getTypeElement();
PsiTypeElement typeElement = parameter.getTypeElement();
if (typeElement != null) {
parameter.normalizeDeclaration();
typeElement = parameter.getTypeElement();
String oldType = oldParameterTypes[index];
if (!oldType.equals(info.getTypeText())) {
parameter.normalizeDeclaration();
PsiType newType =
substitutor.substitute(info.createType(changeInfo.getMethod().getParameterList(), changeInfo.getMethod().getManager()));
typeElement.replace(factory.createTypeElement(newType));
@@ -0,0 +1,3 @@
class Test {
void <caret>foo(int a[]) {}
}
@@ -0,0 +1,3 @@
class Test {
void foo(int... a) {}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -355,6 +355,10 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
}, false);
}
public void testReplaceOldStyleArrayWithVarargs() throws Exception {
doTest(null, new ParameterInfoImpl[] {new ParameterInfoImpl(0, "a", new PsiEllipsisType(PsiType.INT))}, false);
}
public void testReorderParamsOfFunctionalInterface() {
doTest(null, null, null, method -> new ParameterInfoImpl[]{
new ParameterInfoImpl(1, "b", PsiType.INT),