类 AstUtils


  • public abstract class AstUtils
    extends Object
    General purpose AST utilities.
    • 构造器概要

      构造器 
      构造器说明
      AstUtils() 
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型方法说明
      static org.codehaus.groovy.ast.expr.ClosureExpressiongetClosure​(org.codehaus.groovy.ast.stmt.BlockStatement block, String name) 
      static org.codehaus.groovy.ast.expr.ClosureExpressiongetClosure​(org.codehaus.groovy.ast.stmt.BlockStatement block, String name, boolean remove)
      Extract a top-level name closure from inside this block if there is one, optionally removing it from the block at the same time.
      static booleanhasAtLeastOneAnnotation​(org.codehaus.groovy.ast.AnnotatedNode node, String... annotations)
      Determine if an AnnotatedNode has one or more of the specified annotations.
      static booleanhasAtLeastOneAnnotation​(org.codehaus.groovy.ast.ClassNode node, String... annotations)
      Determine if a ClassNode has one or more of the specified annotations on the class or any of its methods.
      static booleanhasAtLeastOneFieldOrMethod​(org.codehaus.groovy.ast.ClassNode node, String... types)
      Determine if a ClassNode has one or more fields of the specified types or method returning one or more of the specified types.
      static booleanhasAtLeastOneInterface​(org.codehaus.groovy.ast.ClassNode classNode, String... types) 
      static booleansubclasses​(org.codehaus.groovy.ast.ClassNode node, String... types)
      Determine if a ClassNode subclasses any of the specified types N.B. the type names are not normally fully qualified.
    • 构造器详细资料

    • 方法详细资料

      • hasAtLeastOneAnnotation

        public static boolean hasAtLeastOneAnnotation​(org.codehaus.groovy.ast.ClassNode node,
                                                      String... annotations)
        Determine if a ClassNode has one or more of the specified annotations on the class or any of its methods. N.B. the type names are not normally fully qualified.
        参数:
        node - the class to examine
        annotations - the annotations to look for
        返回:
        true if at least one of the annotations is found, otherwise false
      • hasAtLeastOneAnnotation

        public static boolean hasAtLeastOneAnnotation​(org.codehaus.groovy.ast.AnnotatedNode node,
                                                      String... annotations)
        Determine if an AnnotatedNode has one or more of the specified annotations. N.B. the annotation type names are not normally fully qualified.
        参数:
        node - the node to examine
        annotations - the annotations to look for
        返回:
        true if at least one of the annotations is found, otherwise false
      • hasAtLeastOneFieldOrMethod

        public static boolean hasAtLeastOneFieldOrMethod​(org.codehaus.groovy.ast.ClassNode node,
                                                         String... types)
        Determine if a ClassNode has one or more fields of the specified types or method returning one or more of the specified types. N.B. the type names are not normally fully qualified.
        参数:
        node - the class to examine
        types - the types to look for
        返回:
        true if at least one of the types is found, otherwise false
      • subclasses

        public static boolean subclasses​(org.codehaus.groovy.ast.ClassNode node,
                                         String... types)
        Determine if a ClassNode subclasses any of the specified types N.B. the type names are not normally fully qualified.
        参数:
        node - the class to examine
        types - the types that may have been sub-classed
        返回:
        true if the class subclasses any of the specified types, otherwise false
      • getClosure

        public static org.codehaus.groovy.ast.expr.ClosureExpression getClosure​(org.codehaus.groovy.ast.stmt.BlockStatement block,
                                                                                String name,
                                                                                boolean remove)
        Extract a top-level name closure from inside this block if there is one, optionally removing it from the block at the same time.
        参数:
        block - a block statement (class definition)
        name - the name to look for
        remove - whether or not the extracted closure should be removed
        返回:
        a beans Closure if one can be found, null otherwise
      • getClosure

        public static org.codehaus.groovy.ast.expr.ClosureExpression getClosure​(org.codehaus.groovy.ast.stmt.BlockStatement block,
                                                                                String name)