ASTNode (ASTNode node) { IElementType elementType = node.getElementType(); if (elementType == GroovyElementTypes.CLOSABLE_BLOCK) { PsiElement rBrace = ((GrClosableBlock)node.getPsi()).getRBrace(); return rBrace != null ? rBrace.getNode() : null; } ASTNode lastChild = node.getLastChildNode(); while (lastChild != null && PsiImplUtil.isWhiteSpaceOrNls(lastChild)) { lastChild = lastChild.getTreePrev(); } if (lastChild == null) return null; return getClosureRBraceAtTheEnd(lastChild); }