MCPcopy
hub / github.com/colbymchenry/codegraph / swiftPropertyInfo

Function swiftPropertyInfo

src/extraction/tree-sitter.ts:252–266  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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). */
252function 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. */

Callers 2

visitNodeMethod · 0.85
extractVariableMethod · 0.85

Calls 3

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
firstSimpleIdentifierFunction · 0.85

Tested by

no test coverage detected