]> git.uio.no Git - ifi-stolz-refaktor.git/blob - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/change/executors/RefactoringExecutor.java
Prune imports & tidy
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor / src / no / uio / ifi / refaktor / change / executors / RefactoringExecutor.java
1 package no.uio.ifi.refaktor.change.executors;
2
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;
9
10 /**
11  * RefactoringExecutor spesific for Extract Local variable refactoring
12  * 
13  * 
14  * TODO Might be changed
15  * 
16  * 
17  * @author Anna Eilertsen
18  *
19  */
20 public class RefactoringExecutor<Candidate extends RefactorCandidate> implements Executor{
21
22         /**
23          * Text selection containing the expression we want to refactor, and only that
24          */
25         final private CompilationUnitTextSelection textSelection;
26         final private String newName;
27         final private RefactoringFactory<Candidate> factory;
28
29         public RefactoringExecutor(Candidate analysisResult, RefactoringFactory<Candidate> factory) {
30                 this.factory = factory;
31                 this.textSelection = analysisResult.getTextSelection();
32                 this.newName = analysisResult.generateName();
33         }
34
35         @Override
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);
41         }
42
43 }