* 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)
| 7171 | * call's result, a built-in type — which no declaration here types. |
| 7172 | */ |
| 7173 | private vbReceiverPath(node: SyntaxNode, depth = 0): string | null { |
| 7174 | if (depth > 6) return null; |
| 7175 | switch (node.type) { |
| 7176 | case 'identifier': |
| 7177 | return getNodeText(node, this.source); |
| 7178 | case 'me_expression': |
| 7179 | return 'Me'; |
| 7180 | case 'myclass_expression': |
| 7181 | return 'MyClass'; |
| 7182 | case 'mybase_expression': |
| 7183 | return 'MyBase'; |
| 7184 | case 'parenthesized_expression': { |
| 7185 | const inner = node.namedChild(0); |
| 7186 | return inner ? this.vbReceiverPath(inner, depth + 1) : null; |
| 7187 | } |
| 7188 | case 'member_access_expression': |
| 7189 | case 'with_member_access_expression': { |
| 7190 | const through = node.type === 'member_access_expression'; |
| 7191 | const member = through ? getChildByField(node, 'member') : node.namedChild(0); |
| 7192 | if (member?.type !== 'identifier') return null; |
| 7193 | const object = through ? getChildByField(node, 'object') : this.vbWithTarget(node); |
| 7194 | if (through && object && this.isVbSplitNew(object)) return null; |
| 7195 | const head = object ? this.vbReceiverPath(object, depth + 1) : null; |
| 7196 | return head ? `${head}.${getNodeText(member, this.source)}` : null; |
| 7197 | } |
| 7198 | case 'cast_expression': |
| 7199 | case 'object_creation_expression': { |
| 7200 | let type = getChildByField(node, 'type'); |
| 7201 | // `New T()` parses as an array type whose rank is the constructor's empty parentheses. |
| 7202 | if (node.type === 'object_creation_expression' && type?.type === 'array_type') { |
| 7203 | const rank = type.namedChildren.find((c: SyntaxNode) => c.type === 'array_rank_specifier'); |
| 7204 | type = rank && /^\(\s*\)$/.test(getNodeText(rank, this.source)) ? getChildByField(type, 'element_type') : null; |
| 7205 | } |
| 7206 | if (!type || type.type === 'predefined_type' || type.type === 'array_type') return null; |
| 7207 | const written = getNodeText(type, this.source).replace(/\s+/g, ' '); |
| 7208 | // .NET's own types (`System.Drawing.Point`) are never the project's. |
| 7209 | return /^(?:System|Microsoft|My)\./i.test(written) ? null : `{${written}}`; |
| 7210 | } |
| 7211 | default: |
| 7212 | return null; |
| 7213 | } |
| 7214 | } |
| 7215 | |
| 7216 | /** |
| 7217 | * Whether `node`, a member access's object, is `New System` of `New |
no test coverage detected