28 import com.sun.source.tree.CompilationUnitTree; |
28 import com.sun.source.tree.CompilationUnitTree; |
29 import com.sun.source.util.TreePath; |
29 import com.sun.source.util.TreePath; |
30 import com.sun.source.util.Trees; |
30 import com.sun.source.util.Trees; |
31 import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
31 import com.sun.xml.internal.bind.v2.model.nav.Navigator; |
32 import com.sun.xml.internal.bind.v2.runtime.Location; |
32 import com.sun.xml.internal.bind.v2.runtime.Location; |
33 |
33 import java.lang.annotation.Annotation; |
|
34 import java.util.ArrayList; |
|
35 import java.util.Collection; |
|
36 import java.util.HashMap; |
|
37 import java.util.List; |
|
38 import java.util.Map; |
34 import javax.annotation.processing.ProcessingEnvironment; |
39 import javax.annotation.processing.ProcessingEnvironment; |
35 import javax.lang.model.element.AnnotationMirror; |
40 import javax.lang.model.element.AnnotationMirror; |
36 import javax.lang.model.element.Element; |
41 import javax.lang.model.element.Element; |
37 import javax.lang.model.element.ElementKind; |
42 import javax.lang.model.element.ElementKind; |
38 import javax.lang.model.element.ExecutableElement; |
43 import javax.lang.model.element.ExecutableElement; |
50 import javax.lang.model.type.WildcardType; |
55 import javax.lang.model.type.WildcardType; |
51 import javax.lang.model.util.ElementFilter; |
56 import javax.lang.model.util.ElementFilter; |
52 import javax.lang.model.util.Elements; |
57 import javax.lang.model.util.Elements; |
53 import javax.lang.model.util.SimpleTypeVisitor6; |
58 import javax.lang.model.util.SimpleTypeVisitor6; |
54 import javax.lang.model.util.Types; |
59 import javax.lang.model.util.Types; |
55 import java.lang.annotation.Annotation; |
|
56 import java.util.Collection; |
|
57 import java.util.HashMap; |
|
58 import java.util.HashSet; |
|
59 import java.util.List; |
|
60 import java.util.Map; |
|
61 |
60 |
62 /** |
61 /** |
63 * {@link Navigator} implementation for annotation processing. |
62 * {@link Navigator} implementation for annotation processing. |
64 * TODO: check the spec on how generics are supposed to be handled |
63 * TODO: check the spec on how generics are supposed to be handled |
65 * |
64 * |
239 return hasModifier(clazz, Modifier.FINAL); |
238 return hasModifier(clazz, Modifier.FINAL); |
240 } |
239 } |
241 |
240 |
242 public VariableElement[] getEnumConstants(TypeElement clazz) { |
241 public VariableElement[] getEnumConstants(TypeElement clazz) { |
243 List<? extends Element> elements = env.getElementUtils().getAllMembers(clazz); |
242 List<? extends Element> elements = env.getElementUtils().getAllMembers(clazz); |
244 Collection<VariableElement> constants = new HashSet<VariableElement>(); |
243 Collection<VariableElement> constants = new ArrayList<VariableElement>(); |
245 for (Element element : elements) { |
244 for (Element element : elements) { |
246 if (element.getKind().equals(ElementKind.ENUM_CONSTANT)) { |
245 if (element.getKind().equals(ElementKind.ENUM_CONSTANT)) { |
247 constants.add((VariableElement) element); |
246 constants.add((VariableElement) element); |
248 } |
247 } |
249 } |
248 } |