boolean (@NotNull PsiElement element) { if (element instanceof GrMethodCallExpression expression) { // final PsiElement parent = expression.getParent(); // if (parent instanceof GrAssignmentExpression) return false; // if (parent instanceof GrArgumentList) return false; // if (parent instanceof GrReturnStatement) return false; // if (!(parent instanceof GrCodeBlock || parent instanceof GrIfStatement|| parent instanceof GrCaseSection)) return false; final GrExpression invokedExpression = expression.getInvokedExpression(); if (invokedExpression instanceof GrReferenceExpression referenceExpression) { if ("each".equals(referenceExpression.getReferenceName())) { final GrArgumentList argumentList = expression.getArgumentList(); if (PsiImplUtil.hasExpressionArguments(argumentList)) return false; if (PsiImplUtil.hasNamedArguments(argumentList)) return false; final GrClosableBlock[] closureArguments = expression.getClosureArguments(); if (closureArguments.length != 1) return false; final GrParameter[] parameters = closureArguments[0].getParameterList().getParameters(); if (parameters.length > 1) return false; return true; } } } return false; }