Land upstream PR #1687 by danusha2345 (fix commit 6e9bbb26), using the PR tip implementation with only a Rust doc-comment placement cleanup. Read parameter lists and return types positionally in the wasm extractor and native kernel in lockstep, preserving verbatim signature text. Verified on Linux x64 with Node 22.19.0: reproduced three undefined signatures in both backends before the fix, then confirmed all three expected signatures and exact wasm/kernel parity after rebuilding TypeScript and the linux-x64 kernel. All 31 focused tests pass: 15 Kotlin extraction, 6 Kotlin parity, and 10 kernel scaffold checks, with CODEGRAPH_KERNEL_EXPECT=1 for the native suites. Add the upstream #1495 changelog bullet while preserving all other Unreleased entries. Keep EXTRACTION_VERSION unchanged for this bug fix. Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
co-authored by
Colby McHenry
parent
799f8b2a45
commit
748311feff
@@ -1,5 +1,5 @@
|
||||
import type { Node as SyntaxNode } from 'web-tree-sitter';
|
||||
import { getNodeText, getChildByField } from '../tree-sitter-helpers';
|
||||
import { getNodeText } from '../tree-sitter-helpers';
|
||||
import type { LanguageExtractor } from '../tree-sitter-types';
|
||||
|
||||
/** Kotlin return types that can't be a chained-call receiver (no class to chain on). */
|
||||
@@ -390,9 +390,26 @@ export const kotlinExtractor: LanguageExtractor = {
|
||||
return undefined;
|
||||
},
|
||||
getSignature: (node, source) => {
|
||||
// Kotlin function signature: fun name(params): ReturnType
|
||||
const params = getChildByField(node, 'function_value_parameters');
|
||||
const returnType = getChildByField(node, 'type');
|
||||
// Kotlin function signature: fun name(params): ReturnType. tree-sitter-kotlin
|
||||
// exposes no field names, so both parts are found positionally, the way
|
||||
// extractKotlinReturnType does (#1495): the `function_value_parameters`
|
||||
// child, then the type node that follows it before the body.
|
||||
let params: SyntaxNode | null = null;
|
||||
let returnType: SyntaxNode | null = null;
|
||||
for (let i = 0; i < node.namedChildCount; i++) {
|
||||
const child = node.namedChild(i);
|
||||
if (!child) continue;
|
||||
if (child.type === 'function_value_parameters') {
|
||||
params = child;
|
||||
continue;
|
||||
}
|
||||
if (!params) continue;
|
||||
if (child.type === 'function_body' || child.type === 'type_constraints') break;
|
||||
if (child.type === 'user_type' || child.type === 'nullable_type' || child.type === 'function_type') {
|
||||
returnType = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!params) return undefined;
|
||||
let sig = getNodeText(params, source);
|
||||
if (returnType) {
|
||||
|
||||
Reference in New Issue
Block a user