From 1bb9e3fb1e18ce223d8a9546e7dda1a87355cb12 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 25 May 2012 18:01:09 +0400 Subject: [PATCH] provide api to filter out references with another names --- .../rename/inplace/InplaceRefactoring.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java index 9439abe27109..293ab0095f42 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java @@ -71,6 +71,8 @@ import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.ui.awt.RelativePoint; +import com.intellij.util.CommonProcessors; +import com.intellij.util.Query; import com.intellij.util.containers.Stack; import com.intellij.util.ui.PositionTracker; import org.jetbrains.annotations.NonNls; @@ -220,8 +222,22 @@ public abstract class InplaceRefactoring { return new MyLookupExpression(getInitialName(), myNameSuggestions, myElementToRename, shouldSelectAll(), myAdvertisementText); } + protected boolean acceptReference(PsiReference reference) { + return true; + } + protected Collection collectRefs(SearchScope referencesSearchScope) { - return ReferencesSearch.search(myElementToRename, referencesSearchScope, false).findAll(); + final Query search = ReferencesSearch.search(myElementToRename, referencesSearchScope, false); + + final CommonProcessors.CollectProcessor processor = new CommonProcessors.CollectProcessor() { + @Override + protected boolean accept(PsiReference reference) { + return acceptReference(reference); + } + }; + + search.forEach(processor); + return processor.getResults(); } protected boolean buildTemplateAndStart(final Collection refs,