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