]>
Commit | Line | Data |
---|---|---|
7256e850 EK |
1 | package no.uio.ifi.refaktor.analyze; |
2 | ||
3 | import java.util.LinkedList; | |
4 | import java.util.List; | |
5 | ||
d6c79186 | 6 | import no.uio.ifi.refaktor.analyze.comparators.FavorNoUnfixesAnalysisResultComparator; |
7256e850 EK |
7 | import no.uio.ifi.refaktor.utils.RefaktorDebug; |
8 | ||
9 | import org.eclipse.jdt.core.IMethod; | |
10 | import org.eclipse.jdt.core.IType; | |
11 | import org.eclipse.jdt.core.JavaModelException; | |
12 | ||
85bef15c | 13 | public 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 | } |