boolean (@NotNull PsiElement element) { if (element.getLanguage() != GroovyLanguage.INSTANCE) return false; if (!CodeStyleSettingsManager.getInstance(element.getProject()).getCurrentSettings() .getCustomSettings(GroovyCodeStyleSettings.class).USE_FLYING_GEESE_BRACES) { return false; } if (PsiImplUtil.isWhiteSpaceOrNls(element)) { element = PsiTreeUtil.prevLeaf(element); } if (!GeeseUtil.isClosureRBrace(element)) return false; String text = element.getContainingFile().getText(); PsiElement first = element; PsiElement last = element; for (PsiElement cur = getNext(element); GeeseUtil.isClosureRBrace(cur); cur = getNext(cur)) { if (!StringUtil.contains(text, last.getTextRange().getEndOffset(), cur.getTextRange().getStartOffset(), '\n')) return true; last = cur; } for (PsiElement cur = getPrev(element); GeeseUtil.isClosureRBrace(cur); cur = getPrev(cur)) { if (!StringUtil.contains(text, cur.getTextRange().getEndOffset(), first.getTextRange().getStartOffset(), '\n')) return true; first = cur; } return false; }