Codota Logo
ClassNode.getDeclaredMethod
Code IndexAdd Codota to your IDE (free)

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

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

  • Common ways to obtain ClassNode
private void myMethod () {
ClassNode c =
  • Codota IconExpression expression;expression.getType()
  • Codota IconMethodNode methodNode;methodNode.getReturnType()
  • Codota IconString name;ClassHelper.make(name)
  • Smart code suggestions by Codota
}
origin: org.codehaus.groovy/groovy

/**
 * @see #getDeclaredMethod(String, Parameter[])
 */
public boolean hasDeclaredMethod(String name, Parameter[] parameters) {
  MethodNode other = getDeclaredMethod(name, parameters);
  return other != null;
}
origin: org.codehaus.groovy/groovy

@Override
public MethodNode getDeclaredMethod(final String name, final Parameter[] parameters) {
  for (ClassNode delegate : delegates) {
    MethodNode node = delegate.getDeclaredMethod(name, parameters);
    if (node != null) return node;
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private static MethodNode findExistingMethod(final ClassNode cNode, final String name, final Parameter[] params) {
  return cNode.getDeclaredMethod(name, params);
}
origin: org.codehaus.groovy/groovy

/**
 * If a method with the given name and parameters is already defined then it is returned
 * otherwise the given method is added to this node. This method is useful for
 * default method adding like getProperty() or invokeMethod() where there may already
 * be a method defined in a class and so the default implementations should not be added
 * if already present.
 */
public MethodNode addMethod(String name,
              int modifiers,
              ClassNode returnType,
              Parameter[] parameters,
              ClassNode[] exceptions,
              Statement code) {
  MethodNode other = getDeclaredMethod(name, parameters);
  // let's not add duplicate methods
  if (other != null) {
    return other;
  }
  MethodNode node = new MethodNode(name, modifiers, returnType, parameters, exceptions, code);
  addMethod(node);
  return node;
}
origin: org.codehaus.groovy/groovy

/**
 * Creates, if necessary, a super forwarder method, for stackable traits.
 * @param forwarder a forwarder method
 * @param genericsSpec
 */
private static void createSuperForwarder(ClassNode targetNode, MethodNode forwarder, final Map<String,ClassNode> genericsSpec) {
  List<ClassNode> interfaces = new ArrayList<ClassNode>(Traits.collectAllInterfacesReverseOrder(targetNode, new LinkedHashSet<ClassNode>()));
  String name = forwarder.getName();
  Parameter[] forwarderParameters = forwarder.getParameters();
  LinkedHashSet<ClassNode> traits = new LinkedHashSet<ClassNode>();
  List<MethodNode> superForwarders = new LinkedList<MethodNode>();
  for (ClassNode node : interfaces) {
    if (Traits.isTrait(node)) {
      MethodNode method = node.getDeclaredMethod(name, forwarderParameters);
      if (method!=null) {
        // a similar method exists, we need a super bridge
        // trait$super$foo(Class currentTrait, ...)
        traits.add(node);
        superForwarders.add(method);
      }
    }
  }
  for (MethodNode superForwarder : superForwarders) {
    doCreateSuperForwarder(targetNode, superForwarder, traits.toArray(ClassNode.EMPTY_ARRAY), genericsSpec);
  }
}
origin: groovy/groovy-core

private void transformRunMethod(final ClassNode classNode, final SourceUnit source) {
  MethodNode runMethod = classNode.getDeclaredMethod("run", Parameter.EMPTY_ARRAY);
  Statement code = runMethod.getCode();
  MarkupBuilderCodeTransformer transformer = new MarkupBuilderCodeTransformer(source, classNode, config.isAutoEscape());
  code.visit(transformer);
}
origin: org.codehaus.groovy/groovy

@Override
protected boolean makeDirectCall(final Expression origin, final Expression receiver, final Expression message, final Expression arguments, final MethodCallerMultiAdapter adapter, final boolean implicitThis, final boolean containsSpreadExpression) {
  if (origin instanceof MethodCallExpression &&
      receiver instanceof VariableExpression &&
      ((VariableExpression) receiver).isSuperExpression()) {
    ClassNode superClass = receiver.getNodeMetaData(StaticCompilationMetadataKeys.PROPERTY_OWNER);
    if (superClass!=null && !controller.getCompileStack().isLHS()) {
      // GROOVY-7300
      MethodCallExpression mce = (MethodCallExpression) origin;
      MethodNode node = superClass.getDeclaredMethod(mce.getMethodAsString(), Parameter.EMPTY_ARRAY);
      mce.setMethodTarget(node);
    }
  }
  return super.makeDirectCall(origin, receiver, message, arguments, adapter, implicitThis, containsSpreadExpression);
}
origin: org.codehaus.groovy/groovy

private static boolean hasUsableImplementation(ClassNode c, MethodNode m) {
  if (c == m.getDeclaringClass()) return false;
  MethodNode found = c.getDeclaredMethod(m.getName(), m.getParameters());
  if (found == null) return false;
  int asp = found.getModifiers() & ABSTRACT_STATIC_PRIVATE;
  int visible = found.getModifiers() & VISIBILITY;
  if (visible != 0 && asp == 0) return true;
  if (c.equals(OBJECT_TYPE)) return false;
  return hasUsableImplementation(c.getSuperClass(), m);
}
origin: org.codehaus.groovy/groovy

MethodNode getAtNode = null;
while (current!=null && getAtNode==null) {
  getAtNode = current.getDeclaredMethod("getAt", new Parameter[]{new Parameter(aType, "index")});
  if (getAtNode == null) {
    getAtNode = getCompatibleMethod(current, "getAt", aType);
    getAtNode = current.getDeclaredMethod("getAt", new Parameter[]{new Parameter(getWrapper(aType), "index")});
    if (getAtNode == null) {
      getAtNode = getCompatibleMethod(current, "getAt", getWrapper(aType));
    getAtNode = current.getDeclaredMethod("getAt", new Parameter[]{new Parameter(getUnwrapper(aType), "index")});
    if (getAtNode == null) {
      getAtNode = getCompatibleMethod(current, "getAt", getUnwrapper(aType));
origin: org.codehaus.groovy/groovy

if (OBJECT_TYPE.getDeclaredMethod(mi.getName(), mi.getParameters()) != null) continue;
origin: org.codehaus.groovy/groovy

  params[i] = new Parameter(argumentTypes[i-1], "p" + i);
MethodNode method = helper.getDeclaredMethod(name, params);
if (method != null) {
  return Collections.singletonList(makeDynamic(call, method.getReturnType()));
origin: org.codehaus.groovy/groovy

final ClassNode next = i < interfacesToGenerateForwarderFor.length - 1 ? interfacesToGenerateForwarderFor[i + 1] : null;
String forwarderName = Traits.getSuperTraitMethodName(current, forwarderMethod.getName());
if (targetNode.getDeclaredMethod(forwarderName, superForwarderParams) == null) {
  ClassNode returnType = correctToGenericsSpecRecurse(genericsSpec, forwarderMethod.getReturnType());
  Statement delegate = next == null ? createSuperFallback(forwarderMethod, returnType) : createDelegatingForwarder(forwarderMethod, next);
origin: org.codehaus.groovy/groovy

MethodNode clinit = annotatedClass.getDeclaredMethod("<clinit>", noparams);
if (clinit == null) {
  clinit = annotatedClass.addMethod("<clinit>", ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, ClassHelper.VOID_TYPE, noparams, null, new BlockStatement());
origin: remkop/picocli

MethodNode defaultMethod = cNode.getDeclaredMethod("run", Parameter.EMPTY_ARRAY);
origin: org.codehaus.groovy/groovy

MethodNode defaultMethod = cNode.getDeclaredMethod("run", Parameter.EMPTY_ARRAY);
origin: org.codehaus.groovy/groovy

  newMethod.addAnnotations(annotations);
MethodNode oldMethod = node.getDeclaredMethod(method.getName(), newParams);
if (oldMethod != null) {
  throw new RuntimeParserException(
origin: org.gcontracts/gcontracts-core

/**
 * @param classNode the {@link org.codehaus.groovy.ast.ClassNode} used to look up the invariant closure field
 *
 * @return the {@link org.codehaus.groovy.ast.MethodNode} which contains the invariant of the given <tt>classNode</tt>
 */
public static MethodNode getInvariantMethodNode(final ClassNode classNode)  {
  return classNode.getDeclaredMethod(getInvariantMethodName(classNode), Parameter.EMPTY_ARRAY);
}
origin: org.grails/grails-plugin-testing

  protected void autoAnnotateSetupTeardown(ClassNode classNode) {
    MethodNode setupMethod = classNode.getDeclaredMethod(SET_UP_METHOD, GrailsArtefactClassInjector.ZERO_PARAMETERS);
    if ( setupMethod != null && setupMethod.getAnnotations(TestForTransformation.BEFORE_CLASS_NODE).size() == 0) {
      setupMethod.addAnnotation(TestForTransformation.BEFORE_ANNOTATION);
    }

    MethodNode tearDown = classNode.getDeclaredMethod(TEAR_DOWN_METHOD, GrailsArtefactClassInjector.ZERO_PARAMETERS);
    if ( tearDown != null && tearDown.getAnnotations(TestForTransformation.AFTER_CLASS_NODE).size() == 0) {
      tearDown.addAnnotation(TestForTransformation.AFTER_ANNOTATION);
    }
  }
}
origin: org.codehaus.griffon/griffon-groovy-compile

/**
 * Tests whether the ClasNode implements the specified method name.
 *
 * @param classNode  The ClassNode
 * @param methodName The method name
 *
 * @return True if it does implement the method
 */
public static boolean implementsZeroArgMethod(ClassNode classNode, String methodName) {
  MethodNode method = classNode.getDeclaredMethod(methodName, new Parameter[]{});
  return method != null && (method.isPublic() || method.isProtected()) && !method.isAbstract();
}
origin: org.codehaus.groovy/groovy-templates

private void transformRunMethod(final ClassNode classNode, final SourceUnit source) {
  MethodNode runMethod = classNode.getDeclaredMethod("run", Parameter.EMPTY_ARRAY);
  Statement code = runMethod.getCode();
  MarkupBuilderCodeTransformer transformer = new MarkupBuilderCodeTransformer(source, classNode, config.isAutoEscape());
  code.visit(transformer);
}
org.codehaus.groovy.astClassNodegetDeclaredMethod

Javadoc

Finds a method matching the given name and parameters in this 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,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • startActivity (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now