congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ClassNode.getDeclaredMethods
Code IndexAdd Tabnine to your IDE (free)

How to use
getDeclaredMethods
method
in
org.codehaus.groovy.ast.ClassNode

Best Java code snippets using org.codehaus.groovy.ast.ClassNode.getDeclaredMethods (Showing top 20 results out of 315)

origin: org.codehaus.groovy/groovy

@Override
public List<MethodNode> getDeclaredMethods(final String name) {
  List<MethodNode> nodes = new LinkedList<MethodNode>();
  for (ClassNode delegate : delegates) {
    List<MethodNode> methods = delegate.getDeclaredMethods(name);
    if (methods != null) nodes.addAll(methods);
  }
  return nodes;
}
origin: org.codehaus.groovy/groovy

public static boolean hasDeclaredMethod(ClassNode cNode, String name, int argsCount) {
  List<MethodNode> ms = cNode.getDeclaredMethods(name);
  for (MethodNode m : ms) {
    Parameter[] paras = m.getParameters();
    if (paras != null && paras.length == argsCount) {
      return true;
    }
  }
  return false;
}
origin: org.codehaus.groovy/groovy

@Override
public List<MethodNode> getDeclaredMethods(String name) {
  lazyInitMembers();
  return super.getDeclaredMethods(name);
}
origin: spockframework/spock

public static void deleteMethod(ClassNode clazz, MethodNode method) {
 // as of 1.8.6, this is the best possible implementation
 clazz.getMethods().remove(method);
 clazz.getDeclaredMethods(method.getName()).remove(method);
}
origin: org.codehaus.groovy/groovy

/**
 * This methods creates a list of all methods with this name of the
 * current class and of all super classes
 * @return the methods list
 * @see #getDeclaredMethods(String)
 */
public List<MethodNode> getMethods(String name) {
  List<MethodNode> answer = new ArrayList<MethodNode>();
  ClassNode node = this;
  while (node != null) {
    answer.addAll(node.getDeclaredMethods(name));
    node = node.getSuperClass();
  }
  return answer;
}
origin: org.codehaus.groovy/groovy

/**
 * Finds a method matching the given name and parameters in this class.
 *
 * @return the method matching the given name and parameters or null
 */
public MethodNode getDeclaredMethod(String name, Parameter[] parameters) {
  for (MethodNode method :  getDeclaredMethods(name)) {
    if (parametersEqual(method.getParameters(), parameters)) {
      return method;
    }
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private MethodNode getOrAddStaticConstructorNode() {
  MethodNode method = null;
  List declaredMethods = getDeclaredMethods("<clinit>");
  if (declaredMethods.isEmpty()) {
    method =
        addMethod("<clinit>", ACC_STATIC, ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new BlockStatement());
    method.setSynthetic(true);
  }
  else {
    method = (MethodNode) declaredMethods.get(0);
  }
  return method;
}

origin: org.codehaus.groovy/groovy

/**
 * This methods returns a list of all methods of the given name
 * defined in the current class
 * @return the method list
 * @see #getMethods(String)
 */
public List<MethodNode> getDeclaredMethods(String name) {
  if (redirect!=null) return redirect().getDeclaredMethods(name);
  lazyClassInit();
  return methods.getNotNull(name);
}
origin: org.codehaus.groovy/groovy

public static List<MethodNode> findSetters(ClassNode cn, String setterName, boolean voidOnly) {
  List<MethodNode> result = null;
  for (MethodNode method : cn.getDeclaredMethods(setterName)) {
    if (setterName.equals(method.getName())
        && (!voidOnly || VOID_TYPE == method.getReturnType())
        && method.getParameters().length == 1) {
      if (result == null) {
        result = new LinkedList<MethodNode>();
      }
      result.add(method);
    }
  }
  if (result == null) {
    ClassNode parent = cn.getSuperClass();
    if (parent != null) {
      return findSetters(parent, setterName, voidOnly);
    }
    return Collections.emptyList();
  }
  return result;
}
origin: org.codehaus.groovy/groovy

public MethodNode getSetterMethod(String setterName, boolean voidOnly) {
  for (MethodNode method : getDeclaredMethods(setterName)) {
    if (setterName.equals(method.getName())
        && (!voidOnly || ClassHelper.VOID_TYPE==method.getReturnType())
        && method.getParameters().length == 1) {
      return method;
    }
  }
  ClassNode parent = getSuperClass();
  if (parent!=null) return parent.getSetterMethod(setterName, voidOnly);
  return null;
}
origin: apache/groovy

private static void visit(Closure closure, CodeVisitorSupport visitor) {
  if (closure != null) {
    ClassNode classNode = closure.getMetaClass().getClassNode();
    if (classNode == null) {
      throw new GroovyRuntimeException(
          "DataSet unable to evaluate expression. AST not available for closure: " + closure.getMetaClass().getTheClass().getName() +
              ". Is the source code on the classpath?");
    }
    List methods = classNode.getDeclaredMethods("doCall");
    if (!methods.isEmpty()) {
      MethodNode method = (MethodNode) methods.get(0);
      if (method != null) {
        Statement statement = method.getCode();
        if (statement != null) {
          statement.visit(visitor);
        }
      }
    }
  }
}
origin: org.codehaus.groovy/groovy

public void visitMethod(final MethodNode node) {
  if (visitor!=null) visitor.visitMethod(node);
  ClassNode declaringClass = node.getDeclaringClass();
  if (declaringClass!=null){
    if (StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(declaringClass, ClassHelper.LIST_TYPE)) {
      List<MethodNode> properties = declaringClass.getDeclaredMethods(node.getName());
      boolean spread = true;
      for (MethodNode mn : properties) {
        if (node==mn) {
          spread = false;
          break;
        }
      }
      // it's no real property but a property of the component
      pexp.setSpreadSafe(spread);
    }
    rType.set(declaringClass);
  }
}
origin: org.codehaus.groovy/groovy

private static MethodNode getDeclaredMethodCorrected(Map genericsSpec, MethodNode mn, ClassNode correctedNext) {
  for (MethodNode orig :  correctedNext.getDeclaredMethods(mn.getName())) {
    MethodNode method = correctToGenericsSpec(genericsSpec, orig);
    if (ParameterUtils.parametersEqual(method.getParameters(), mn.getParameters())) {
      return method;
    }
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private static MethodNode getDeclaredMethodCorrected(Map<String, ClassNode> genericsSpec, MethodNode origMethod, ClassNode correctedClass) {
  for (MethodNode nameMatch : correctedClass.getDeclaredMethods(origMethod.getName())) {
    MethodNode correctedMethod = correctToGenericsSpec(genericsSpec, nameMatch);
    if (ParameterUtils.parametersEqual(correctedMethod.getParameters(), origMethod.getParameters())) {
      return correctedMethod;
    }
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private MethodNode getCompatibleMethod(ClassNode current, String getAt, ClassNode aType) {
  // TODO this really should find "best" match or find all matches and complain about ambiguity if more than one
  // TODO handle getAt with more than one parameter
  // TODO handle default getAt methods on Java 8 interfaces
  for (MethodNode methodNode : current.getDeclaredMethods("getAt")) {
    if (methodNode.getParameters().length == 1) {
      ClassNode paramType = methodNode.getParameters()[0].getType();
      if (aType.isDerivedFrom(paramType) || aType.declaresInterface(paramType)) {
        return methodNode;
      }
    }
  }
  return null;
}
origin: org.codehaus.groovy/groovy

@Override
protected ClassNode createClosureClass(final ClosureExpression expression, final int mods) {
  ClassNode closureClass = super.createClosureClass(expression, mods);
  List<MethodNode> methods = closureClass.getDeclaredMethods("call");
  List<MethodNode> doCall = closureClass.getMethods("doCall");
  if (doCall.size() != 1) {
    throw new GroovyBugError("Expected to find one (1) doCall method on generated closure, but found " + doCall.size());
  }
  MethodNode doCallMethod = doCall.get(0);
  if (methods.isEmpty() && doCallMethod.getParameters().length == 1) {
    createDirectCallMethod(closureClass, doCallMethod);
  }
  MethodTargetCompletionVisitor visitor = new MethodTargetCompletionVisitor(doCallMethod);
  Object dynamic = expression.getNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION);
  if (dynamic != null) {
    doCallMethod.putNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION, dynamic);
  }
  for (MethodNode method : methods) {
    visitor.visitMethod(method);
  }
  closureClass.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.TRUE);
  return closureClass;
}
origin: org.codehaus.groovy/groovy

public MethodNode getGetterMethod(String getterName, boolean searchSuperClasses) {
  MethodNode getterMethod = null;
  boolean booleanReturnOnly = getterName.startsWith("is");
  for (MethodNode method : getDeclaredMethods(getterName)) {
    if (getterName.equals(method.getName())
        && ClassHelper.VOID_TYPE!=method.getReturnType()
        && method.getParameters().length == 0
        && (!booleanReturnOnly || ClassHelper.Boolean_TYPE.equals(ClassHelper.getWrapper(method.getReturnType())))) {
      // GROOVY-7363: There can be multiple matches for a getter returning a generic parameter type, due to
      // the generation of a bridge method. The real getter is really the non-bridge, non-synthetic one as it
      // has the most specific and exact return type of the two. Picking the bridge method results in loss of
      // type information, as it down-casts the return type to the lower bound of the generic parameter.
      if (getterMethod == null || getterMethod.isSynthetic()) {
        getterMethod = method;
      }
    }
  }
  if (getterMethod != null) return getterMethod;
  if (searchSuperClasses) {
    ClassNode parent = getSuperClass();
    if (parent != null) return parent.getGetterMethod(getterName);
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private void visitOverride(AnnotatedNode node, AnnotationNode visited) {
  ClassNode annotationClassNode = visited.getClassNode();
  if (annotationClassNode.isResolved() && annotationClassNode.getName().equals("java.lang.Override")) {
    if (node instanceof MethodNode && !Boolean.TRUE.equals(node.getNodeMetaData(Verifier.DEFAULT_PARAMETER_GENERATED))) {
      boolean override = false;
      MethodNode origMethod = (MethodNode) node;
      ClassNode cNode = origMethod.getDeclaringClass();
      if (origMethod.hasDefaultValue()) {
        List<MethodNode> variants = cNode.getDeclaredMethods(origMethod.getName());
        for (MethodNode m : variants) {
          if (m.getAnnotations().contains(visited) && isOverrideMethod(m)) {
            override = true;
            break;
          }
        }
      } else {
        override = isOverrideMethod(origMethod);
      }
      if (!override) {
        addError("Method '" + origMethod.getName() + "' from class '" + cNode.getName() + "' does not override " +
            "method from its superclass or interfaces but is annotated with @Override.", visited);
      }
    }
  }
}
origin: org.codehaus.groovy/groovy-all-minimal

/**
 * This methods creates a list of all methods with this name of the
 * current class and of all super classes
 * @return the methods list
 * @see #getDeclaredMethods(String)
 */
public List getMethods(String name) {
  List answer = new ArrayList(getDeclaredMethods(name));
  ClassNode parent = getSuperClass();
  if (parent!=null) answer.addAll(parent.getMethods(name));
  return answer;
}
origin: org.codehaus.groovy/groovy-all-minimal

/**
 * This methods returns a list of all methods of the given name
 * defined in the current class
 * @return the method list
 * @see #getMethods(String)
 */
public List getDeclaredMethods(String name) {
  if (!redirect().lazyInitDone) redirect().lazyClassInit();
  if (redirect!=null) return redirect().getDeclaredMethods(name);
  return methods.getNotNull(name);
}
org.codehaus.groovy.astClassNodegetDeclaredMethods

Javadoc

This methods returns a list of all methods of the given name defined in the current class

Popular methods of ClassNode

  • getName
  • getMethods
    This methods creates a list of all methods with this name of the current class and of all super clas
  • <init>
    Constructor used by makeArray() if no real class is available
  • getSuperClass
  • equals
  • addMethod
  • getAnnotations
  • addField
  • getFields
    Returns a list containing FieldNode objects for each field in the class represented by this ClassNod
  • getPlainNodeReference
  • getField
    Finds a field matching the given name in this class or a parent class.
  • getMethod
    Finds a method matching the given name and parameters in this class or any parent class.
  • getField,
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • getResourceAsStream (ClassLoader)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Notification (javax.management)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now