org.codehaus.groovy.ast.ClassNode.hasPossibleMethod()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.codehaus.groovy.ast.ClassNode.hasPossibleMethod()方法的一些代码示例,展示了ClassNode.hasPossibleMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassNode.hasPossibleMethod()方法的具体详情如下:
包路径:org.codehaus.groovy.ast.ClassNode
类名称:ClassNode
方法名:hasPossibleMethod

ClassNode.hasPossibleMethod介绍

[英]Returns true if the given method has a possibly matching instance method with the given name and arguments.
[中]如果给定方法具有可能与给定名称和参数匹配的实例方法,则返回true。

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy

protected boolean isClosureCall(final String name, final Expression objectExpression, final Expression arguments) {
  if (objectExpression instanceof ClosureExpression && ("call".equals(name) || "doCall".equals(name)))
    return true;
  if (objectExpression == VariableExpression.THIS_EXPRESSION) {
    FieldNode fieldNode = typeCheckingContext.getEnclosingClassNode().getDeclaredField(name);
    if (fieldNode != null) {
      ClassNode type = fieldNode.getType();
      if (CLOSURE_TYPE.equals(type) && !typeCheckingContext.getEnclosingClassNode().hasPossibleMethod(name, arguments)) {
        return true;
      }
    }
  } else {
    if (!"call".equals(name) && !"doCall".equals(name)) return false;
  }
  return (getType(objectExpression).equals(CLOSURE_TYPE));
}

代码示例来源:origin: org.codehaus.groovy/groovy

private boolean isClosureCall(MethodCallExpression call) {
  // are we a local variable?
  // it should not be an explicitly "this" qualified method call
  // and the current class should have a possible method
  ClassNode classNode = controller.getClassNode();
  String methodName = call.getMethodAsString();
  if (methodName==null) return false;
  if (!call.isImplicitThis()) return false;
  if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false;
  FieldNode field = classNode.getDeclaredField(methodName);
  if (field == null) return false;
  if (isStaticInvocation(call) && !field.isStatic()) return false;
  Expression arguments = call.getArguments();
  return ! classNode.hasPossibleMethod(methodName, arguments);
}

代码示例来源:origin: org.codehaus.groovy/groovy

leftFieldName = ((PropertyExpression) leftExpression).getPropertyAsString();
FieldNode fn = tryGetFieldNode(weavedType, leftFieldName);
if (fieldHelper == null || fn == null && !fieldHelper.hasPossibleMethod(Traits.helperSetterName(new FieldNode(leftFieldName, 0, ClassHelper.OBJECT_TYPE, weavedType, null)), rightExpression)) {
  return createAssignmentToField(rightExpression, operation, leftFieldName);

代码示例来源:origin: org.codehaus.groovy/groovy

boolean inInnerClass = isInnerClass(currentClass);
if (currentMethod != null && !currentMethod.isStatic()) {
  if (currentClass.hasPossibleMethod(methodName, args)) {
    foundInstanceMethod = true;
  if (currentClass.getOuterClass().hasPossibleMethod(methodName, args)) {
    object = new PropertyExpression(new ClassExpression(currentClass.getOuterClass()), new ConstantExpression("this"));
  } else if (hasPossibleStaticMethod(currentClass.getOuterClass(), methodName, args, true)

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

private boolean isClosureCall(MethodCallExpression call) {
  // are we a local variable?
  // it should not be an explicitly "this" qualified method call
  // and the current class should have a possible method
  String methodName = call.getMethodAsString();
  if (methodName==null) return false;
  if (!call.isImplicitThis()) return false;
  if (!isThisExpression(call.getObjectExpression())) return false;
  //if (isNotExplicitThisInClosure(call.isImplicitThis()) return false;
  if (classNode.getDeclaredField(methodName) == null) return false;
  Expression arguments = call.getArguments();
  return ! classNode.hasPossibleMethod(methodName, arguments);
}

代码示例来源:origin: org.kohsuke.droovy/groovy

private boolean isClosureCall(MethodCallExpression call) {
  // are we a local variable?
  // it should not be an explicitly "this" qualified method call
  // and the current class should have a possible method
  String methodName = call.getMethodAsString();
  if (methodName==null) return false;
  if (!call.isImplicitThis()) return false;
  if (!isThisExpression(call.getObjectExpression())) return false;
  //if (isNotExplicitThisInClosure(call.isImplicitThis()) return false;
  if (classNode.getDeclaredField(methodName) == null) return false;
  Expression arguments = call.getArguments();
  return ! classNode.hasPossibleMethod(methodName, arguments);
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

private boolean isClosureCall(MethodCallExpression call) {
  // are we a local variable?
  // it should not be an explicitly "this" qualified method call
  // and the current class should have a possible method
  String methodName = call.getMethodAsString();
  if (methodName==null) return false;
  if (!call.isImplicitThis()) return false;
  if (!isThisExpression(call.getObjectExpression())) return false;
  FieldNode field = classNode.getDeclaredField(methodName);
  if (field == null) return false;
  if (isStaticInvocation(call) && !field.isStatic()) return false;
  Expression arguments = call.getArguments();
  return ! classNode.hasPossibleMethod(methodName, arguments);
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

private boolean isClosureCall(MethodCallExpression call) {
  // are we a local variable?
  // it should not be an explicitly "this" qualified method call
  // and the current class should have a possible method
  ClassNode classNode = controller.getClassNode();
  String methodName = call.getMethodAsString();
  if (methodName==null) return false;
  if (!call.isImplicitThis()) return false;
  if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false;
  FieldNode field = classNode.getDeclaredField(methodName);
  if (field == null) return false;
  if (isStaticInvocation(call) && !field.isStatic()) return false;
  Expression arguments = call.getArguments();
  return ! classNode.hasPossibleMethod(methodName, arguments);
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

boolean lookForPossibleStaticMethod = !methodName.equals("call");
if (currentMethod != null && !currentMethod.isStatic()) {
  if (currentClass.hasPossibleMethod(methodName, args)) {
    lookForPossibleStaticMethod = false;

代码示例来源:origin: org.kohsuke.droovy/groovy

boolean lookForPossibleStaticMethod = true;
if(this.currentMethod != null && !this.currentMethod.isStatic()) {
  if(currentClass.hasPossibleMethod(methodName, args)) {
    lookForPossibleStaticMethod = false;

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

boolean lookForPossibleStaticMethod = true;
if(this.currentMethod != null && !this.currentMethod.isStatic()) {
  if(currentClass.hasPossibleMethod(methodName, args)) {
    lookForPossibleStaticMethod = false;

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

boolean lookForPossibleStaticMethod = !methodName.equals("call");
if (currentMethod != null && !currentMethod.isStatic()) {
  if (currentClass.hasPossibleMethod(methodName, args)) {
    lookForPossibleStaticMethod = false;

相关文章

微信公众号

最新文章

更多

ClassNode类方法