コード例 #1
0
 public void visitClass(ClassNode node) {
   visitAnnotations(node);
   visitPackage(node.getPackage());
   visitImports(node.getModule());
   node.visitContents(this);
   visitObjectInitializerStatements(node);
 }
コード例 #2
0
 public void visitClass(ClassNode node) {
   AnnotationConstantsVisitor acv = new AnnotationConstantsVisitor();
   acv.visitClass(node, this.source);
   this.currentClass = node;
   if (node.isAnnotationDefinition()) {
     visitAnnotations(node, AnnotationNode.ANNOTATION_TARGET);
   } else {
     visitAnnotations(node, AnnotationNode.TYPE_TARGET);
   }
   PackageNode packageNode = node.getPackage();
   if (packageNode != null) {
     visitAnnotations(packageNode, AnnotationNode.PACKAGE_TARGET);
   }
   node.visitContents(this);
 }
コード例 #3
0
  // GroovyClassVisitor interface
  // -------------------------------------------------------------------------
  public void visitClass(ClassNode classNode) {
    try {
      this.classNode = classNode;
      this.internalClassName = BytecodeHelper.getClassInternalName(classNode);

      // System.out.println("Generating class: " + classNode.getName());

      this.internalBaseClassName = BytecodeHelper.getClassInternalName(classNode.getSuperClass());

      cv.visit(
          Opcodes.V1_3,
          classNode.getModifiers(),
          internalClassName,
          (String) null,
          internalBaseClassName,
          BytecodeHelper.getClassInternalNames(classNode.getInterfaces()));

      classNode.visitContents(this);

      for (Iterator iter = innerClasses.iterator(); iter.hasNext(); ) {
        ClassNode innerClass = (ClassNode) iter.next();
        ClassNode innerClassType = innerClass;
        String innerClassInternalName = BytecodeHelper.getClassInternalName(innerClassType);
        String outerClassName = internalClassName; // default for inner classes
        MethodNode enclosingMethod = innerClass.getEnclosingMethod();
        if (enclosingMethod != null) {
          // local inner classes do not specify the outer class name
          outerClassName = null;
        }
        cv.visitInnerClass(
            innerClassInternalName,
            outerClassName,
            innerClassType.getName(),
            innerClass.getModifiers());
      }
      cv.visitEnd();
    } catch (GroovyRuntimeException e) {
      e.setModule(classNode.getModule());
      throw e;
    }
  }