package no.uio.ifi.refaktor.handlers;
-import static no.uio.ifi.refaktor.assertion.RefaktorAssert.assertThat;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import no.uio.ifi.refaktor.analyze.ExtractAndMoveMethodAnalysisResult;
+import no.uio.ifi.refaktor.analyze.ExtractAndMoveMethodCandidate;
import no.uio.ifi.refaktor.analyze.analyzers.SearchBasedExtractAndMoveMethodAnalyzer;
-import no.uio.ifi.refaktor.analyze.comparators.FavorNoUnfixesAnalysisResultComparator;
+import no.uio.ifi.refaktor.analyze.comparators.FavorNoUnfixesCandidateComparator;
import no.uio.ifi.refaktor.analyze.exceptions.NoTargetFoundException;
+import no.uio.ifi.refaktor.aspects.StatisticsAspect;
+import no.uio.ifi.refaktor.aspects.StatisticsAspect.Statistics;
+import no.uio.ifi.refaktor.utils.RefaktorDebug;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- assertThat(selection, instanceOf(ITreeSelection.class));
+ assert selection instanceof ITreeSelection;
ITreeSelection treeSelection = (ITreeSelection) selection;
Object o = treeSelection.getFirstElement();
- assertThat(o, instanceOf(IMethod.class));
+ assert o instanceof IMethod;
IMethod method = (IMethod) o;
String message = "";
try {
- SearchBasedExtractAndMoveMethodAnalyzer analyzer = new SearchBasedExtractAndMoveMethodAnalyzer(method, new FavorNoUnfixesAnalysisResultComparator());
+ StatisticsAspect.init();
+ SearchBasedExtractAndMoveMethodAnalyzer analyzer = new SearchBasedExtractAndMoveMethodAnalyzer(method, new FavorNoUnfixesCandidateComparator());
analyzer.analyze();
- ExtractAndMoveMethodAnalysisResult result = analyzer.getResult();
+ ExtractAndMoveMethodCandidate result = analyzer.getCandidate();
message = "Result:\n\nText selection:\n" + result.textSelection
- + "\n\nSelected text:\n" + result.textSelection.getText()
+ "\n\nNumber of text selections analyzed:\n" + result.numberOfTextSelectionsAnalyzed
- + "\n\nOriginal target:\n" + result.calculateOriginalTarget();
+ + "\n\nOriginal target:\n" + result.calculateOriginalTarget()
+ + "\n\nSelected text:\n" + result.textSelection.getText();
} catch (NoTargetFoundException e) {
message = "No solution found for " + method;
+ } finally {
+ Statistics snapshot = StatisticsAspect.getSnapshot();
+ RefaktorDebug.log(snapshot.toString());
}
MessageDialog.openInformation(window.getShell(), "no.uio.ifi.refaktor", message);