diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java index e44d3f9c3f82..5f4aa5f6865c 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java @@ -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); diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodParameterFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodParameterFix.java index 27ab1ac545b3..ddeca90b1522 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodParameterFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodParameterFix.java @@ -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(); diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnFix.java index 8cf522ccfc37..450ac05bf9ef 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/MethodReturnFix.java @@ -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(); } diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedParameterFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedParameterFix.java index 044eb5de1eaf..354519edde5b 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedParameterFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedParameterFix.java @@ -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(); diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java index 3560f19c2fa3..2dad7844fe37 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/SuperMethodReturnFix.java @@ -63,7 +63,6 @@ public class SuperMethodReturnFix implements IntentionAction { mySuperMethod.getName(), mySuperMethodType, ParameterInfo.fromMethod(mySuperMethod), - false, null); if (ApplicationManager.getApplication().isUnitTestMode()) { processor.testRun(); diff --git a/source/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java b/source/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java index a9c2fbfa152c..dc7c5b2ca0d9 100644 --- a/source/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java +++ b/source/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java @@ -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); } diff --git a/source/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java b/source/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java index 5a6402915078..827cd7e25916 100644 --- a/source/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java +++ b/source/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java @@ -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); } diff --git a/source/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java b/source/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java index cebeff48affc..d7508ef24941 100644 --- a/source/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java +++ b/source/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java @@ -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); } diff --git a/source/com/intellij/refactoring/changeSignature/ChangeSignatureHandler.java b/source/com/intellij/refactoring/changeSignature/ChangeSignatureHandler.java index 4ee2c32a04db..4cef91bc37b8 100644 --- a/source/com/intellij/refactoring/changeSignature/ChangeSignatureHandler.java +++ b/source/com/intellij/refactoring/changeSignature/ChangeSignatureHandler.java @@ -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); diff --git a/source/com/intellij/refactoring/changeSignature/ChangeSignatureProcessor.java b/source/com/intellij/refactoring/changeSignature/ChangeSignatureProcessor.java index 435b0e1c1a39..3fa1d7b5f287 100644 --- a/source/com/intellij/refactoring/changeSignature/ChangeSignatureProcessor.java +++ b/source/com/intellij/refactoring/changeSignature/ChangeSignatureProcessor.java @@ -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 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 conflictDescriptions = new HashSet(); conflictDescriptions.addAll(Arrays.asList(RenameUtil.getConflictDescriptions(usages[0]))); diff --git a/source/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java b/source/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java index 2fcdf6e167b0..71db6e6402fe 100644 --- a/source/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java +++ b/source/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java @@ -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); } diff --git a/source/com/intellij/refactoring/extractInterface/ExtractClassUtil.java b/source/com/intellij/refactoring/extractInterface/ExtractClassUtil.java index b87dbc880328..3aec8ddea404 100644 --- a/source/com/intellij/refactoring/extractInterface/ExtractClassUtil.java +++ b/source/com/intellij/refactoring/extractInterface/ExtractClassUtil.java @@ -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); } } diff --git a/source/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java b/source/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java index 9c14c16d063c..ef5e480ef731 100644 --- a/source/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java +++ b/source/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationProcessor.java @@ -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 myDelegatedInterfaces; + private final LinkedHashSet myDelegatedMethods; + private final HashMap myDelegatedMethodsVisibility; + private final LinkedHashSet myOverridenMethods; private boolean myPreviewUsages; private final PsiClass myBaseClass; - private final Set myBaseClassMembers; + private final Set myBaseClassMembers; private final String myFieldName; private final String myGetterName; private final boolean myGenerateGetter; - private Set myBaseClassBases; - private Set myClassImplementedInterfaces; + private Set myBaseClassBases; + private Set myClassImplementedInterfaces; private PsiElementFactory myFactory; private final PsiType myBaseClassType; private final PsiManager myManager; private final boolean myIsInnerClassNeeded; - private Set myClassInheritors; - private HashSet myAbstractDelegatedMethods; + private Set myClassInheritors; + private HashSet 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(); addAll(myDelegatedInterfaces, delegatedInterfaces); - myDelegatedMethods = new LinkedHashSet(); + myDelegatedMethods = new LinkedHashSet(); addAll(myDelegatedMethods, delegatedMethods); - myDelegatedMethodsVisibility = new com.intellij.util.containers.HashMap(); - for (Iterator iterator = myDelegatedMethods.iterator(); iterator.hasNext();) { + myDelegatedMethodsVisibility = new com.intellij.util.containers.HashMap(); + for (Iterator 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 usages = new ArrayList(); PsiSearchHelper searchHelper = myManager.getSearchHelper(); GlobalSearchScope projectScope = GlobalSearchScope.projectScope(myProject); final PsiClass[] inheritors = searchHelper.findInheritors(myClass, projectScope, true); - myClassInheritors = new HashSet(); + myClassInheritors = new HashSet(); 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 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 oldUsages = new ArrayList(); addAll(oldUsages, usages[0]); final ObjectUpcastedUsageInfo[] objectUpcastedUsageInfos = objectUpcastedUsages(usages[0]); if (myPrepareSuccessfulSwingThreadCallback != null) { - ArrayList conflicts = new ArrayList(); + ArrayList conflicts = new ArrayList(); 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 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 conflicts) { + HashMap> reportedNonDelegatedUsages = new HashMap>(); + HashMap> reportedUpcasts = new HashMap>(); // 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 reportedContainers = reportedNonDelegatedUsages.get(nonDelegatedMember); if (reportedContainers == null) { - reportedContainers = new HashSet(); + reportedContainers = new HashSet(); 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 reportedContainers = reportedUpcasts.get(upcastedTo); if (reportedContainers == null) { - reportedContainers = new HashSet(); + reportedContainers = new HashSet(); 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 result = new ArrayList(); 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 filterUsages(ArrayList usages) { + ArrayList result = new ArrayList(); 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 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(); 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 innerClassMethods = getInnerClassMethods(); + for (Iterator 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 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 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 getInnerClassMethods() { + ArrayList result = new ArrayList(); // 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 actions = visitor.getPsiActions(); + for (Iterator 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 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 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 getOverriddenMethods() { + LinkedHashSet result = new LinkedHashSet(); 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 getAllBaseClassMembers() { + HashSet result = new HashSet(); addAll(result, myBaseClass.getAllFields()); addAll(result, myBaseClass.getAllInnerClasses()); addAll(result, myBaseClass.getAllMethods()); - ArrayList javaLangObjectMembers = new ArrayList(); + ArrayList javaLangObjectMembers = new ArrayList(); - for (Iterator iterator = result.iterator(); iterator.hasNext();) { + for (Iterator 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 getAllBases() { + HashSet temp = new HashSet(); 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 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 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 myUsageInfoStorage; private ClassInstanceScanner.ClassInstanceReferenceVisitor myInstanceVisitor; - MyClassInheritorMemberReferencesVisitor(PsiClass aClass, List usageInfoStorage, + MyClassInheritorMemberReferencesVisitor(PsiClass aClass, List 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 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 myPsiActions; private final PsiThisExpression myQualifiedThis; private final PsiJavaCodeReferenceElement myClassReferenceElement; OverridenMethodClassMemberReferencesVisitor() throws IncorrectOperationException { super(myClass); - myPsiActions = new ArrayList(); + myPsiActions = new ArrayList(); myClassReferenceElement = myFactory.createClassReferenceElement(myClass); myQualifiedThis = (PsiThisExpression) myFactory.createExpressionFromText("A.this", null); myQualifiedThis.getQualifier().replace(myClassReferenceElement); } - public List getPsiActions() { + public List 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 myUsageInfoStorage; + private final Set myImplementedInterfaces; - public MyClassInstanceReferenceVisitor(PsiClass aClass, List usageInfoStorage) { + public MyClassInstanceReferenceVisitor(PsiClass aClass, List usageInfoStorage) { myClass = aClass; myUsageInfoStorage = usageInfoStorage; myImplementedInterfaces = getImplementedInterfaces(); } - public Set getImplementedInterfaces() { + public Set getImplementedInterfaces() { PsiClass aClass = myClass; - HashSet result = new HashSet(); + HashSet result = new HashSet(); 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); } } diff --git a/source/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java b/source/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java index 7dac63ba4390..f861f2819139 100644 --- a/source/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java +++ b/source/com/intellij/refactoring/inline/InlineConstantFieldProcessor.java @@ -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); diff --git a/source/com/intellij/refactoring/inline/InlineMethodProcessor.java b/source/com/intellij/refactoring/inline/InlineMethodProcessor.java index 3681acda4bc1..6e125ec0f7eb 100644 --- a/source/com/intellij/refactoring/inline/InlineMethodProcessor.java +++ b/source/com/intellij/refactoring/inline/InlineMethodProcessor.java @@ -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; diff --git a/source/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java b/source/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java index f5c896aa97e9..e72e10c5dd4b 100644 --- a/source/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java +++ b/source/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java @@ -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() { diff --git a/source/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java b/source/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java index 19e8a1462fd5..cbd8983cc570 100644 --- a/source/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java +++ b/source/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java @@ -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(); diff --git a/source/com/intellij/refactoring/makeMethodStatic/MakeMethodStaticProcessor.java b/source/com/intellij/refactoring/makeMethodStatic/MakeMethodStaticProcessor.java index 96c8d1476ff6..945cd35b0120 100644 --- a/source/com/intellij/refactoring/makeMethodStatic/MakeMethodStaticProcessor.java +++ b/source/com/intellij/refactoring/makeMethodStatic/MakeMethodStaticProcessor.java @@ -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(); diff --git a/source/com/intellij/refactoring/memberPushDown/PushDownHandler.java b/source/com/intellij/refactoring/memberPushDown/PushDownHandler.java index 63253045f30f..7ef9ab3d6490 100644 --- a/source/com/intellij/refactoring/memberPushDown/PushDownHandler.java +++ b/source/com/intellij/refactoring/memberPushDown/PushDownHandler.java @@ -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); } diff --git a/source/com/intellij/refactoring/memberPushDown/PushDownProcessor.java b/source/com/intellij/refactoring/memberPushDown/PushDownProcessor.java index 9da14e88583e..9e490e9f3dd3 100644 --- a/source/com/intellij/refactoring/memberPushDown/PushDownProcessor.java +++ b/source/com/intellij/refactoring/memberPushDown/PushDownProcessor.java @@ -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++) { diff --git a/source/com/intellij/refactoring/migration/MigrationProcessor.java b/source/com/intellij/refactoring/migration/MigrationProcessor.java index a27398a53717..0e12c02f94ea 100644 --- a/source/com/intellij/refactoring/migration/MigrationProcessor.java +++ b/source/com/intellij/refactoring/migration/MigrationProcessor.java @@ -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; } diff --git a/source/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java b/source/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java index 77e20ca2df31..2763687d48eb 100644 --- a/source/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java +++ b/source/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java @@ -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; } diff --git a/source/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/source/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java index 52479ae7427b..2590161b2345 100644 --- a/source/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java +++ b/source/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java @@ -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 diff --git a/source/com/intellij/refactoring/openapi/impl/IntroduceParameterRefactoringImpl.java b/source/com/intellij/refactoring/openapi/impl/IntroduceParameterRefactoringImpl.java index 819a2a23eb0e..78cf6fc46e69 100644 --- a/source/com/intellij/refactoring/openapi/impl/IntroduceParameterRefactoringImpl.java +++ b/source/com/intellij/refactoring/openapi/impl/IntroduceParameterRefactoringImpl.java @@ -28,7 +28,7 @@ public class IntroduceParameterRefactoringImpl extends RefactoringImpl 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() { diff --git a/source/com/intellij/refactoring/openapi/impl/TurnRefsToSuperRefactoringImpl.java b/source/com/intellij/refactoring/openapi/impl/TurnRefsToSuperRefactoringImpl.java index b628ecf6ba3c..83d8d814d44c 100644 --- a/source/com/intellij/refactoring/openapi/impl/TurnRefsToSuperRefactoringImpl.java +++ b/source/com/intellij/refactoring/openapi/impl/TurnRefsToSuperRefactoringImpl.java @@ -15,7 +15,7 @@ import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor; */ public class TurnRefsToSuperRefactoringImpl extends RefactoringImpl 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() { diff --git a/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryHandler.java b/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryHandler.java index 06b645dafc77..f19d09ae1301 100644 --- a/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryHandler.java +++ b/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryHandler.java @@ -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); } diff --git a/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java b/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java index 37ea4fc861fb..90e9d4934a21 100644 --- a/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java +++ b/source/com/intellij/refactoring/replaceConstructorWithFactory/ReplaceConstructorWithFactoryProcessor.java @@ -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 { diff --git a/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperHandler.java b/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperHandler.java index 35381b74c20f..f76e56bcc376 100644 --- a/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperHandler.java +++ b/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperHandler.java @@ -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); } } diff --git a/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java b/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java index bdbc6b9f7ce1..63ce92df7c03 100644 --- a/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java +++ b/source/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessor.java @@ -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" + diff --git a/source/com/intellij/refactoring/typeCook/TypeCookProcessor.java b/source/com/intellij/refactoring/typeCook/TypeCookProcessor.java index 364f77442d71..67d3a8d941cb 100644 --- a/source/com/intellij/refactoring/typeCook/TypeCookProcessor.java +++ b/source/com/intellij/refactoring/typeCook/TypeCookProcessor.java @@ -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 victims = new HashSet(); diff --git a/testSource/com/intellij/refactoring/ChangeSignatureTest.java b/testSource/com/intellij/refactoring/ChangeSignatureTest.java index 90b6638ee814..5deabf5539ec 100644 --- a/testSource/com/intellij/refactoring/ChangeSignatureTest.java +++ b/testSource/com/intellij/refactoring/ChangeSignatureTest.java @@ -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"); } diff --git a/testSource/com/intellij/refactoring/IntroduceParameterTest.java b/testSource/com/intellij/refactoring/IntroduceParameterTest.java index b383f2caa082..862c0ef80e5b 100644 --- a/testSource/com/intellij/refactoring/IntroduceParameterTest.java +++ b/testSource/com/intellij/refactoring/IntroduceParameterTest.java @@ -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(); diff --git a/testSource/com/intellij/refactoring/MakeMethodStaticTest.java b/testSource/com/intellij/refactoring/MakeMethodStaticTest.java index 1b41c760248a..83af774f37c6 100644 --- a/testSource/com/intellij/refactoring/MakeMethodStaticTest.java +++ b/testSource/com/intellij/refactoring/MakeMethodStaticTest.java @@ -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(); diff --git a/testSource/com/intellij/refactoring/ReplaceConstructorWithFactoryTest.java b/testSource/com/intellij/refactoring/ReplaceConstructorWithFactoryTest.java index 4329a8ff2abd..272e776d3fc8 100644 --- a/testSource/com/intellij/refactoring/ReplaceConstructorWithFactoryTest.java +++ b/testSource/com/intellij/refactoring/ReplaceConstructorWithFactoryTest.java @@ -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(); diff --git a/testSource/com/intellij/refactoring/TurnRefsToSuperTest.java b/testSource/com/intellij/refactoring/TurnRefsToSuperTest.java index 2ef1fe91dff5..2c7554fa0fc0 100644 --- a/testSource/com/intellij/refactoring/TurnRefsToSuperTest.java +++ b/testSource/com/intellij/refactoring/TurnRefsToSuperTest.java @@ -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(); } } \ No newline at end of file