public static DslPointcut<GroovyClassDescriptor, GdslMethod> enclosingMethod(final Object arg) {
    final DslPointcut<? super GdslMethod,?> inner;
    if (arg instanceof String) {
      inner = name(arg);
    } else {
      inner = (DslPointcut<GdslMethod, ?>)arg;
      assert inner.operatesOn(GdslMethod.class) : "The argument to enclosingMethod should be a pointcut working with methods, e.g. name";
    }

    return new DslPointcut<>() {
      @Override
      List<GdslMethod> matches(GroovyClassDescriptor src, ProcessingContext context) {
        List<GdslMethod> result = new ArrayList<>();
        PsiElement place = src.getPlace();
        while (true) {
          final PsiMethod method = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
          if (method == null) {
            break;
          }
          final GdslMethod wrapper = new GdslMethod(method);
          if (inner.matches(wrapper, context) != null) {
            result.add(wrapper);
          }
          place = method;
        }
        return result.isEmpty() ? null : result;
      }

      @Override
      boolean operatesOn(Class c) {
        return GroovyClassDescriptor.class == c;
      }
    };
  }
public static DslPointcut<GroovyClassDescriptor, GdslMethod> enclosingMethod(final Object arg)