boolean (final ASTNode child, @Nullable final ASTNode parentNode) { if (parentNode != null) { final IElementType parentType = parentNode.getElementType(); if (parentType == JavaElementType.CODE_BLOCK) return false; final int role = ((CompositeElement)parentNode).getChildRole(child); if (parentType == JavaElementType.IF_STATEMENT) return role == ChildRole.THEN_BRANCH || role == ChildRole.ELSE_BRANCH; if (parentType == JavaElementType.FOR_STATEMENT) return role == ChildRole.LOOP_BODY; if (parentType == JavaElementType.WHILE_STATEMENT) return role == ChildRole.LOOP_BODY; if (parentType == JavaElementType.DO_WHILE_STATEMENT) return role == ChildRole.LOOP_BODY; if (parentType == JavaElementType.FOREACH_STATEMENT) return role == ChildRole.LOOP_BODY; } return false; }