Checks that the new block is directly in a namespace. Args: nesting_state: The NestingState object that contains info about our state. is_forward_declaration: If the class is a forward declared class. Returns: Whether or not the new block is directly in a namespace.
(nesting_state: NestingState, is_forward_declaration: bool)
| 7172 | # Returns true if we are at a new block, and it is directly |
| 7173 | # inside of a namespace. |
| 7174 | def IsBlockInNameSpace(nesting_state: NestingState, is_forward_declaration: bool): # noqa: FBT001 |
| 7175 | """Checks that the new block is directly in a namespace. |
| 7176 | |
| 7177 | Args: |
| 7178 | nesting_state: The NestingState object that contains info about our state. |
| 7179 | is_forward_declaration: If the class is a forward declared class. |
| 7180 | Returns: |
| 7181 | Whether or not the new block is directly in a namespace. |
| 7182 | """ |
| 7183 | if is_forward_declaration: |
| 7184 | return len(nesting_state.stack) >= 1 and ( |
| 7185 | isinstance(nesting_state.stack[-1], _NamespaceInfo) |
| 7186 | ) |
| 7187 | |
| 7188 | if len(nesting_state.stack) >= 1: |
| 7189 | if isinstance(nesting_state.stack[-1], _NamespaceInfo): |
| 7190 | return True |
| 7191 | if ( |
| 7192 | len(nesting_state.stack) > 1 |
| 7193 | and isinstance(nesting_state.previous_stack_top, _NamespaceInfo) |
| 7194 | and ( |
| 7195 | isinstance(nesting_state.stack[-2], _NamespaceInfo) |
| 7196 | or len(nesting_state.stack) > 2 # Accommodate for WrappedInfo |
| 7197 | and issubclass(type(nesting_state.stack[-1]), _WrappedInfo) |
| 7198 | and not nesting_state.stack[-2].seen_open_brace |
| 7199 | and isinstance(nesting_state.stack[-3], _NamespaceInfo) |
| 7200 | ) |
| 7201 | ): |
| 7202 | return True |
| 7203 | return False |
| 7204 | |
| 7205 | |
| 7206 | def ShouldCheckNamespaceIndentation( |
no outgoing calls
no test coverage detected