| 1 | package dolda.jglob; |
| 2 | |
| 3 | import java.util.*; |
| 4 | import javax.lang.model.element.*; |
| 5 | import javax.lang.model.util.*; |
| 6 | |
| 7 | public class TypeMap { |
| 8 | private final Map<String, TypeElement> types; |
| 9 | |
| 10 | public TypeMap(Collection<? extends Element> roots, final Elements eu) { |
| 11 | final Map<String, TypeElement> types = new HashMap<String, TypeElement>(); |
| 12 | ElementVisitor<Void, Void> v = new ElementScanner6<Void, Void>() { |
| 13 | public Void visitType(TypeElement el, Void p) { |
| 14 | if((types.put(eu.getBinaryName(el).toString(), el)) != null) |
| 15 | throw(new RuntimeException("type name conflict: " + eu.getBinaryName(el))); |
| 16 | return(super.visitType(el, p)); |
| 17 | } |
| 18 | }; |
| 19 | for(Element el : roots) |
| 20 | v.visit(el); |
| 21 | this.types = types; |
| 22 | } |
| 23 | |
| 24 | public TypeElement get(String name) { |
| 25 | return(types.get(name)); |
| 26 | } |
| 27 | } |