1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
123 if ( tm instanceof DeclaredType ) |
123 if ( tm instanceof DeclaredType ) |
124 annotationTypeElement = (DeclaredType) a.asType(); |
124 annotationTypeElement = (DeclaredType) a.asType(); |
125 else |
125 else |
126 throw new AssertionError("Bad implementation type for " + tm); |
126 throw new AssertionError("Bad implementation type for " + tm); |
127 |
127 |
128 ElementScanner7<Set<Element>, DeclaredType> scanner = |
128 ElementScanner8<Set<Element>, DeclaredType> scanner = |
129 new AnnotationSetScanner(result, typeUtil); |
129 new AnnotationSetScanner(result, typeUtil); |
130 |
130 |
131 for (Element element : rootElements) |
131 for (Element element : rootElements) |
132 result = scanner.scan(element, annotationTypeElement); |
132 result = scanner.scan(element, annotationTypeElement); |
133 |
133 |
134 return result; |
134 return result; |
135 } |
135 } |
136 |
136 |
137 // Could be written as a local class inside getElementsAnnotatedWith |
137 // Could be written as a local class inside getElementsAnnotatedWith |
138 private class AnnotationSetScanner extends |
138 private class AnnotationSetScanner extends |
139 ElementScanner7<Set<Element>, DeclaredType> { |
139 ElementScanner8<Set<Element>, DeclaredType> { |
140 // Insertion-order preserving set |
140 // Insertion-order preserving set |
141 Set<Element> annotatedElements = new LinkedHashSet<Element>(); |
141 Set<Element> annotatedElements = new LinkedHashSet<Element>(); |
142 Types typeUtil; |
142 Types typeUtil; |
143 |
143 |
144 AnnotationSetScanner(Set<Element> defaultSet, Types typeUtil) { |
144 AnnotationSetScanner(Set<Element> defaultSet, Types typeUtil) { |