MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / tsThisSubscriptReceiver

Function tsThisSubscriptReceiver

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

* A TS/JS receiver that subscripts the enclosing class's object: an element * of a field, `this. [k]` → `this. []`, or a field named by a * string key, `this['svc']` → `this.svc`. Null for any other subscript. * Mirrored in the kernel's this_subscript_of.

(node: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

762 * Mirrored in the kernel's this_subscript_of.
763 */
764function tsThisSubscriptReceiver(node: SyntaxNode, source: string): string | null {
765 if (node.type !== 'subscript_expression') return null;
766 const objectNode = getChildByField(node, 'object');
767 if (!objectNode) return null;
768 const object = peelTsJsReceiver(objectNode);
769 if (object.type === 'this') {
770 const key = quotedIdentifier(getChildByField(node, 'index'), source);
771 return key ? `this.${key}` : null;
772 }
773 if (object.type !== 'member_expression' || getChildByField(object, 'object')?.type !== 'this') return null;
774 const property = getChildByField(object, 'property');
775 if (!property || !THIS_FIELD_PROPERTY_TYPES.has(property.type)) return null;
776 return `this.${getNodeText(property, source)}[]`;
777}
778
779/**
780 * Whether a TS/JS receiver still collapses to the bare method name: `this` /

Callers 1

extractCallMethod · 0.85

Calls 5

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
peelTsJsReceiverFunction · 0.85
quotedIdentifierFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected