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

Method vbReceiverPath

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

* A VB.NET receiver as the resolver reads it: a name, `Me` / `MyClass` / * `MyBase`, a member of one (`Me._h`, `user.Settings`), a `With` block's * `.Inner`, or `{T}` for a value whose type the code writes there * (`DirectCast(o, T)`, `New T(…)`). Null for anything else — an index, a * c

(node: SyntaxNode, depth = 0)

Source from the content-addressed store, hash-verified

6963 * call's result, a built-in type — which no declaration here types.
6964 */
6965 private vbReceiverPath(node: SyntaxNode, depth = 0): string | null {
6966 if (depth > 6) return null;
6967 switch (node.type) {
6968 case 'identifier':
6969 return getNodeText(node, this.source);
6970 case 'me_expression':
6971 return 'Me';
6972 case 'myclass_expression':
6973 return 'MyClass';
6974 case 'mybase_expression':
6975 return 'MyBase';
6976 case 'parenthesized_expression': {
6977 const inner = node.namedChild(0);
6978 return inner ? this.vbReceiverPath(inner, depth + 1) : null;
6979 }
6980 case 'member_access_expression':
6981 case 'with_member_access_expression': {
6982 const through = node.type === 'member_access_expression';
6983 const member = through ? getChildByField(node, 'member') : node.namedChild(0);
6984 if (member?.type !== 'identifier') return null;
6985 const object = through ? getChildByField(node, 'object') : this.vbWithTarget(node);
6986 if (through && object && this.isVbSplitNew(object)) return null;
6987 const head = object ? this.vbReceiverPath(object, depth + 1) : null;
6988 return head ? `${head}.${getNodeText(member, this.source)}` : null;
6989 }
6990 case 'cast_expression':
6991 case 'object_creation_expression': {
6992 let type = getChildByField(node, 'type');
6993 // `New T()` parses as an array type whose rank is the constructor's empty parentheses.
6994 if (node.type === 'object_creation_expression' && type?.type === 'array_type') {
6995 const rank = type.namedChildren.find((c: SyntaxNode) => c.type === 'array_rank_specifier');
6996 type = rank && /^\(\s*\)$/.test(getNodeText(rank, this.source)) ? getChildByField(type, 'element_type') : null;
6997 }
6998 if (!type || type.type === 'predefined_type' || type.type === 'array_type') return null;
6999 const written = getNodeText(type, this.source).replace(/\s+/g, ' ');
7000 // .NET's own types (`System.Drawing.Point`) are never the project's.
7001 return /^(?:System|Microsoft|My)\./i.test(written) ? null : `{${written}}`;
7002 }
7003 default:
7004 return null;
7005 }
7006 }
7007
7008 /**
7009 * Whether `node`, a member access's object, is `New System` of `New

Callers 2

extractCallMethod · 0.95
extractVbMemberReadMethod · 0.95

Calls 4

vbWithTargetMethod · 0.95
isVbSplitNewMethod · 0.95
getNodeTextFunction · 0.90
getChildByFieldFunction · 0.90

Tested by

no test coverage detected