gitnexus 1.4.8 → 1.4.10
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 +7 -0
- package/dist/cli/index-repo.d.ts +15 -0
- package/dist/cli/index-repo.js +115 -0
- package/dist/cli/index.js +11 -2
- package/dist/cli/setup.js +12 -9
- package/dist/cli/wiki.d.ts +4 -0
- package/dist/cli/wiki.js +174 -53
- package/dist/config/supported-languages.d.ts +7 -5
- package/dist/config/supported-languages.js +6 -4
- package/dist/core/graph/graph.js +9 -1
- package/dist/core/graph/types.d.ts +10 -2
- package/dist/core/ingestion/call-processor.d.ts +18 -1
- package/dist/core/ingestion/call-processor.js +297 -38
- package/dist/core/ingestion/call-routing.d.ts +3 -18
- package/dist/core/ingestion/call-routing.js +0 -19
- package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
- package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
- package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
- package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
- package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
- package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
- package/dist/core/ingestion/cobol-processor.d.ts +54 -0
- package/dist/core/ingestion/cobol-processor.js +1186 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
- package/dist/core/ingestion/entry-point-scoring.js +18 -4
- package/dist/core/ingestion/export-detection.d.ts +47 -8
- package/dist/core/ingestion/export-detection.js +29 -50
- package/dist/core/ingestion/field-extractor.d.ts +29 -0
- package/dist/core/ingestion/field-extractor.js +25 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
- package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
- package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
- package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
- package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
- package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
- package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
- package/dist/core/ingestion/field-extractors/generic.js +111 -0
- package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
- package/dist/core/ingestion/field-extractors/typescript.js +291 -0
- package/dist/core/ingestion/field-types.d.ts +59 -0
- package/dist/core/ingestion/field-types.js +2 -0
- package/dist/core/ingestion/framework-detection.d.ts +87 -0
- package/dist/core/ingestion/framework-detection.js +65 -2
- package/dist/core/ingestion/heritage-processor.js +15 -17
- package/dist/core/ingestion/import-processor.d.ts +9 -10
- package/dist/core/ingestion/import-processor.js +59 -14
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
- package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/dart.js +44 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +9 -1
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.js +56 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/php.d.ts +6 -10
- package/dist/core/ingestion/{resolvers → import-resolvers}/php.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
- package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/swift.js +23 -0
- package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
- package/dist/core/ingestion/import-resolvers/types.js +6 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +0 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +0 -9
- package/dist/core/ingestion/language-config.d.ts +4 -1
- package/dist/core/ingestion/language-provider.d.ts +121 -0
- package/dist/core/ingestion/language-provider.js +24 -0
- package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +71 -0
- package/dist/core/ingestion/languages/cobol.d.ts +1 -0
- package/dist/core/ingestion/languages/cobol.js +26 -0
- package/dist/core/ingestion/languages/csharp.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp.js +49 -0
- package/dist/core/ingestion/languages/dart.d.ts +12 -0
- package/dist/core/ingestion/languages/dart.js +58 -0
- package/dist/core/ingestion/languages/go.d.ts +11 -0
- package/dist/core/ingestion/languages/go.js +28 -0
- package/dist/core/ingestion/languages/index.d.ts +38 -0
- package/dist/core/ingestion/languages/index.js +63 -0
- package/dist/core/ingestion/languages/java.d.ts +9 -0
- package/dist/core/ingestion/languages/java.js +29 -0
- package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
- package/dist/core/ingestion/languages/kotlin.js +53 -0
- package/dist/core/ingestion/languages/php.d.ts +8 -0
- package/dist/core/ingestion/languages/php.js +145 -0
- package/dist/core/ingestion/languages/python.d.ts +12 -0
- package/dist/core/ingestion/languages/python.js +39 -0
- package/dist/core/ingestion/languages/ruby.d.ts +9 -0
- package/dist/core/ingestion/languages/ruby.js +44 -0
- package/dist/core/ingestion/languages/rust.d.ts +12 -0
- package/dist/core/ingestion/languages/rust.js +44 -0
- package/dist/core/ingestion/languages/swift.d.ts +12 -0
- package/dist/core/ingestion/languages/swift.js +133 -0
- package/dist/core/ingestion/languages/typescript.d.ts +10 -0
- package/dist/core/ingestion/languages/typescript.js +60 -0
- package/dist/core/ingestion/mro-processor.js +14 -15
- package/dist/core/ingestion/{named-binding-extraction.d.ts → named-binding-processor.d.ts} +0 -9
- package/dist/core/ingestion/named-binding-processor.js +42 -0
- package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/csharp.js +37 -0
- package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/java.js +29 -0
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
- package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/php.js +61 -0
- package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/python.js +49 -0
- package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/rust.js +64 -0
- package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
- package/dist/core/ingestion/named-bindings/types.js +6 -0
- package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/typescript.js +58 -0
- package/dist/core/ingestion/parsing-processor.d.ts +5 -1
- package/dist/core/ingestion/parsing-processor.js +115 -16
- package/dist/core/ingestion/pipeline.js +925 -424
- package/dist/core/ingestion/resolution-context.js +1 -1
- package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
- package/dist/core/ingestion/route-extractors/expo.js +36 -0
- package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
- package/dist/core/ingestion/route-extractors/middleware.js +143 -0
- package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
- package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
- package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
- package/dist/core/ingestion/route-extractors/php.js +21 -0
- package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
- package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +8 -7
- package/dist/core/ingestion/tree-sitter-queries.js +231 -9
- package/dist/core/ingestion/type-env.d.ts +14 -17
- package/dist/core/ingestion/type-env.js +66 -14
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/csharp.js +1 -1
- package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
- package/dist/core/ingestion/type-extractors/dart.js +371 -0
- package/dist/core/ingestion/type-extractors/jvm.js +1 -1
- package/dist/core/ingestion/type-extractors/shared.d.ts +1 -13
- package/dist/core/ingestion/type-extractors/shared.js +9 -102
- package/dist/core/ingestion/type-extractors/swift.js +334 -4
- package/dist/core/ingestion/type-extractors/types.d.ts +3 -1
- package/dist/core/ingestion/{ast-helpers.d.ts → utils/ast-helpers.d.ts} +16 -13
- package/dist/core/ingestion/{ast-helpers.js → utils/ast-helpers.js} +111 -32
- package/dist/core/ingestion/{call-analysis.js → utils/call-analysis.js} +37 -0
- package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
- package/dist/core/ingestion/utils/event-loop.js +5 -0
- package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
- package/dist/core/ingestion/utils/language-detection.js +70 -0
- package/dist/core/ingestion/utils/verbose.d.ts +1 -0
- package/dist/core/ingestion/utils/verbose.js +7 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +43 -2
- package/dist/core/ingestion/workers/parse-worker.js +361 -150
- package/dist/core/lbug/csv-generator.js +34 -1
- package/dist/core/lbug/lbug-adapter.js +6 -0
- package/dist/core/lbug/schema.d.ts +5 -3
- package/dist/core/lbug/schema.js +39 -2
- package/dist/core/tree-sitter/parser-loader.js +7 -1
- package/dist/core/wiki/cursor-client.d.ts +31 -0
- package/dist/core/wiki/cursor-client.js +127 -0
- package/dist/core/wiki/generator.d.ts +28 -9
- package/dist/core/wiki/generator.js +115 -18
- package/dist/core/wiki/graph-queries.d.ts +4 -0
- package/dist/core/wiki/graph-queries.js +7 -1
- package/dist/core/wiki/llm-client.d.ts +2 -0
- package/dist/core/wiki/llm-client.js +8 -4
- package/dist/core/wiki/prompts.d.ts +3 -3
- package/dist/core/wiki/prompts.js +6 -0
- package/dist/mcp/core/lbug-adapter.d.ts +5 -0
- package/dist/mcp/core/lbug-adapter.js +11 -1
- package/dist/mcp/local/local-backend.d.ts +16 -5
- package/dist/mcp/local/local-backend.js +711 -74
- package/dist/mcp/tools.js +71 -2
- package/dist/storage/repo-manager.d.ts +3 -0
- package/package.json +14 -14
- package/dist/core/ingestion/import-resolution.d.ts +0 -101
- package/dist/core/ingestion/import-resolution.js +0 -251
- package/dist/core/ingestion/named-binding-extraction.js +0 -373
- package/dist/core/ingestion/resolvers/index.d.ts +0 -18
- package/dist/core/ingestion/resolvers/index.js +0 -13
- package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
- package/dist/core/ingestion/type-extractors/index.js +0 -31
- package/dist/core/ingestion/utils.d.ts +0 -20
- package/dist/core/ingestion/utils.js +0 -242
- package/scripts/patch-tree-sitter-swift.cjs +0 -74
- /package/dist/core/ingestion/{call-analysis.d.ts → utils/call-analysis.d.ts} +0 -0
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import { findChild } from './resolvers/utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* Walk a named-binding re-export chain through NamedImportMap.
|
|
4
|
-
*
|
|
5
|
-
* When file A imports { User } from B, and B re-exports { User } from C,
|
|
6
|
-
* the NamedImportMap for A points to B, but B has no User definition.
|
|
7
|
-
* This function follows the chain: A→B→C until a definition is found.
|
|
8
|
-
*
|
|
9
|
-
* Returns the definitions found at the end of the chain, or null if the
|
|
10
|
-
* chain breaks (missing binding, circular reference, or depth exceeded).
|
|
11
|
-
* Max depth 5 to prevent infinite loops.
|
|
12
|
-
*
|
|
13
|
-
* @param allDefs Pre-computed `symbolTable.lookupFuzzy(name)` result — must be the
|
|
14
|
-
* complete unfiltered result. Passing a file-filtered subset will cause
|
|
15
|
-
* silent misses at depth=0 for non-aliased bindings.
|
|
16
|
-
*/
|
|
17
|
-
export function walkBindingChain(name, currentFilePath, symbolTable, namedImportMap, allDefs) {
|
|
18
|
-
let lookupFile = currentFilePath;
|
|
19
|
-
let lookupName = name;
|
|
20
|
-
const visited = new Set();
|
|
21
|
-
for (let depth = 0; depth < 5; depth++) {
|
|
22
|
-
const bindings = namedImportMap.get(lookupFile);
|
|
23
|
-
if (!bindings)
|
|
24
|
-
return null;
|
|
25
|
-
const binding = bindings.get(lookupName);
|
|
26
|
-
if (!binding)
|
|
27
|
-
return null;
|
|
28
|
-
const key = `${binding.sourcePath}:${binding.exportedName}`;
|
|
29
|
-
if (visited.has(key))
|
|
30
|
-
return null; // circular
|
|
31
|
-
visited.add(key);
|
|
32
|
-
const targetName = binding.exportedName;
|
|
33
|
-
const resolvedDefs = targetName !== lookupName || depth > 0
|
|
34
|
-
? symbolTable.lookupFuzzy(targetName).filter(def => def.filePath === binding.sourcePath)
|
|
35
|
-
: allDefs.filter(def => def.filePath === binding.sourcePath);
|
|
36
|
-
if (resolvedDefs.length > 0)
|
|
37
|
-
return resolvedDefs;
|
|
38
|
-
// No definition in source file → follow re-export chain
|
|
39
|
-
lookupFile = binding.sourcePath;
|
|
40
|
-
lookupName = targetName;
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
export function extractTsNamedBindings(importNode) {
|
|
45
|
-
// import_statement > import_clause > named_imports > import_specifier*
|
|
46
|
-
const importClause = findChild(importNode, 'import_clause');
|
|
47
|
-
if (importClause) {
|
|
48
|
-
const namedImports = findChild(importClause, 'named_imports');
|
|
49
|
-
if (!namedImports)
|
|
50
|
-
return undefined; // default import, namespace import, or side-effect
|
|
51
|
-
const bindings = [];
|
|
52
|
-
for (let i = 0; i < namedImports.namedChildCount; i++) {
|
|
53
|
-
const specifier = namedImports.namedChild(i);
|
|
54
|
-
if (specifier?.type !== 'import_specifier')
|
|
55
|
-
continue;
|
|
56
|
-
const identifiers = [];
|
|
57
|
-
for (let j = 0; j < specifier.namedChildCount; j++) {
|
|
58
|
-
const child = specifier.namedChild(j);
|
|
59
|
-
if (child?.type === 'identifier')
|
|
60
|
-
identifiers.push(child.text);
|
|
61
|
-
}
|
|
62
|
-
if (identifiers.length === 1) {
|
|
63
|
-
bindings.push({ local: identifiers[0], exported: identifiers[0] });
|
|
64
|
-
}
|
|
65
|
-
else if (identifiers.length === 2) {
|
|
66
|
-
// import { Foo as Bar } → exported='Foo', local='Bar'
|
|
67
|
-
bindings.push({ local: identifiers[1], exported: identifiers[0] });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
71
|
-
}
|
|
72
|
-
// Re-export: export { X } from './y' → export_statement > export_clause > export_specifier
|
|
73
|
-
const exportClause = findChild(importNode, 'export_clause');
|
|
74
|
-
if (exportClause) {
|
|
75
|
-
const bindings = [];
|
|
76
|
-
for (let i = 0; i < exportClause.namedChildCount; i++) {
|
|
77
|
-
const specifier = exportClause.namedChild(i);
|
|
78
|
-
if (specifier?.type !== 'export_specifier')
|
|
79
|
-
continue;
|
|
80
|
-
const identifiers = [];
|
|
81
|
-
for (let j = 0; j < specifier.namedChildCount; j++) {
|
|
82
|
-
const child = specifier.namedChild(j);
|
|
83
|
-
if (child?.type === 'identifier')
|
|
84
|
-
identifiers.push(child.text);
|
|
85
|
-
}
|
|
86
|
-
if (identifiers.length === 1) {
|
|
87
|
-
// export { User } from './base' → re-exports User as User
|
|
88
|
-
bindings.push({ local: identifiers[0], exported: identifiers[0] });
|
|
89
|
-
}
|
|
90
|
-
else if (identifiers.length === 2) {
|
|
91
|
-
// export { Repo as Repository } from './models' → name=Repo, alias=Repository
|
|
92
|
-
// For re-exports, the first id is the source name, second is what's exported
|
|
93
|
-
// When another file imports { Repository }, they get Repo from the source
|
|
94
|
-
bindings.push({ local: identifiers[1], exported: identifiers[0] });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
98
|
-
}
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
export function extractPythonNamedBindings(importNode) {
|
|
102
|
-
// Handle: from x import User, Repo as R
|
|
103
|
-
if (importNode.type === 'import_from_statement') {
|
|
104
|
-
const bindings = [];
|
|
105
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
106
|
-
const child = importNode.namedChild(i);
|
|
107
|
-
if (!child)
|
|
108
|
-
continue;
|
|
109
|
-
if (child.type === 'dotted_name') {
|
|
110
|
-
// Skip the module_name (first dotted_name is the source module)
|
|
111
|
-
const fieldName = importNode.childForFieldName?.('module_name');
|
|
112
|
-
if (fieldName && child.startIndex === fieldName.startIndex)
|
|
113
|
-
continue;
|
|
114
|
-
// This is an imported name: from x import User
|
|
115
|
-
const name = child.text;
|
|
116
|
-
if (name)
|
|
117
|
-
bindings.push({ local: name, exported: name });
|
|
118
|
-
}
|
|
119
|
-
if (child.type === 'aliased_import') {
|
|
120
|
-
// from x import Repo as R
|
|
121
|
-
const dottedName = findChild(child, 'dotted_name');
|
|
122
|
-
const aliasIdent = findChild(child, 'identifier');
|
|
123
|
-
if (dottedName && aliasIdent) {
|
|
124
|
-
bindings.push({ local: aliasIdent.text, exported: dottedName.text });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
129
|
-
}
|
|
130
|
-
// Handle: import numpy as np (import_statement with aliased_import child)
|
|
131
|
-
// Tagged with isModuleAlias so applyImportResult routes these directly to
|
|
132
|
-
// moduleAliasMap (e.g. "np" → "numpy.py") instead of namedImportMap.
|
|
133
|
-
if (importNode.type === 'import_statement') {
|
|
134
|
-
const bindings = [];
|
|
135
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
136
|
-
const child = importNode.namedChild(i);
|
|
137
|
-
if (!child || child.type !== 'aliased_import')
|
|
138
|
-
continue;
|
|
139
|
-
const dottedName = findChild(child, 'dotted_name');
|
|
140
|
-
const aliasIdent = findChild(child, 'identifier');
|
|
141
|
-
if (dottedName && aliasIdent) {
|
|
142
|
-
bindings.push({ local: aliasIdent.text, exported: dottedName.text, isModuleAlias: true });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
146
|
-
}
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
export function extractKotlinNamedBindings(importNode) {
|
|
150
|
-
// import_header > identifier + import_alias > simple_identifier
|
|
151
|
-
if (importNode.type !== 'import_header')
|
|
152
|
-
return undefined;
|
|
153
|
-
const fullIdent = findChild(importNode, 'identifier');
|
|
154
|
-
if (!fullIdent)
|
|
155
|
-
return undefined;
|
|
156
|
-
const fullText = fullIdent.text;
|
|
157
|
-
const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
158
|
-
const importAlias = findChild(importNode, 'import_alias');
|
|
159
|
-
if (importAlias) {
|
|
160
|
-
// Aliased: import com.example.User as U
|
|
161
|
-
const aliasIdent = findChild(importAlias, 'simple_identifier');
|
|
162
|
-
if (!aliasIdent)
|
|
163
|
-
return undefined;
|
|
164
|
-
return [{ local: aliasIdent.text, exported: exportedName }];
|
|
165
|
-
}
|
|
166
|
-
// Non-aliased: import com.example.User → local="User", exported="User"
|
|
167
|
-
// Also handles top-level function imports: import models.getUser → local="getUser"
|
|
168
|
-
// Skip wildcard imports (ending in *)
|
|
169
|
-
if (fullText.endsWith('.*') || fullText.endsWith('*'))
|
|
170
|
-
return undefined;
|
|
171
|
-
// Skip class-member imports (e.g., import util.OneArg.writeAudit) where the
|
|
172
|
-
// second-to-last segment is PascalCase (a class name). Multiple member imports
|
|
173
|
-
// with the same function name would collide in NamedImportMap, breaking
|
|
174
|
-
// arity-based disambiguation. Top-level function imports (import models.getUser)
|
|
175
|
-
// and class imports (import models.User) have package-only prefixes.
|
|
176
|
-
const segments = fullText.split('.');
|
|
177
|
-
if (segments.length >= 3) {
|
|
178
|
-
const parentSegment = segments[segments.length - 2];
|
|
179
|
-
if (parentSegment[0] && parentSegment[0] === parentSegment[0].toUpperCase())
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
|
-
return [{ local: exportedName, exported: exportedName }];
|
|
183
|
-
}
|
|
184
|
-
export function extractRustNamedBindings(importNode) {
|
|
185
|
-
// use_declaration may contain use_as_clause at any depth
|
|
186
|
-
if (importNode.type !== 'use_declaration')
|
|
187
|
-
return undefined;
|
|
188
|
-
const bindings = [];
|
|
189
|
-
collectRustBindings(importNode, bindings);
|
|
190
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
191
|
-
}
|
|
192
|
-
function collectRustBindings(node, bindings) {
|
|
193
|
-
if (node.type === 'use_as_clause') {
|
|
194
|
-
// First identifier = exported name, second identifier = local alias
|
|
195
|
-
const idents = [];
|
|
196
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
197
|
-
const child = node.namedChild(i);
|
|
198
|
-
if (child?.type === 'identifier')
|
|
199
|
-
idents.push(child.text);
|
|
200
|
-
// For scoped_identifier, extract the last segment
|
|
201
|
-
if (child?.type === 'scoped_identifier') {
|
|
202
|
-
const nameNode = child.childForFieldName?.('name');
|
|
203
|
-
if (nameNode)
|
|
204
|
-
idents.push(nameNode.text);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (idents.length === 2) {
|
|
208
|
-
bindings.push({ local: idents[1], exported: idents[0] });
|
|
209
|
-
}
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
// Terminal identifier in a use_list: use crate::models::{User, Repo}
|
|
213
|
-
if (node.type === 'identifier' && node.parent?.type === 'use_list') {
|
|
214
|
-
bindings.push({ local: node.text, exported: node.text });
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
// Skip scoped_identifier that serves as path prefix in scoped_use_list
|
|
218
|
-
// e.g. use crate::models::{User, Repo} — the path node "crate::models" is not an importable symbol
|
|
219
|
-
if (node.type === 'scoped_identifier' && node.parent?.type === 'scoped_use_list') {
|
|
220
|
-
return; // path prefix — the use_list sibling handles the actual symbols
|
|
221
|
-
}
|
|
222
|
-
// Terminal scoped_identifier: use crate::models::User;
|
|
223
|
-
// Only extract if this is a leaf (no deeper use_list/use_as_clause/scoped_use_list)
|
|
224
|
-
if (node.type === 'scoped_identifier') {
|
|
225
|
-
let hasDeeper = false;
|
|
226
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
227
|
-
const child = node.namedChild(i);
|
|
228
|
-
if (child?.type === 'use_list' || child?.type === 'use_as_clause' || child?.type === 'scoped_use_list') {
|
|
229
|
-
hasDeeper = true;
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (!hasDeeper) {
|
|
234
|
-
const nameNode = node.childForFieldName?.('name');
|
|
235
|
-
if (nameNode) {
|
|
236
|
-
bindings.push({ local: nameNode.text, exported: nameNode.text });
|
|
237
|
-
}
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
// Recurse into children
|
|
242
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
243
|
-
const child = node.namedChild(i);
|
|
244
|
-
if (child)
|
|
245
|
-
collectRustBindings(child, bindings);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
export function extractPhpNamedBindings(importNode) {
|
|
249
|
-
// namespace_use_declaration > namespace_use_clause* (flat)
|
|
250
|
-
// namespace_use_declaration > namespace_use_group > namespace_use_clause* (grouped)
|
|
251
|
-
if (importNode.type !== 'namespace_use_declaration')
|
|
252
|
-
return undefined;
|
|
253
|
-
// Skip 'use function' and 'use const' declarations — these import callables/constants,
|
|
254
|
-
// not class types, and should not be added to namedImportMap as type bindings.
|
|
255
|
-
const useTypeNode = importNode.childForFieldName?.('type');
|
|
256
|
-
if (useTypeNode && (useTypeNode.text === 'function' || useTypeNode.text === 'const')) {
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
const bindings = [];
|
|
260
|
-
// Collect all clauses — from direct children AND from namespace_use_group
|
|
261
|
-
const clauses = [];
|
|
262
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
263
|
-
const child = importNode.namedChild(i);
|
|
264
|
-
if (child?.type === 'namespace_use_clause') {
|
|
265
|
-
clauses.push(child);
|
|
266
|
-
}
|
|
267
|
-
else if (child?.type === 'namespace_use_group') {
|
|
268
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
269
|
-
const groupChild = child.namedChild(j);
|
|
270
|
-
if (groupChild?.type === 'namespace_use_clause')
|
|
271
|
-
clauses.push(groupChild);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
for (const clause of clauses) {
|
|
276
|
-
// Flat imports: qualified_name + name (alias)
|
|
277
|
-
let qualifiedName = null;
|
|
278
|
-
const names = [];
|
|
279
|
-
for (let j = 0; j < clause.namedChildCount; j++) {
|
|
280
|
-
const child = clause.namedChild(j);
|
|
281
|
-
if (child?.type === 'qualified_name')
|
|
282
|
-
qualifiedName = child;
|
|
283
|
-
else if (child?.type === 'name')
|
|
284
|
-
names.push(child);
|
|
285
|
-
}
|
|
286
|
-
if (qualifiedName && names.length > 0) {
|
|
287
|
-
// Flat aliased import: use App\Models\Repo as R;
|
|
288
|
-
const fullText = qualifiedName.text;
|
|
289
|
-
const exportedName = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
|
|
290
|
-
bindings.push({ local: names[0].text, exported: exportedName });
|
|
291
|
-
}
|
|
292
|
-
else if (qualifiedName && names.length === 0) {
|
|
293
|
-
// Flat non-aliased import: use App\Models\User;
|
|
294
|
-
const fullText = qualifiedName.text;
|
|
295
|
-
const lastSegment = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
|
|
296
|
-
bindings.push({ local: lastSegment, exported: lastSegment });
|
|
297
|
-
}
|
|
298
|
-
else if (!qualifiedName && names.length >= 2) {
|
|
299
|
-
// Grouped aliased import: {Repo as R} — first name = exported, second = alias
|
|
300
|
-
bindings.push({ local: names[1].text, exported: names[0].text });
|
|
301
|
-
}
|
|
302
|
-
else if (!qualifiedName && names.length === 1) {
|
|
303
|
-
// Grouped non-aliased import: {User} in use App\Models\{User, Repo as R}
|
|
304
|
-
bindings.push({ local: names[0].text, exported: names[0].text });
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
308
|
-
}
|
|
309
|
-
export function extractCsharpNamedBindings(importNode) {
|
|
310
|
-
// using_directive — three forms:
|
|
311
|
-
// using Alias = NS.Type; → aliasIdent + qualifiedName
|
|
312
|
-
// using static NS.Type; → static + qualifiedName (no alias)
|
|
313
|
-
// using NS; → qualifiedName only (namespace, not capturable)
|
|
314
|
-
if (importNode.type !== 'using_directive')
|
|
315
|
-
return undefined;
|
|
316
|
-
let aliasIdent = null;
|
|
317
|
-
let qualifiedName = null;
|
|
318
|
-
let isStatic = false;
|
|
319
|
-
for (let i = 0; i < importNode.childCount; i++) {
|
|
320
|
-
const child = importNode.child(i);
|
|
321
|
-
if (child?.text === 'static')
|
|
322
|
-
isStatic = true;
|
|
323
|
-
}
|
|
324
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
325
|
-
const child = importNode.namedChild(i);
|
|
326
|
-
if (child?.type === 'identifier' && !aliasIdent)
|
|
327
|
-
aliasIdent = child;
|
|
328
|
-
else if (child?.type === 'qualified_name')
|
|
329
|
-
qualifiedName = child;
|
|
330
|
-
}
|
|
331
|
-
// Form 1: using Alias = NS.Type;
|
|
332
|
-
if (aliasIdent && qualifiedName) {
|
|
333
|
-
const fullText = qualifiedName.text;
|
|
334
|
-
const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
335
|
-
return [{ local: aliasIdent.text, exported: exportedName }];
|
|
336
|
-
}
|
|
337
|
-
// Form 2: using static NS.Type; — last segment is the class name
|
|
338
|
-
if (isStatic && qualifiedName) {
|
|
339
|
-
const fullText = qualifiedName.text;
|
|
340
|
-
const lastSegment = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
341
|
-
return [{ local: lastSegment, exported: lastSegment }];
|
|
342
|
-
}
|
|
343
|
-
// Form 3: using NS; — namespace import, can't resolve to per-symbol bindings
|
|
344
|
-
return undefined;
|
|
345
|
-
}
|
|
346
|
-
export function extractJavaNamedBindings(importNode) {
|
|
347
|
-
// import_declaration > scoped_identifier "com.example.models.User"
|
|
348
|
-
// Wildcard imports (.*) don't produce named bindings
|
|
349
|
-
if (importNode.type !== 'import_declaration')
|
|
350
|
-
return undefined;
|
|
351
|
-
// Check for asterisk (wildcard import) and static modifier
|
|
352
|
-
let isStatic = false;
|
|
353
|
-
for (let i = 0; i < importNode.childCount; i++) {
|
|
354
|
-
const child = importNode.child(i);
|
|
355
|
-
if (child?.type === 'asterisk')
|
|
356
|
-
return undefined;
|
|
357
|
-
if (child?.text === 'static')
|
|
358
|
-
isStatic = true;
|
|
359
|
-
}
|
|
360
|
-
const scopedId = findChild(importNode, 'scoped_identifier');
|
|
361
|
-
if (!scopedId)
|
|
362
|
-
return undefined;
|
|
363
|
-
const fullText = scopedId.text;
|
|
364
|
-
const lastDot = fullText.lastIndexOf('.');
|
|
365
|
-
if (lastDot === -1)
|
|
366
|
-
return undefined;
|
|
367
|
-
const name = fullText.slice(lastDot + 1);
|
|
368
|
-
// Non-static: skip lowercase names — those are package imports, not class imports.
|
|
369
|
-
// Static: allow lowercase — `import static models.UserFactory.getUser` imports a method.
|
|
370
|
-
if (!isStatic && name[0] && name[0] === name[0].toLowerCase())
|
|
371
|
-
return undefined;
|
|
372
|
-
return [{ local: name, exported: name }];
|
|
373
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language-specific import resolvers.
|
|
3
|
-
* Extracted from import-processor.ts for maintainability.
|
|
4
|
-
*/
|
|
5
|
-
export { EXTENSIONS, tryResolveWithExtensions, buildSuffixIndex, suffixResolve, EMPTY_INDEX } from './utils.js';
|
|
6
|
-
export type { SuffixIndex } from './utils.js';
|
|
7
|
-
export { KOTLIN_EXTENSIONS, appendKotlinWildcard, resolveJvmWildcard, resolveJvmMemberImport } from './jvm.js';
|
|
8
|
-
export { resolveGoPackageDir, resolveGoPackage } from './go.js';
|
|
9
|
-
export type { GoModuleConfig } from './go.js';
|
|
10
|
-
export { resolveCSharpImport, resolveCSharpNamespaceDir } from './csharp.js';
|
|
11
|
-
export type { CSharpProjectConfig } from './csharp.js';
|
|
12
|
-
export { resolvePhpImport } from './php.js';
|
|
13
|
-
export type { ComposerConfig } from './php.js';
|
|
14
|
-
export { resolveRustImport, tryRustModulePath } from './rust.js';
|
|
15
|
-
export { resolveRubyImport } from './ruby.js';
|
|
16
|
-
export { resolvePythonImport } from './python.js';
|
|
17
|
-
export { resolveImportPath, RESOLVE_CACHE_CAP } from './standard.js';
|
|
18
|
-
export type { TsconfigPaths } from './standard.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language-specific import resolvers.
|
|
3
|
-
* Extracted from import-processor.ts for maintainability.
|
|
4
|
-
*/
|
|
5
|
-
export { EXTENSIONS, tryResolveWithExtensions, buildSuffixIndex, suffixResolve, EMPTY_INDEX } from './utils.js';
|
|
6
|
-
export { KOTLIN_EXTENSIONS, appendKotlinWildcard, resolveJvmWildcard, resolveJvmMemberImport } from './jvm.js';
|
|
7
|
-
export { resolveGoPackageDir, resolveGoPackage } from './go.js';
|
|
8
|
-
export { resolveCSharpImport, resolveCSharpNamespaceDir } from './csharp.js';
|
|
9
|
-
export { resolvePhpImport } from './php.js';
|
|
10
|
-
export { resolveRustImport, tryRustModulePath } from './rust.js';
|
|
11
|
-
export { resolveRubyImport } from './ruby.js';
|
|
12
|
-
export { resolvePythonImport } from './python.js';
|
|
13
|
-
export { resolveImportPath, RESOLVE_CACHE_CAP } from './standard.js';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-language type extraction configurations.
|
|
3
|
-
* Assembled here into a dispatch map keyed by SupportedLanguages.
|
|
4
|
-
*/
|
|
5
|
-
import type { LanguageTypeConfig } from './types.js';
|
|
6
|
-
export declare const typeConfigs: {
|
|
7
|
-
javascript: LanguageTypeConfig;
|
|
8
|
-
typescript: LanguageTypeConfig;
|
|
9
|
-
java: LanguageTypeConfig;
|
|
10
|
-
kotlin: LanguageTypeConfig;
|
|
11
|
-
csharp: LanguageTypeConfig;
|
|
12
|
-
go: LanguageTypeConfig;
|
|
13
|
-
rust: LanguageTypeConfig;
|
|
14
|
-
python: LanguageTypeConfig;
|
|
15
|
-
swift: LanguageTypeConfig;
|
|
16
|
-
c: LanguageTypeConfig;
|
|
17
|
-
cpp: LanguageTypeConfig;
|
|
18
|
-
php: LanguageTypeConfig;
|
|
19
|
-
ruby: LanguageTypeConfig;
|
|
20
|
-
};
|
|
21
|
-
export type { LanguageTypeConfig, TypeBindingExtractor, ParameterExtractor, ConstructorBindingScanner, ForLoopExtractor, PendingAssignmentExtractor, PatternBindingExtractor, } from './types.js';
|
|
22
|
-
export { TYPED_PARAMETER_TYPES, extractSimpleTypeName, extractGenericTypeArgs, extractVarName, extractRubyConstructorAssignment } from './shared.js';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-language type extraction configurations.
|
|
3
|
-
* Assembled here into a dispatch map keyed by SupportedLanguages.
|
|
4
|
-
*/
|
|
5
|
-
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
6
|
-
import { typeConfig as typescriptConfig } from './typescript.js';
|
|
7
|
-
import { javaTypeConfig, kotlinTypeConfig } from './jvm.js';
|
|
8
|
-
import { typeConfig as csharpConfig } from './csharp.js';
|
|
9
|
-
import { typeConfig as goConfig } from './go.js';
|
|
10
|
-
import { typeConfig as rustConfig } from './rust.js';
|
|
11
|
-
import { typeConfig as pythonConfig } from './python.js';
|
|
12
|
-
import { typeConfig as swiftConfig } from './swift.js';
|
|
13
|
-
import { typeConfig as cCppConfig } from './c-cpp.js';
|
|
14
|
-
import { typeConfig as phpConfig } from './php.js';
|
|
15
|
-
import { typeConfig as rubyConfig } from './ruby.js';
|
|
16
|
-
export const typeConfigs = {
|
|
17
|
-
[SupportedLanguages.JavaScript]: typescriptConfig,
|
|
18
|
-
[SupportedLanguages.TypeScript]: typescriptConfig,
|
|
19
|
-
[SupportedLanguages.Java]: javaTypeConfig,
|
|
20
|
-
[SupportedLanguages.Kotlin]: kotlinTypeConfig,
|
|
21
|
-
[SupportedLanguages.CSharp]: csharpConfig,
|
|
22
|
-
[SupportedLanguages.Go]: goConfig,
|
|
23
|
-
[SupportedLanguages.Rust]: rustConfig,
|
|
24
|
-
[SupportedLanguages.Python]: pythonConfig,
|
|
25
|
-
[SupportedLanguages.Swift]: swiftConfig,
|
|
26
|
-
[SupportedLanguages.C]: cCppConfig,
|
|
27
|
-
[SupportedLanguages.CPlusPlus]: cCppConfig,
|
|
28
|
-
[SupportedLanguages.PHP]: phpConfig,
|
|
29
|
-
[SupportedLanguages.Ruby]: rubyConfig,
|
|
30
|
-
};
|
|
31
|
-
export { TYPED_PARAMETER_TYPES, extractSimpleTypeName, extractGenericTypeArgs, extractVarName, extractRubyConstructorAssignment } from './shared.js';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
2
|
-
/**
|
|
3
|
-
* Built-in function/method names that should not be tracked as call targets.
|
|
4
|
-
* Covers JS/TS, Python, Kotlin, C/C++, PHP, Swift standard library functions.
|
|
5
|
-
*/
|
|
6
|
-
export declare const BUILT_IN_NAMES: Set<string>;
|
|
7
|
-
/** Check if a name is a built-in function or common noise that should be filtered out */
|
|
8
|
-
export declare const isBuiltInOrNoise: (name: string) => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Yield control to the event loop so spinners/progress can render.
|
|
11
|
-
* Call periodically in hot loops to prevent UI freezes.
|
|
12
|
-
*/
|
|
13
|
-
export declare const yieldToEventLoop: () => Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Map file extension to SupportedLanguage enum
|
|
16
|
-
*/
|
|
17
|
-
export declare const getLanguageFromFilename: (filename: string) => SupportedLanguages | null;
|
|
18
|
-
export declare const isVerboseIngestionEnabled: () => boolean;
|
|
19
|
-
export * from './ast-helpers.js';
|
|
20
|
-
export * from './call-analysis.js';
|