mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline superclass: proceed arrays (IDEA-152539)
This commit is contained in:
+6
-3
@@ -354,7 +354,7 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
|
||||
public void visitTypeElement(final PsiTypeElement typeElement) {
|
||||
super.visitTypeElement(typeElement);
|
||||
final PsiType superClassType = typeElement.getType();
|
||||
if (PsiUtil.resolveClassInType(superClassType) == mySuperClass) {
|
||||
if (PsiUtil.resolveClassInClassTypeOnly(superClassType) == mySuperClass) {
|
||||
PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
|
||||
replacementMap.put(new UsageInfo(typeElement), elementFactory.createTypeElement(elementFactory.createType(targetClass, subst)));
|
||||
}
|
||||
@@ -367,8 +367,11 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
|
||||
if (PsiUtil.resolveClassInType(superClassType) == mySuperClass) {
|
||||
PsiSubstitutor subst = getSuperClassSubstitutor(superClassType, targetClassType, resolveHelper, targetClass);
|
||||
try {
|
||||
replacementMap.put(new UsageInfo(expression), elementFactory.createExpressionFromText("new " + elementFactory.createType(
|
||||
targetClass, subst).getCanonicalText() + expression.getArgumentList().getText(), expression));
|
||||
final String typeCanonicalText = elementFactory.createType(targetClass, subst).getCanonicalText();
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null) {
|
||||
replacementMap.put(new UsageInfo(classReference), elementFactory.createReferenceFromText(typeCanonicalText, expression));
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public static Test[] getArray() {
|
||||
return new Test[0];
|
||||
}
|
||||
|
||||
public static Test[] getArrayWithInitializer() {
|
||||
return new Test[]{};
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Super {
|
||||
public static Super[] getArray() {
|
||||
return new Super[0];
|
||||
}
|
||||
|
||||
public static Super[] getArrayWithInitializer() {
|
||||
return new Super[]{};
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
class Test extends Super {}
|
||||
@@ -71,6 +71,7 @@ public class InlineSuperClassTest extends MultiFileTestCase {
|
||||
public void testInterfaceHierarchyWithSubstitution() { doTest(); }
|
||||
public void testTypeParameterBound() { doTest();}
|
||||
public void testInlineInterfaceDoNotChangeConstructor() { doTest(); }
|
||||
public void testArrayTypeElements() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
doTest(false, false);
|
||||
|
||||
Reference in New Issue
Block a user