package no.uio.ifi.refaktor.change.executors; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import no.uio.ifi.refaktor.analyze.candidates.RefactorCandidate; import no.uio.ifi.refaktor.change.changers.RefaktorChanger; import no.uio.ifi.refaktor.factories.RefactoringFactory; import no.uio.ifi.refaktor.textselection.CompilationUnitTextSelection; /** * RefactoringExecutor spesific for Extract Local variable refactoring * * * TODO Might be changed * * * @author Anna Eilertsen * */ public class RefactoringExecutor implements Executor{ /** * Text selection containing the expression we want to refactor, and only that */ final private CompilationUnitTextSelection textSelection; final private String newName; final private RefactoringFactory factory; public RefactoringExecutor(Candidate analysisResult, RefactoringFactory factory) { this.factory = factory; this.textSelection = analysisResult.getTextSelection(); this.newName = analysisResult.generateName(); } @Override public void execute(IProgressMonitor monitor) throws CoreException { //TODO should be generic RefaktorChanger changer = factory.getChanger(textSelection, newName); changer.checkPreconditions(); changer.execute(monitor); } }