@Nullable
  private static GrCodeBlock getControlStatementBlock(int caret, PsiElement element) {
    GrStatement body = null;

    if (element instanceof GrMethod) return ((GrMethod)element).getBlock();

    if (element instanceof GrMethodCall) {
      final GrClosableBlock[] arguments = ((GrMethodCall)element).getClosureArguments();
      if (arguments.length > 0) return arguments[0]; else return null;
    }

    if (element instanceof GrIfStatement) {
      body = ((GrIfStatement)element).getThenBranch();
      if (body != null && caret > body.getTextRange().getEndOffset()) {
        body = ((GrIfStatement)element).getElseBranch();
      }
    }
    else if (element instanceof GrWhileStatement) {
      body = ((GrWhileStatement)element).getBody();
    }
    else if (element instanceof GrForStatement) {
      body = ((GrForStatement)element).getBody();
    }

    if (body instanceof GrBlockStatement) {
      return ((GrBlockStatement)body).getBlock();
    }

    return null;
  }
@Nullable
  private static GrCodeBlock getControlStatementBlock(int caret, PsiElement element)