]> git.uio.no Git - ifi-stolz-refaktor.git/blobdiff - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/handlers/SearchBasedExtractAndMoveMethodAnalysisHandler.java
Software: moving text selections to new package
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor / src / no / uio / ifi / refaktor / handlers / SearchBasedExtractAndMoveMethodAnalysisHandler.java
index 467319ca175ad3a1255ea717cf9254e903d5ade4..7b05d6bf091dddf7302d9459bd2feea48f7c26e6 100644 (file)
@@ -1,11 +1,12 @@
 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;
@@ -24,23 +25,27 @@ public class SearchBasedExtractAndMoveMethodAnalysisHandler extends AbstractHand
                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\nNumber of text selections analyzed:\n" + result.numberOfTextSelectionsAnalyzed
                                        + "\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);