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.textselection.CompilationUnitTextSelection;
12 * RefactoringExecutor spesific for Extract Local variable refactoring
15 * TODO Might be changed
18 * @author Anna Eilertsen
21 public class RefactoringExecutor<Candidate extends RefactorCandidate> implements Executor{
24 * Text selection containing the expression we want to refactor, and only that
26 private CompilationUnitTextSelection textSelection;
27 private String newVariableNameName;
29 public RefactoringExecutor(Candidate analysisResult) {
30 this.textSelection = analysisResult.getTextSelection();
31 this.newVariableNameName = analysisResult.generateName();
35 public void execute(IProgressMonitor monitor) throws CoreException {
36 //TODO should be generic
37 ExtractLocalVariableWithAssertsChanger changer = new ExtractLocalVariableWithAssertsChanger(textSelection, newVariableNameName);
38 changer.checkPreconditions();
40 changer.execute(new NullProgressMonitor());
41 } catch (CoreException e) {