@zuvia-software-solutions/code-mapper 1.4.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/ai-context.js +1 -1
- package/dist/cli/analyze.d.ts +1 -0
- package/dist/cli/analyze.js +73 -82
- package/dist/cli/augment.js +0 -2
- package/dist/cli/eval-server.d.ts +2 -2
- package/dist/cli/eval-server.js +6 -6
- package/dist/cli/index.js +6 -10
- package/dist/cli/mcp.d.ts +1 -3
- package/dist/cli/mcp.js +3 -3
- package/dist/cli/refresh.d.ts +2 -2
- package/dist/cli/refresh.js +24 -29
- package/dist/cli/status.js +4 -13
- package/dist/cli/tool.d.ts +5 -4
- package/dist/cli/tool.js +8 -10
- package/dist/config/ignore-service.js +14 -34
- package/dist/core/augmentation/engine.js +53 -83
- package/dist/core/db/adapter.d.ts +99 -0
- package/dist/core/db/adapter.js +402 -0
- package/dist/core/db/graph-loader.d.ts +27 -0
- package/dist/core/db/graph-loader.js +148 -0
- package/dist/core/db/queries.d.ts +160 -0
- package/dist/core/db/queries.js +441 -0
- package/dist/core/db/schema.d.ts +108 -0
- package/dist/core/db/schema.js +136 -0
- package/dist/core/embeddings/embedder.d.ts +21 -12
- package/dist/core/embeddings/embedder.js +104 -50
- package/dist/core/embeddings/embedding-pipeline.d.ts +48 -22
- package/dist/core/embeddings/embedding-pipeline.js +220 -262
- package/dist/core/embeddings/text-generator.js +4 -19
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/graph.d.ts +1 -1
- package/dist/core/graph/graph.js +1 -0
- package/dist/core/graph/types.d.ts +11 -9
- package/dist/core/graph/types.js +4 -1
- package/dist/core/incremental/refresh.d.ts +46 -0
- package/dist/core/incremental/refresh.js +503 -0
- package/dist/core/incremental/types.d.ts +2 -1
- package/dist/core/incremental/types.js +42 -44
- package/dist/core/ingestion/ast-cache.js +1 -0
- package/dist/core/ingestion/call-processor.d.ts +15 -3
- package/dist/core/ingestion/call-processor.js +448 -60
- package/dist/core/ingestion/cluster-enricher.d.ts +1 -1
- package/dist/core/ingestion/cluster-enricher.js +2 -0
- package/dist/core/ingestion/community-processor.d.ts +1 -1
- package/dist/core/ingestion/community-processor.js +8 -3
- package/dist/core/ingestion/export-detection.d.ts +1 -1
- package/dist/core/ingestion/export-detection.js +1 -1
- package/dist/core/ingestion/filesystem-walker.js +1 -1
- package/dist/core/ingestion/heritage-processor.d.ts +2 -2
- package/dist/core/ingestion/heritage-processor.js +22 -11
- package/dist/core/ingestion/import-processor.d.ts +2 -2
- package/dist/core/ingestion/import-processor.js +24 -9
- package/dist/core/ingestion/language-config.js +7 -4
- package/dist/core/ingestion/mro-processor.d.ts +1 -1
- package/dist/core/ingestion/mro-processor.js +23 -11
- package/dist/core/ingestion/named-binding-extraction.js +5 -5
- package/dist/core/ingestion/parsing-processor.d.ts +4 -4
- package/dist/core/ingestion/parsing-processor.js +26 -18
- package/dist/core/ingestion/pipeline.d.ts +4 -2
- package/dist/core/ingestion/pipeline.js +50 -20
- package/dist/core/ingestion/process-processor.d.ts +2 -2
- package/dist/core/ingestion/process-processor.js +28 -14
- package/dist/core/ingestion/resolution-context.d.ts +1 -1
- package/dist/core/ingestion/resolution-context.js +14 -4
- package/dist/core/ingestion/resolvers/csharp.js +4 -3
- package/dist/core/ingestion/resolvers/go.js +3 -1
- package/dist/core/ingestion/resolvers/jvm.js +13 -4
- package/dist/core/ingestion/resolvers/standard.js +2 -2
- package/dist/core/ingestion/resolvers/utils.js +6 -2
- package/dist/core/ingestion/route-stitcher.d.ts +15 -0
- package/dist/core/ingestion/route-stitcher.js +92 -0
- package/dist/core/ingestion/structure-processor.d.ts +1 -1
- package/dist/core/ingestion/structure-processor.js +3 -2
- package/dist/core/ingestion/symbol-table.d.ts +2 -0
- package/dist/core/ingestion/symbol-table.js +5 -1
- package/dist/core/ingestion/tree-sitter-queries.d.ts +2 -2
- package/dist/core/ingestion/tree-sitter-queries.js +177 -0
- package/dist/core/ingestion/type-env.js +20 -0
- package/dist/core/ingestion/type-extractors/csharp.js +4 -3
- package/dist/core/ingestion/type-extractors/go.js +23 -12
- package/dist/core/ingestion/type-extractors/php.js +18 -10
- package/dist/core/ingestion/type-extractors/ruby.js +15 -3
- package/dist/core/ingestion/type-extractors/rust.js +3 -2
- package/dist/core/ingestion/type-extractors/shared.js +3 -2
- package/dist/core/ingestion/type-extractors/typescript.js +11 -5
- package/dist/core/ingestion/utils.d.ts +27 -4
- package/dist/core/ingestion/utils.js +145 -100
- package/dist/core/ingestion/workers/parse-worker.d.ts +1 -0
- package/dist/core/ingestion/workers/parse-worker.js +97 -29
- package/dist/core/ingestion/workers/worker-pool.js +3 -0
- package/dist/core/search/bm25-index.d.ts +15 -8
- package/dist/core/search/bm25-index.js +48 -98
- package/dist/core/search/hybrid-search.d.ts +9 -3
- package/dist/core/search/hybrid-search.js +30 -25
- package/dist/core/search/reranker.js +9 -7
- package/dist/core/search/types.d.ts +0 -4
- package/dist/core/semantic/tsgo-service.d.ts +7 -1
- package/dist/core/semantic/tsgo-service.js +165 -66
- package/dist/lib/tsgo-test.d.ts +2 -0
- package/dist/lib/tsgo-test.js +6 -0
- package/dist/lib/type-utils.d.ts +25 -0
- package/dist/lib/type-utils.js +22 -0
- package/dist/lib/utils.d.ts +3 -2
- package/dist/lib/utils.js +3 -2
- package/dist/mcp/compatible-stdio-transport.js +1 -1
- package/dist/mcp/local/local-backend.d.ts +29 -56
- package/dist/mcp/local/local-backend.js +808 -1118
- package/dist/mcp/resources.js +35 -25
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +5 -5
- package/dist/mcp/tools.js +24 -25
- package/dist/storage/repo-manager.d.ts +2 -12
- package/dist/storage/repo-manager.js +1 -47
- package/dist/types/pipeline.d.ts +8 -5
- package/dist/types/pipeline.js +5 -0
- package/package.json +18 -11
- package/dist/cli/serve.d.ts +0 -5
- package/dist/cli/serve.js +0 -8
- package/dist/core/incremental/child-process.d.ts +0 -8
- package/dist/core/incremental/child-process.js +0 -649
- package/dist/core/incremental/refresh-coordinator.d.ts +0 -32
- package/dist/core/incremental/refresh-coordinator.js +0 -147
- package/dist/core/lbug/csv-generator.d.ts +0 -28
- package/dist/core/lbug/csv-generator.js +0 -355
- package/dist/core/lbug/lbug-adapter.d.ts +0 -96
- package/dist/core/lbug/lbug-adapter.js +0 -753
- package/dist/core/lbug/schema.d.ts +0 -46
- package/dist/core/lbug/schema.js +0 -402
- package/dist/mcp/core/embedder.d.ts +0 -24
- package/dist/mcp/core/embedder.js +0 -168
- package/dist/mcp/core/lbug-adapter.d.ts +0 -29
- package/dist/mcp/core/lbug-adapter.js +0 -330
- package/dist/server/api.d.ts +0 -5
- package/dist/server/api.js +0 -340
- package/dist/server/mcp-http.d.ts +0 -7
- package/dist/server/mcp-http.js +0 -95
- package/models/mlx-embedder.py +0 -185
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* some grammars (typescript vs tsx vs javascript) have slightly different node types
|
|
5
5
|
*/
|
|
6
6
|
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
7
|
-
export declare const TYPESCRIPT_QUERIES = "\n(class_declaration\n name: (type_identifier) @name) @definition.class\n\n(interface_declaration\n name: (type_identifier) @name) @definition.interface\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; B3: Dynamic import calls: const { foo } = await import('./module.js')\n(call_expression\n function: (import) @call.name) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (extends_clause\n value: (identifier) @heritage.extends))) @heritage\n\n; Heritage queries - class implements interface\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (implements_clause\n (type_identifier) @heritage.implements))) @heritage.impl\n";
|
|
8
|
-
export declare const JAVASCRIPT_QUERIES = "\n(class_declaration\n name: (identifier) @name) @definition.class\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; B3: Dynamic import calls: const { foo } = await import('./module.js')\n(call_expression\n function: (import) @call.name) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends (JavaScript uses different AST than TypeScript)\n; In tree-sitter-javascript, class_heritage directly contains the parent identifier\n(class_declaration\n name: (identifier) @heritage.class\n (class_heritage\n (identifier) @heritage.extends)) @heritage\n";
|
|
7
|
+
export declare const TYPESCRIPT_QUERIES = "\n(class_declaration\n name: (type_identifier) @name) @definition.class\n\n(abstract_class_declaration\n name: (type_identifier) @name) @definition.class\n\n(interface_declaration\n name: (type_identifier) @name) @definition.interface\n\n(type_alias_declaration\n name: (type_identifier) @name) @definition.type\n\n(enum_declaration\n name: (identifier) @name) @definition.enum\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n; Interface method signatures: interface Foo { method(): void }\n(method_signature\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n; Namespace / internal module\n(internal_module\n name: (identifier) @name) @definition.namespace\n\n; Ambient declarations: declare function foo(): void\n(ambient_declaration\n (function_signature\n name: (identifier) @name)) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; Await calls: await foo() \u2014 tree-sitter wraps await inside the function position\n(call_expression\n function: (await_expression\n (identifier) @call.name)) @call\n\n; Await member calls: await obj.method()\n(call_expression\n function: (await_expression\n (member_expression\n property: (property_identifier) @call.name))) @call\n\n; B3: Dynamic import calls: const { foo } = await import('./module.js')\n(call_expression\n function: (import) @call.name) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Exported const from call: export const Schema = z.object({...})\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (call_expression)))) @definition.const\n\n; Exported const from new: export const client = new PrismaClient()\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (new_expression)))) @definition.const\n\n; Module-level const from new: const prisma = new PrismaClient()\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (new_expression))) @definition.const\n\n; Exported const from array: export const EDGE_TYPES = [...] as const\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (as_expression)))) @definition.const\n\n; Exported const from array literal: export const FOO = [1, 2, 3]\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (array)))) @definition.const\n\n; Exported const from object literal: export const CONFIG = { port: 3000 }\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (object)))) @definition.const\n\n; Exported const from number/string: export const MAX_DEPTH = 10\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (number)))) @definition.const\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (string)))) @definition.const\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (template_string)))) @definition.const\n\n; Object literal arrow function methods: const x = { method: () => {} }\n(pair\n key: (property_identifier) @name\n value: (arrow_function)) @definition.function\n\n; Object literal function expression methods: const x = { method: function() {} }\n(pair\n key: (property_identifier) @name\n value: (function_expression)) @definition.function\n\n; Heritage queries - class extends\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (extends_clause\n value: (identifier) @heritage.extends))) @heritage\n\n; Heritage queries - class implements interface\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (implements_clause\n (type_identifier) @heritage.implements))) @heritage.impl\n";
|
|
8
|
+
export declare const JAVASCRIPT_QUERIES = "\n(class_declaration\n name: (identifier) @name) @definition.class\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; Await calls: await foo()\n(call_expression\n function: (await_expression\n (identifier) @call.name)) @call\n\n; Await member calls: await obj.method()\n(call_expression\n function: (await_expression\n (member_expression\n property: (property_identifier) @call.name))) @call\n\n; B3: Dynamic import calls: const { foo } = await import('./module.js')\n(call_expression\n function: (import) @call.name) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Exported const from call: export const schema = z.object({...})\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (call_expression)))) @definition.const\n\n; Exported const from new: export const client = new Client()\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (new_expression)))) @definition.const\n\n; Module-level const from new: const instance = new Class()\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (new_expression))) @definition.const\n\n; Exported const from array: export const ITEMS = [...]\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (array)))) @definition.const\n\n; Exported const from object: export const CONFIG = { ... }\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (object)))) @definition.const\n\n; Exported const from number/string\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (number)))) @definition.const\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (string)))) @definition.const\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (template_string)))) @definition.const\n\n; Object literal arrow function methods: const x = { method: () => {} }\n(pair\n key: (property_identifier) @name\n value: (arrow_function)) @definition.function\n\n; Object literal function expression methods: const x = { method: function() {} }\n(pair\n key: (property_identifier) @name\n value: (function_expression)) @definition.function\n\n; Heritage queries - class extends (JavaScript uses different AST than TypeScript)\n; In tree-sitter-javascript, class_heritage directly contains the parent identifier\n(class_declaration\n name: (identifier) @heritage.class\n (class_heritage\n (identifier) @heritage.extends)) @heritage\n";
|
|
9
9
|
export declare const PYTHON_QUERIES = "\n(class_definition\n name: (identifier) @name) @definition.class\n\n(function_definition\n name: (identifier) @name) @definition.function\n\n(import_statement\n name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (relative_import) @import.source) @import\n\n(call\n function: (identifier) @call.name) @call\n\n(call\n function: (attribute\n attribute: (identifier) @call.name)) @call\n\n; Heritage queries - Python class inheritance\n(class_definition\n name: (identifier) @heritage.class\n superclasses: (argument_list\n (identifier) @heritage.extends)) @heritage\n";
|
|
10
10
|
export declare const JAVA_QUERIES = "\n; Classes, Interfaces, Enums, Annotations\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(enum_declaration name: (identifier) @name) @definition.enum\n(annotation_type_declaration name: (identifier) @name) @definition.annotation\n\n; Methods & Constructors\n(method_declaration name: (identifier) @name) @definition.method\n(constructor_declaration name: (identifier) @name) @definition.constructor\n\n; Imports - capture any import declaration child as source\n(import_declaration (_) @import.source) @import\n\n; Calls\n(method_invocation name: (identifier) @call.name) @call\n(method_invocation object: (_) name: (identifier) @call.name) @call\n\n; Constructor calls: new Foo()\n(object_creation_expression type: (type_identifier) @call.name) @call\n\n; Heritage - extends class\n(class_declaration name: (identifier) @heritage.class\n (superclass (type_identifier) @heritage.extends)) @heritage\n\n; Heritage - implements interfaces\n(class_declaration name: (identifier) @heritage.class\n (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl\n";
|
|
11
11
|
export declare const C_QUERIES = "\n; Functions (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n\n; Functions returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Functions returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n\n; Structs, Unions, Enums, Typedefs\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(union_specifier name: (type_identifier) @name) @definition.union\n(enum_specifier name: (type_identifier) @name) @definition.enum\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n";
|
|
@@ -10,15 +10,28 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
10
10
|
(class_declaration
|
|
11
11
|
name: (type_identifier) @name) @definition.class
|
|
12
12
|
|
|
13
|
+
(abstract_class_declaration
|
|
14
|
+
name: (type_identifier) @name) @definition.class
|
|
15
|
+
|
|
13
16
|
(interface_declaration
|
|
14
17
|
name: (type_identifier) @name) @definition.interface
|
|
15
18
|
|
|
19
|
+
(type_alias_declaration
|
|
20
|
+
name: (type_identifier) @name) @definition.type
|
|
21
|
+
|
|
22
|
+
(enum_declaration
|
|
23
|
+
name: (identifier) @name) @definition.enum
|
|
24
|
+
|
|
16
25
|
(function_declaration
|
|
17
26
|
name: (identifier) @name) @definition.function
|
|
18
27
|
|
|
19
28
|
(method_definition
|
|
20
29
|
name: (property_identifier) @name) @definition.method
|
|
21
30
|
|
|
31
|
+
; Interface method signatures: interface Foo { method(): void }
|
|
32
|
+
(method_signature
|
|
33
|
+
name: (property_identifier) @name) @definition.method
|
|
34
|
+
|
|
22
35
|
(lexical_declaration
|
|
23
36
|
(variable_declarator
|
|
24
37
|
name: (identifier) @name
|
|
@@ -41,6 +54,15 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
41
54
|
name: (identifier) @name
|
|
42
55
|
value: (function_expression)))) @definition.function
|
|
43
56
|
|
|
57
|
+
; Namespace / internal module
|
|
58
|
+
(internal_module
|
|
59
|
+
name: (identifier) @name) @definition.namespace
|
|
60
|
+
|
|
61
|
+
; Ambient declarations: declare function foo(): void
|
|
62
|
+
(ambient_declaration
|
|
63
|
+
(function_signature
|
|
64
|
+
name: (identifier) @name)) @definition.function
|
|
65
|
+
|
|
44
66
|
(import_statement
|
|
45
67
|
source: (string) @import.source) @import
|
|
46
68
|
|
|
@@ -55,6 +77,17 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
55
77
|
function: (member_expression
|
|
56
78
|
property: (property_identifier) @call.name)) @call
|
|
57
79
|
|
|
80
|
+
; Await calls: await foo() — tree-sitter wraps await inside the function position
|
|
81
|
+
(call_expression
|
|
82
|
+
function: (await_expression
|
|
83
|
+
(identifier) @call.name)) @call
|
|
84
|
+
|
|
85
|
+
; Await member calls: await obj.method()
|
|
86
|
+
(call_expression
|
|
87
|
+
function: (await_expression
|
|
88
|
+
(member_expression
|
|
89
|
+
property: (property_identifier) @call.name))) @call
|
|
90
|
+
|
|
58
91
|
; B3: Dynamic import calls: const { foo } = await import('./module.js')
|
|
59
92
|
(call_expression
|
|
60
93
|
function: (import) @call.name) @call
|
|
@@ -63,6 +96,76 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
63
96
|
(new_expression
|
|
64
97
|
constructor: (identifier) @call.name) @call
|
|
65
98
|
|
|
99
|
+
; Exported const from call: export const Schema = z.object({...})
|
|
100
|
+
(export_statement
|
|
101
|
+
declaration: (lexical_declaration
|
|
102
|
+
(variable_declarator
|
|
103
|
+
name: (identifier) @name
|
|
104
|
+
value: (call_expression)))) @definition.const
|
|
105
|
+
|
|
106
|
+
; Exported const from new: export const client = new PrismaClient()
|
|
107
|
+
(export_statement
|
|
108
|
+
declaration: (lexical_declaration
|
|
109
|
+
(variable_declarator
|
|
110
|
+
name: (identifier) @name
|
|
111
|
+
value: (new_expression)))) @definition.const
|
|
112
|
+
|
|
113
|
+
; Module-level const from new: const prisma = new PrismaClient()
|
|
114
|
+
(lexical_declaration
|
|
115
|
+
(variable_declarator
|
|
116
|
+
name: (identifier) @name
|
|
117
|
+
value: (new_expression))) @definition.const
|
|
118
|
+
|
|
119
|
+
; Exported const from array: export const EDGE_TYPES = [...] as const
|
|
120
|
+
(export_statement
|
|
121
|
+
declaration: (lexical_declaration
|
|
122
|
+
(variable_declarator
|
|
123
|
+
name: (identifier) @name
|
|
124
|
+
value: (as_expression)))) @definition.const
|
|
125
|
+
|
|
126
|
+
; Exported const from array literal: export const FOO = [1, 2, 3]
|
|
127
|
+
(export_statement
|
|
128
|
+
declaration: (lexical_declaration
|
|
129
|
+
(variable_declarator
|
|
130
|
+
name: (identifier) @name
|
|
131
|
+
value: (array)))) @definition.const
|
|
132
|
+
|
|
133
|
+
; Exported const from object literal: export const CONFIG = { port: 3000 }
|
|
134
|
+
(export_statement
|
|
135
|
+
declaration: (lexical_declaration
|
|
136
|
+
(variable_declarator
|
|
137
|
+
name: (identifier) @name
|
|
138
|
+
value: (object)))) @definition.const
|
|
139
|
+
|
|
140
|
+
; Exported const from number/string: export const MAX_DEPTH = 10
|
|
141
|
+
(export_statement
|
|
142
|
+
declaration: (lexical_declaration
|
|
143
|
+
(variable_declarator
|
|
144
|
+
name: (identifier) @name
|
|
145
|
+
value: (number)))) @definition.const
|
|
146
|
+
|
|
147
|
+
(export_statement
|
|
148
|
+
declaration: (lexical_declaration
|
|
149
|
+
(variable_declarator
|
|
150
|
+
name: (identifier) @name
|
|
151
|
+
value: (string)))) @definition.const
|
|
152
|
+
|
|
153
|
+
(export_statement
|
|
154
|
+
declaration: (lexical_declaration
|
|
155
|
+
(variable_declarator
|
|
156
|
+
name: (identifier) @name
|
|
157
|
+
value: (template_string)))) @definition.const
|
|
158
|
+
|
|
159
|
+
; Object literal arrow function methods: const x = { method: () => {} }
|
|
160
|
+
(pair
|
|
161
|
+
key: (property_identifier) @name
|
|
162
|
+
value: (arrow_function)) @definition.function
|
|
163
|
+
|
|
164
|
+
; Object literal function expression methods: const x = { method: function() {} }
|
|
165
|
+
(pair
|
|
166
|
+
key: (property_identifier) @name
|
|
167
|
+
value: (function_expression)) @definition.function
|
|
168
|
+
|
|
66
169
|
; Heritage queries - class extends
|
|
67
170
|
(class_declaration
|
|
68
171
|
name: (type_identifier) @heritage.class
|
|
@@ -124,6 +227,17 @@ export const JAVASCRIPT_QUERIES = `
|
|
|
124
227
|
function: (member_expression
|
|
125
228
|
property: (property_identifier) @call.name)) @call
|
|
126
229
|
|
|
230
|
+
; Await calls: await foo()
|
|
231
|
+
(call_expression
|
|
232
|
+
function: (await_expression
|
|
233
|
+
(identifier) @call.name)) @call
|
|
234
|
+
|
|
235
|
+
; Await member calls: await obj.method()
|
|
236
|
+
(call_expression
|
|
237
|
+
function: (await_expression
|
|
238
|
+
(member_expression
|
|
239
|
+
property: (property_identifier) @call.name))) @call
|
|
240
|
+
|
|
127
241
|
; B3: Dynamic import calls: const { foo } = await import('./module.js')
|
|
128
242
|
(call_expression
|
|
129
243
|
function: (import) @call.name) @call
|
|
@@ -132,6 +246,69 @@ export const JAVASCRIPT_QUERIES = `
|
|
|
132
246
|
(new_expression
|
|
133
247
|
constructor: (identifier) @call.name) @call
|
|
134
248
|
|
|
249
|
+
; Exported const from call: export const schema = z.object({...})
|
|
250
|
+
(export_statement
|
|
251
|
+
declaration: (lexical_declaration
|
|
252
|
+
(variable_declarator
|
|
253
|
+
name: (identifier) @name
|
|
254
|
+
value: (call_expression)))) @definition.const
|
|
255
|
+
|
|
256
|
+
; Exported const from new: export const client = new Client()
|
|
257
|
+
(export_statement
|
|
258
|
+
declaration: (lexical_declaration
|
|
259
|
+
(variable_declarator
|
|
260
|
+
name: (identifier) @name
|
|
261
|
+
value: (new_expression)))) @definition.const
|
|
262
|
+
|
|
263
|
+
; Module-level const from new: const instance = new Class()
|
|
264
|
+
(lexical_declaration
|
|
265
|
+
(variable_declarator
|
|
266
|
+
name: (identifier) @name
|
|
267
|
+
value: (new_expression))) @definition.const
|
|
268
|
+
|
|
269
|
+
; Exported const from array: export const ITEMS = [...]
|
|
270
|
+
(export_statement
|
|
271
|
+
declaration: (lexical_declaration
|
|
272
|
+
(variable_declarator
|
|
273
|
+
name: (identifier) @name
|
|
274
|
+
value: (array)))) @definition.const
|
|
275
|
+
|
|
276
|
+
; Exported const from object: export const CONFIG = { ... }
|
|
277
|
+
(export_statement
|
|
278
|
+
declaration: (lexical_declaration
|
|
279
|
+
(variable_declarator
|
|
280
|
+
name: (identifier) @name
|
|
281
|
+
value: (object)))) @definition.const
|
|
282
|
+
|
|
283
|
+
; Exported const from number/string
|
|
284
|
+
(export_statement
|
|
285
|
+
declaration: (lexical_declaration
|
|
286
|
+
(variable_declarator
|
|
287
|
+
name: (identifier) @name
|
|
288
|
+
value: (number)))) @definition.const
|
|
289
|
+
|
|
290
|
+
(export_statement
|
|
291
|
+
declaration: (lexical_declaration
|
|
292
|
+
(variable_declarator
|
|
293
|
+
name: (identifier) @name
|
|
294
|
+
value: (string)))) @definition.const
|
|
295
|
+
|
|
296
|
+
(export_statement
|
|
297
|
+
declaration: (lexical_declaration
|
|
298
|
+
(variable_declarator
|
|
299
|
+
name: (identifier) @name
|
|
300
|
+
value: (template_string)))) @definition.const
|
|
301
|
+
|
|
302
|
+
; Object literal arrow function methods: const x = { method: () => {} }
|
|
303
|
+
(pair
|
|
304
|
+
key: (property_identifier) @name
|
|
305
|
+
value: (arrow_function)) @definition.function
|
|
306
|
+
|
|
307
|
+
; Object literal function expression methods: const x = { method: function() {} }
|
|
308
|
+
(pair
|
|
309
|
+
key: (property_identifier) @name
|
|
310
|
+
value: (function_expression)) @definition.function
|
|
311
|
+
|
|
135
312
|
; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
|
|
136
313
|
; In tree-sitter-javascript, class_heritage directly contains the parent identifier
|
|
137
314
|
(class_declaration
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Tier 2: single-pass assignment chain propagation
|
|
7
7
|
*/
|
|
8
8
|
import { FUNCTION_NODE_TYPES, extractFunctionName, CLASS_CONTAINER_TYPES } from './utils.js';
|
|
9
|
+
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
9
10
|
import { typeConfigs, TYPED_PARAMETER_TYPES } from './type-extractors/index.js';
|
|
10
11
|
import { extractSimpleTypeName, stripNullable } from './type-extractors/shared.js';
|
|
11
12
|
// File-level scope key
|
|
@@ -329,6 +330,25 @@ export const buildTypeEnv = (tree, language, symbolTable) => {
|
|
|
329
330
|
}
|
|
330
331
|
};
|
|
331
332
|
walk(tree.rootNode, FILE_SCOPE);
|
|
333
|
+
// Tier 1.5: Promote TypeScript constructor parameter properties to file scope.
|
|
334
|
+
// `constructor(private eventBus: EventBus)` makes `eventBus` a class property
|
|
335
|
+
// accessible in ALL methods via `this.eventBus`, not just within the constructor.
|
|
336
|
+
// Walk constructor scopes and find parameters with accessibility modifiers.
|
|
337
|
+
if (language === SupportedLanguages.TypeScript || language === SupportedLanguages.JavaScript) {
|
|
338
|
+
const fileEnv = env.get(FILE_SCOPE) ?? new Map();
|
|
339
|
+
if (!env.has(FILE_SCOPE))
|
|
340
|
+
env.set(FILE_SCOPE, fileEnv);
|
|
341
|
+
for (const [scope, scopeEnv] of env) {
|
|
342
|
+
if (!scope.startsWith('constructor@'))
|
|
343
|
+
continue;
|
|
344
|
+
for (const [varName, typeName] of scopeEnv) {
|
|
345
|
+
// Promote to file scope so all class methods can access via this.varName
|
|
346
|
+
if (!fileEnv.has(varName)) {
|
|
347
|
+
fileEnv.set(varName, typeName);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
332
352
|
// Tier 2: single-pass assignment chain propagation in source order
|
|
333
353
|
// Resolves `const b = a` where `a` has a known type from Tier 0/1
|
|
334
354
|
// No fixpoint iteration — covers 95%+ of real-world patterns
|
|
@@ -59,9 +59,10 @@ const extractDeclaration = (node, env) => {
|
|
|
59
59
|
// Try to infer from initializer: var x = new Foo()
|
|
60
60
|
// tree-sitter-c-sharp may put object_creation_expression as direct child
|
|
61
61
|
// or inside equals_value_clause depending on grammar version
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const firstDeclarator = declarators.length === 1 ? declarators[0] : undefined;
|
|
63
|
+
if (firstDeclarator) {
|
|
64
|
+
const initializer = findChildByType(firstDeclarator, 'object_creation_expression')
|
|
65
|
+
?? findChildByType(firstDeclarator, 'equals_value_clause')?.firstNamedChild;
|
|
65
66
|
if (initializer?.type === 'object_creation_expression') {
|
|
66
67
|
const ctorType = initializer.childForFieldName('type');
|
|
67
68
|
if (ctorType)
|
|
@@ -61,6 +61,9 @@ const extractGoShortVarDeclaration = (node, env) => {
|
|
|
61
61
|
const count = Math.min(lhsNodes.length, rhsNodes.length);
|
|
62
62
|
for (let i = 0; i < count; i++) {
|
|
63
63
|
let valueNode = rhsNodes[i];
|
|
64
|
+
const lhsNode = lhsNodes[i];
|
|
65
|
+
if (!valueNode || !lhsNode)
|
|
66
|
+
continue;
|
|
64
67
|
// Unwrap &User{} -- unary_expression (address-of) wrapping composite_literal
|
|
65
68
|
if (valueNode.type === 'unary_expression' && valueNode.firstNamedChild?.type === 'composite_literal') {
|
|
66
69
|
valueNode = valueNode.firstNamedChild;
|
|
@@ -73,7 +76,7 @@ const extractGoShortVarDeclaration = (node, env) => {
|
|
|
73
76
|
const args = valueNode.childForFieldName('arguments');
|
|
74
77
|
if (args?.firstNamedChild) {
|
|
75
78
|
const typeName = extractSimpleTypeName(args.firstNamedChild);
|
|
76
|
-
const varName = extractVarName(
|
|
79
|
+
const varName = extractVarName(lhsNode);
|
|
77
80
|
if (varName && typeName)
|
|
78
81
|
env.set(varName, typeName);
|
|
79
82
|
}
|
|
@@ -91,7 +94,7 @@ const extractGoShortVarDeclaration = (node, env) => {
|
|
|
91
94
|
}
|
|
92
95
|
if (innerType) {
|
|
93
96
|
const typeName = extractSimpleTypeName(innerType);
|
|
94
|
-
const varName = extractVarName(
|
|
97
|
+
const varName = extractVarName(lhsNode);
|
|
95
98
|
if (varName && typeName)
|
|
96
99
|
env.set(varName, typeName);
|
|
97
100
|
}
|
|
@@ -104,7 +107,7 @@ const extractGoShortVarDeclaration = (node, env) => {
|
|
|
104
107
|
const typeNode = valueNode.childForFieldName('type');
|
|
105
108
|
if (typeNode) {
|
|
106
109
|
const typeName = extractSimpleTypeName(typeNode);
|
|
107
|
-
const varName = extractVarName(
|
|
110
|
+
const varName = extractVarName(lhsNode);
|
|
108
111
|
if (varName && typeName)
|
|
109
112
|
env.set(varName, typeName);
|
|
110
113
|
}
|
|
@@ -118,7 +121,7 @@ const extractGoShortVarDeclaration = (node, env) => {
|
|
|
118
121
|
const typeName = extractSimpleTypeName(typeNode);
|
|
119
122
|
if (!typeName)
|
|
120
123
|
continue;
|
|
121
|
-
const varName = extractVarName(
|
|
124
|
+
const varName = extractVarName(lhsNode);
|
|
122
125
|
if (varName)
|
|
123
126
|
env.set(varName, typeName);
|
|
124
127
|
}
|
|
@@ -162,15 +165,19 @@ const scanConstructorBinding = (node) => {
|
|
|
162
165
|
const rightExprs = right.type === 'expression_list' ? right.namedChildren : [right];
|
|
163
166
|
// Multi-return: user, err := NewUser() -- bind first var when second is err/ok/_
|
|
164
167
|
if (leftIds.length === 2 && rightExprs.length === 1) {
|
|
168
|
+
const firstVar = leftIds[0];
|
|
165
169
|
const secondVar = leftIds[1];
|
|
170
|
+
const singleExpr = rightExprs[0];
|
|
171
|
+
if (!firstVar || !secondVar || !singleExpr)
|
|
172
|
+
return undefined;
|
|
166
173
|
const isErrorOrDiscard = secondVar.text === '_' ||
|
|
167
174
|
secondVar.text === 'err' ||
|
|
168
175
|
secondVar.text === 'ok' ||
|
|
169
176
|
secondVar.text === 'error';
|
|
170
|
-
if (isErrorOrDiscard &&
|
|
171
|
-
if (
|
|
177
|
+
if (isErrorOrDiscard && firstVar.type === 'identifier') {
|
|
178
|
+
if (singleExpr.type !== 'call_expression')
|
|
172
179
|
return undefined;
|
|
173
|
-
const func =
|
|
180
|
+
const func = singleExpr.childForFieldName('function');
|
|
174
181
|
if (!func)
|
|
175
182
|
return undefined;
|
|
176
183
|
if (func.text === 'new' || func.text === 'make')
|
|
@@ -178,15 +185,19 @@ const scanConstructorBinding = (node) => {
|
|
|
178
185
|
const calleeName = extractSimpleTypeName(func);
|
|
179
186
|
if (!calleeName)
|
|
180
187
|
return undefined;
|
|
181
|
-
return { varName:
|
|
188
|
+
return { varName: firstVar.text, calleeName };
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
// Single assignment only
|
|
185
|
-
|
|
192
|
+
const singleLeft = leftIds[0];
|
|
193
|
+
const singleRight = rightExprs[0];
|
|
194
|
+
if (!singleLeft || !singleRight)
|
|
195
|
+
return undefined;
|
|
196
|
+
if (leftIds.length !== 1 || singleLeft.type !== 'identifier')
|
|
186
197
|
return undefined;
|
|
187
|
-
if (rightExprs.length !== 1 ||
|
|
198
|
+
if (rightExprs.length !== 1 || singleRight.type !== 'call_expression')
|
|
188
199
|
return undefined;
|
|
189
|
-
const func =
|
|
200
|
+
const func = singleRight.childForFieldName('function');
|
|
190
201
|
if (!func)
|
|
191
202
|
return undefined;
|
|
192
203
|
// Skip new() and make() -- already handled by extractDeclaration
|
|
@@ -195,7 +206,7 @@ const scanConstructorBinding = (node) => {
|
|
|
195
206
|
const calleeName = extractSimpleTypeName(func);
|
|
196
207
|
if (!calleeName)
|
|
197
208
|
return undefined;
|
|
198
|
-
return { varName:
|
|
209
|
+
return { varName: singleLeft.text, calleeName };
|
|
199
210
|
};
|
|
200
211
|
// Go: alias := u (short_var_declaration) or var b = u (var_spec)
|
|
201
212
|
const extractPendingAssignment = (node, scopeEnv) => {
|
|
@@ -53,12 +53,15 @@ const normalizePhpType = (raw) => {
|
|
|
53
53
|
type = type.replace(/\[\]$/, '');
|
|
54
54
|
// Strip union with null/false/void: User|null -> User
|
|
55
55
|
const parts = type.split('|').filter(p => p !== 'null' && p !== 'false' && p !== 'void' && p !== 'mixed');
|
|
56
|
-
if (parts.length !== 1)
|
|
56
|
+
if (parts.length !== 1 || !parts[0])
|
|
57
57
|
return undefined;
|
|
58
58
|
type = parts[0];
|
|
59
59
|
// Strip namespace: \App\Models\User -> User
|
|
60
60
|
const segments = type.split('\\');
|
|
61
|
-
|
|
61
|
+
const lastSegment = segments[segments.length - 1];
|
|
62
|
+
if (!lastSegment)
|
|
63
|
+
return undefined;
|
|
64
|
+
type = lastSegment;
|
|
62
65
|
// Skip uninformative types
|
|
63
66
|
if (type === 'mixed' || type === 'void' || type === 'self' || type === 'static' || type === 'object')
|
|
64
67
|
return undefined;
|
|
@@ -96,8 +99,11 @@ const collectPhpDocParams = (methodNode) => {
|
|
|
96
99
|
PHPDOC_PARAM_RE.lastIndex = 0;
|
|
97
100
|
let match;
|
|
98
101
|
while ((match = PHPDOC_PARAM_RE.exec(commentBlock)) !== null) {
|
|
99
|
-
const
|
|
102
|
+
const rawType = match[1];
|
|
100
103
|
const paramName = match[2]; // without $ prefix
|
|
104
|
+
if (!rawType || !paramName)
|
|
105
|
+
continue;
|
|
106
|
+
const typeName = normalizePhpType(rawType);
|
|
101
107
|
if (typeName) {
|
|
102
108
|
// Store with $ prefix to match how PHP variables appear in the env
|
|
103
109
|
params.set('$' + paramName, typeName);
|
|
@@ -107,9 +113,12 @@ const collectPhpDocParams = (methodNode) => {
|
|
|
107
113
|
PHPDOC_PARAM_ALT_RE.lastIndex = 0;
|
|
108
114
|
while ((match = PHPDOC_PARAM_ALT_RE.exec(commentBlock)) !== null) {
|
|
109
115
|
const paramName = match[1];
|
|
116
|
+
const rawType = match[2];
|
|
117
|
+
if (!paramName || !rawType)
|
|
118
|
+
continue;
|
|
110
119
|
if (params.has('$' + paramName))
|
|
111
120
|
continue; // standard format takes priority
|
|
112
|
-
const typeName = normalizePhpType(
|
|
121
|
+
const typeName = normalizePhpType(rawType);
|
|
113
122
|
if (typeName) {
|
|
114
123
|
params.set('$' + paramName, typeName);
|
|
115
124
|
}
|
|
@@ -197,7 +206,6 @@ const extractParameter = (node, env) => {
|
|
|
197
206
|
if (varName && typeName)
|
|
198
207
|
env.set(varName, typeName);
|
|
199
208
|
};
|
|
200
|
-
// PHP: $x = SomeFactory() or $x = $this->getUser() -- bind variable to call return type
|
|
201
209
|
const scanConstructorBinding = (node) => {
|
|
202
210
|
if (node.type !== 'assignment_expression')
|
|
203
211
|
return undefined;
|
|
@@ -224,14 +232,14 @@ const scanConstructorBinding = (node) => {
|
|
|
224
232
|
// When receiver is $this/self/static, qualify with enclosing class for disambiguation
|
|
225
233
|
const receiver = right.childForFieldName('object');
|
|
226
234
|
const receiverText = receiver?.text;
|
|
227
|
-
let receiverClassName;
|
|
228
235
|
if (receiverText === '$this' || receiverText === 'self' || receiverText === 'static') {
|
|
229
236
|
const cls = findEnclosingClass(node);
|
|
230
237
|
const clsName = cls?.childForFieldName('name');
|
|
231
|
-
if (clsName)
|
|
232
|
-
receiverClassName
|
|
238
|
+
if (clsName) {
|
|
239
|
+
return { varName: left.text, calleeName: methodName.text, receiverClassName: clsName.text };
|
|
240
|
+
}
|
|
233
241
|
}
|
|
234
|
-
return { varName: left.text, calleeName: methodName.text
|
|
242
|
+
return { varName: left.text, calleeName: methodName.text };
|
|
235
243
|
}
|
|
236
244
|
return undefined;
|
|
237
245
|
};
|
|
@@ -243,7 +251,7 @@ const extractReturnType = (node) => {
|
|
|
243
251
|
while (sibling) {
|
|
244
252
|
if (sibling.type === 'comment') {
|
|
245
253
|
const match = PHPDOC_RETURN_RE.exec(sibling.text);
|
|
246
|
-
if (match)
|
|
254
|
+
if (match?.[1])
|
|
247
255
|
return normalizePhpType(match[1]);
|
|
248
256
|
}
|
|
249
257
|
else if (sibling.isNamed && !SKIP_NODE_TYPES.has(sibling.type))
|
|
@@ -44,13 +44,21 @@ const extractYardTypeName = (yardType) => {
|
|
|
44
44
|
if (filtered.length !== 1)
|
|
45
45
|
return undefined; // ambiguous union
|
|
46
46
|
const typePart = filtered[0];
|
|
47
|
+
if (typePart === undefined)
|
|
48
|
+
return undefined;
|
|
47
49
|
// Handle qualified: "Models::User" -> "User"
|
|
48
50
|
const segments = typePart.split('::');
|
|
49
51
|
const last = segments[segments.length - 1];
|
|
52
|
+
if (last === undefined)
|
|
53
|
+
return undefined;
|
|
50
54
|
// Handle generic: "Array<User>" -> "Array"
|
|
51
55
|
const genericMatch = last.match(/^(\w+)\s*[<{(]/);
|
|
52
|
-
if (genericMatch)
|
|
53
|
-
|
|
56
|
+
if (genericMatch) {
|
|
57
|
+
const matched = genericMatch[1];
|
|
58
|
+
if (matched === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
return matched;
|
|
61
|
+
}
|
|
54
62
|
// Simple identifier check
|
|
55
63
|
if (/^\w+$/.test(last))
|
|
56
64
|
return last;
|
|
@@ -97,6 +105,8 @@ const collectYardParams = (methodNode) => {
|
|
|
97
105
|
while ((match = YARD_PARAM_RE.exec(commentBlock)) !== null) {
|
|
98
106
|
const paramName = match[1];
|
|
99
107
|
const rawType = match[2];
|
|
108
|
+
if (paramName === undefined || rawType === undefined)
|
|
109
|
+
continue;
|
|
100
110
|
const typeName = extractYardTypeName(rawType);
|
|
101
111
|
if (typeName) {
|
|
102
112
|
params.set(paramName, typeName);
|
|
@@ -107,6 +117,8 @@ const collectYardParams = (methodNode) => {
|
|
|
107
117
|
while ((match = YARD_PARAM_ALT_RE.exec(commentBlock)) !== null) {
|
|
108
118
|
const rawType = match[1];
|
|
109
119
|
const paramName = match[2];
|
|
120
|
+
if (rawType === undefined || paramName === undefined)
|
|
121
|
+
continue;
|
|
110
122
|
if (params.has(paramName))
|
|
111
123
|
continue; // standard format takes priority
|
|
112
124
|
const typeName = extractYardTypeName(rawType);
|
|
@@ -163,7 +175,7 @@ const extractReturnType = (node) => {
|
|
|
163
175
|
while (sibling) {
|
|
164
176
|
if (sibling.type === 'comment') {
|
|
165
177
|
const match = YARD_RETURN_RE.exec(sibling.text);
|
|
166
|
-
if (match)
|
|
178
|
+
if (match && match[1] !== undefined)
|
|
167
179
|
return extractYardTypeName(match[1]);
|
|
168
180
|
}
|
|
169
181
|
else if (sibling.isNamed) {
|
|
@@ -275,9 +275,10 @@ const extractPatternBinding = (node, scopeEnv, declarationTypeNodes, scope) => {
|
|
|
275
275
|
return undefined;
|
|
276
276
|
const typeArgs = extractGenericTypeArgs(typeAstNode);
|
|
277
277
|
const argIndex = wrapperName === 'Err' ? 1 : 0;
|
|
278
|
-
|
|
278
|
+
const extractedType = typeArgs[argIndex];
|
|
279
|
+
if (!extractedType)
|
|
279
280
|
return undefined;
|
|
280
|
-
return { varName: innerVar, typeName:
|
|
281
|
+
return { varName: innerVar, typeName: extractedType };
|
|
281
282
|
};
|
|
282
283
|
export const typeConfig = {
|
|
283
284
|
declarationNodeTypes: DECLARATION_NODE_TYPES,
|
|
@@ -76,8 +76,9 @@ export const extractSimpleTypeName = (typeNode) => {
|
|
|
76
76
|
nonNullTypes.push(child);
|
|
77
77
|
}
|
|
78
78
|
// Only unwrap if exactly one meaningful type remains
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const single = nonNullTypes.length === 1 ? nonNullTypes[0] : undefined;
|
|
80
|
+
if (single) {
|
|
81
|
+
return extractSimpleTypeName(single);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
// Type annotations that wrap the actual type (TS/Python: `: Foo`, Kotlin: user_type)
|
|
@@ -16,7 +16,7 @@ const normalizeJsDocType = (raw) => {
|
|
|
16
16
|
type = type.slice(1);
|
|
17
17
|
// Strip union with null/undefined/void: User|null -> User
|
|
18
18
|
const parts = type.split('|').map(p => p.trim()).filter(p => p !== 'null' && p !== 'undefined' && p !== 'void');
|
|
19
|
-
if (parts.length !== 1)
|
|
19
|
+
if (parts.length !== 1 || !parts[0])
|
|
20
20
|
return undefined; // ambiguous union
|
|
21
21
|
type = parts[0];
|
|
22
22
|
// Strip module: prefix -- module:models.User -> models.User
|
|
@@ -24,10 +24,13 @@ const normalizeJsDocType = (raw) => {
|
|
|
24
24
|
type = type.slice(7);
|
|
25
25
|
// Take last segment of dotted path: models.User -> User
|
|
26
26
|
const segments = type.split('.');
|
|
27
|
-
|
|
27
|
+
const lastSegment = segments[segments.length - 1];
|
|
28
|
+
if (!lastSegment)
|
|
29
|
+
return undefined;
|
|
30
|
+
type = lastSegment;
|
|
28
31
|
// Strip generic wrapper: Promise<User> -> Promise (base type, not inner)
|
|
29
32
|
const genericMatch = type.match(/^(\w+)\s*</);
|
|
30
|
-
if (genericMatch)
|
|
33
|
+
if (genericMatch?.[1])
|
|
31
34
|
type = genericMatch[1];
|
|
32
35
|
// Simple identifier check
|
|
33
36
|
if (/^\w+$/.test(type))
|
|
@@ -59,8 +62,11 @@ const collectJsDocParams = (funcNode) => {
|
|
|
59
62
|
JSDOC_PARAM_RE.lastIndex = 0;
|
|
60
63
|
let match;
|
|
61
64
|
while ((match = JSDOC_PARAM_RE.exec(commentBlock)) !== null) {
|
|
62
|
-
const
|
|
65
|
+
const rawType = match[1];
|
|
63
66
|
const paramName = match[2];
|
|
67
|
+
if (!rawType || !paramName)
|
|
68
|
+
continue;
|
|
69
|
+
const typeName = normalizeJsDocType(rawType);
|
|
64
70
|
if (typeName) {
|
|
65
71
|
params.set(paramName, typeName);
|
|
66
72
|
}
|
|
@@ -189,7 +195,7 @@ const extractReturnType = (node) => {
|
|
|
189
195
|
while (sibling) {
|
|
190
196
|
if (sibling.type === 'comment') {
|
|
191
197
|
const match = JSDOC_RETURN_RE.exec(sibling.text);
|
|
192
|
-
if (match)
|
|
198
|
+
if (match?.[1])
|
|
193
199
|
return sanitizeReturnType(match[1]);
|
|
194
200
|
}
|
|
195
201
|
else if (sibling.isNamed && sibling.type !== 'decorator')
|
|
@@ -14,10 +14,33 @@ export declare const getDefinitionNodeFromCaptures: (captureMap: Record<string,
|
|
|
14
14
|
export declare const FUNCTION_NODE_TYPES: Set<string>;
|
|
15
15
|
/** Node types for standard function declarations that need C/C++ declarator handling */
|
|
16
16
|
export declare const FUNCTION_DECLARATION_TYPES: Set<string>;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Built-in names that are noise when called as FREE functions: `list()`, `print()`, `console()`.
|
|
19
|
+
* These are ONLY filtered for free calls (callForm !== 'member').
|
|
20
|
+
* Member calls like `obj.list()`, `obj.set()`, `obj.map()` are NEVER filtered —
|
|
21
|
+
* they are real method calls on user-defined objects.
|
|
22
|
+
*
|
|
23
|
+
* Names that appear in multiple languages are kept only if they are universally noise.
|
|
24
|
+
* Names that are valid user method names in some languages (list, set, type, get, put,
|
|
25
|
+
* map, filter, etc.) are excluded — they belong in MEMBER_NOISE_NAMES for member-only filtering.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FREE_CALL_BUILTINS: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Method names that are noise ONLY when called as MEMBER calls on unknown receivers.
|
|
30
|
+
* These are generic methods on built-in types (Array, Promise, Map, etc.) that would
|
|
31
|
+
* falsely resolve to user-defined functions of the same name.
|
|
32
|
+
*
|
|
33
|
+
* Only filtered when receiver type is unknown — if receiver type IS resolved,
|
|
34
|
+
* the call is kept because we know it's on a specific user type.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MEMBER_NOISE_NAMES: Set<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a name should be filtered based on call form.
|
|
39
|
+
* - Free calls: filtered if name is a known built-in free function
|
|
40
|
+
* - Member calls: filtered ONLY if name is a known noise method AND receiver type is unknown
|
|
41
|
+
* - Constructor calls: never filtered
|
|
42
|
+
*/
|
|
43
|
+
export declare const isBuiltInOrNoise: (name: string, callForm?: "free" | "member" | "constructor") => boolean;
|
|
21
44
|
/** AST node types representing class-like containers (for HAS_METHOD edges) */
|
|
22
45
|
export declare const CLASS_CONTAINER_TYPES: Set<string>;
|
|
23
46
|
export declare const CONTAINER_TYPE_TO_LABEL: Record<string, string>;
|