GrCall (String name, GdslMembersHolderConsumer consumer) { final PsiElement place = consumer.getPlace(); if (place == null) return null; GrCall call = PsiTreeUtil.getParentOfType(place, GrCall.class, true); if (call == null) return null; while (call != null && !name.equals(getInvokedMethodName(call))) { call = PsiTreeUtil.getParentOfType(call, GrCall.class, true); } if (call == null) return null; final GrArgumentList argumentList = call.getArgumentList(); if (argumentList != null) { for (GrExpression arg : argumentList.getExpressionArguments()) { if (arg instanceof GrClosableBlock && PsiTreeUtil.findCommonParent(place, arg) == arg) { return call; } } } if (call instanceof GrMethodCallExpression) { for (GrExpression arg : call.getClosureArguments()) { if (arg instanceof GrClosableBlock && PsiTreeUtil.findCommonParent(place, arg) == arg) { return call; } } } return null; }