mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Removed unnecessary "preview usages?" tests
This commit is contained in:
-2
@@ -125,7 +125,6 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction {
|
||||
method.getName(),
|
||||
method.getReturnType(),
|
||||
myNewParametersInfo,
|
||||
false,
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
processor.testRun();
|
||||
@@ -152,7 +151,6 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction {
|
||||
dialog.getReturnType(),
|
||||
dialog.getParameters(),
|
||||
null,
|
||||
dialog.isPreviewUsages(),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
dialog.close(DialogWrapper.OK_EXIT_CODE);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class MethodParameterFix implements IntentionAction {
|
||||
method.getName(),
|
||||
method.getReturnType(),
|
||||
getNewParametersInfo(),
|
||||
false, BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
processor.testRun();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MethodReturnFix implements IntentionAction {
|
||||
method.getName(),
|
||||
myReturnType,
|
||||
RemoveUnusedParameterFix.getNewParametersInfo(method, null),
|
||||
false, BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
processor.testRun();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RemoveUnusedParameterFix implements IntentionAction {
|
||||
method.getName(),
|
||||
method.getReturnType(),
|
||||
getNewParametersInfo(method, parameter),
|
||||
false, BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
processor.testRun();
|
||||
|
||||
@@ -63,7 +63,6 @@ public class SuperMethodReturnFix implements IntentionAction {
|
||||
mySuperMethod.getName(),
|
||||
mySuperMethodType,
|
||||
ParameterInfo.fromMethod(mySuperMethod),
|
||||
false,
|
||||
null);
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
processor.testRun();
|
||||
|
||||
@@ -198,7 +198,7 @@ public class UnusedParametersInspection extends FilteringInspectionTool {
|
||||
false, null, psiMethod.getName(),
|
||||
psiMethod.getReturnType(),
|
||||
parameterInfos,
|
||||
false, BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
|
||||
csp.run(null);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class UnusedReturnValue extends DescriptorProviderInspection {
|
||||
false, null, psiMethod.getName(),
|
||||
PsiType.VOID,
|
||||
infos,
|
||||
false, BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK);
|
||||
|
||||
csp.run(null);
|
||||
}
|
||||
|
||||
-4
@@ -44,10 +44,6 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
|
||||
return "Change Class Signature";
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages);
|
||||
}
|
||||
|
||||
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages, FindUsagesCommand refreshCommand) {
|
||||
return new ChangeClassSigntaureViewDescriptor(myClass, usages, refreshCommand);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ public class ChangeSignatureHandler implements RefactoringActionHandler {
|
||||
dialog.getReturnType(),
|
||||
dialog.getParameters(),
|
||||
dialog.getExceptions(),
|
||||
dialog.isPreviewUsages(),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
dialog.close(DialogWrapper.OK_EXIT_CODE);
|
||||
|
||||
@@ -49,7 +49,6 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
private String myNewName;
|
||||
private CanonicalTypes.Type myNewType;
|
||||
private ParameterInfo[] myParameterInfo;
|
||||
private boolean myToPreviewUsages;
|
||||
private ChangeInfo myChangeInfo;
|
||||
private PsiManager myManager;
|
||||
private PsiElementFactory myFactory;
|
||||
@@ -58,38 +57,42 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
private HashSet<PsiMethod> myMethodsToBeChanged;
|
||||
private final boolean myGenerateDelegate;
|
||||
|
||||
public ChangeSignatureProcessor(Project project, PsiMethod method,
|
||||
final boolean generateDelegate, String newVisibility,
|
||||
String newName, PsiType newType,
|
||||
ParameterInfo[] parameterInfo, boolean toPreviewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
public ChangeSignatureProcessor(Project project,
|
||||
PsiMethod method,
|
||||
final boolean generateDelegate,
|
||||
String newVisibility,
|
||||
String newName,
|
||||
PsiType newType,
|
||||
ParameterInfo[] parameterInfo,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
this(project, method, generateDelegate, newVisibility, newName,
|
||||
newType != null ? CanonicalTypes.createTypeWrapper(newType) : null,
|
||||
parameterInfo, null, toPreviewUsages, prepareSuccessfulCallback);
|
||||
}
|
||||
|
||||
public ChangeSignatureProcessor(Project project, PsiMethod method,
|
||||
final boolean generateDelegate, String newVisibility,
|
||||
String newName, PsiType newType,
|
||||
ParameterInfo[] parameterInfo,
|
||||
ThrownExceptionInfo[] exceptionInfos,
|
||||
boolean toPreviewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
this(project, method, generateDelegate, newVisibility, newName,
|
||||
newType != null ? CanonicalTypes.createTypeWrapper(newType) : null,
|
||||
parameterInfo, exceptionInfos, toPreviewUsages, prepareSuccessfulCallback);
|
||||
parameterInfo, null, prepareSuccessfulCallback);
|
||||
}
|
||||
|
||||
public ChangeSignatureProcessor(Project project,
|
||||
PsiMethod method,
|
||||
boolean generateDelegate,
|
||||
String newVisibility,
|
||||
String newName,
|
||||
CanonicalTypes.Type newType,
|
||||
ParameterInfo[] parameterInfo,
|
||||
ThrownExceptionInfo[] thrownExceptions,
|
||||
boolean toPreviewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
PsiMethod method,
|
||||
final boolean generateDelegate,
|
||||
String newVisibility,
|
||||
String newName,
|
||||
PsiType newType,
|
||||
ParameterInfo[] parameterInfo,
|
||||
ThrownExceptionInfo[] exceptionInfos,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
this(project, method, generateDelegate, newVisibility, newName,
|
||||
newType != null ? CanonicalTypes.createTypeWrapper(newType) : null,
|
||||
parameterInfo, exceptionInfos, prepareSuccessfulCallback);
|
||||
}
|
||||
|
||||
public ChangeSignatureProcessor(Project project,
|
||||
PsiMethod method,
|
||||
boolean generateDelegate,
|
||||
String newVisibility,
|
||||
String newName,
|
||||
CanonicalTypes.Type newType,
|
||||
ParameterInfo[] parameterInfo,
|
||||
ThrownExceptionInfo[] thrownExceptions,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
myGenerateDelegate = generateDelegate;
|
||||
LOG.assertTrue(method.isValid());
|
||||
@@ -101,7 +104,6 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
myNewName = newName;
|
||||
myNewType = newType;
|
||||
myParameterInfo = parameterInfo;
|
||||
myToPreviewUsages = toPreviewUsages;
|
||||
|
||||
myChangeInfo = new ChangeInfo(myNewVisibility, method, myNewName, myNewType, myParameterInfo, thrownExceptions);
|
||||
LOG.assertTrue(myChangeInfo.getMethod().isValid());
|
||||
@@ -265,10 +267,6 @@ public class ChangeSignatureProcessor extends BaseRefactoringProcessor {
|
||||
myChangeInfo.updateMethod((PsiMethod) elements[0]);
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages) || myToPreviewUsages;
|
||||
}
|
||||
|
||||
protected boolean preprocessUsages(UsageInfo[][] usages) {
|
||||
Set<String> conflictDescriptions = new HashSet<String>();
|
||||
conflictDescriptions.addAll(Arrays.asList(RenameUtil.getConflictDescriptions(usages[0])));
|
||||
|
||||
@@ -53,11 +53,6 @@ public class EncapsulateFieldsProcessor extends BaseRefactoringProcessor impleme
|
||||
return new EncapsulateFieldsViewDescriptor(fields, usages, refreshCommand);
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myDialog.isPreviewUsages();
|
||||
return super.isPreviewUsages(usages) || toPreview;
|
||||
}
|
||||
|
||||
protected String getCommandName() {
|
||||
return "Encapsulating fields in " + UsageViewUtil.getDescriptiveName(myClass);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ExtractClassUtil {
|
||||
if (dialog.isOK()) {
|
||||
RefactoringSettings.getInstance().EXTRACT_INTERFACE_PREVIEW_USAGES = dialog.isPreviewUsages();
|
||||
TurnRefsToSuperProcessor processor =
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass) classElement, (PsiClass) interfaceElement, true, dialog.isPreviewUsages());
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass) classElement, (PsiClass) interfaceElement, true);
|
||||
processor.run(null);
|
||||
}
|
||||
}
|
||||
|
||||
+75
-77
@@ -28,8 +28,12 @@ import com.intellij.usageView.FindUsagesCommand;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.usages.UsageInfoToUsageConverter;
|
||||
import com.intellij.usages.UsageTarget;
|
||||
import com.intellij.usages.UsageViewManager;
|
||||
import com.intellij.usages.UsageViewPresentation;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -41,26 +45,26 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
private final PsiClass myClass;
|
||||
private final String myInnerClassName;
|
||||
private boolean myIsDelegateOtherMembers;
|
||||
private final LinkedHashSet myDelegatedInterfaces;
|
||||
private final LinkedHashSet myDelegatedMethods;
|
||||
private final com.intellij.util.containers.HashMap myDelegatedMethodsVisibility;
|
||||
private final LinkedHashSet myOverridenMethods;
|
||||
private final LinkedHashSet<Object> myDelegatedInterfaces;
|
||||
private final LinkedHashSet<Object> myDelegatedMethods;
|
||||
private final HashMap<PsiMethod,String> myDelegatedMethodsVisibility;
|
||||
private final LinkedHashSet<PsiMethod> myOverridenMethods;
|
||||
|
||||
private boolean myPreviewUsages;
|
||||
|
||||
private final PsiClass myBaseClass;
|
||||
private final Set myBaseClassMembers;
|
||||
private final Set<Object> myBaseClassMembers;
|
||||
private final String myFieldName;
|
||||
private final String myGetterName;
|
||||
private final boolean myGenerateGetter;
|
||||
private Set myBaseClassBases;
|
||||
private Set myClassImplementedInterfaces;
|
||||
private Set<PsiClass> myBaseClassBases;
|
||||
private Set<PsiClass> myClassImplementedInterfaces;
|
||||
private PsiElementFactory myFactory;
|
||||
private final PsiType myBaseClassType;
|
||||
private final PsiManager myManager;
|
||||
private final boolean myIsInnerClassNeeded;
|
||||
private Set myClassInheritors;
|
||||
private HashSet myAbstractDelegatedMethods;
|
||||
private Set<Object> myClassInheritors;
|
||||
private HashSet<PsiMethod> myAbstractDelegatedMethods;
|
||||
|
||||
|
||||
public InheritanceToDelegationProcessor(Project project,
|
||||
@@ -96,12 +100,12 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
myGetterName = PropertyUtil.suggestGetterName(propertyName, myBaseClassType);
|
||||
myGenerateGetter = generateGetter;
|
||||
|
||||
myDelegatedInterfaces = new LinkedHashSet();
|
||||
myDelegatedInterfaces = new LinkedHashSet<Object>();
|
||||
addAll(myDelegatedInterfaces, delegatedInterfaces);
|
||||
myDelegatedMethods = new LinkedHashSet();
|
||||
myDelegatedMethods = new LinkedHashSet<Object>();
|
||||
addAll(myDelegatedMethods, delegatedMethods);
|
||||
myDelegatedMethodsVisibility = new com.intellij.util.containers.HashMap();
|
||||
for (Iterator iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
myDelegatedMethodsVisibility = new com.intellij.util.containers.HashMap<PsiMethod, String>();
|
||||
for (Iterator<Object> iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod method = (PsiMethod) iterator.next();
|
||||
PsiMethod overridingMethod = myClass.findMethodBySignature(method, false);
|
||||
if (overridingMethod != null) {
|
||||
@@ -113,22 +117,16 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
myOverridenMethods = getOverriddenMethods();
|
||||
}
|
||||
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages) || myPreviewUsages;
|
||||
}
|
||||
|
||||
|
||||
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages, FindUsagesCommand refreshCommand) {
|
||||
return new InheritanceToDelegationViewDescriptor(myClass, usages, refreshCommand);
|
||||
}
|
||||
|
||||
protected UsageInfo[] findUsages() {
|
||||
ArrayList usages = new ArrayList();
|
||||
ArrayList<Object> usages = new ArrayList<Object>();
|
||||
PsiSearchHelper searchHelper = myManager.getSearchHelper();
|
||||
GlobalSearchScope projectScope = GlobalSearchScope.projectScope(myProject);
|
||||
final PsiClass[] inheritors = searchHelper.findInheritors(myClass, projectScope, true);
|
||||
myClassInheritors = new HashSet();
|
||||
myClassInheritors = new HashSet<Object>();
|
||||
myClassInheritors.add(myClass);
|
||||
addAll(myClassInheritors, inheritors);
|
||||
|
||||
@@ -146,11 +144,11 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
processClass(inheritors[i], usages);
|
||||
}
|
||||
|
||||
return (UsageInfo[]) usages.toArray(new UsageInfo[usages.size()]);
|
||||
return usages.toArray(new UsageInfo[usages.size()]);
|
||||
}
|
||||
|
||||
private FieldAccessibility getFieldAccessibility(PsiElement element) {
|
||||
for (Iterator iterator = myClassInheritors.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = myClassInheritors.iterator(); iterator.hasNext();) {
|
||||
PsiClass aClass = (PsiClass) iterator.next();
|
||||
if (PsiTreeUtil.isAncestor(aClass, element, false)) {
|
||||
return new FieldAccessibility(true, aClass);
|
||||
@@ -160,11 +158,11 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
protected boolean preprocessUsages(UsageInfo[][] usages) {
|
||||
ArrayList oldUsages = new ArrayList();
|
||||
ArrayList<Object> oldUsages = new ArrayList<Object>();
|
||||
addAll(oldUsages, usages[0]);
|
||||
final ObjectUpcastedUsageInfo[] objectUpcastedUsageInfos = objectUpcastedUsages(usages[0]);
|
||||
if (myPrepareSuccessfulSwingThreadCallback != null) {
|
||||
ArrayList conflicts = new ArrayList();
|
||||
ArrayList<String> conflicts = new ArrayList<String>();
|
||||
if (objectUpcastedUsageInfos.length > 0) {
|
||||
final String message = "Instances of " + ConflictsUtil.getDescription(myClass, true) + " upcasted to " +
|
||||
ConflictsUtil.htmlEmphasize("java.lang.Object") + " were found. If you continue, they will be shown " +
|
||||
@@ -176,25 +174,25 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
analyzeConflicts(usages[0], conflicts);
|
||||
if (!conflicts.isEmpty()) {
|
||||
ConflictsDialog conflictsDialog =
|
||||
new ConflictsDialog((String[]) conflicts.toArray(new String[conflicts.size()]), myProject);
|
||||
new ConflictsDialog(conflicts.toArray(new String[conflicts.size()]), myProject);
|
||||
conflictsDialog.show();
|
||||
if (!conflictsDialog.isOK()) return false;
|
||||
}
|
||||
|
||||
if (objectUpcastedUsageInfos.length > 0) {
|
||||
showObjectUpcastedUsageView(objectUpcastedUsageInfos);
|
||||
myPreviewUsages = true;
|
||||
setPreviewUsages(true);
|
||||
}
|
||||
}
|
||||
ArrayList filteredUsages = filterUsages(oldUsages);
|
||||
usages[0] = (UsageInfo[]) filteredUsages.toArray(new UsageInfo[filteredUsages.size()]);
|
||||
ArrayList<UsageInfo> filteredUsages = filterUsages(oldUsages);
|
||||
usages[0] = filteredUsages.toArray(new UsageInfo[filteredUsages.size()]);
|
||||
prepareSuccessful();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void analyzeConflicts(UsageInfo[] usage, ArrayList conflicts) {
|
||||
com.intellij.util.containers.HashMap reportedNonDelegatedUsages = new com.intellij.util.containers.HashMap();
|
||||
com.intellij.util.containers.HashMap reportedUpcasts = new com.intellij.util.containers.HashMap();
|
||||
private void analyzeConflicts(UsageInfo[] usage, ArrayList<String> conflicts) {
|
||||
HashMap<PsiElement,HashSet<PsiElement>> reportedNonDelegatedUsages = new HashMap<PsiElement, HashSet<PsiElement>>();
|
||||
HashMap<PsiClass,HashSet<PsiElement>> reportedUpcasts = new HashMap<PsiClass, HashSet<PsiElement>>();
|
||||
// HashSet reportedObjectUpcasts = new HashSet();
|
||||
|
||||
// final String nameJavaLangObject = ConflictsUtil.htmlEmphasize("java.lang.Object");
|
||||
@@ -215,9 +213,9 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
if (!myIsDelegateOtherMembers && !usageInfo.getDelegateFieldAccessible().isAccessible()) {
|
||||
if (usageInfo instanceof NonDelegatedMemberUsageInfo) {
|
||||
final PsiElement nonDelegatedMember = ((NonDelegatedMemberUsageInfo) usageInfo).nonDelegatedMember;
|
||||
HashSet reportedContainers = (HashSet) reportedNonDelegatedUsages.get(nonDelegatedMember);
|
||||
HashSet<PsiElement> reportedContainers = reportedNonDelegatedUsages.get(nonDelegatedMember);
|
||||
if (reportedContainers == null) {
|
||||
reportedContainers = new HashSet();
|
||||
reportedContainers = new HashSet<PsiElement>();
|
||||
reportedNonDelegatedUsages.put(nonDelegatedMember, reportedContainers);
|
||||
}
|
||||
final PsiElement container = ConflictsUtil.getContainer(usageInfo.getElement());
|
||||
@@ -230,9 +228,9 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
} else if (usageInfo instanceof UpcastedUsageInfo) {
|
||||
final PsiClass upcastedTo = ((UpcastedUsageInfo) usageInfo).upcastedTo;
|
||||
HashSet reportedContainers = (HashSet) reportedUpcasts.get(upcastedTo);
|
||||
HashSet<PsiElement> reportedContainers = reportedUpcasts.get(upcastedTo);
|
||||
if (reportedContainers == null) {
|
||||
reportedContainers = new HashSet();
|
||||
reportedContainers = new HashSet<PsiElement>();
|
||||
reportedUpcasts.put(upcastedTo, reportedContainers);
|
||||
}
|
||||
final PsiElement container = ConflictsUtil.getContainer(usageInfo.getElement());
|
||||
@@ -254,18 +252,18 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
private ObjectUpcastedUsageInfo[] objectUpcastedUsages(UsageInfo[] usages) {
|
||||
ArrayList result = new ArrayList();
|
||||
ArrayList<ObjectUpcastedUsageInfo> result = new ArrayList<ObjectUpcastedUsageInfo>();
|
||||
for (int i = 0; i < usages.length; i++) {
|
||||
UsageInfo usage = usages[i];
|
||||
if (usage instanceof ObjectUpcastedUsageInfo) {
|
||||
result.add(((ObjectUpcastedUsageInfo) usage));
|
||||
}
|
||||
}
|
||||
return (ObjectUpcastedUsageInfo[]) result.toArray(new ObjectUpcastedUsageInfo[result.size()]);
|
||||
return result.toArray(new ObjectUpcastedUsageInfo[result.size()]);
|
||||
}
|
||||
|
||||
private ArrayList filterUsages(ArrayList usages) {
|
||||
ArrayList result = new ArrayList();
|
||||
private ArrayList<UsageInfo> filterUsages(ArrayList<Object> usages) {
|
||||
ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
|
||||
for (int i = 0; i < usages.size(); i++) {
|
||||
UsageInfo usageInfo = (UsageInfo) usages.get(i);
|
||||
@@ -287,7 +285,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void processClass(PsiClass inheritor, ArrayList usages) {
|
||||
private void processClass(PsiClass inheritor, ArrayList<Object> usages) {
|
||||
ClassReferenceScanner scanner = new ClassReferenceSearchingScanner(inheritor);
|
||||
final MyClassInstanceReferenceVisitor instanceVisitor = new MyClassInstanceReferenceVisitor(inheritor, usages);
|
||||
scanner.processReferences(
|
||||
@@ -333,7 +331,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
myAbstractDelegatedMethods = new HashSet();
|
||||
myAbstractDelegatedMethods = new HashSet<PsiMethod>();
|
||||
addInnerClass();
|
||||
addField(usages);
|
||||
delegateMethods();
|
||||
@@ -356,8 +354,8 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
innerClass.getModifierList().setModifierProperty(PsiModifier.PRIVATE, true);
|
||||
innerClass = (PsiClass) myClass.add(innerClass);
|
||||
|
||||
List innerClassMethods = getInnerClassMethods();
|
||||
for (Iterator iterator = innerClassMethods.iterator(); iterator.hasNext();) {
|
||||
List<Object> innerClassMethods = getInnerClassMethods();
|
||||
for (Iterator<Object> iterator = innerClassMethods.iterator(); iterator.hasNext();) {
|
||||
InnerClassMethod innerClassMethod = (InnerClassMethod) iterator.next();
|
||||
innerClassMethod.createMethod(innerClass, myClass);
|
||||
}
|
||||
@@ -463,13 +461,13 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
private void delegateMethods() throws IncorrectOperationException {
|
||||
for (Iterator iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod method = (PsiMethod) iterator.next();
|
||||
|
||||
if (!myAbstractDelegatedMethods.contains(method)) {
|
||||
PsiMethod methodToAdd = delegateMethod(myFieldName, method);
|
||||
|
||||
String visibility = (String) myDelegatedMethodsVisibility.get(method);
|
||||
String visibility = myDelegatedMethodsVisibility.get(method);
|
||||
if (visibility != null) {
|
||||
methodToAdd.getModifierList().setModifierProperty(visibility, true);
|
||||
}
|
||||
@@ -554,7 +552,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private void addImplementingInterfaces() throws IncorrectOperationException {
|
||||
final PsiReferenceList implementsList = myClass.getImplementsList();
|
||||
for (Iterator iterator = myDelegatedInterfaces.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = myDelegatedInterfaces.iterator(); iterator.hasNext();) {
|
||||
PsiClass delegatedInterface = (PsiClass) iterator.next();
|
||||
|
||||
if (!myClassImplementedInterfaces.contains(delegatedInterface)) {
|
||||
@@ -720,8 +718,8 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
return true;
|
||||
}
|
||||
|
||||
private List getInnerClassMethods() {
|
||||
ArrayList result = new ArrayList();
|
||||
private List<Object> getInnerClassMethods() {
|
||||
ArrayList<Object> result = new ArrayList<Object>();
|
||||
|
||||
// find all neccessary constructors
|
||||
if (!myBaseClass.isInterface()) {
|
||||
@@ -751,8 +749,8 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
throws IncorrectOperationException {
|
||||
OverridenMethodClassMemberReferencesVisitor visitor = new OverridenMethodClassMemberReferencesVisitor();
|
||||
myMethod.accept(visitor);
|
||||
final List actions = visitor.getPsiActions();
|
||||
for (Iterator iterator = actions.iterator(); iterator.hasNext();) {
|
||||
final List<Object> actions = visitor.getPsiActions();
|
||||
for (Iterator<Object> iterator = actions.iterator(); iterator.hasNext();) {
|
||||
PsiAction action = (PsiAction) iterator.next();
|
||||
action.run();
|
||||
}
|
||||
@@ -762,8 +760,8 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator iterator = myOverridenMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod method = (PsiMethod) iterator.next();
|
||||
for (Iterator<PsiMethod> iterator = myOverridenMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod method = iterator.next();
|
||||
result.add(new InnerClassOverridingMethod(method));
|
||||
}
|
||||
}
|
||||
@@ -837,7 +835,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
*/
|
||||
private String checkOuterClassAbstractMethod(PsiMethod methodSignature) {
|
||||
String visibility = PsiModifier.PROTECTED;
|
||||
for (Iterator iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod method = (PsiMethod) iterator.next();
|
||||
|
||||
if (MethodSignatureUtil.areSignaturesEqual(method, methodSignature)) {
|
||||
@@ -849,8 +847,8 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
private LinkedHashSet getOverriddenMethods() {
|
||||
LinkedHashSet result = new LinkedHashSet();
|
||||
private LinkedHashSet<PsiMethod> getOverriddenMethods() {
|
||||
LinkedHashSet<PsiMethod> result = new LinkedHashSet<PsiMethod>();
|
||||
|
||||
PsiMethod[] methods = myClass.getMethods();
|
||||
|
||||
@@ -875,15 +873,15 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
return "Replacing inheritance with delegation in " + UsageViewUtil.getDescriptiveName(myClass);
|
||||
}
|
||||
|
||||
private Set getAllBaseClassMembers() {
|
||||
HashSet result = new HashSet();
|
||||
private Set<Object> getAllBaseClassMembers() {
|
||||
HashSet<Object> result = new HashSet<Object>();
|
||||
addAll(result, myBaseClass.getAllFields());
|
||||
addAll(result, myBaseClass.getAllInnerClasses());
|
||||
addAll(result, myBaseClass.getAllMethods());
|
||||
|
||||
ArrayList javaLangObjectMembers = new ArrayList();
|
||||
ArrayList<PsiElement> javaLangObjectMembers = new ArrayList<PsiElement>();
|
||||
|
||||
for (Iterator iterator = result.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = result.iterator(); iterator.hasNext();) {
|
||||
PsiElement element = (PsiElement) iterator.next();
|
||||
String qName = null;
|
||||
if (element instanceof PsiField) {
|
||||
@@ -899,14 +897,14 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
return Collections.unmodifiableSet(result);
|
||||
}
|
||||
|
||||
private Set getAllBases() {
|
||||
HashSet temp = new HashSet();
|
||||
private Set<PsiClass> getAllBases() {
|
||||
HashSet<PsiClass> temp = new HashSet<PsiClass>();
|
||||
RefactoringHierarchyUtil.getSuperClasses(myBaseClass, temp, true);
|
||||
temp.add(myBaseClass);
|
||||
return Collections.unmodifiableSet(temp);
|
||||
}
|
||||
|
||||
private static void addAll(Collection collection, Object[] objs) {
|
||||
private static void addAll(Collection<Object> collection, Object[] objs) {
|
||||
for (int i = 0; i < objs.length; i++) {
|
||||
collection.add(objs[i]);
|
||||
}
|
||||
@@ -915,7 +913,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
private boolean isDelegated(PsiElement classMember) {
|
||||
if(!(classMember instanceof PsiMethod)) return false;
|
||||
final PsiMethod method = (PsiMethod) classMember;
|
||||
for (Iterator iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<Object> iterator = myDelegatedMethods.iterator(); iterator.hasNext();) {
|
||||
PsiMethod delegatedMethod = (PsiMethod) iterator.next();
|
||||
if (MethodSignatureUtil.areSignaturesEqual(method, delegatedMethod)) return true;
|
||||
}
|
||||
@@ -923,10 +921,10 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
private class MyClassInheritorMemberReferencesVisitor extends ClassMemberReferencesVisitor {
|
||||
private final List myUsageInfoStorage;
|
||||
private final List<Object> myUsageInfoStorage;
|
||||
private ClassInstanceScanner.ClassInstanceReferenceVisitor myInstanceVisitor;
|
||||
|
||||
MyClassInheritorMemberReferencesVisitor(PsiClass aClass, List usageInfoStorage,
|
||||
MyClassInheritorMemberReferencesVisitor(PsiClass aClass, List<Object> usageInfoStorage,
|
||||
ClassInstanceScanner.ClassInstanceReferenceVisitor instanceScanner) {
|
||||
super(aClass);
|
||||
|
||||
@@ -977,7 +975,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
private class MyClassMemberReferencesVisitor extends MyClassInheritorMemberReferencesVisitor {
|
||||
MyClassMemberReferencesVisitor(List usageInfoStorage,
|
||||
MyClassMemberReferencesVisitor(List<Object> usageInfoStorage,
|
||||
ClassInstanceScanner.ClassInstanceReferenceVisitor instanceScanner) {
|
||||
super(InheritanceToDelegationProcessor.this.myClass, usageInfoStorage, instanceScanner);
|
||||
}
|
||||
@@ -997,19 +995,19 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
* This visitor should be called for overriden methods before they are moved to an inner class
|
||||
*/
|
||||
private class OverridenMethodClassMemberReferencesVisitor extends ClassMemberReferencesVisitor {
|
||||
private final ArrayList myPsiActions;
|
||||
private final ArrayList<Object> myPsiActions;
|
||||
private final PsiThisExpression myQualifiedThis;
|
||||
private final PsiJavaCodeReferenceElement myClassReferenceElement;
|
||||
|
||||
OverridenMethodClassMemberReferencesVisitor() throws IncorrectOperationException {
|
||||
super(myClass);
|
||||
myPsiActions = new ArrayList();
|
||||
myPsiActions = new ArrayList<Object>();
|
||||
myClassReferenceElement = myFactory.createClassReferenceElement(myClass);
|
||||
myQualifiedThis = (PsiThisExpression) myFactory.createExpressionFromText("A.this", null);
|
||||
myQualifiedThis.getQualifier().replace(myClassReferenceElement);
|
||||
}
|
||||
|
||||
public List getPsiActions() {
|
||||
public List<Object> getPsiActions() {
|
||||
return myPsiActions;
|
||||
}
|
||||
|
||||
@@ -1108,18 +1106,18 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private final class MyClassInstanceReferenceVisitor implements ClassInstanceScanner.ClassInstanceReferenceVisitor {
|
||||
private final PsiClass myClass;
|
||||
private final List myUsageInfoStorage;
|
||||
private final Set myImplementedInterfaces;
|
||||
private final List<Object> myUsageInfoStorage;
|
||||
private final Set<PsiClass> myImplementedInterfaces;
|
||||
|
||||
public MyClassInstanceReferenceVisitor(PsiClass aClass, List usageInfoStorage) {
|
||||
public MyClassInstanceReferenceVisitor(PsiClass aClass, List<Object> usageInfoStorage) {
|
||||
myClass = aClass;
|
||||
myUsageInfoStorage = usageInfoStorage;
|
||||
myImplementedInterfaces = getImplementedInterfaces();
|
||||
}
|
||||
|
||||
public Set getImplementedInterfaces() {
|
||||
public Set<PsiClass> getImplementedInterfaces() {
|
||||
PsiClass aClass = myClass;
|
||||
HashSet result = new HashSet();
|
||||
HashSet<PsiClass> result = new HashSet<PsiClass>();
|
||||
while (aClass != null && !myManager.areElementsEquivalent(aClass, myBaseClass)) {
|
||||
final PsiReferenceList referenceList = aClass.getImplementsList();
|
||||
if (referenceList != null) {
|
||||
@@ -1128,7 +1126,7 @@ public class InheritanceToDelegationProcessor extends BaseRefactoringProcessor {
|
||||
PsiClassType superType = implementsList[i];
|
||||
PsiElement resolved = superType.resolve();
|
||||
if (resolved instanceof PsiClass && !myManager.areElementsEquivalent(resolved, myBaseClass)) {
|
||||
result.add(resolved);
|
||||
result.add((PsiClass)resolved);
|
||||
RefactoringHierarchyUtil.getSuperClasses((PsiClass) resolved, result, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,15 +207,6 @@ class InlineConstantFieldProcessor extends BaseRefactoringProcessor implements I
|
||||
return PsiUtil.isAccessedForWriting(expr);
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myDialog.isPreviewUsages();
|
||||
if (UsageViewUtil.hasReadOnlyUsages(usages)) {
|
||||
toPreview = true;
|
||||
WindowManager.getInstance().getStatusBar(myProject).setInfo("Occurrences found in read-only files");
|
||||
}
|
||||
return toPreview;
|
||||
}
|
||||
|
||||
public void run(InlineFieldDialog dialog) {
|
||||
myDialog = dialog;
|
||||
this.run((Object)null);
|
||||
|
||||
@@ -178,16 +178,6 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor implements I
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
//if (myDialog.isInlineThisOnly()) return false;
|
||||
boolean toPreview = myDialog.isPreviewUsages();
|
||||
if (UsageViewUtil.hasReadOnlyUsages(usages)) {
|
||||
toPreview = true;
|
||||
WindowManager.getInstance().getStatusBar(myProject).setInfo("Occurrences found in read-only files");
|
||||
}
|
||||
return toPreview;
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
int col = -1;
|
||||
int line = -1;
|
||||
|
||||
@@ -225,7 +225,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
myProject, myMethod, myMethodToSearchFor,
|
||||
myParameterInitializer, myExpressionToSearchFor,
|
||||
myLocalVar, isDeleteLocalVariable,
|
||||
parameterName, previewUsages, replaceAllOccurences,
|
||||
parameterName, replaceAllOccurences,
|
||||
IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, null, null).run(null);
|
||||
return true;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
myProject, myMethod, myMethodToSearchFor,
|
||||
myParameterInitializer, myExpressionToSearchFor,
|
||||
myLocalVar, isDeleteLocalVariable,
|
||||
dialog.getParameterName(), dialog.isPreviewUsages(), dialog.isReplaceAllOccurences(),
|
||||
dialog.getParameterName(), dialog.isReplaceAllOccurences(),
|
||||
dialog.getReplaceFieldsWithGetters(), dialog.isDeclareFinal(),
|
||||
dialog.getSelectedType(), new Runnable() {
|
||||
public void run() {
|
||||
|
||||
+13
-12
@@ -55,7 +55,6 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor {
|
||||
private final PsiLocalVariable myLocalVariable;
|
||||
private final boolean myRemoveLocalVariable;
|
||||
private String myParameterName;
|
||||
private boolean myPreviewUsages;
|
||||
private boolean myReplaceAllOccurences;
|
||||
|
||||
private int myReplaceFieldsWithGetters;
|
||||
@@ -66,12 +65,19 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor {
|
||||
/**
|
||||
* if expressionToSearch is null, search for localVariable
|
||||
*/
|
||||
public IntroduceParameterProcessor(Project project, PsiMethod methodToReplaceIn, PsiMethod methodToSearchFor,
|
||||
PsiExpression parameterInitializer,
|
||||
PsiExpression expressionToSearch,
|
||||
PsiLocalVariable localVariable,
|
||||
boolean removeLocalVariable, String parameterName, boolean previewUsages, boolean replaceAllOccurences,
|
||||
int replaceFieldsWithGetters, boolean declareFinal, PsiType forcedType, Runnable prepareSuccessfulCallback) {
|
||||
public IntroduceParameterProcessor(Project project,
|
||||
PsiMethod methodToReplaceIn,
|
||||
PsiMethod methodToSearchFor,
|
||||
PsiExpression parameterInitializer,
|
||||
PsiExpression expressionToSearch,
|
||||
PsiLocalVariable localVariable,
|
||||
boolean removeLocalVariable,
|
||||
String parameterName,
|
||||
boolean replaceAllOccurences,
|
||||
int replaceFieldsWithGetters,
|
||||
boolean declareFinal,
|
||||
PsiType forcedType,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
|
||||
myMethodToReplaceIn = methodToReplaceIn;
|
||||
@@ -82,7 +88,6 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor {
|
||||
myLocalVariable = localVariable;
|
||||
myRemoveLocalVariable = removeLocalVariable;
|
||||
myParameterName = parameterName;
|
||||
myPreviewUsages = previewUsages;
|
||||
myReplaceAllOccurences = replaceAllOccurences;
|
||||
myReplaceFieldsWithGetters = replaceFieldsWithGetters;
|
||||
myDeclareFinal = declareFinal;
|
||||
@@ -312,10 +317,6 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor {
|
||||
protected void refreshElements(PsiElement[] elements) {
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return myPreviewUsages || super.isPreviewUsages(usages);
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
try {
|
||||
PsiElementFactory factory = myMethodToReplaceIn.getManager().getElementFactory();
|
||||
|
||||
@@ -37,17 +37,16 @@ public class MakeMethodStaticProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private PsiMethod myMethod;
|
||||
private PsiClass myMethodClass;
|
||||
private boolean myPreviewUsages;
|
||||
private Settings mySettings;
|
||||
|
||||
public MakeMethodStaticProcessor(Project project,
|
||||
PsiMethod method,
|
||||
boolean previewUsages, Settings settings, Runnable prepareSuccessfulCallback) {
|
||||
PsiMethod method,
|
||||
Settings settings,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
myMethod = method;
|
||||
mySettings = settings;
|
||||
myMethodClass = method.getContainingClass();
|
||||
myPreviewUsages = previewUsages;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,10 +229,6 @@ public class MakeMethodStaticProcessor extends BaseRefactoringProcessor {
|
||||
protected void refreshElements(PsiElement[] elements) {
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages) || myPreviewUsages;
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
PsiManager manager = myMethod.getManager();
|
||||
PsiElementFactory factory = manager.getElementFactory();
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PushDownHandler implements RefactoringActionHandler, PushDownDialog
|
||||
public void run(final PushDownDialog dialog) {
|
||||
new PushDownProcessor(
|
||||
myProject, dialog.getSelectedMemberInfos(), myClass,
|
||||
new JavaDocPolicy(dialog.getJavaDocPolicy()), dialog.isPreviewUsages(), new Runnable() {
|
||||
new JavaDocPolicy(dialog.getJavaDocPolicy()), new Runnable() {
|
||||
public void run() {
|
||||
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ public class PushDownProcessor extends BaseRefactoringProcessor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.memberPushDown.PushDownProcessor");
|
||||
private MemberInfo myMemberInfos[];
|
||||
private PsiClass myClass;
|
||||
private boolean myIsPreviewUsages;
|
||||
private JavaDocPolicy myJavaDocPolicy;
|
||||
|
||||
public PushDownProcessor(Project project, MemberInfo[] memberInfos, PsiClass aClass, JavaDocPolicy javaDocPolicy, boolean previewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
public PushDownProcessor(Project project,
|
||||
MemberInfo[] memberInfos,
|
||||
PsiClass aClass,
|
||||
JavaDocPolicy javaDocPolicy,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
myMemberInfos = memberInfos;
|
||||
myClass = aClass;
|
||||
myIsPreviewUsages = previewUsages;
|
||||
myJavaDocPolicy = javaDocPolicy;
|
||||
}
|
||||
|
||||
@@ -90,10 +91,6 @@ public class PushDownProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages) || myIsPreviewUsages;
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
try {
|
||||
for (int i = 0; i < usages.length; i++) {
|
||||
|
||||
@@ -110,10 +110,7 @@ class MigrationProcessor extends BaseRefactoringProcessor {
|
||||
Messages.showInfoMessage(myProject, "No Usages Found in the Project", "Migration");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
setPreviewUsages(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,15 +117,6 @@ public class MoveInnerProcessor extends BaseRefactoringProcessor {
|
||||
myInnerClass = (PsiClass)elements[0];
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myPreviewUsages;
|
||||
if (UsageViewUtil.hasReadOnlyUsages(usages)) {
|
||||
toPreview = true;
|
||||
WindowManager.getInstance().getStatusBar(myProject).setInfo("Occurrences found in read-only files");
|
||||
}
|
||||
return toPreview;
|
||||
}
|
||||
|
||||
public boolean isSearchInComments() {
|
||||
return mySearchInComments;
|
||||
}
|
||||
|
||||
@@ -152,15 +152,6 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor implements Mo
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myDialog.isPreviewUsages();
|
||||
if (UsageViewUtil.hasReadOnlyUsages(usages)){
|
||||
toPreview = true;
|
||||
WindowManager.getInstance().getStatusBar(myProject).setInfo("Occurrences found in read-only files");
|
||||
}
|
||||
return toPreview;
|
||||
}
|
||||
|
||||
protected void performRefactoring(final UsageInfo[] usages) {
|
||||
try {
|
||||
// correct references to moved members from the outside
|
||||
|
||||
@@ -28,7 +28,7 @@ public class IntroduceParameterRefactoringImpl extends RefactoringImpl<Introduce
|
||||
boolean removeLocalVariable, boolean declareFinal, final boolean replaceAllOccurences) {
|
||||
super(
|
||||
new IntroduceParameterProcessor(project, methodToReplaceIn, methodToSearchFor,
|
||||
parameterInitializer, expressionToSearch, localVariable, removeLocalVariable, parameterName, true, replaceAllOccurences,
|
||||
parameterInitializer, expressionToSearch, localVariable, removeLocalVariable, parameterName, replaceAllOccurences,
|
||||
REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, declareFinal, null,
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class MakeMethodStaticRefactoringImpl extends RefactoringImpl<MakeMethodS
|
||||
String classParameterName,
|
||||
PsiField[] fields,
|
||||
String[] names) {
|
||||
super(new MakeMethodStaticProcessor(project, method, true,
|
||||
super(new MakeMethodStaticProcessor(project, method,
|
||||
new Settings(replaceUsages, classParameterName, fields, names),
|
||||
BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@ import com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructor
|
||||
*/
|
||||
public class ReplaceConstructorWithFactoryRefactoringImpl extends RefactoringImpl<ReplaceConstructorWithFactoryProcessor> implements ReplaceConstructorWithFactoryRefactoring {
|
||||
ReplaceConstructorWithFactoryRefactoringImpl(Project project, PsiMethod method, PsiClass targetClass, String factoryName) {
|
||||
super(new ReplaceConstructorWithFactoryProcessor(project, method, targetClass, factoryName, true, BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
super(new ReplaceConstructorWithFactoryProcessor(project, method, targetClass, factoryName, BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
}
|
||||
|
||||
ReplaceConstructorWithFactoryRefactoringImpl(Project project, PsiClass originalClass, PsiClass targetClass, String factoryName) {
|
||||
super(new ReplaceConstructorWithFactoryProcessor(project, originalClass, targetClass, factoryName, true, BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
super(new ReplaceConstructorWithFactoryProcessor(project, originalClass, targetClass, factoryName, BaseRefactoringProcessor.EMPTY_CALLBACK));
|
||||
}
|
||||
|
||||
public PsiClass getOriginalClass() {
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor;
|
||||
*/
|
||||
public class TurnRefsToSuperRefactoringImpl extends RefactoringImpl<TurnRefsToSuperProcessor> implements TurnRefsToSuperRefactoring {
|
||||
TurnRefsToSuperRefactoringImpl(Project project, PsiClass aClass, PsiClass aSuper, boolean replaceInstanceOf) {
|
||||
super(new TurnRefsToSuperProcessor(project, aClass, aSuper, replaceInstanceOf, true));
|
||||
super(new TurnRefsToSuperProcessor(project, aClass, aSuper, replaceInstanceOf));
|
||||
}
|
||||
|
||||
public PsiClass getSuper() {
|
||||
|
||||
+2
-2
@@ -152,7 +152,7 @@ public class ReplaceConstructorWithFactoryHandler
|
||||
}
|
||||
|
||||
new ReplaceConstructorWithFactoryProcessor(myProject, myMethod,
|
||||
targetClass, dialog.getName(), dialog.isPreviewUsages(), new Runnable() {
|
||||
targetClass, dialog.getName(), new Runnable() {
|
||||
public void run() {
|
||||
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class ReplaceConstructorWithFactoryHandler
|
||||
return;
|
||||
}
|
||||
new ReplaceConstructorWithFactoryProcessor(myProject, myClass,
|
||||
targetClass, dialog.getName(), dialog.isPreviewUsages(), new Runnable() {
|
||||
targetClass, dialog.getName(), new Runnable() {
|
||||
public void run() {
|
||||
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
|
||||
}
|
||||
|
||||
+10
-13
@@ -32,21 +32,21 @@ public class ReplaceConstructorWithFactoryProcessor extends BaseRefactoringProce
|
||||
"#com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructorWithFactoryProcessor");
|
||||
private final PsiMethod myConstructor;
|
||||
private final String myFactoryName;
|
||||
private final boolean myPreviewUsages;
|
||||
private final PsiElementFactory myFactory;
|
||||
private final PsiClass myOriginalClass;
|
||||
private final PsiClass myTargetClass;
|
||||
private PsiManager myManager;
|
||||
private boolean myIsInner;
|
||||
|
||||
public ReplaceConstructorWithFactoryProcessor(Project project, PsiMethod constructor,
|
||||
PsiClass targetClass, String factoryName, boolean previewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
public ReplaceConstructorWithFactoryProcessor(Project project,
|
||||
PsiMethod constructor,
|
||||
PsiClass targetClass,
|
||||
String factoryName,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
myOriginalClass = null;
|
||||
myConstructor = constructor;
|
||||
myFactoryName = factoryName;
|
||||
myPreviewUsages = previewUsages;
|
||||
myTargetClass = targetClass;
|
||||
LOG.assertTrue(myConstructor.isConstructor());
|
||||
myManager = PsiManager.getInstance(project);
|
||||
@@ -55,15 +55,16 @@ public class ReplaceConstructorWithFactoryProcessor extends BaseRefactoringProce
|
||||
myIsInner = isInner(myConstructor.getContainingClass());
|
||||
}
|
||||
|
||||
public ReplaceConstructorWithFactoryProcessor(Project project, PsiClass aClass, PsiClass targetClass,
|
||||
String factoryName, boolean previewUsages,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
public ReplaceConstructorWithFactoryProcessor(Project project,
|
||||
PsiClass aClass,
|
||||
PsiClass targetClass,
|
||||
String factoryName,
|
||||
Runnable prepareSuccessfulCallback) {
|
||||
super(project, prepareSuccessfulCallback);
|
||||
myOriginalClass = aClass;
|
||||
myConstructor = null;
|
||||
myTargetClass = targetClass;
|
||||
myFactoryName = factoryName;
|
||||
myPreviewUsages = previewUsages;
|
||||
myManager = PsiManager.getInstance(project);
|
||||
myFactory = myManager.getElementFactory();
|
||||
|
||||
@@ -199,10 +200,6 @@ public class ReplaceConstructorWithFactoryProcessor extends BaseRefactoringProce
|
||||
protected void refreshElements(PsiElement[] elements) {
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
return super.isPreviewUsages(usages) || myPreviewUsages;
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -71,9 +71,7 @@ public class TurnRefsToSuperHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
new TurnRefsToSuperProcessor(
|
||||
myProject, subClass, dialog.getSuperClass(), dialog.isUseInInstanceOf(),
|
||||
dialog.isPreviewUsages()
|
||||
).run(null);
|
||||
myProject, subClass, dialog.getSuperClass(), dialog.isUseInInstanceOf()).run(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,18 +19,13 @@ public class TurnRefsToSuperProcessor extends TurnRefsToSuperProcessorBase {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor");
|
||||
|
||||
private PsiClass mySuper;
|
||||
private final boolean myPreviewUsages;
|
||||
|
||||
public TurnRefsToSuperProcessor(Project project,
|
||||
PsiClass aClass,
|
||||
PsiClass aSuper,
|
||||
boolean replaceInstanceOf,
|
||||
boolean previewUsages
|
||||
) {
|
||||
PsiClass aClass,
|
||||
PsiClass aSuper,
|
||||
boolean replaceInstanceOf) {
|
||||
super(project, replaceInstanceOf);
|
||||
myClass = aClass;
|
||||
mySuper = aSuper;
|
||||
myPreviewUsages = previewUsages;
|
||||
}
|
||||
|
||||
protected String getCommandName() {
|
||||
@@ -62,11 +57,6 @@ public class TurnRefsToSuperProcessor extends TurnRefsToSuperProcessorBase {
|
||||
mySuper = (PsiClass) elements[1];
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myPreviewUsages;
|
||||
return super.isPreviewUsages(usages) || toPreview;
|
||||
}
|
||||
|
||||
protected boolean preprocessUsages(UsageInfo[][] usages) {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && usages[0].length == 0) {
|
||||
String message = "No usages of " + myClass.getQualifiedName() + "\n" +
|
||||
|
||||
@@ -5,14 +5,12 @@ import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.usageView.FindUsagesCommand;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -56,17 +54,6 @@ public class TypeCookProcessor extends BaseRefactoringProcessor implements TypeC
|
||||
myElements = elements;
|
||||
}
|
||||
|
||||
protected boolean isPreviewUsages(UsageInfo[] usages) {
|
||||
boolean toPreview = myDialog.isPreviewUsages();
|
||||
|
||||
if (UsageViewUtil.hasReadOnlyUsages(usages)) {
|
||||
toPreview = true;
|
||||
WindowManager.getInstance().getStatusBar(myProject).setInfo("Occurrences found in read-only files");
|
||||
}
|
||||
|
||||
return toPreview;
|
||||
}
|
||||
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
HashSet<PsiElement> victims = new HashSet<PsiElement>();
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ public class ChangeSignatureTest extends CodeInsightTestCase {
|
||||
PsiType newType = newReturnType != null ? factory.createTypeFromText(newReturnType, method) : method.getReturnType();
|
||||
new ChangeSignatureProcessor(getProject(), method, generateDelegate, newVisibility,
|
||||
newName != null ? newName : method.getName(),
|
||||
newType, genParams.genParams(method), genExceptions.genExceptions(method), false, null).testRun();
|
||||
newType, genParams.genParams(method), genExceptions.genExceptions(method), null).testRun();
|
||||
checkResultByFile(filePath + ".after");
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public class IntroduceParameterTest extends CodeInsightTestCase {
|
||||
methodToSearchFor = method;
|
||||
}
|
||||
new IntroduceParameterProcessor(
|
||||
myProject, method, methodToSearchFor, expr, expr, null, true, parameterName, false, replaceAllOccurences,
|
||||
myProject, method, methodToSearchFor, expr, expr, null, true, parameterName, replaceAllOccurences,
|
||||
replaceFieldsWithGetters,
|
||||
declareFinal, null, null).testRun();
|
||||
|
||||
@@ -247,7 +247,7 @@ public class IntroduceParameterTest extends CodeInsightTestCase {
|
||||
new IntroduceParameterProcessor(
|
||||
myProject, method, methodToSearchFor,
|
||||
parameterInitializer, null, localVariable, removeLocalVariable,
|
||||
localVariable.getName(), false, replaceAllOccurences,
|
||||
localVariable.getName(), replaceAllOccurences,
|
||||
IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
|
||||
declareFinal, null, null
|
||||
).testRun();
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MakeMethodStaticTest extends CodeInsightTestCase {
|
||||
new MakeMethodStaticProcessor(
|
||||
myProject,
|
||||
method,
|
||||
false, new Settings(true, addClassParameter ? "anObject" : null, null), null).testRun();
|
||||
new Settings(true, addClassParameter ? "anObject" : null, null), null).testRun();
|
||||
}
|
||||
|
||||
private void performWithFields() {
|
||||
@@ -166,7 +166,7 @@ public class MakeMethodStaticTest extends CodeInsightTestCase {
|
||||
new MakeMethodStaticProcessor(
|
||||
myProject,
|
||||
method,
|
||||
false, new Settings(true, addClassParameter ? "anObject" : null,
|
||||
new Settings(true, addClassParameter ? "anObject" : null,
|
||||
(ParameterTablePanel.VariableData[])parametersForFields.toArray(
|
||||
new ParameterTablePanel.VariableData[parametersForFields.size()])),
|
||||
null).testRun();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ReplaceConstructorWithFactoryTest extends CodeInsightTestCase {
|
||||
targetClass = constructor.getContainingClass();
|
||||
}
|
||||
replaceConstructorWithFactoryProcessor = new ReplaceConstructorWithFactoryProcessor(
|
||||
myProject, constructor, targetClass, "new" + constructor.getName(), false, null
|
||||
myProject, constructor, targetClass, "new" + constructor.getName(), null
|
||||
);
|
||||
}
|
||||
else {
|
||||
@@ -74,7 +74,7 @@ public class ReplaceConstructorWithFactoryTest extends CodeInsightTestCase {
|
||||
targetClass = aClass;
|
||||
}
|
||||
replaceConstructorWithFactoryProcessor = new ReplaceConstructorWithFactoryProcessor(
|
||||
myProject, aClass, targetClass, "new" + aClass.getName(), false, null
|
||||
myProject, aClass, targetClass, "new" + aClass.getName(), null
|
||||
);
|
||||
}
|
||||
replaceConstructorWithFactoryProcessor.testRun();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TurnRefsToSuperTest extends MultiFileTestCase {
|
||||
PsiClass superClass = myPsiManager.findClass(superClassName);
|
||||
assertNotNull("Class " + superClassName + " not found", superClass);
|
||||
|
||||
new TurnRefsToSuperProcessor(myProject, aClass, superClass, replaceInstanceOf, false).testRun();
|
||||
new TurnRefsToSuperProcessor(myProject, aClass, superClass, replaceInstanceOf).testRun();
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user