* Normalize a Java type node to the bare class name a chained * `foo.getThing().bar()` could be called on (the #645/#608 mechanism): * primitives/void/arrays yield undefined (no class to chain on), `List ` * is unwrapped to its base `List`, and a dotted package/outer-class qualifier * (`java
(typeNode: SyntaxNode | null, source: string)
| 22 | * (`java.util.List`) is stripped to the simple name. |
| 23 | */ |
| 24 | function normalizeJavaType(typeNode: SyntaxNode | null, source: string): string | undefined { |
| 25 | if (!typeNode) return undefined; |
| 26 | if (JAVA_NON_CLASS_RETURN_NODES.has(typeNode.type)) return undefined; |
| 27 | // An array (`Foo[]`) isn't a receiver you call instance methods on. |
| 28 | if (typeNode.type === 'array_type') return undefined; |
| 29 | // Strip type arguments (`List<Foo>` → `List`) — the chain resolves on the base. |
| 30 | const raw = getNodeText(typeNode, source).trim().replace(/<[^>]*>/g, ''); |
| 31 | // Strip a dotted package / outer-class qualifier (`java.util.List` → `List`). |
| 32 | const last = raw.split('.').pop()?.trim(); |
| 33 | if (!last || !/^[A-Za-z_]\w*$/.test(last)) return undefined; |
| 34 | return last; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * A Java method's declared return type. Reads the `type` field; constructors |
no test coverage detected