public class ExtractMethodHelper
extends java.lang.Object
| Constructor and Description |
|---|
ExtractMethodHelper() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<SimpleMatch> |
collectDuplicates(SimpleDuplicatesFinder finder,
java.util.List<PsiElement> searchScopes,
PsiElement generatedMethod)
Finds duplicates of the code fragment specified in the finder in given scopes.
|
static void |
processDuplicates(PsiElement callElement,
PsiElement generatedMethod,
java.util.List<PsiElement> scope,
SimpleDuplicatesFinder finder,
Editor editor,
Consumer<? super Pair<SimpleMatch,PsiElement>> replacer) |
static void |
replaceDuplicates(PsiElement callElement,
Editor editor,
Consumer<? super Pair<SimpleMatch,PsiElement>> replacer,
java.util.List<? extends SimpleMatch> duplicates)
Notifies user about found duplicates and then highlights each of them in the editor and asks user how to proceed.
|
public static void processDuplicates(PsiElement callElement, PsiElement generatedMethod, java.util.List<PsiElement> scope, SimpleDuplicatesFinder finder, Editor editor, Consumer<? super Pair<SimpleMatch,PsiElement>> replacer)
public static java.util.List<SimpleMatch> collectDuplicates(SimpleDuplicatesFinder finder, java.util.List<PsiElement> searchScopes, PsiElement generatedMethod)
processDuplicates(com.intellij.psi.PsiElement, com.intellij.psi.PsiElement, java.util.List<com.intellij.psi.PsiElement>, com.intellij.refactoring.extractMethod.SimpleDuplicatesFinder, com.intellij.openapi.editor.Editor, com.intellij.util.Consumer<? super com.intellij.openapi.util.Pair<com.intellij.refactoring.extractMethod.SimpleMatch, com.intellij.psi.PsiElement>>) the search is performed synchronously because normally you need the results in
order to complete the refactoring. If user cancels it, empty list will be returned.finder - finder object to seek for duplicatessearchScopes - scopes where to look them ingeneratedMethod - new method that should be excluded from the searchreplaceDuplicates(PsiElement, Editor, Consumer, List)public static void replaceDuplicates(PsiElement callElement, Editor editor, Consumer<? super Pair<SimpleMatch,PsiElement>> replacer, java.util.List<? extends SimpleMatch> duplicates)
callElement - generated expression or statement that contains invocation of the new methodeditor - instance of editor where refactoring is performedreplacer - strategy of substituting each duplicate occurence with the replacement fragmentduplicates - discovered duplicates of extracted code fragmentcollectDuplicates(SimpleDuplicatesFinder, List, PsiElement)