void (PsiStatement statement, PsiStatement body) { if (body instanceof PsiBlockStatement || body == null) { return; } final boolean lineBreakBeforeBody; PsiElement bodyWhiteSpace = body.getPrevSibling(); if (!(bodyWhiteSpace instanceof PsiWhiteSpace)) { lineBreakBeforeBody = false; bodyWhiteSpace = statement.getPrevSibling(); if (!(bodyWhiteSpace instanceof PsiWhiteSpace)) { return; } } else { final String text = bodyWhiteSpace.getText(); final int bodyLineBreak = text.lastIndexOf('\n'); if (bodyLineBreak < 0) { lineBreakBeforeBody = false; bodyWhiteSpace = statement.getPrevSibling(); if (!(bodyWhiteSpace instanceof PsiWhiteSpace)) { return; } } else { lineBreakBeforeBody = true; final PsiElement statementWhiteSpace = statement.getPrevSibling(); if (statementWhiteSpace instanceof PsiWhiteSpace) { final String siblingText = statementWhiteSpace.getText(); final int statementLineBreak = siblingText.lastIndexOf('\n'); if (statementLineBreak >= 0) { final int statementIndent = getIndent(siblingText.substring(statementLineBreak + 1)); final String indentText = text.substring(bodyLineBreak + 1); final int bodyIndent = getIndent(indentText); if (statementIndent == bodyIndent) { registerErrorAtOffset(bodyWhiteSpace, bodyLineBreak + 1, indentText.length(), statement); return; } } } } } final PsiStatement nextStatement = PsiTreeUtil.getNextSiblingOfType(statement, PsiStatement.class); if (nextStatement == null) { return; } final String text = bodyWhiteSpace.getText(); final int bodyLineBreak = text.lastIndexOf('\n'); if (bodyLineBreak < 0) { return; } final PsiElement nextWhiteSpace = nextStatement.getPrevSibling(); if (!(nextWhiteSpace instanceof PsiWhiteSpace)) { return; } final String nextText = nextWhiteSpace.getText(); final int nextLineBreak = nextText.lastIndexOf('\n'); if (nextLineBreak < 0) { return; } final int bodyIndent = getIndent(text.substring(bodyLineBreak + 1)); final String nextIndentText = nextText.substring(nextLineBreak + 1); final int nextIndent = getIndent(nextIndentText); if (nextIndent > bodyIndent || lineBreakBeforeBody && nextIndent == bodyIndent) { registerErrorAtOffset(nextWhiteSpace, nextLineBreak + 1, nextIndentText.length(), statement); } }