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