]> git.uio.no Git - ifi-stolz-refaktor.git/blob - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/change/executors/RefactoringExecutor.java
testing generics, not sure if it will work
[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 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;
10
11 /**
12  * RefactoringExecutor spesific for Extract Local variable refactoring
13  * 
14  * 
15  * TODO Might be changed
16  * 
17  * 
18  * @author Anna Eilertsen
19  *
20  */
21 public class RefactoringExecutor<Candidate extends RefactorCandidate> implements Executor{
22
23         /**
24          * Text selection containing the expression we want to refactor, and only that
25          */
26         private CompilationUnitTextSelection textSelection;
27         private String newVariableNameName;
28
29         public RefactoringExecutor(Candidate analysisResult) {
30                 this.textSelection = analysisResult.getTextSelection();
31                 this.newVariableNameName = analysisResult.generateName();
32         }
33
34         @Override
35         public void execute(IProgressMonitor monitor) throws CoreException {
36
37                 ExtractLocalVariableWithAssertsChanger changer = new ExtractLocalVariableWithAssertsChanger(textSelection, newVariableNameName);
38                 changer.checkPreconditions();
39                 try {
40                         changer.execute(new NullProgressMonitor());
41                 } catch (CoreException e) {
42                         e.printStackTrace();
43                 }
44         }
45
46 }