]> git.uio.no Git - ifi-stolz-refaktor.git/blame - software/no.uio.ifi.refaktor/src/no/uio/ifi/refaktor/analyze/TypeWideSearchBasedExtractAndMoveMethodAnalyzer.java
Making the SearchBasedExtractAndMoveMethodChangerBenchmark more error tolerant.
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor / src / no / uio / ifi / refaktor / analyze / TypeWideSearchBasedExtractAndMoveMethodAnalyzer.java
CommitLineData
7256e850
EK
1package no.uio.ifi.refaktor.analyze;
2
3import java.util.LinkedList;
4import java.util.List;
5
6import no.uio.ifi.refaktor.utils.RefaktorDebug;
7
8import org.eclipse.jdt.core.IMethod;
9import org.eclipse.jdt.core.IType;
10import org.eclipse.jdt.core.JavaModelException;
11
85bef15c 12public class TypeWideSearchBasedExtractAndMoveMethodAnalyzer implements SearchBasedAnalyzer {
7256e850
EK
13
14 private final IType type;
15 private final AnalysisStatistics statistics;
16 private final List<ExtractAndMoveMethodAnalysisResult> results;
17
18 public TypeWideSearchBasedExtractAndMoveMethodAnalyzer(IType type, AnalysisStatistics statistics) {
19 this.type = type;
20 this.statistics = statistics;
21 results = new LinkedList<ExtractAndMoveMethodAnalysisResult>();
22 }
23
85bef15c 24 @Override
7256e850
EK
25 public List<ExtractAndMoveMethodAnalysisResult> getResults() {
26 return results;
27 }
28
85bef15c 29 @Override
7256e850
EK
30 public void analyze() {
31 try {
32 analyzeMethodsInType();
33 } catch (JavaModelException e) {
34 RefaktorDebug.log(e);
35 }
8a96c34b 36 statistics.incrementTypeCount();
7256e850
EK
37 }
38
39 private void analyzeMethodsInType() throws JavaModelException {
40 for (IMethod method: type.getMethods()) {
41 analyzeMethod(method);
42 }
43 }
44
45 private void analyzeMethod(IMethod method) {
46 try {
47 SearchBasedExtractAndMoveMethodAnalyzer analyzer =
48 new SearchBasedExtractAndMoveMethodAnalyzer(method, new FavorNoUnfixesAnalysisResultComparator(), statistics);
49 analyzer.analyze();
50 results.add(analyzer.getResult());
51 } catch (NoTargetFoundException e) {
52 // Ignoring
53 } catch (AssertionError err) {
54 RefaktorDebug.log(err);
55 }
56 }
57}