View Javadoc

    1   /********************************************************************************
    2    * Copyright (c) 2004 IBM Corporation and others.
    3    * All rights reserved.   This program and the accompanying materials
    4    * are made available under the terms of the Common Public License v1.0
    5    * which accompanies this distribution, and is available at
    6    * http://www.eclipse.org/legal/cpl-v10.html
    7    *
    8    * Contributors:
    9    * IBM - Initial API and implementation
    10   ******************************************************************************/
    11
    12
    13  package org.codehaus.groovy.classgen;
    14
    15  import java.util.ArrayList;
    16  import java.util.Iterator;
    17  import java.util.List;
    18
    19  import org.codehaus.groovy.ast.ClassNode;
    20  import org.codehaus.groovy.ast.ConstructorNode;
    21  import org.codehaus.groovy.ast.FieldNode;
    22  import org.codehaus.groovy.ast.GroovyClassVisitor;
    23  import org.codehaus.groovy.ast.MethodNode;
    24  import org.codehaus.groovy.ast.PropertyNode;
    25  import org.objectweb.asm.Constants;
    26
    27
    28  /***
    29   * ClassCompletionVerifier
    30   *
    31   */
    32  public class ClassCompletionVerifier implements Constants, GroovyClassVisitor {
    33
    34      ClassNode classNode;
    35
    36      public ClassNode getClassNode() {
    37          return classNode;
    38      }
    39
    40
    41      /* (non-Javadoc)
    42       * @see org.codehaus.groovy.ast.GroovyClassVisitor#visitClass(org.codehaus.groovy.ast.ClassNode)
    43       */
    44      public void visitClass(ClassNode a_node) {
    45          classNode = a_node;
    46          if ((classNode.getModifiers() & Constants.ACC_ABSTRACT) == 0 ) {
    47              List abstractMethods = classNode.getAbstractMethods();
    48              if (abstractMethods != null) {
    49                  List methodNames = new ArrayList();
    50                  for (Iterator iter = abstractMethods.iterator(); iter.hasNext();) {
    51                      MethodNode method = (MethodNode) iter.next();
    52                      String methodName = method.getTypeDescriptor();
    53                      methodNames.add(methodName);
    54                  }
    55                  throw new RuntimeIncompleteClassException(methodNames, classNode);
    56              }
    57          }
    58      }
    59
    60      /* (non-Javadoc)
    61       * @see org.codehaus.groovy.ast.GroovyClassVisitor#visitConstructor(org.codehaus.groovy.ast.ConstructorNode)
    62       */
    63      public void visitConstructor(ConstructorNode a_node) {
    64      }
    65
    66      /* (non-Javadoc)
    67       * @see org.codehaus.groovy.ast.GroovyClassVisitor#visitMethod(org.codehaus.groovy.ast.MethodNode)
    68       */
    69      public void visitMethod(MethodNode a_node) {
    70      }
    71
    72      /* (non-Javadoc)
    73       * @see org.codehaus.groovy.ast.GroovyClassVisitor#visitField(org.codehaus.groovy.ast.FieldNode)
    74       */
    75      public void visitField(FieldNode a_node) {
    76      }
    77
    78      /* (non-Javadoc)
    79       * @see org.codehaus.groovy.ast.GroovyClassVisitor#visitProperty(org.codehaus.groovy.ast.PropertyNode)
    80       */
    81      public void visitProperty(PropertyNode a_node) {
    82      }
    83
    84  }