shorten qualified names in change signature return type (IDEA-130277)

This commit is contained in:
Anna Kozlova
2014-09-29 14:08:35 +02:00
parent 7be506a901
commit d34eaa9ad2
3 changed files with 18 additions and 2 deletions
@@ -17,7 +17,6 @@ package com.intellij.refactoring.changeSignature;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.codeInsight.InferredAnnotationsManager;
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
import com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer;
import com.intellij.lang.StdLanguages;
@@ -694,6 +693,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
final PsiSubstitutor substitutor =
baseMethod == null ? PsiSubstitutor.EMPTY : ChangeSignatureProcessor.calculateSubstitutor(method, baseMethod);
final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(method.getProject());
if (changeInfo.isReturnTypeChanged()) {
PsiType newTypeElement = changeInfo.getNewReturnType().getType(changeInfo.getMethod().getParameterList(), method.getManager());
final PsiType returnType = substitutor.substitute(newTypeElement);
@@ -701,7 +701,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
if (method.getName().equals(changeInfo.getNewName())) {
final PsiTypeElement typeElement = method.getReturnTypeElement();
if (typeElement != null) {
typeElement.replace(factory.createTypeElement(returnType));
javaCodeStyleManager.shortenClassReferences(typeElement.replace(factory.createTypeElement(returnType)));
}
}
}
@@ -0,0 +1,9 @@
// "Make 'bar' return 'java.util.Iterator'" "true"
import java.util.ArrayList;
import java.util.Iterator;
public class Foo {
Iterator bar() {
return new ArrayList().iterator();
}
}
@@ -0,0 +1,7 @@
// "Make 'bar' return 'java.util.Iterator'" "true"
import java.util.ArrayList;
public class Foo {
void bar() {
return new ArrayList().itera<caret>tor();
}
}