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