コード例 #1
0
 private Expression findStaticField(ClassNode staticImportType, String fieldName) {
   if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
     FieldNode field = staticImportType.getField(fieldName);
     if (field != null && field.isStatic())
       return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
   }
   return null;
 }
コード例 #2
0
 private Expression findStaticMethod(
     ClassNode staticImportType, String methodName, Expression args) {
   if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
     if (staticImportType.hasPossibleStaticMethod(methodName, args)) {
       return new StaticMethodCallExpression(staticImportType, methodName, args);
     }
   }
   return null;
 }
コード例 #3
0
  /**
   * Returns the concrete class this classnode relates to. However, this method is inherently unsafe
   * as it may return null depending on the compile phase you are using. AST transformations should
   * never use this method directly, but rather obtain a new class node using {@link
   * #getPlainNodeReference()}.
   *
   * @return the class this classnode relates to. May return null.
   */
  public Class getTypeClass() {
    if (clazz != null) return clazz;
    if (redirect != null) return redirect.getTypeClass();

    ClassNode component = redirect().componentType;
    if (component != null && component.isResolved()) {
      return Array.newInstance(component.getTypeClass(), 0).getClass();
    }
    throw new GroovyBugError(
        "ClassNode#getTypeClass for " + getName() + " is called before the type class is set ");
  }
コード例 #4
0
 public boolean isResolved() {
   if (clazz != null) return true;
   if (redirect != null) return redirect.isResolved();
   return componentType != null && componentType.isResolved();
 }