boolean (@NotNull ASTNode child) { // The general idea is to handle situations like below: // test(new Runnable() { // public void run() { // } // }, new Runnable() { // public void run() { // } // } // ); // I.e. we want to align subsequent anonymous class argument to the previous one if it's not preceded by another argument // at the same line, e.g.: // test("this is a long argument", new Runnable() { // public void run() { // } // }, new Runnable() { // public void run() { // } // } // ); if (!isAnonymousClass(child)) { return false; } for (ASTNode node = child.getTreePrev(); node != null; node = node.getTreePrev()) { if (node.getElementType() == TokenType.WHITE_SPACE) { if (StringUtil.countNewLines(node.getChars()) > 0) { return false; } } else if (node.getElementType() == JavaTokenType.LPARENTH) { // First method call argument. return true; } else if (node.getElementType() != JavaTokenType.COMMA && !isAnonymousClass(node)) { return false; } } return true; }