1 package no.uio.ifi.refaktor.change.executors;
3 import org.eclipse.core.runtime.CoreException;
4 import org.eclipse.core.runtime.IProgressMonitor;
5 import no.uio.ifi.refaktor.analyze.candidates.RefactorCandidate;
6 import no.uio.ifi.refaktor.change.changers.RefaktorChanger;
7 import no.uio.ifi.refaktor.factories.RefactoringFactory;
8 import no.uio.ifi.refaktor.textselection.CompilationUnitTextSelection;
11 * RefactoringExecutor spesific for Extract Local variable refactoring
14 * TODO Might be changed
17 * @author Anna Eilertsen
20 public class RefactoringExecutor<Candidate extends RefactorCandidate> implements Executor{
23 * Text selection containing the expression we want to refactor, and only that
25 final private CompilationUnitTextSelection textSelection;
26 final private String newName;
27 final private RefactoringFactory<Candidate> factory;
29 public RefactoringExecutor(Candidate analysisResult, RefactoringFactory<Candidate> factory) {
30 this.factory = factory;
31 this.textSelection = analysisResult.getTextSelection();
32 this.newName = analysisResult.generateName();
36 public void execute(IProgressMonitor monitor) throws CoreException {
37 //TODO should be generic
38 RefaktorChanger changer = factory.getChanger(textSelection, newName);
39 changer.checkPreconditions();
40 changer.execute(monitor);