]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | package no.uio.ifi.refaktor.analyze.analyzers; |
2 | ||
3 | import java.util.LinkedList; | |
4 | import java.util.List; | |
5 | ||
6 | import no.uio.ifi.refaktor.analyze.ExtractAndMoveMethodCandidate; | |
7 | import no.uio.ifi.refaktor.analyze.comparators.FavorNoUnfixesCandidateComparator; | |
8 | import no.uio.ifi.refaktor.analyze.exceptions.NoTargetFoundException; | |
9 | import no.uio.ifi.refaktor.analyze.exceptions.RefaktorAnalyzerException; | |
10 | import no.uio.ifi.refaktor.debugging.RefaktorDebug; | |
11 | ||
12 | import org.eclipse.jdt.core.IMethod; | |
13 | import org.eclipse.jdt.core.IType; | |
14 | import org.eclipse.jdt.core.JavaModelException; | |
15 | ||
16 | /** | |
17 | * Responsible for analyzing all methods in a type for | |
18 | * candidates to the Extract and Move Method refactoring. | |
19 | */ | |
20 | public class TypeWideExtractAndMoveMethodAnalyzer implements AggregationAnalyzer<ExtractAndMoveMethodCandidate> { | |
21 | ||
22 | private final IType type; | |
23 | final List<ExtractAndMoveMethodCandidate> candidates; | |
24 | ||
25 | public TypeWideExtractAndMoveMethodAnalyzer(IType type) { | |
26 | this.type = type; | |
27 | candidates = new LinkedList<ExtractAndMoveMethodCandidate>(); | |
28 | } | |
29 | ||
30 | @Override | |
31 | public List<ExtractAndMoveMethodCandidate> getResults() { | |
32 | return candidates; | |
33 | } | |
34 | ||
35 | @Override | |
36 | public void analyze() throws RefaktorAnalyzerException { | |
37 | try { | |
38 | analyzeMethodsInType(); | |
39 | } catch (JavaModelException e) { | |
40 | RefaktorDebug.log(e); | |
41 | } | |
42 | } | |
43 | ||
44 | private void analyzeMethodsInType() throws JavaModelException { | |
45 | for (IMethod method: type.getMethods()) { | |
46 | analyzeMethod(method); | |
47 | } | |
48 | } | |
49 | ||
50 | private void analyzeMethod(IMethod method) { | |
51 | try { | |
52 | SearchBasedExtractAndMoveMethodAnalyzer analyzer = | |
53 | new SearchBasedExtractAndMoveMethodAnalyzer(method, new FavorNoUnfixesCandidateComparator()); | |
54 | analyzer.generated_8976769988341837625(this); | |
55 | } catch (NoTargetFoundException e) { | |
56 | // Ignoring | |
57 | } catch (AssertionError err) { | |
58 | RefaktorDebug.log(err); | |
59 | } catch (Exception e) { | |
60 | RefaktorDebug.log(e); | |
61 | } | |
62 | } | |
63 | ||
64 | public void generated_6956230269237502630( | |
65 | CompilationUnitWideExtractAndMoveMethodAnalyzer compilationunitwideextractandmovemethodanalyzer) { | |
66 | analyze(); | |
67 | compilationunitwideextractandmovemethodanalyzer.results.addAll(getResults()); | |
68 | } | |
69 | } |