Example #1
0
  public void visit(EnumDeclaration n, Object arg) {
    if (n.getJavaDoc() != null) {
      n.getJavaDoc().accept(this, arg);
    }
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    if (n.getImplements() != null) {
      for (Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        if (i.hasNext()) {}
      }
    }

    if (n.getEntries() != null) {
      for (Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext(); ) {
        EnumConstantDeclaration e = i.next();
        e.accept(this, arg);
        if (i.hasNext()) {}
      }
    }
    if (n.getMembers() != null) {
      printMembers(n.getMembers(), arg);
    } else {
      if (n.getEntries() != null) {}
    }
  }
 public void visit(TypeParameter n, A arg) {
   if (n.getTypeBound() != null) {
     for (ClassOrInterfaceType c : n.getTypeBound()) {
       c.accept(this, arg);
     }
   }
 }
 public void visit(EnumDeclaration n, A arg) {
   if (n.getJavaDoc() != null) {
     n.getJavaDoc().accept(this, arg);
   }
   if (n.getAnnotations() != null) {
     for (AnnotationExpr a : n.getAnnotations()) {
       a.accept(this, arg);
     }
   }
   if (n.getImplements() != null) {
     for (ClassOrInterfaceType c : n.getImplements()) {
       c.accept(this, arg);
     }
   }
   if (n.getEntries() != null) {
     for (EnumConstantDeclaration e : n.getEntries()) {
       e.accept(this, arg);
     }
   }
   if (n.getMembers() != null) {
     for (BodyDeclaration member : n.getMembers()) {
       member.accept(this, arg);
     }
   }
 }
  public void visit(ClassOrInterfaceDeclaration n, A arg) {
    if (n.getJavaDoc() != null) {
      n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
      for (AnnotationExpr a : n.getAnnotations()) {
        a.accept(this, arg);
      }
    }
    if (n.getTypeParameters() != null) {
      for (TypeParameter t : n.getTypeParameters()) {
        t.accept(this, arg);
      }
    }
    if (n.getExtends() != null) {
      for (ClassOrInterfaceType c : n.getExtends()) {
        c.accept(this, arg);
      }
    }

    if (n.getImplements() != null) {
      for (ClassOrInterfaceType c : n.getImplements()) {
        c.accept(this, arg);
      }
    }
    if (n.getMembers() != null) {
      for (BodyDeclaration member : n.getMembers()) {
        member.accept(this, arg);
      }
    }
  }
Example #5
0
 public void visit(TypeParameter n, Object arg) {
   if (n.getTypeBound() != null) {
     for (Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext(); ) {
       ClassOrInterfaceType c = i.next();
       c.accept(this, arg);
       if (i.hasNext()) {}
     }
   }
 }
 private String getName(ClassOrInterfaceType type) {
   final String name = type.getName();
   final ClassOrInterfaceType scope = type.getScope();
   if (scope == null) {
     return name;
   } else {
     return getName(scope) + "." + name;
   }
 }
 public void visit(ClassOrInterfaceType n, A arg) {
   if (n.getScope() != null) {
     n.getScope().accept(this, arg);
   }
   if (n.getTypeArgs() != null) {
     for (Type t : n.getTypeArgs()) {
       t.accept(this, arg);
     }
   }
 }
Example #8
0
  public void visit(ClassOrInterfaceDeclaration n, Object arg) {
    if (n.getJavaDoc() != null) {
      n.getJavaDoc().accept(this, arg);
    }
    printMemberAnnotations(n.getAnnotations(), arg);
    printModifiers(n.getModifiers());

    if (n.isInterface()) {
    } else {
    }

    printTypeParameters(n.getTypeParameters(), arg);

    Scope currentScope = (Scope) n.getData();
    ClassSymbol currentClass = (ClassSymbol) currentScope.resolve(n.getName());
    if (n.getExtends() != null) {
      for (Iterator<ClassOrInterfaceType> i = n.getExtends().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        ClassSymbol parentClass = (ClassSymbol) currentScope.resolve((c.getName()));
        currentClass.setInheritedScope(parentClass);

        if (i.hasNext()) {}
      }
    }

    if (n.getImplements() != null) {
      for (Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) {
        ClassOrInterfaceType c = i.next();
        c.accept(this, arg);
        if (i.hasNext()) {}
      }
    }

    if (n.getMembers() != null) {
      printMembers(n.getMembers(), arg);
    }
  }
 @Override
 public JType visit(ClassOrInterfaceType type, JCodeModel codeModel) {
   final String name = getName(type);
   final JClass knownClass = this.knownClasses.get(name);
   final JClass jclass = knownClass != null ? knownClass : codeModel.ref(name);
   final List<Type> typeArgs = type.getTypeArgs();
   if (typeArgs == null || typeArgs.isEmpty()) {
     return jclass;
   } else {
     final List<JClass> jtypeArgs = new ArrayList<JClass>(typeArgs.size());
     for (Type typeArg : typeArgs) {
       final JType jtype = typeArg.accept(this, codeModel);
       if (!(jtype instanceof JClass)) {
         throw new IllegalArgumentException(
             "Type argument [" + typeArg.toString() + "] is not a class.");
       } else {
         jtypeArgs.add((JClass) jtype);
       }
     }
     return jclass.narrow(jtypeArgs);
   }
 }
Example #10
0
 public void visit(ClassOrInterfaceType n, Object arg) {
   if (n.getScope() != null) {
     n.getScope().accept(this, arg);
   }
   printTypeArgs(n.getTypeArgs(), arg);
 }