From 57425dde4471b9878aee938fea4f6d88195c24c9 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 19 Sep 2010 21:42:50 +0000 Subject: [PATCH] Fixed a bug in renaming of virtual methods. --- .../ui/refactoring/rename/ASTManager.java | 99 ++++++++----------- .../rename/CRenameLocalProcessor.java | 11 ++- .../rename/CRenameMacroProcessor.java | 17 ++-- .../rename/CRenameMethodProcessor.java | 10 +- .../refactoring/rename/CRenameProcessor.java | 16 ++- .../rename/CRenameProcessorDelegate.java | 71 ++++++------- 6 files changed, 108 insertions(+), 116 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index 02088ff6b79..f52bbd37f8e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * IBM Corporation - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * IBM Corporation + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -115,8 +115,8 @@ import org.eclipse.cdt.internal.corext.util.CModelUtil; import org.eclipse.cdt.internal.ui.editor.ASTProvider; /** - * Used per refactoring to cache the IASTTranslationUnits. Collects methods operating - * on ASTNodes. + * Used for refactoring to cache the IASTTranslationUnits. + * Contains a collection of methods operating on ASTNodes. */ public class ASTManager { public final static int TRUE= 1; @@ -331,8 +331,7 @@ public class ASTManager { return TRUE; } - if (node1 instanceof IASTTranslationUnit && - node2 instanceof IASTTranslationUnit) { + if (node1 instanceof IASTTranslationUnit && node2 instanceof IASTTranslationUnit) { return hasSameLocation(node1, node2, fileStatic); } @@ -379,7 +378,7 @@ public class ASTManager { return FALSE; } if (s1 instanceof ICFunctionScope || s1 instanceof ICFunctionPrototypeScope - || s1 instanceof ICScope) { + || s1 instanceof ICScope) { if (s2 instanceof ICFunctionScope || s2 instanceof ICFunctionPrototypeScope || s2 instanceof ICScope) { return hasSameLocation(node1, node2, true); @@ -425,8 +424,7 @@ public class ASTManager { return isSameParameterList(b1.getParameterTypes(), b2.getParameterTypes()); } - private static int isSameParameterList(IType[] p1, - IType[] p2) throws DOMException { + private static int isSameParameterList(IType[] p1, IType[] p2) throws DOMException { if (p1 == p2) { return TRUE; } @@ -439,11 +437,11 @@ public class ASTManager { int retval= TRUE; for (int i = 0; i < p2.length; i++) { switch (isSameType(p1[i], p2[i])) { - case FALSE: - return FALSE; - case UNKNOWN: - retval= UNKNOWN; - break; + case FALSE: + return FALSE; + case UNKNOWN: + retval= UNKNOWN; + break; } } @@ -464,11 +462,11 @@ public class ASTManager { int retval= TRUE; for (int i = 0; i < p2.length; i++) { switch (isSameType(p1[i].getType(), p2[i].getType())) { - case FALSE: - return FALSE; - case UNKNOWN: - retval= UNKNOWN; - break; + case FALSE: + return FALSE; + case UNKNOWN: + retval= UNKNOWN; + break; } } @@ -484,8 +482,7 @@ public class ASTManager { if (t1 == t2) { return TRUE; } - if (t1 == null || t2 == null || t1 instanceof IProblemBinding || - t2 instanceof IProblemBinding) { + if (t1 == null || t2 == null || t1 instanceof IProblemBinding || t2 instanceof IProblemBinding) { return UNKNOWN; } @@ -750,8 +747,8 @@ public class ASTManager { } } - public static IBinding[] findInScope(final IScope scope, String name, - boolean removeGlobalsWhenClassScope) throws DOMException { + public static IBinding[] findInScope(final IScope scope, String name, boolean removeGlobalsWhenClassScope) + throws DOMException { IBinding[] result= null; result = scope.find(name); if (result == null || result.length == 0) { @@ -841,7 +838,8 @@ public class ASTManager { node instanceof IASTPreprocessorIfStatement) { final IASTFileLocation fileLocation = node.getFileLocation(); if (fileLocation != null) { - final String ident= extractIdentifier(node.getRawSignature(), offset - fileLocation.getNodeOffset(), length); + final String ident= extractIdentifier(node.getRawSignature(), + offset - fileLocation.getNodeOffset(), length); if (ident != null) { IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions(); for (IASTPreprocessorMacroDefinition mdef : mdefs) { @@ -898,22 +896,13 @@ public class ASTManager { return rawSignature.substring(offset, end); } - private IASTTranslationUnit getTranslationUnit(IIndex index, IFile sourceFile, - boolean cacheit, RefactoringStatus status) { + private IASTTranslationUnit getTranslationUnit(IIndex index, IFile sourceFile, boolean cacheit, + RefactoringStatus status) { IASTTranslationUnit ast= fTranslationUnits.get(sourceFile); if (ast == null) { ICElement celem= CoreModel.getDefault().create(sourceFile); if (celem instanceof ITranslationUnit) { ITranslationUnit tu= CModelUtil.toWorkingCopy((ITranslationUnit) celem); -// if (tu instanceof IWorkingCopy) { -// synchronized (tu) { -// try { -// ast = ((IWorkingCopy) tu).reconcile(true, false, null); -// } catch (CModelException e) { -// CUIPlugin.log(e); -// } -// } -// } // Try to get a shared AST before creating our own. final IASTTranslationUnit[] ast_holder = new IASTTranslationUnit[1]; ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, null, new ASTRunnable() { @@ -942,8 +931,8 @@ public class ASTManager { return ast; } - public void analyzeTextMatches(IIndex index, ArrayList matches, IProgressMonitor monitor, - RefactoringStatus status) { + public void analyzeTextMatches(IIndex index, Collection matches, + IProgressMonitor monitor, RefactoringStatus status) { CRefactoringMatchStore store= new CRefactoringMatchStore(); for (CRefactoringMatch match : matches) { store.addMatch(match); @@ -1030,9 +1019,8 @@ public class ASTManager { fConflictingBinding= null; } - private void analyzeLanguageMatches(IASTTranslationUnit tu, - final CRefactoringMatchStore store, final Set paths, - final RefactoringStatus status) { + private void analyzeLanguageMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store, + final Set paths, final RefactoringStatus status) { ASTNameVisitor nv = new ASTSpecificNameVisitor(fArgument.getName()) { @Override protected int visitName(IASTName name, boolean isDestructor) { @@ -1044,9 +1032,8 @@ public class ASTManager { tu.accept(nv); } - private void analyzeMacroMatches(IASTTranslationUnit tu, - final CRefactoringMatchStore store, final Set pathsVisited, - final RefactoringStatus status) { + private void analyzeMacroMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store, + final Set pathsVisited, final RefactoringStatus status) { String lookfor= fArgument.getName(); IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions(); for (IASTPreprocessorMacroDefinition mdef : mdefs) { @@ -1122,10 +1109,8 @@ public class ASTManager { // } // } - private void findConflictingBindingsWithNewName(IASTTranslationUnit tu, - CRefactoringMatchStore store, final Set paths, - final RefactoringStatus status) { - + private void findConflictingBindingsWithNewName(IASTTranslationUnit tu, CRefactoringMatchStore store, + final Set paths, final RefactoringStatus status) { ASTNameVisitor nv = new ASTSpecificNameVisitor(fRenameTo) { @Override protected int visitName(IASTName name, boolean isDestructor) { @@ -1156,8 +1141,8 @@ public class ASTManager { return path; } - protected IPath analyzeAstMatch(IASTName name, CRefactoringMatchStore store, - boolean isDestructor, RefactoringStatus status) { + protected IPath analyzeAstMatch(IASTName name, CRefactoringMatchStore store, boolean isDestructor, + RefactoringStatus status) { IPath path= null; CRefactoringMatch match= null; @@ -1250,7 +1235,8 @@ public class ASTManager { handleProblemBinding(tu, e.getProblem(), status); } - public void handleProblemBinding(IASTTranslationUnit tu, final IProblemBinding pb, RefactoringStatus status) { + public void handleProblemBinding(IASTTranslationUnit tu, final IProblemBinding pb, + RefactoringStatus status) { if (tu != null) { String fpath= tu.getFilePath(); if (fProblemUnits.add(fpath)) { @@ -1316,11 +1302,11 @@ public class ASTManager { } Collection[] cflc= - new Collection[] { new HashSet(), new ArrayList(), new ArrayList() }; + new Collection[] { new HashSet(), new ArrayList(), + new ArrayList() }; String[] errs= null; if (isMacro) { - errs= new String[] { - RenameMessages.CRenameLocalProcessor_error_conflict }; + errs= new String[] { RenameMessages.CRenameLocalProcessor_error_conflict }; cflc[0]= fConflictingBinding; } else { errs= new String[] { @@ -1464,9 +1450,8 @@ public class ASTManager { } } - protected void classifyConflictingBindings(IASTTranslationUnit tu, - Set shadows, Collection redecl, Collection barriers, - RefactoringStatus status) { + protected void classifyConflictingBindings(IASTTranslationUnit tu, Set shadows, + Collection redecl, Collection barriers, RefactoringStatus status) { // collect bindings on higher or equal level String name= fArgument.getName(); IBinding[] newBindingsAboverOrEqual= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index eaa099b8991..6baeebdc024 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -11,7 +11,7 @@ ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; -import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import org.eclipse.core.runtime.IProgressMonitor; @@ -19,6 +19,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; @@ -51,10 +52,10 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate { return TextSearchWrapper.SCOPE_FILE; } - @Override - protected void analyzeTextMatches(ArrayList matches, IProgressMonitor monitor, - RefactoringStatus status) { - super.analyzeTextMatches(matches, monitor, status); + @Override + protected void analyzeTextMatches(IBinding[] renameBindings, Collection matches, + IProgressMonitor monitor, RefactoringStatus status) { + super.analyzeTextMatches(renameBindings, matches, monitor, status); if (fScope != null) { CRefactoringArgument argument = getArgument(); int[] result= new int[] {0, Integer.MAX_VALUE}; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java index ad3bfbf2954..3bebc37ce79 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java @@ -1,20 +1,23 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Wind River Systems, Inc and others. + * Copyright (c) 2005, 2010 Wind River Systems, Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; -import java.util.ArrayList; +import java.util.Collection; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.cdt.core.dom.ast.IBinding; + /** * Rename processor that sets up the input page for renaming a global entity. @@ -35,14 +38,14 @@ public class CRenameMacroProcessor extends CRenameGlobalProcessor { return selectedOptions | CRefactory.OPTION_IN_MACRO_DEFINITION; } - @Override - protected void analyzeTextMatches(ArrayList matches, IProgressMonitor monitor, - RefactoringStatus status) { + @Override + protected void analyzeTextMatches(IBinding[] renameBindings, Collection matches, + IProgressMonitor monitor, RefactoringStatus status) { for (CRefactoringMatch m : matches) { if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0) { m.setASTInformation(CRefactoringMatch.AST_REFERENCE); } } - super.analyzeTextMatches(matches, monitor, status); + super.analyzeTextMatches(renameBindings, matches, monitor, status); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java index a28e636fcf3..629cea9ed5c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -63,8 +64,8 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor { } @Override - public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, - CheckConditionsContext context) throws OperationCanceledException, CoreException { + public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) + throws OperationCanceledException, CoreException { CRefactoringArgument argument= getArgument(); RefactoringStatus result= new RefactoringStatus(); IScope scope= argument.getScope(); @@ -84,7 +85,8 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor { } } } - if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD && (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) { + if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD && + (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) { result.merge(RefactoringStatus.createWarningStatus(RenameMessages.CRenameMethodProcessor_warning_renameVirtual)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java index 3a5c762e784..1a355ea0b6d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -182,23 +183,20 @@ public class CRenameProcessor extends RenameProcessor { } @Override - public RefactoringStatus checkFinalConditions(IProgressMonitor pm, - CheckConditionsContext context) throws CoreException, - OperationCanceledException { + public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) + throws CoreException, OperationCanceledException { return fDelegate.checkFinalConditions(pm, context); } @Override - public Change createChange(IProgressMonitor pm) throws CoreException, - OperationCanceledException { + public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { return fDelegate.createChange(pm); } @Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException { - RenameArguments arguments= new RenameArguments(getReplacementText(), - true); + RenameArguments arguments= new RenameArguments(getReplacementText(), true); final String[] natures= {CCProjectNature.CC_NATURE_ID, CProjectNature.C_NATURE_ID}; List result= new ArrayList(); IBinding binding= getArgument().getBinding(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java index c112c951d6e..4d7fd99504e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java @@ -1,14 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * IBM Corporation - Bug 112366 - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * IBM Corporation - Bug 112366 + * Sergey Prigogin (Google) ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -53,7 +53,7 @@ import org.eclipse.cdt.ui.refactoring.CTextFileChange; */ public abstract class CRenameProcessorDelegate { private CRenameProcessor fTopProcessor; - private ArrayList fMatches= null; + private ArrayList fMatches; protected String fProcessorBaseName; private int fAvailableOptions= CRefactory.OPTION_ASK_SCOPE | @@ -113,7 +113,8 @@ public abstract class CRenameProcessorDelegate { final public String getProcessorName() { String identifier= getArgument().getName(); if (identifier != null) { - return NLS.bind(RenameMessages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName, identifier); + return NLS.bind(RenameMessages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName, + identifier); } return null; } @@ -158,29 +159,28 @@ public abstract class CRenameProcessorDelegate { /** * Builds an index-based file filter for the name search. - * @return A set of files containing references to the name, or null if + * @param bindings bindings being renamed + * @return A set of files containing references to the bindings, or null if * exhaustive file search is requested. */ - private Collection getFileFilter() { + private Collection getFileFilter(IBinding[] bindings) { if ((getSelectedOptions() & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0) { return null; } IIndex index = getIndex(); if (index == null) { return null; - } - IBinding binding = getArgument().getBinding(); - if (binding == null) { - return null; } Set locations = new HashSet(); try { index.acquireReadLock(); - IIndexName[] names = index.findNames(binding, - IIndex.FIND_ALL_OCCURRENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); - for (IIndexName name : names) { - locations.add(name.getFile().getLocation()); - } + for (IBinding binding : bindings) { + IIndexName[] names = index.findNames(binding, + IIndex.FIND_ALL_OCCURRENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); + for (IIndexName name : names) { + locations.add(name.getFile().getLocation()); + } + } } catch (InterruptedException e) { return null; } catch (CoreException e) { @@ -208,16 +208,19 @@ public abstract class CRenameProcessorDelegate { return new RefactoringStatus(); } - public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { + public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) + throws CoreException, OperationCanceledException { RefactoringStatus result= new RefactoringStatus(); monitor.beginTask(RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2); IFile file= getArgument().getSourceFile(); //assert file!=null; - + + IBinding[] renameBindings= getBindingsToBeRenamed(result); + // perform text-search fMatches= new ArrayList(); TextSearchWrapper txtSearch= getManager().getTextSearch(); - Collection fileFilter = getFileFilter(); + Collection fileFilter = getFileFilter(renameBindings); if (fileFilter != null && !fileFilter.contains(file)) { fileFilter.add(file); } @@ -232,8 +235,8 @@ public abstract class CRenameProcessorDelegate { if (result.hasFatalError()) { return result; } - selectMatchesByLocation(fMatches); - analyzeTextMatches(fMatches, new SubProgressMonitor(monitor, 1), result); + selectMatchesByLocation(fMatches); + analyzeTextMatches(renameBindings, fMatches, new SubProgressMonitor(monitor, 1), result); if (result.hasFatalError()) { return result; } @@ -266,7 +269,8 @@ public abstract class CRenameProcessorDelegate { if (potentialMatchCount == 1) { msg= RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_singular; } else { - msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_plural, potentialMatchCount); + msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_plural, + potentialMatchCount); } result.addWarning(msg); } @@ -275,7 +279,8 @@ public abstract class CRenameProcessorDelegate { if (commentCount == 1) { msg= RenameMessages.CRenameProcessorDelegate_warning_commentMatch_singular; } else { - msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_commentMatch_plural, commentCount); + msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_commentMatch_plural, + commentCount); } result.addWarning(msg); } @@ -289,11 +294,9 @@ public abstract class CRenameProcessorDelegate { return result; } - protected void analyzeTextMatches(ArrayList matches, IProgressMonitor monitor, RefactoringStatus status) { - CRefactoringArgument argument= getArgument(); - IBinding[] renameBindings= getBindingsToBeRenamed(status); - if (renameBindings != null && renameBindings.length > 0 && - argument.getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) { + protected void analyzeTextMatches(IBinding[] renameBindings, Collection matches, + IProgressMonitor monitor, RefactoringStatus status) { + if (renameBindings.length > 0 && getArgument().getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) { ASTManager mngr= getAstManager(); mngr.setValidBindings(renameBindings); mngr.setRenameTo(getReplacementText()); @@ -301,7 +304,7 @@ public abstract class CRenameProcessorDelegate { } } - private void selectMatchesByLocation(ArrayList matches) { + private void selectMatchesByLocation(Collection matches) { int acceptTextLocation= getAcceptedLocations(getSelectedOptions()); for (Iterator iter = matches.iterator(); iter.hasNext();) { CRefactoringMatch match = iter.next(); @@ -317,10 +320,10 @@ public abstract class CRenameProcessorDelegate { } public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { - if (fMatches.size() == 0) { + if (fMatches.isEmpty()) { return null; } - Collections.sort(fMatches, new Comparator(){ + Collections.sort(fMatches, new Comparator() { public int compare(CRefactoringMatch m1, CRefactoringMatch m2) { IFile f1= m1.getFile(); IFile f2= m2.getFile(); @@ -371,10 +374,10 @@ public abstract class CRenameProcessorDelegate { } /** - * Returns the array of bindings that must be renamed + * Returns the array of bindings that must be renamed. */ protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) { - return new IBinding[] {getArgument().getBinding()}; + return new IBinding[] { getArgument().getBinding() }; } /**