ASTNode (@NotNull IElementType from, @Nullable final IElementType to, @NotNull final List<Block> result, @NotNull ASTNode child, @NotNull final WrappingStrategy wrappingStrategy, final boolean doAlign) { Indent externalIndent = Indent.getNoneIndent(); Indent internalIndent = Indent.getContinuationWithoutFirstIndent(false); if (isInsideMethodCallParenthesis(child)) { internalIndent = Indent.getSmartIndent(Indent.Type.CONTINUATION); } AlignmentStrategy alignmentStrategy = AlignmentStrategy.wrap(createAlignment(doAlign, null), JavaTokenType.COMMA); setChildIndent(internalIndent); setChildAlignment(alignmentStrategy.getAlignment(null)); boolean methodParametersBlock = true; ASTNode lBracketParent = child.getTreeParent(); if (lBracketParent != null) { ASTNode methodCandidate = lBracketParent.getTreeParent(); methodParametersBlock = methodCandidate != null && (methodCandidate.getElementType() == JavaElementType.METHOD || methodCandidate.getElementType() == JavaElementType.METHOD_CALL_EXPRESSION); } Alignment bracketAlignment = methodParametersBlock && mySettings.ALIGN_MULTILINE_METHOD_BRACKETS ? Alignment.createAlignment() : null; AlignmentStrategy anonymousClassStrategy = doAlign ? alignmentStrategy : AlignmentStrategy.wrap(Alignment.createAlignment(), false, JavaTokenType.NEW_KEYWORD, JavaElementType.NEW_EXPRESSION, JavaTokenType.RBRACE); setChildIndent(internalIndent); setChildAlignment(alignmentStrategy.getAlignment(null)); ASTNode prev = child; while (child != null) { if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0) { if (child.getElementType() == from) { result.add(createJavaBlock(child, mySettings, myJavaSettings, externalIndent, null, bracketAlignment, myFormattingMode)); } else if (child.getElementType() == to) { boolean isAfterIncomplete = isAfterErrorElement(child); Indent parenIndent = isAfterIncomplete ? internalIndent : externalIndent; Alignment parenAlignment = isAfterIncomplete ? alignmentStrategy.getAlignment(null) : bracketAlignment; ChildAttributes attributes = getDelegateAttributes(result); if (attributes != null) { parenIndent = attributes.getChildIndent(); parenAlignment = attributes.getAlignment(); } Block block = createJavaBlock(child, mySettings, myJavaSettings, parenIndent, null, parenAlignment, myFormattingMode); result.add(block); return child; } else { final IElementType elementType = child.getElementType(); AlignmentStrategy alignmentStrategyToUse = canUseAnonymousClassAlignment(child) ? anonymousClassStrategy : alignmentStrategy; processChild(result, child, alignmentStrategyToUse.getAlignment(elementType), wrappingStrategy.getWrap(elementType), internalIndent); if (to == null) {//process only one statement return child; } } } prev = child; child = child.getTreeNext(); } return prev; }