int (@NotNull PsiElement element, @NotNull CharSequence documentChars) { if (element instanceof PsiField || element instanceof PsiTypeParameter) return 1; if (element instanceof PsiClass || element instanceof PsiClassInitializer) return 2; if (element instanceof PsiMethod) { if (((PsiMethod)element).hasModifierProperty(PsiModifier.ABSTRACT)) { return 1; } TextRange textRange = element.getTextRange(); int start = textRange.getStartOffset(); int end = Math.min(documentChars.length(), textRange.getEndOffset()); int crlf = StringUtil.getLineBreakCount(documentChars.subSequence(start, end)); return crlf == 0 ? 1 : 2; } return 0; }