112 public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) { |
112 public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) { |
113 Set<Element> result = Collections.emptySet(); |
113 Set<Element> result = Collections.emptySet(); |
114 if (a.getKind() != ElementKind.ANNOTATION_TYPE) |
114 if (a.getKind() != ElementKind.ANNOTATION_TYPE) |
115 throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a); |
115 throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a); |
116 |
116 |
117 ElementScanner8<Set<Element>, TypeElement> scanner = |
117 ElementScanner9<Set<Element>, TypeElement> scanner = |
118 new AnnotationSetScanner(result); |
118 new AnnotationSetScanner(result); |
119 |
119 |
120 for (Element element : rootElements) |
120 for (Element element : rootElements) |
121 result = scanner.scan(element, a); |
121 result = scanner.scan(element, a); |
122 |
122 |
123 return result; |
123 return result; |
124 } |
124 } |
125 |
125 |
126 // Could be written as a local class inside getElementsAnnotatedWith |
126 // Could be written as a local class inside getElementsAnnotatedWith |
127 private class AnnotationSetScanner extends |
127 private class AnnotationSetScanner extends |
128 ElementScanner8<Set<Element>, TypeElement> { |
128 ElementScanner9<Set<Element>, TypeElement> { |
129 // Insertion-order preserving set |
129 // Insertion-order preserving set |
130 Set<Element> annotatedElements = new LinkedHashSet<>(); |
130 Set<Element> annotatedElements = new LinkedHashSet<>(); |
131 |
131 |
132 AnnotationSetScanner(Set<Element> defaultSet) { |
132 AnnotationSetScanner(Set<Element> defaultSet) { |
133 super(defaultSet); |
133 super(defaultSet); |