private List<TypeSymbol> resolveInterfaces(
     final JavacNode annotationNode,
     final Class<? extends java.lang.annotation.Annotation> annotationType,
     final List<Object> listenerInterfaces) {
   List<TypeSymbol> resolvedInterfaces = new ArrayList<TypeSymbol>();
   for (Object listenerInterface : listenerInterfaces) {
     if (listenerInterface instanceof JCFieldAccess) {
       JCFieldAccess interfaze = (JCFieldAccess) listenerInterface;
       if ("class".equals(As.string(interfaze.name))) {
         Type interfaceType = CLASS.resolveMember(annotationNode, interfaze.selected);
         if (interfaceType == null) continue;
         if (interfaceType.isInterface()) {
           TypeSymbol interfaceSymbol = interfaceType.asElement();
           if (interfaceSymbol != null) resolvedInterfaces.add(interfaceSymbol);
         } else {
           annotationNode.addWarning(
               String.format(
                   "@%s works only with interfaces. %s was skipped",
                   annotationType.getName(), listenerInterface));
         }
       }
     }
   }
   return resolvedInterfaces;
 }
Beispiel #2
0
 public Element asElement(TypeMirror t) {
   switch (t.getKind()) {
     case DECLARED:
     case ERROR:
     case TYPEVAR:
       Type type = cast(Type.class, t);
       return type.asElement();
     default:
       return null;
   }
 }
Beispiel #3
0
 public Element asElement(TypeMirror t) {
   Type type = cast(Type.class, t);
   switch (type.tag) {
     case TypeTags.CLASS:
     case TypeTags.ERROR:
     case TypeTags.TYPEVAR:
       return type.asElement();
     default:
       return null;
   }
 }
 private void addAllFireListenerMethods(
     final JavacType type, final TypeSymbol interfaze, final TypeSymbol superInterfaze) {
   for (Symbol member : superInterfaze.getEnclosedElements()) {
     if (member.getKind() != ElementKind.METHOD) continue;
     handler.addFireListenerMethod(type, interfaze, (MethodSymbol) member);
   }
   ClassType superInterfazeType = (ClassType) superInterfaze.type;
   if (superInterfazeType.interfaces_field != null)
     for (Type iface : superInterfazeType.interfaces_field) {
       addAllFireListenerMethods(type, interfaze, iface.asElement());
     }
 }