boolean (@NotNull final ASTNode child) { int role = getChildRole(child); final IElementType nodeType = myNode.getElementType(); if (nodeType == JavaElementType.FOR_STATEMENT) { if (role == ChildRole.FOR_INITIALIZATION || role == ChildRole.CONDITION || role == ChildRole.FOR_UPDATE) { return true; } return false; } else if (nodeType == JavaElementType.EXTENDS_LIST || nodeType == JavaElementType.IMPLEMENTS_LIST || nodeType == JavaElementType.PERMITS_LIST || nodeType == JavaElementType.THROWS_LIST) { return role == ChildRole.REFERENCE_IN_LIST; } else if (nodeType == JavaElementType.CLASS) { if (role == ChildRole.CLASS_OR_INTERFACE_KEYWORD) return true; if (myIsAfterClassKeyword) return false; if (role == ChildRole.MODIFIER_LIST) return true; return false; } else if (JavaElementType.FIELD == nodeType) { return shouldAlignFieldInColumns(child); } else if (nodeType == JavaElementType.METHOD) { if (role == ChildRole.MODIFIER_LIST) return true; if (role == ChildRole.TYPE_PARAMETER_LIST) return true; if (role == ChildRole.TYPE) return true; if (role == ChildRole.NAME) return true; if (role == ChildRole.THROWS_LIST && mySettings.ALIGN_THROWS_KEYWORD) return true; if (role == ChildRole.METHOD_BODY) return !getNode().textContains('\n'); return false; } else if (nodeType == JavaElementType.ASSIGNMENT_EXPRESSION) { if (role == ChildRole.LOPERAND) return true; if (role == ChildRole.ROPERAND && child.getElementType() == JavaElementType.ASSIGNMENT_EXPRESSION) { return true; } return false; } else if (child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) { ASTNode previous = child.getTreePrev(); // There is a special case - comment block that is located at the very start of the line. We don't reformat such a blocks, // hence, no alignment should be applied to them in order to avoid subsequent blocks aligned with the same alignment to // be located at the left editor edge as well. CharSequence prevChars; if (previous != null && previous.getElementType() == TokenType.WHITE_SPACE && (prevChars = previous.getChars()).length() > 0 && prevChars.charAt(prevChars.length() - 1) == '\n') { return false; } return true; } else if (nodeType == JavaElementType.MODIFIER_LIST) { // There is a possible case that modifier list contains from more than one elements, e.g. 'private final'. It's also possible // that the list is aligned. We want to apply alignment rule only to the first element then. ASTNode previous = child.getTreePrev(); if (previous == null || previous.getTreeParent() != myNode) { return true; } return false; } else { return true; } }