Swift property facts: the bound name, whether it's a `let`, and whether it's * a *computed* property (a getter block, no stored value — never a constant).
( node: SyntaxNode, source: string, )
| 250 | /** Swift property facts: the bound name, whether it's a `let`, and whether it's |
| 251 | * a *computed* property (a getter block, no stored value — never a constant). */ |
| 252 | function swiftPropertyInfo( |
| 253 | node: SyntaxNode, |
| 254 | source: string, |
| 255 | ): { nameNode: SyntaxNode | null; isLet: boolean; isComputed: boolean } { |
| 256 | const pattern = |
| 257 | getChildByField(node, 'name') ?? |
| 258 | node.namedChildren.find((c) => c.type === 'value_binding_pattern' || c.type === 'pattern') ?? |
| 259 | null; |
| 260 | const binding = node.namedChildren.find((c) => c.type === 'value_binding_pattern'); |
| 261 | const isLet = binding != null && getNodeText(binding, source).trimStart().startsWith('let'); |
| 262 | const isComputed = node.namedChildren.some( |
| 263 | (c) => c.type === 'computed_property' || c.type === 'protocol_property_requirements', |
| 264 | ); |
| 265 | return { nameNode: firstSimpleIdentifier(pattern), isLet, isComputed }; |
| 266 | } |
| 267 | |
| 268 | /** True when `node` is (transitively) inside a C function body — i.e. a local, |
| 269 | * not a file/namespace-scope declaration. Walks the parent chain to the root. */ |
no test coverage detected