private static void addUsagesInClosure(final Map<String, VariableInfo> imap,
                                             final Map<String, VariableInfo> omap,
                                             final GrClosableBlock closure,
                                             final GrStatement first,
                                             final GrStatement last) {
        closure.accept(new GroovyRecursiveElementVisitor() {
          @Override
          public void visitReferenceExpression(@NotNull GrReferenceExpression refExpr) {
            if (refExpr.isQualified()) {
              return;
            }
            String name = refExpr.getReferenceName();
            if (name == null) return;
            GrVariable variable = resolveToLocalVariable(refExpr, name);
            if (variable == null) return;
            if (PsiImplUtilKt.isDeclaredIn(variable, closure)) return;

            if (!(variable instanceof GrField)) {
              if (!isInFragment(first, last, variable)) {
                if (isInFragment(first, last, closure)) {
                  addVariable(name, imap, variable.getManager(), variable.getType());
                }
              }
              else {
                if (!isInFragment(first, last, closure)) {
                  addVariable(name, omap, variable.getManager(), variable.getType());
                }
              }
            }
          }
        });
      }
private static void addUsagesInClosure(final Map<String, VariableInfo> imap,
                                             final Map<String, VariableInfo> omap,
                                             final GrClosableBlock closure,
                                             final GrStatement first,
                                             final GrStatement last)