gitnexus 1.4.9 → 1.5.0
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/README.md +6 -5
- package/dist/cli/ai-context.d.ts +4 -1
- package/dist/cli/ai-context.js +19 -11
- package/dist/cli/analyze.d.ts +6 -0
- package/dist/cli/analyze.js +105 -251
- package/dist/cli/eval-server.js +20 -11
- package/dist/cli/index-repo.js +20 -22
- package/dist/cli/index.js +8 -7
- package/dist/cli/mcp.js +1 -1
- package/dist/cli/serve.js +29 -1
- package/dist/cli/setup.js +9 -9
- package/dist/cli/skill-gen.js +15 -9
- package/dist/cli/wiki.d.ts +2 -0
- package/dist/cli/wiki.js +141 -26
- package/dist/config/ignore-service.js +102 -22
- package/dist/config/supported-languages.d.ts +8 -42
- package/dist/config/supported-languages.js +8 -43
- package/dist/core/augmentation/engine.js +19 -7
- package/dist/core/embeddings/embedder.js +19 -15
- package/dist/core/embeddings/embedding-pipeline.js +6 -6
- package/dist/core/embeddings/http-client.js +3 -3
- package/dist/core/embeddings/text-generator.js +9 -24
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/embeddings/types.js +1 -7
- package/dist/core/graph/graph.js +6 -2
- package/dist/core/graph/types.d.ts +9 -59
- package/dist/core/ingestion/ast-cache.js +3 -3
- package/dist/core/ingestion/call-processor.d.ts +20 -2
- package/dist/core/ingestion/call-processor.js +347 -144
- package/dist/core/ingestion/call-routing.js +10 -4
- package/dist/core/ingestion/call-sites/extract-language-call-site.d.ts +10 -0
- package/dist/core/ingestion/call-sites/extract-language-call-site.js +22 -0
- package/dist/core/ingestion/call-sites/java.d.ts +9 -0
- package/dist/core/ingestion/call-sites/java.js +30 -0
- package/dist/core/ingestion/cluster-enricher.js +6 -8
- package/dist/core/ingestion/cobol/cobol-copy-expander.js +10 -3
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +287 -81
- package/dist/core/ingestion/cobol/jcl-parser.js +1 -1
- package/dist/core/ingestion/cobol/jcl-processor.js +1 -1
- package/dist/core/ingestion/cobol-processor.js +102 -56
- package/dist/core/ingestion/community-processor.js +21 -15
- package/dist/core/ingestion/entry-point-scoring.d.ts +1 -1
- package/dist/core/ingestion/entry-point-scoring.js +5 -6
- package/dist/core/ingestion/export-detection.js +32 -9
- package/dist/core/ingestion/field-extractor.d.ts +1 -1
- package/dist/core/ingestion/field-extractors/configs/c-cpp.js +8 -12
- package/dist/core/ingestion/field-extractors/configs/csharp.js +45 -2
- package/dist/core/ingestion/field-extractors/configs/dart.js +5 -3
- package/dist/core/ingestion/field-extractors/configs/go.js +3 -7
- package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +5 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.js +14 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.js +7 -7
- package/dist/core/ingestion/field-extractors/configs/php.js +9 -11
- package/dist/core/ingestion/field-extractors/configs/python.js +1 -1
- package/dist/core/ingestion/field-extractors/configs/ruby.js +4 -3
- package/dist/core/ingestion/field-extractors/configs/rust.js +2 -5
- package/dist/core/ingestion/field-extractors/configs/swift.js +9 -7
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +2 -6
- package/dist/core/ingestion/field-extractors/generic.d.ts +5 -2
- package/dist/core/ingestion/field-extractors/generic.js +6 -0
- package/dist/core/ingestion/field-extractors/typescript.d.ts +1 -1
- package/dist/core/ingestion/field-extractors/typescript.js +1 -1
- package/dist/core/ingestion/field-types.d.ts +4 -2
- package/dist/core/ingestion/filesystem-walker.js +3 -3
- package/dist/core/ingestion/framework-detection.d.ts +1 -1
- package/dist/core/ingestion/framework-detection.js +355 -85
- package/dist/core/ingestion/heritage-processor.d.ts +24 -0
- package/dist/core/ingestion/heritage-processor.js +99 -8
- package/dist/core/ingestion/import-processor.js +44 -15
- package/dist/core/ingestion/import-resolvers/csharp.js +7 -3
- package/dist/core/ingestion/import-resolvers/dart.js +1 -1
- package/dist/core/ingestion/import-resolvers/go.js +4 -2
- package/dist/core/ingestion/import-resolvers/jvm.js +4 -4
- package/dist/core/ingestion/import-resolvers/php.js +4 -4
- package/dist/core/ingestion/import-resolvers/python.js +1 -1
- package/dist/core/ingestion/import-resolvers/rust.js +9 -3
- package/dist/core/ingestion/import-resolvers/standard.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/standard.js +6 -5
- package/dist/core/ingestion/import-resolvers/swift.js +2 -1
- package/dist/core/ingestion/import-resolvers/utils.js +26 -7
- package/dist/core/ingestion/language-config.js +5 -4
- package/dist/core/ingestion/language-provider.d.ts +7 -2
- package/dist/core/ingestion/languages/c-cpp.js +106 -21
- package/dist/core/ingestion/languages/cobol.js +1 -1
- package/dist/core/ingestion/languages/csharp.js +96 -19
- package/dist/core/ingestion/languages/dart.js +23 -7
- package/dist/core/ingestion/languages/go.js +1 -1
- package/dist/core/ingestion/languages/index.d.ts +1 -1
- package/dist/core/ingestion/languages/index.js +2 -3
- package/dist/core/ingestion/languages/java.js +4 -1
- package/dist/core/ingestion/languages/kotlin.js +60 -13
- package/dist/core/ingestion/languages/php.js +102 -25
- package/dist/core/ingestion/languages/python.js +28 -5
- package/dist/core/ingestion/languages/ruby.js +56 -14
- package/dist/core/ingestion/languages/rust.js +55 -11
- package/dist/core/ingestion/languages/swift.js +112 -27
- package/dist/core/ingestion/languages/typescript.js +95 -19
- package/dist/core/ingestion/markdown-processor.js +5 -5
- package/dist/core/ingestion/method-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/csharp.js +283 -0
- package/dist/core/ingestion/method-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/method-extractors/configs/jvm.js +326 -0
- package/dist/core/ingestion/method-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/method-extractors/generic.js +137 -0
- package/dist/core/ingestion/method-types.d.ts +61 -0
- package/dist/core/ingestion/method-types.js +2 -0
- package/dist/core/ingestion/mro-processor.d.ts +1 -1
- package/dist/core/ingestion/mro-processor.js +12 -8
- package/dist/core/ingestion/named-binding-processor.js +2 -2
- package/dist/core/ingestion/named-bindings/rust.js +3 -1
- package/dist/core/ingestion/parsing-processor.js +74 -24
- package/dist/core/ingestion/pipeline.d.ts +2 -1
- package/dist/core/ingestion/pipeline.js +208 -102
- package/dist/core/ingestion/process-processor.js +12 -10
- package/dist/core/ingestion/resolution-context.js +3 -3
- package/dist/core/ingestion/route-extractors/middleware.js +31 -7
- package/dist/core/ingestion/route-extractors/php.js +2 -1
- package/dist/core/ingestion/route-extractors/response-shapes.js +8 -4
- package/dist/core/ingestion/structure-processor.d.ts +1 -1
- package/dist/core/ingestion/structure-processor.js +4 -4
- package/dist/core/ingestion/symbol-table.d.ts +1 -1
- package/dist/core/ingestion/symbol-table.js +22 -6
- package/dist/core/ingestion/tree-sitter-queries.d.ts +1 -1
- package/dist/core/ingestion/tree-sitter-queries.js +1 -1
- package/dist/core/ingestion/type-env.d.ts +2 -2
- package/dist/core/ingestion/type-env.js +75 -50
- package/dist/core/ingestion/type-extractors/c-cpp.js +33 -30
- package/dist/core/ingestion/type-extractors/csharp.js +24 -14
- package/dist/core/ingestion/type-extractors/dart.js +6 -8
- package/dist/core/ingestion/type-extractors/go.js +7 -6
- package/dist/core/ingestion/type-extractors/jvm.js +10 -21
- package/dist/core/ingestion/type-extractors/php.js +26 -13
- package/dist/core/ingestion/type-extractors/python.js +11 -15
- package/dist/core/ingestion/type-extractors/ruby.js +8 -3
- package/dist/core/ingestion/type-extractors/rust.js +6 -8
- package/dist/core/ingestion/type-extractors/shared.js +134 -50
- package/dist/core/ingestion/type-extractors/swift.js +16 -13
- package/dist/core/ingestion/type-extractors/typescript.js +23 -15
- package/dist/core/ingestion/utils/ast-helpers.d.ts +8 -8
- package/dist/core/ingestion/utils/ast-helpers.js +72 -35
- package/dist/core/ingestion/utils/call-analysis.d.ts +2 -0
- package/dist/core/ingestion/utils/call-analysis.js +96 -49
- package/dist/core/ingestion/utils/event-loop.js +1 -1
- package/dist/core/ingestion/workers/parse-worker.d.ts +7 -2
- package/dist/core/ingestion/workers/parse-worker.js +364 -84
- package/dist/core/ingestion/workers/worker-pool.js +5 -10
- package/dist/core/lbug/csv-generator.js +54 -15
- package/dist/core/lbug/lbug-adapter.d.ts +5 -0
- package/dist/core/lbug/lbug-adapter.js +86 -23
- package/dist/core/lbug/schema.d.ts +3 -6
- package/dist/core/lbug/schema.js +6 -30
- package/dist/core/run-analyze.d.ts +49 -0
- package/dist/core/run-analyze.js +257 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +1 -1
- package/dist/core/tree-sitter/parser-loader.js +1 -1
- package/dist/core/wiki/cursor-client.js +2 -7
- package/dist/core/wiki/generator.js +38 -23
- package/dist/core/wiki/graph-queries.js +10 -10
- package/dist/core/wiki/html-viewer.js +7 -3
- package/dist/core/wiki/llm-client.d.ts +23 -2
- package/dist/core/wiki/llm-client.js +96 -26
- package/dist/core/wiki/prompts.js +7 -6
- package/dist/mcp/core/embedder.js +1 -1
- package/dist/mcp/core/lbug-adapter.d.ts +4 -1
- package/dist/mcp/core/lbug-adapter.js +17 -7
- package/dist/mcp/local/local-backend.js +247 -95
- package/dist/mcp/resources.js +14 -6
- package/dist/mcp/server.js +13 -5
- package/dist/mcp/staleness.js +5 -1
- package/dist/mcp/tools.js +100 -23
- package/dist/server/analyze-job.d.ts +53 -0
- package/dist/server/analyze-job.js +146 -0
- package/dist/server/analyze-worker.d.ts +13 -0
- package/dist/server/analyze-worker.js +59 -0
- package/dist/server/api.js +795 -44
- package/dist/server/git-clone.d.ts +25 -0
- package/dist/server/git-clone.js +91 -0
- package/dist/storage/git.js +1 -3
- package/dist/storage/repo-manager.d.ts +5 -2
- package/dist/storage/repo-manager.js +4 -4
- package/dist/types/pipeline.d.ts +1 -21
- package/dist/types/pipeline.js +1 -18
- package/hooks/claude/gitnexus-hook.cjs +52 -22
- package/package.json +13 -13
- package/dist/core/ingestion/utils/language-detection.d.ts +0 -9
- package/dist/core/ingestion/utils/language-detection.js +0 -70
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { findChild } from '../utils/ast-helpers.js';
|
|
2
|
-
import { extractSimpleTypeName, extractVarName, hasTypeAnnotation, extractElementTypeFromString, resolveIterableElementType } from './shared.js';
|
|
2
|
+
import { extractSimpleTypeName, extractVarName, hasTypeAnnotation, extractElementTypeFromString, resolveIterableElementType, } from './shared.js';
|
|
3
3
|
const DECLARATION_NODE_TYPES = new Set([
|
|
4
4
|
'property_declaration',
|
|
5
5
|
'if_statement',
|
|
6
6
|
'guard_statement',
|
|
7
7
|
]);
|
|
8
|
-
const FOR_LOOP_NODE_TYPES = new Set([
|
|
9
|
-
'for_statement',
|
|
10
|
-
]);
|
|
8
|
+
const FOR_LOOP_NODE_TYPES = new Set(['for_statement']);
|
|
11
9
|
/**
|
|
12
10
|
* Unwrap Swift `await_expression` and `try_expression` nodes to find the inner
|
|
13
11
|
* call_expression or other value node. `try` nodes contain a `try_operator` child
|
|
@@ -26,10 +24,8 @@ function unwrapSwiftExpression(node) {
|
|
|
26
24
|
/** Swift: let x: Foo = ... */
|
|
27
25
|
const extractDeclaration = (node, env) => {
|
|
28
26
|
// Swift property_declaration has pattern and type_annotation
|
|
29
|
-
const pattern = node.childForFieldName('pattern')
|
|
30
|
-
|
|
31
|
-
const typeAnnotation = node.childForFieldName('type')
|
|
32
|
-
?? findChild(node, 'type_annotation');
|
|
27
|
+
const pattern = node.childForFieldName('pattern') ?? findChild(node, 'pattern');
|
|
28
|
+
const typeAnnotation = node.childForFieldName('type') ?? findChild(node, 'type_annotation');
|
|
33
29
|
if (!pattern || !typeAnnotation)
|
|
34
30
|
return;
|
|
35
31
|
const varName = extractVarName(pattern) ?? pattern.text;
|
|
@@ -42,8 +38,7 @@ const extractParameter = (node, env) => {
|
|
|
42
38
|
let nameNode = null;
|
|
43
39
|
let typeNode = null;
|
|
44
40
|
if (node.type === 'parameter') {
|
|
45
|
-
nameNode = node.childForFieldName('name')
|
|
46
|
-
?? node.childForFieldName('internal_name');
|
|
41
|
+
nameNode = node.childForFieldName('name') ?? node.childForFieldName('internal_name');
|
|
47
42
|
typeNode = node.childForFieldName('type');
|
|
48
43
|
}
|
|
49
44
|
else {
|
|
@@ -235,7 +230,12 @@ function extractIfGuardBinding(node, scopeEnv) {
|
|
|
235
230
|
if (receiver?.type === 'simple_identifier' && suffix?.type === 'navigation_suffix') {
|
|
236
231
|
const method = suffix.lastNamedChild;
|
|
237
232
|
if (method?.type === 'simple_identifier') {
|
|
238
|
-
return {
|
|
233
|
+
return {
|
|
234
|
+
kind: 'methodCallResult',
|
|
235
|
+
lhs: varName,
|
|
236
|
+
receiver: receiver.text,
|
|
237
|
+
method: method.text,
|
|
238
|
+
};
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -281,7 +281,9 @@ const extractPendingAssignment = (node, scopeEnv) => {
|
|
|
281
281
|
const child = node.namedChild(i);
|
|
282
282
|
if (!child)
|
|
283
283
|
continue;
|
|
284
|
-
if (child.type === 'pattern' ||
|
|
284
|
+
if (child.type === 'pattern' ||
|
|
285
|
+
child.type === 'value_binding_pattern' ||
|
|
286
|
+
child.type === 'type_annotation')
|
|
285
287
|
continue;
|
|
286
288
|
valueNode = child;
|
|
287
289
|
break;
|
|
@@ -358,7 +360,8 @@ const extractForLoopBinding = (node, { scopeEnv, declarationTypeNodes, scope, re
|
|
|
358
360
|
}
|
|
359
361
|
// After we found the loop var, the next expression-like node is the iterable
|
|
360
362
|
if (loopVarName && !iterableNode) {
|
|
361
|
-
if (child.type === 'simple_identifier' ||
|
|
363
|
+
if (child.type === 'simple_identifier' ||
|
|
364
|
+
child.type === 'call_expression' ||
|
|
362
365
|
child.type === 'navigation_expression') {
|
|
363
366
|
iterableNode = child;
|
|
364
367
|
break;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractSimpleTypeName, extractVarName, hasTypeAnnotation, unwrapAwait, extractCalleeName, extractElementTypeFromString, extractGenericTypeArgs, resolveIterableElementType, methodToTypeArgPosition } from './shared.js';
|
|
1
|
+
import { extractSimpleTypeName, extractVarName, hasTypeAnnotation, unwrapAwait, extractCalleeName, extractElementTypeFromString, extractGenericTypeArgs, resolveIterableElementType, methodToTypeArgPosition, } from './shared.js';
|
|
2
2
|
const DECLARATION_NODE_TYPES = new Set([
|
|
3
3
|
'lexical_declaration',
|
|
4
4
|
'variable_declaration',
|
|
@@ -12,7 +12,10 @@ const normalizeJsDocType = (raw) => {
|
|
|
12
12
|
if (type.startsWith('?') || type.startsWith('!'))
|
|
13
13
|
type = type.slice(1);
|
|
14
14
|
// Strip union with null/undefined/void: User|null → User
|
|
15
|
-
const parts = type
|
|
15
|
+
const parts = type
|
|
16
|
+
.split('|')
|
|
17
|
+
.map((p) => p.trim())
|
|
18
|
+
.filter((p) => p !== 'null' && p !== 'undefined' && p !== 'void');
|
|
16
19
|
if (parts.length !== 1)
|
|
17
20
|
return undefined; // ambiguous union
|
|
18
21
|
type = parts[0];
|
|
@@ -218,13 +221,15 @@ const extractReturnType = (node) => {
|
|
|
218
221
|
}
|
|
219
222
|
return undefined;
|
|
220
223
|
};
|
|
221
|
-
const FOR_LOOP_NODE_TYPES = new Set([
|
|
222
|
-
'for_in_statement',
|
|
223
|
-
]);
|
|
224
|
+
const FOR_LOOP_NODE_TYPES = new Set(['for_in_statement']);
|
|
224
225
|
/** TS function/method node types that carry a parameters list. */
|
|
225
226
|
const TS_FUNCTION_NODE_TYPES = new Set([
|
|
226
|
-
'function_declaration',
|
|
227
|
-
'
|
|
227
|
+
'function_declaration',
|
|
228
|
+
'function_expression',
|
|
229
|
+
'arrow_function',
|
|
230
|
+
'method_definition',
|
|
231
|
+
'generator_function',
|
|
232
|
+
'generator_function_declaration',
|
|
228
233
|
]);
|
|
229
234
|
/**
|
|
230
235
|
* Extract element type from a TypeScript type annotation AST node.
|
|
@@ -306,8 +311,7 @@ const findTsIterableElementType = (iterableName, startNode, pos = 'last') => {
|
|
|
306
311
|
while (current) {
|
|
307
312
|
if (TS_FUNCTION_NODE_TYPES.has(current.type)) {
|
|
308
313
|
// Search function parameters
|
|
309
|
-
const paramsNode = current.childForFieldName('parameters')
|
|
310
|
-
?? current.childForFieldName('formal_parameters');
|
|
314
|
+
const paramsNode = current.childForFieldName('parameters') ?? current.childForFieldName('formal_parameters');
|
|
311
315
|
if (paramsNode) {
|
|
312
316
|
for (let i = 0; i < paramsNode.namedChildCount; i++) {
|
|
313
317
|
const param = paramsNode.namedChild(i);
|
|
@@ -497,7 +501,8 @@ const extractPendingAssignment = (node, scopeEnv) => {
|
|
|
497
501
|
if (valueNode.type === 'member_expression') {
|
|
498
502
|
const obj = valueNode.childForFieldName('object');
|
|
499
503
|
const prop = valueNode.childForFieldName('property');
|
|
500
|
-
if (obj &&
|
|
504
|
+
if (obj &&
|
|
505
|
+
prop?.type === 'property_identifier' &&
|
|
501
506
|
(obj.type === 'identifier' || obj.type === 'this')) {
|
|
502
507
|
return { kind: 'fieldAccess', lhs, receiver: obj.text, field: prop.text };
|
|
503
508
|
}
|
|
@@ -518,7 +523,8 @@ const extractPendingAssignment = (node, scopeEnv) => {
|
|
|
518
523
|
if (funcNode.type === 'member_expression') {
|
|
519
524
|
const obj = funcNode.childForFieldName('object');
|
|
520
525
|
const prop = funcNode.childForFieldName('property');
|
|
521
|
-
if (obj &&
|
|
526
|
+
if (obj &&
|
|
527
|
+
prop?.type === 'property_identifier' &&
|
|
522
528
|
(obj.type === 'identifier' || obj.type === 'this')) {
|
|
523
529
|
return { kind: 'methodCallResult', lhs, receiver: obj.text, method: prop.text };
|
|
524
530
|
}
|
|
@@ -550,8 +556,10 @@ const findIfConsequenceBlock = (binaryExpr) => {
|
|
|
550
556
|
return undefined;
|
|
551
557
|
}
|
|
552
558
|
// Stop climbing at function/block boundaries — don't cross scope
|
|
553
|
-
if (current.type === 'function_declaration' ||
|
|
554
|
-
|
|
559
|
+
if (current.type === 'function_declaration' ||
|
|
560
|
+
current.type === 'function_expression' ||
|
|
561
|
+
current.type === 'arrow_function' ||
|
|
562
|
+
current.type === 'method_definition')
|
|
555
563
|
return undefined;
|
|
556
564
|
current = current.parent;
|
|
557
565
|
}
|
|
@@ -565,7 +573,7 @@ const extractPatternBinding = (node, scopeEnv, declarationTypeNodes, scope) => {
|
|
|
565
573
|
if (node.type !== 'binary_expression')
|
|
566
574
|
return undefined;
|
|
567
575
|
// Check for instanceof first (existing behavior)
|
|
568
|
-
const instanceofOp = node.children.find(c => !c.isNamed && c.text === 'instanceof');
|
|
576
|
+
const instanceofOp = node.children.find((c) => !c.isNamed && c.text === 'instanceof');
|
|
569
577
|
if (instanceofOp) {
|
|
570
578
|
const left = node.namedChild(0);
|
|
571
579
|
const right = node.namedChild(1);
|
|
@@ -574,7 +582,7 @@ const extractPatternBinding = (node, scopeEnv, declarationTypeNodes, scope) => {
|
|
|
574
582
|
return { varName: left.text, typeName: right.text };
|
|
575
583
|
}
|
|
576
584
|
// Null-check narrowing: x !== null, x != null, x !== undefined, x != undefined
|
|
577
|
-
const op = node.children.find(c => !c.isNamed && (c.text === '!==' || c.text === '!='));
|
|
585
|
+
const op = node.children.find((c) => !c.isNamed && (c.text === '!==' || c.text === '!='));
|
|
578
586
|
if (!op)
|
|
579
587
|
return undefined;
|
|
580
588
|
const left = node.namedChild(0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type Parser from 'tree-sitter';
|
|
2
|
-
import type { NodeLabel } from '
|
|
2
|
+
import type { NodeLabel } from 'gitnexus-shared';
|
|
3
3
|
import type { LanguageProvider } from '../language-provider.js';
|
|
4
4
|
/** Tree-sitter AST node. Re-exported for use across ingestion modules. */
|
|
5
5
|
export type SyntaxNode = Parser.SyntaxNode;
|
|
@@ -9,7 +9,7 @@ export type SyntaxNode = Parser.SyntaxNode;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const DEFINITION_CAPTURE_KEYS: readonly ["definition.function", "definition.class", "definition.interface", "definition.method", "definition.struct", "definition.enum", "definition.namespace", "definition.module", "definition.trait", "definition.impl", "definition.type", "definition.const", "definition.static", "definition.typedef", "definition.macro", "definition.union", "definition.property", "definition.record", "definition.delegate", "definition.annotation", "definition.constructor", "definition.template"];
|
|
11
11
|
/** Extract the definition node from a tree-sitter query capture map. */
|
|
12
|
-
export declare const getDefinitionNodeFromCaptures: (captureMap: Record<string,
|
|
12
|
+
export declare const getDefinitionNodeFromCaptures: (captureMap: Record<string, SyntaxNode>) => SyntaxNode | null;
|
|
13
13
|
/**
|
|
14
14
|
* Node types that represent function/method definitions across languages.
|
|
15
15
|
* Used to find the enclosing function for a call site.
|
|
@@ -27,7 +27,7 @@ export declare const CONTAINER_TYPE_TO_LABEL: Record<string, string>;
|
|
|
27
27
|
* Kotlin grammar uses function_declaration for both top-level functions and class methods.
|
|
28
28
|
* Returns true when the captured definition node has a class_body ancestor. */
|
|
29
29
|
export declare function isKotlinClassMethod(captureNode: {
|
|
30
|
-
parent?:
|
|
30
|
+
parent?: SyntaxNode | null;
|
|
31
31
|
} | null | undefined): boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Determine the graph node label from a tree-sitter capture map.
|
|
@@ -35,15 +35,15 @@ export declare function isKotlinClassMethod(captureNode: {
|
|
|
35
35
|
* (e.g. C/C++ duplicate skipping, Kotlin Method promotion).
|
|
36
36
|
* Returns null if the capture should be skipped (import, call, C/C++ duplicate, missing name).
|
|
37
37
|
*/
|
|
38
|
-
export declare function getLabelFromCaptures(captureMap: Record<string,
|
|
38
|
+
export declare function getLabelFromCaptures(captureMap: Record<string, SyntaxNode>, provider: LanguageProvider): NodeLabel | null;
|
|
39
39
|
/** Walk up AST to find enclosing class/struct/interface/impl, return its generateId or null.
|
|
40
40
|
* For Go method_declaration nodes, extracts receiver type (e.g. `func (u *User) Save()` → User struct). */
|
|
41
|
-
export declare const findEnclosingClassId: (node:
|
|
41
|
+
export declare const findEnclosingClassId: (node: SyntaxNode, filePath: string) => string | null;
|
|
42
42
|
/**
|
|
43
43
|
* Find a child of `childType` within a sibling node of `siblingType`.
|
|
44
44
|
* Used for Kotlin AST traversal where visibility_modifier lives inside a modifiers sibling.
|
|
45
45
|
*/
|
|
46
|
-
export declare const findSiblingChild: (parent:
|
|
46
|
+
export declare const findSiblingChild: (parent: SyntaxNode, siblingType: string, childType: string) => SyntaxNode | null;
|
|
47
47
|
/**
|
|
48
48
|
* Extract function name and label from a function_definition or similar AST node.
|
|
49
49
|
* Handles C/C++ qualified_identifier (ClassName::MethodName) and other language patterns.
|
|
@@ -72,9 +72,9 @@ export declare const CALL_ARGUMENT_LIST_TYPES: Set<string>;
|
|
|
72
72
|
*/
|
|
73
73
|
export declare const extractMethodSignature: (node: SyntaxNode | null | undefined) => MethodSignature;
|
|
74
74
|
/** Walk an AST node depth-first, returning the first descendant with the given type. */
|
|
75
|
-
export declare function findDescendant(node:
|
|
75
|
+
export declare function findDescendant(node: SyntaxNode, type: string): SyntaxNode | null;
|
|
76
76
|
/** Extract the text content from a string or encapsed_string AST node. */
|
|
77
|
-
export declare function extractStringContent(node:
|
|
77
|
+
export declare function extractStringContent(node: SyntaxNode | null | undefined): string | null;
|
|
78
78
|
/** Check if a C/C++ function_definition is inside a class or struct body.
|
|
79
79
|
* Used by the C/C++ labelOverride to skip duplicate function captures
|
|
80
80
|
* that are already covered by definition.method queries. */
|
|
@@ -55,6 +55,8 @@ export const FUNCTION_NODE_TYPES = new Set([
|
|
|
55
55
|
// Java
|
|
56
56
|
'method_declaration',
|
|
57
57
|
'constructor_declaration',
|
|
58
|
+
'compact_constructor_declaration',
|
|
59
|
+
'annotation_type_element_declaration',
|
|
58
60
|
// C/C++
|
|
59
61
|
// 'function_definition' already included above
|
|
60
62
|
// Go
|
|
@@ -91,10 +93,17 @@ export const FUNCTION_DECLARATION_TYPES = new Set([
|
|
|
91
93
|
]);
|
|
92
94
|
/** AST node types that represent a class-like container (for HAS_METHOD edge extraction) */
|
|
93
95
|
export const CLASS_CONTAINER_TYPES = new Set([
|
|
94
|
-
'class_declaration',
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'
|
|
96
|
+
'class_declaration',
|
|
97
|
+
'abstract_class_declaration',
|
|
98
|
+
'interface_declaration',
|
|
99
|
+
'struct_declaration',
|
|
100
|
+
'record_declaration',
|
|
101
|
+
'class_specifier',
|
|
102
|
+
'struct_specifier',
|
|
103
|
+
'impl_item',
|
|
104
|
+
'trait_item',
|
|
105
|
+
'struct_item',
|
|
106
|
+
'enum_item',
|
|
98
107
|
'class_definition',
|
|
99
108
|
'trait_declaration',
|
|
100
109
|
'protocol_declaration',
|
|
@@ -244,15 +253,20 @@ export const findEnclosingClassId = (node, filePath) => {
|
|
|
244
253
|
const children = current.children ?? [];
|
|
245
254
|
const forIdx = children.findIndex((c) => c.text === 'for');
|
|
246
255
|
if (forIdx !== -1) {
|
|
247
|
-
const nameNode = children
|
|
256
|
+
const nameNode = children
|
|
257
|
+
.slice(forIdx + 1)
|
|
258
|
+
.find((c) => c.type === 'type_identifier' || c.type === 'identifier');
|
|
248
259
|
if (nameNode) {
|
|
249
260
|
return generateId('Impl', `${filePath}:${nameNode.text}`);
|
|
250
261
|
}
|
|
251
262
|
}
|
|
252
263
|
// Fall through: plain `impl Struct {}` — use first type_identifier below
|
|
253
264
|
}
|
|
254
|
-
const nameNode = current.childForFieldName?.('name')
|
|
255
|
-
|
|
265
|
+
const nameNode = current.childForFieldName?.('name') ??
|
|
266
|
+
current.children?.find((c) => c.type === 'type_identifier' ||
|
|
267
|
+
c.type === 'identifier' ||
|
|
268
|
+
c.type === 'name' ||
|
|
269
|
+
c.type === 'constant');
|
|
256
270
|
if (nameNode) {
|
|
257
271
|
const label = CONTAINER_TYPE_TO_LABEL[current.type] || 'Class';
|
|
258
272
|
return generateId(label, `${filePath}:${nameNode.text}`);
|
|
@@ -306,12 +320,15 @@ export const extractFunctionName = (node) => {
|
|
|
306
320
|
}
|
|
307
321
|
}
|
|
308
322
|
}
|
|
309
|
-
while (declarator &&
|
|
323
|
+
while (declarator &&
|
|
324
|
+
(declarator.type === 'pointer_declarator' || declarator.type === 'reference_declarator')) {
|
|
310
325
|
let nextDeclarator = declarator.childForFieldName?.('declarator');
|
|
311
326
|
if (!nextDeclarator) {
|
|
312
327
|
for (let i = 0; i < declarator.childCount; i++) {
|
|
313
328
|
const c = declarator.child(i);
|
|
314
|
-
if (c?.type === 'function_declarator' ||
|
|
329
|
+
if (c?.type === 'function_declarator' ||
|
|
330
|
+
c?.type === 'pointer_declarator' ||
|
|
331
|
+
c?.type === 'reference_declarator') {
|
|
315
332
|
nextDeclarator = c;
|
|
316
333
|
break;
|
|
317
334
|
}
|
|
@@ -324,8 +341,10 @@ export const extractFunctionName = (node) => {
|
|
|
324
341
|
if (!innerDeclarator) {
|
|
325
342
|
for (let i = 0; i < declarator.childCount; i++) {
|
|
326
343
|
const c = declarator.child(i);
|
|
327
|
-
if (c?.type === 'qualified_identifier' ||
|
|
328
|
-
|
|
344
|
+
if (c?.type === 'qualified_identifier' ||
|
|
345
|
+
c?.type === 'identifier' ||
|
|
346
|
+
c?.type === 'field_identifier' ||
|
|
347
|
+
c?.type === 'parenthesized_declarator') {
|
|
329
348
|
innerDeclarator = c;
|
|
330
349
|
break;
|
|
331
350
|
}
|
|
@@ -347,7 +366,8 @@ export const extractFunctionName = (node) => {
|
|
|
347
366
|
label = 'Method';
|
|
348
367
|
}
|
|
349
368
|
}
|
|
350
|
-
else if (innerDeclarator?.type === 'identifier' ||
|
|
369
|
+
else if (innerDeclarator?.type === 'identifier' ||
|
|
370
|
+
innerDeclarator?.type === 'field_identifier') {
|
|
351
371
|
// field_identifier is used for method names inside C++ class bodies
|
|
352
372
|
funcName = innerDeclarator.text;
|
|
353
373
|
if (innerDeclarator.type === 'field_identifier')
|
|
@@ -389,7 +409,9 @@ export const extractFunctionName = (node) => {
|
|
|
389
409
|
if (!nameNode) {
|
|
390
410
|
for (let i = 0; i < node.childCount; i++) {
|
|
391
411
|
const c = node.child(i);
|
|
392
|
-
if (c?.type === 'identifier' ||
|
|
412
|
+
if (c?.type === 'identifier' ||
|
|
413
|
+
c?.type === 'property_identifier' ||
|
|
414
|
+
c?.type === 'simple_identifier') {
|
|
393
415
|
nameNode = c;
|
|
394
416
|
break;
|
|
395
417
|
}
|
|
@@ -522,11 +544,7 @@ export const extractFunctionName = (node) => {
|
|
|
522
544
|
return { funcName, label };
|
|
523
545
|
};
|
|
524
546
|
/** Argument list node types shared between extractMethodSignature and countCallArguments. */
|
|
525
|
-
export const CALL_ARGUMENT_LIST_TYPES = new Set([
|
|
526
|
-
'arguments',
|
|
527
|
-
'argument_list',
|
|
528
|
-
'value_arguments',
|
|
529
|
-
]);
|
|
547
|
+
export const CALL_ARGUMENT_LIST_TYPES = new Set(['arguments', 'argument_list', 'value_arguments']);
|
|
530
548
|
/**
|
|
531
549
|
* Extract parameter count and return type text from an AST method/function node.
|
|
532
550
|
* Works across languages by looking for common AST patterns.
|
|
@@ -538,10 +556,19 @@ export const extractMethodSignature = (node) => {
|
|
|
538
556
|
let isVariadic = false;
|
|
539
557
|
const paramTypes = [];
|
|
540
558
|
if (!node)
|
|
541
|
-
return {
|
|
559
|
+
return {
|
|
560
|
+
parameterCount,
|
|
561
|
+
requiredParameterCount: undefined,
|
|
562
|
+
parameterTypes: undefined,
|
|
563
|
+
returnType,
|
|
564
|
+
};
|
|
542
565
|
const paramListTypes = new Set([
|
|
543
|
-
'formal_parameters',
|
|
544
|
-
'
|
|
566
|
+
'formal_parameters',
|
|
567
|
+
'parameters',
|
|
568
|
+
'parameter_list',
|
|
569
|
+
'function_parameters',
|
|
570
|
+
'method_parameters',
|
|
571
|
+
'function_value_parameters',
|
|
545
572
|
'formal_parameter_list', // Dart
|
|
546
573
|
]);
|
|
547
574
|
// Node types that indicate variadic/rest parameters
|
|
@@ -592,14 +619,16 @@ export const extractMethodSignature = (node) => {
|
|
|
592
619
|
}
|
|
593
620
|
return null;
|
|
594
621
|
};
|
|
595
|
-
const parameterList =
|
|
596
|
-
|
|
597
|
-
|
|
622
|
+
const parameterList = paramListTypes.has(node.type)
|
|
623
|
+
? node // node itself IS the parameter list (e.g. C# primary constructors)
|
|
624
|
+
: (node.childForFieldName?.('parameters') ?? findParameterList(node));
|
|
598
625
|
if (parameterList && paramListTypes.has(parameterList.type)) {
|
|
599
626
|
for (const param of parameterList.namedChildren) {
|
|
600
627
|
if (param.type === 'comment')
|
|
601
628
|
continue;
|
|
602
|
-
if (param.text === 'self' ||
|
|
629
|
+
if (param.text === 'self' ||
|
|
630
|
+
param.text === '&self' ||
|
|
631
|
+
param.text === '&mut self' ||
|
|
603
632
|
param.type === 'self_parameter') {
|
|
604
633
|
continue;
|
|
605
634
|
}
|
|
@@ -607,9 +636,11 @@ export const extractMethodSignature = (node) => {
|
|
|
607
636
|
// function_value_parameters, so they appear as named children (e.g.
|
|
608
637
|
// string_literal, integer_literal, boolean_literal, call_expression).
|
|
609
638
|
// Skip any named child that isn't a parameter-like or modifier node.
|
|
610
|
-
if (param.type.endsWith('_literal') ||
|
|
611
|
-
|
|
612
|
-
|
|
639
|
+
if (param.type.endsWith('_literal') ||
|
|
640
|
+
param.type === 'call_expression' ||
|
|
641
|
+
param.type === 'navigation_expression' ||
|
|
642
|
+
param.type === 'prefix_expression' ||
|
|
643
|
+
param.type === 'parenthesized_expression') {
|
|
613
644
|
continue;
|
|
614
645
|
}
|
|
615
646
|
// Check for variadic parameter types
|
|
@@ -650,8 +681,10 @@ export const extractMethodSignature = (node) => {
|
|
|
650
681
|
// Kotlin: parameter → [simple_identifier, user_type|nullable_type]
|
|
651
682
|
let found = false;
|
|
652
683
|
for (const child of param.namedChildren) {
|
|
653
|
-
if (child.type === 'user_type' ||
|
|
654
|
-
|
|
684
|
+
if (child.type === 'user_type' ||
|
|
685
|
+
child.type === 'nullable_type' ||
|
|
686
|
+
child.type === 'type_identifier' ||
|
|
687
|
+
child.type === 'predefined_type') {
|
|
655
688
|
const typeName = extractSimpleTypeName(child);
|
|
656
689
|
paramTypes.push(typeName ?? 'unknown');
|
|
657
690
|
found = true;
|
|
@@ -763,11 +796,15 @@ export const extractMethodSignature = (node) => {
|
|
|
763
796
|
parameterCount = undefined;
|
|
764
797
|
// Only include parameterTypes when at least one type was successfully extracted.
|
|
765
798
|
// Use undefined (not []) to avoid empty array allocations for untyped parameters.
|
|
766
|
-
const hasTypes = paramTypes.length > 0 && paramTypes.some(t => t !== 'unknown');
|
|
799
|
+
const hasTypes = paramTypes.length > 0 && paramTypes.some((t) => t !== 'unknown');
|
|
767
800
|
// Only set requiredParameterCount when it differs from total — saves memory on the common case.
|
|
768
|
-
const requiredParameterCount =
|
|
769
|
-
|
|
770
|
-
|
|
801
|
+
const requiredParameterCount = !isVariadic && requiredCount < (parameterCount ?? 0) ? requiredCount : undefined;
|
|
802
|
+
return {
|
|
803
|
+
parameterCount,
|
|
804
|
+
requiredParameterCount,
|
|
805
|
+
parameterTypes: hasTypes ? paramTypes : undefined,
|
|
806
|
+
returnType,
|
|
807
|
+
};
|
|
771
808
|
};
|
|
772
809
|
// ============================================================================
|
|
773
810
|
// Generic AST traversal helpers (shared by parse-worker + php-helpers)
|
|
@@ -776,7 +813,7 @@ export const extractMethodSignature = (node) => {
|
|
|
776
813
|
export function findDescendant(node, type) {
|
|
777
814
|
if (node.type === type)
|
|
778
815
|
return node;
|
|
779
|
-
for (const child of
|
|
816
|
+
for (const child of node.children ?? []) {
|
|
780
817
|
const found = findDescendant(child, type);
|
|
781
818
|
if (found)
|
|
782
819
|
return found;
|
|
@@ -70,4 +70,6 @@ export declare function extractMixedChain(receiverNode: SyntaxNode): {
|
|
|
70
70
|
chain: MixedChainStep[];
|
|
71
71
|
baseReceiverName: string | undefined;
|
|
72
72
|
} | undefined;
|
|
73
|
+
/** Arg types per call position (literals + optional TypeEnv for ids); undefined if unusable */
|
|
74
|
+
export declare const extractCallArgTypes: (callNode: SyntaxNode, inferLiteralType: (node: SyntaxNode) => string | undefined, typeEnvLookup?: (varName: string, callNode: SyntaxNode) => string | undefined) => (string | undefined)[] | undefined;
|
|
73
75
|
export {};
|