gitnexus 1.6.2-rc.17 → 1.6.2-rc.19
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/core/group/extractors/http-patterns/node.js +130 -0
- package/dist/core/ingestion/import-resolvers/configs/c-cpp.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/configs/c-cpp.js +14 -0
- package/dist/core/ingestion/import-resolvers/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/csharp.js +27 -0
- package/dist/core/ingestion/import-resolvers/configs/dart.d.ts +17 -0
- package/dist/core/ingestion/import-resolvers/{dart.js → configs/dart.js} +26 -16
- package/dist/core/ingestion/import-resolvers/configs/go.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/go.js +26 -0
- package/dist/core/ingestion/import-resolvers/configs/jvm.d.ts +13 -0
- package/dist/core/ingestion/import-resolvers/configs/jvm.js +68 -0
- package/dist/core/ingestion/import-resolvers/configs/php.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/php.js +15 -0
- package/dist/core/ingestion/import-resolvers/configs/python.d.ts +12 -0
- package/dist/core/ingestion/import-resolvers/configs/python.js +27 -0
- package/dist/core/ingestion/import-resolvers/configs/ruby.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/ruby.js +16 -0
- package/dist/core/ingestion/import-resolvers/configs/rust.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/configs/rust.js +54 -0
- package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/{swift.js → configs/swift.js} +10 -5
- package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.d.ts +9 -0
- package/dist/core/ingestion/import-resolvers/configs/typescript-javascript.js +23 -0
- package/dist/core/ingestion/import-resolvers/csharp.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/csharp.js +4 -20
- package/dist/core/ingestion/import-resolvers/go.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/go.js +4 -19
- package/dist/core/ingestion/import-resolvers/jvm.d.ts +5 -10
- package/dist/core/ingestion/import-resolvers/jvm.js +5 -58
- package/dist/core/ingestion/import-resolvers/php.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/php.js +4 -7
- package/dist/core/ingestion/import-resolvers/python.d.ts +3 -6
- package/dist/core/ingestion/import-resolvers/python.js +3 -18
- package/dist/core/ingestion/import-resolvers/resolver-factory.d.ts +24 -0
- package/dist/core/ingestion/import-resolvers/resolver-factory.js +33 -0
- package/dist/core/ingestion/import-resolvers/ruby.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/ruby.js +4 -7
- package/dist/core/ingestion/import-resolvers/rust.d.ts +4 -5
- package/dist/core/ingestion/import-resolvers/rust.js +4 -47
- package/dist/core/ingestion/import-resolvers/standard.d.ts +3 -9
- package/dist/core/ingestion/import-resolvers/standard.js +7 -8
- package/dist/core/ingestion/import-resolvers/types.d.ts +24 -0
- package/dist/core/ingestion/languages/c-cpp.js +4 -3
- package/dist/core/ingestion/languages/csharp.js +3 -2
- package/dist/core/ingestion/languages/dart.js +3 -2
- package/dist/core/ingestion/languages/go.js +3 -2
- package/dist/core/ingestion/languages/java.js +3 -2
- package/dist/core/ingestion/languages/kotlin.js +3 -2
- package/dist/core/ingestion/languages/php.js +3 -2
- package/dist/core/ingestion/languages/python.js +3 -2
- package/dist/core/ingestion/languages/ruby.js +3 -2
- package/dist/core/ingestion/languages/rust.js +3 -2
- package/dist/core/ingestion/languages/swift.js +3 -2
- package/dist/core/ingestion/languages/typescript.js +4 -3
- package/dist/core/ingestion/languages/vue.js +3 -2
- package/package.json +1 -1
- package/dist/core/ingestion/import-resolvers/dart.d.ts +0 -7
- package/dist/core/ingestion/import-resolvers/swift.d.ts +0 -7
- package/dist/core/ingestion/import-resolvers/vue.d.ts +0 -8
- package/dist/core/ingestion/import-resolvers/vue.js +0 -9
|
@@ -7,6 +7,9 @@ import { compilePatterns, runCompiledPatterns, unquoteLiteral, } from '../tree-s
|
|
|
7
7
|
* - Express `router.get(...)` / `app.post(...)` providers
|
|
8
8
|
* - `fetch(url)` / `fetch(url, { method: 'POST' })` consumers
|
|
9
9
|
* - `axios.get(url)` / `axios.delete(url)` consumers
|
|
10
|
+
* - `axios({ method, url })` object-form consumers
|
|
11
|
+
* - jQuery `$.get(url)` / `$.post(url, ...)` shorthand consumers
|
|
12
|
+
* - jQuery `$.ajax({ url, method | type })` consumers
|
|
10
13
|
*
|
|
11
14
|
* Because the JavaScript and TypeScript tree-sitter grammars share
|
|
12
15
|
* node type names for every construct we query, pattern sources are
|
|
@@ -86,6 +89,45 @@ const AXIOS_SPEC = {
|
|
|
86
89
|
arguments: (arguments . [(string) (template_string)] @path))
|
|
87
90
|
`,
|
|
88
91
|
};
|
|
92
|
+
// ─── Consumer: jQuery shorthand $.get(url) / $.post(url, ...) ────────
|
|
93
|
+
// `$` is a valid JS identifier, so tree-sitter parses `$.get(...)` as a
|
|
94
|
+
// call_expression whose function is a member_expression on identifier `$`.
|
|
95
|
+
const JQUERY_SHORTHAND_SPEC = {
|
|
96
|
+
meta: {},
|
|
97
|
+
query: `
|
|
98
|
+
(call_expression
|
|
99
|
+
function: (member_expression
|
|
100
|
+
object: (identifier) @obj (#eq? @obj "$")
|
|
101
|
+
property: (property_identifier) @http_method (#match? @http_method "^(get|post)$"))
|
|
102
|
+
arguments: (arguments . [(string) (template_string)] @path))
|
|
103
|
+
`,
|
|
104
|
+
};
|
|
105
|
+
// ─── Consumer: jQuery $.ajax({ url, method|type }) ───────────────────
|
|
106
|
+
// The query captures the options object only; key/value pairs are read
|
|
107
|
+
// programmatically via `readStringProp` below, which tolerates any key
|
|
108
|
+
// order and accepts either `method:` or `type:` (jQuery supports both).
|
|
109
|
+
const JQUERY_AJAX_SPEC = {
|
|
110
|
+
meta: {},
|
|
111
|
+
query: `
|
|
112
|
+
(call_expression
|
|
113
|
+
function: (member_expression
|
|
114
|
+
object: (identifier) @obj (#eq? @obj "$")
|
|
115
|
+
property: (property_identifier) @fn (#eq? @fn "ajax"))
|
|
116
|
+
arguments: (arguments (object) @options))
|
|
117
|
+
`,
|
|
118
|
+
};
|
|
119
|
+
// ─── Consumer: axios({ method, url }) object form ────────────────────
|
|
120
|
+
// Distinct from AXIOS_SPEC above because the call target is an identifier
|
|
121
|
+
// (`axios`) rather than a member expression (`axios.get`). As with the
|
|
122
|
+
// jQuery ajax form, option keys are resolved programmatically.
|
|
123
|
+
const AXIOS_OBJECT_SPEC = {
|
|
124
|
+
meta: {},
|
|
125
|
+
query: `
|
|
126
|
+
(call_expression
|
|
127
|
+
function: (identifier) @fn (#eq? @fn "axios")
|
|
128
|
+
arguments: (arguments (object) @options))
|
|
129
|
+
`,
|
|
130
|
+
};
|
|
89
131
|
function compileBundle(language, name) {
|
|
90
132
|
const mk = (spec, suffix) => compilePatterns({
|
|
91
133
|
name: `${name}-${suffix}`,
|
|
@@ -99,6 +141,9 @@ function compileBundle(language, name) {
|
|
|
99
141
|
fetchNoOptions: mk(FETCH_NO_OPTIONS_SPEC, 'fetch-no-options'),
|
|
100
142
|
fetchWithOptions: mk(FETCH_WITH_OPTIONS_SPEC, 'fetch-with-options'),
|
|
101
143
|
axios: mk(AXIOS_SPEC, 'axios'),
|
|
144
|
+
jqueryShorthand: mk(JQUERY_SHORTHAND_SPEC, 'jquery-shorthand'),
|
|
145
|
+
jqueryAjax: mk(JQUERY_AJAX_SPEC, 'jquery-ajax'),
|
|
146
|
+
axiosObject: mk(AXIOS_OBJECT_SPEC, 'axios-object'),
|
|
102
147
|
};
|
|
103
148
|
}
|
|
104
149
|
const JAVASCRIPT_BUNDLE = compileBundle(JavaScript, 'javascript-http');
|
|
@@ -130,6 +175,32 @@ function joinPath(prefix, sub) {
|
|
|
130
175
|
return `/${cleanSub}`;
|
|
131
176
|
return `/${cleanPrefix}/${cleanSub}`;
|
|
132
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Walk `pair` children of an `object` literal and return the unquoted
|
|
180
|
+
* string/template_string value for the first pair whose key matches one
|
|
181
|
+
* of `keyNames`. Returns null when no matching pair is present or the
|
|
182
|
+
* value is not a string literal. Used by the jQuery ajax / axios object
|
|
183
|
+
* consumers to resolve `url` / `method` / `type` keys in any order.
|
|
184
|
+
*/
|
|
185
|
+
function readStringProp(objectNode, keyNames) {
|
|
186
|
+
for (let i = 0; i < objectNode.namedChildCount; i++) {
|
|
187
|
+
const pair = objectNode.namedChild(i);
|
|
188
|
+
if (!pair || pair.type !== 'pair')
|
|
189
|
+
continue;
|
|
190
|
+
const keyNode = pair.childForFieldName('key');
|
|
191
|
+
const valueNode = pair.childForFieldName('value');
|
|
192
|
+
if (!keyNode || !valueNode)
|
|
193
|
+
continue;
|
|
194
|
+
if (!keyNames.includes(keyNode.text))
|
|
195
|
+
continue;
|
|
196
|
+
if (valueNode.type !== 'string' && valueNode.type !== 'template_string')
|
|
197
|
+
continue;
|
|
198
|
+
const lit = unquoteLiteral(valueNode.text);
|
|
199
|
+
if (lit !== null)
|
|
200
|
+
return lit;
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
133
204
|
/**
|
|
134
205
|
* For a standalone `decorator` node (child of class_body / program),
|
|
135
206
|
* find the related `class_declaration` node that it decorates. In
|
|
@@ -335,6 +406,65 @@ function scanBundle(bundle, tree) {
|
|
|
335
406
|
confidence: 0.7,
|
|
336
407
|
});
|
|
337
408
|
}
|
|
409
|
+
// Consumer: jQuery shorthand $.get(url) / $.post(url, ...)
|
|
410
|
+
for (const match of runCompiledPatterns(bundle.jqueryShorthand, tree)) {
|
|
411
|
+
const methodNode = match.captures.http_method;
|
|
412
|
+
const pathNode = match.captures.path;
|
|
413
|
+
if (!methodNode || !pathNode)
|
|
414
|
+
continue;
|
|
415
|
+
const path = unquoteLiteral(pathNode.text);
|
|
416
|
+
if (path === null)
|
|
417
|
+
continue;
|
|
418
|
+
out.push({
|
|
419
|
+
role: 'consumer',
|
|
420
|
+
framework: 'jquery',
|
|
421
|
+
method: methodNode.text.toUpperCase(),
|
|
422
|
+
path,
|
|
423
|
+
name: null,
|
|
424
|
+
confidence: 0.7,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
// Consumer: jQuery $.ajax({ url, method|type }). jQuery accepts either
|
|
428
|
+
// `method:` or `type:`; both default to GET when absent.
|
|
429
|
+
for (const match of runCompiledPatterns(bundle.jqueryAjax, tree)) {
|
|
430
|
+
const optionsNode = match.captures.options;
|
|
431
|
+
if (!optionsNode)
|
|
432
|
+
continue;
|
|
433
|
+
const path = readStringProp(optionsNode, ['url']);
|
|
434
|
+
if (path === null)
|
|
435
|
+
continue;
|
|
436
|
+
const rawMethod = readStringProp(optionsNode, ['method', 'type']);
|
|
437
|
+
const method = (rawMethod ?? 'GET').toUpperCase();
|
|
438
|
+
out.push({
|
|
439
|
+
role: 'consumer',
|
|
440
|
+
framework: 'jquery',
|
|
441
|
+
method,
|
|
442
|
+
path,
|
|
443
|
+
name: null,
|
|
444
|
+
confidence: 0.7,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
// Consumer: axios({ method, url }) object form. Structurally distinct
|
|
448
|
+
// from axios.<verb>(url) (identifier vs member_expression call), so no
|
|
449
|
+
// dedup against the member-form loop above is required.
|
|
450
|
+
for (const match of runCompiledPatterns(bundle.axiosObject, tree)) {
|
|
451
|
+
const optionsNode = match.captures.options;
|
|
452
|
+
if (!optionsNode)
|
|
453
|
+
continue;
|
|
454
|
+
const path = readStringProp(optionsNode, ['url']);
|
|
455
|
+
if (path === null)
|
|
456
|
+
continue;
|
|
457
|
+
const rawMethod = readStringProp(optionsNode, ['method']);
|
|
458
|
+
const method = (rawMethod ?? 'GET').toUpperCase();
|
|
459
|
+
out.push({
|
|
460
|
+
role: 'consumer',
|
|
461
|
+
framework: 'axios',
|
|
462
|
+
method,
|
|
463
|
+
path,
|
|
464
|
+
name: null,
|
|
465
|
+
confidence: 0.7,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
338
468
|
return out;
|
|
339
469
|
}
|
|
340
470
|
export const JAVASCRIPT_HTTP_PLUGIN = {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C / C++ import resolution configs.
|
|
3
|
+
* Both use standard resolution for #include directives.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig } from '../types.js';
|
|
6
|
+
export declare const cImportConfig: ImportResolutionConfig;
|
|
7
|
+
export declare const cppImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C / C++ import resolution configs.
|
|
3
|
+
* Both use standard resolution for #include directives.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
export const cImportConfig = {
|
|
8
|
+
language: SupportedLanguages.C,
|
|
9
|
+
strategies: [createStandardStrategy(SupportedLanguages.C)],
|
|
10
|
+
};
|
|
11
|
+
export const cppImportConfig = {
|
|
12
|
+
language: SupportedLanguages.CPlusPlus,
|
|
13
|
+
strategies: [createStandardStrategy(SupportedLanguages.CPlusPlus)],
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# import resolution config.
|
|
3
|
+
* Namespace-based strategy via .csproj configs, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** C# namespace-based resolution strategy via .csproj configs. */
|
|
7
|
+
export declare const csharpNamespaceStrategy: ImportResolverStrategy;
|
|
8
|
+
export declare const csharpImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# import resolution config.
|
|
3
|
+
* Namespace-based strategy via .csproj configs, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
import { resolveCSharpImportInternal, resolveCSharpNamespaceDir } from '../csharp.js';
|
|
8
|
+
/** C# namespace-based resolution strategy via .csproj configs. */
|
|
9
|
+
export const csharpNamespaceStrategy = (rawImportPath, _filePath, ctx) => {
|
|
10
|
+
const csharpConfigs = ctx.configs.csharpConfigs;
|
|
11
|
+
if (csharpConfigs.length > 0) {
|
|
12
|
+
const resolvedFiles = resolveCSharpImportInternal(rawImportPath, csharpConfigs, ctx.normalizedFileList, ctx.allFileList, ctx.index);
|
|
13
|
+
if (resolvedFiles.length > 1) {
|
|
14
|
+
const dirSuffix = resolveCSharpNamespaceDir(rawImportPath, csharpConfigs);
|
|
15
|
+
if (dirSuffix) {
|
|
16
|
+
return { kind: 'package', files: resolvedFiles, dirSuffix };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (resolvedFiles.length > 0)
|
|
20
|
+
return { kind: 'files', files: resolvedFiles };
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
export const csharpImportConfig = {
|
|
25
|
+
language: SupportedLanguages.CSharp,
|
|
26
|
+
strategies: [csharpNamespaceStrategy, createStandardStrategy(SupportedLanguages.CSharp)],
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dart import resolution config.
|
|
3
|
+
* SDK/package strategy first, then relative import strategy (with ./ prepending).
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Dart SDK and package: import strategy.
|
|
8
|
+
* Absorbs dart: SDK imports and external packages (returns empty result to stop chain).
|
|
9
|
+
* Returns null for relative imports to let the next strategy handle them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const dartPackageStrategy: ImportResolverStrategy;
|
|
12
|
+
/**
|
|
13
|
+
* Dart relative import strategy — prepends "./" for bare relative paths,
|
|
14
|
+
* then delegates to standard resolution.
|
|
15
|
+
*/
|
|
16
|
+
export declare const dartRelativeStrategy: ImportResolverStrategy;
|
|
17
|
+
export declare const dartImportConfig: ImportResolutionConfig;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dart import resolution.
|
|
3
|
-
*
|
|
4
|
-
* SDK imports (dart:*) and external packages are skipped.
|
|
2
|
+
* Dart import resolution config.
|
|
3
|
+
* SDK/package strategy first, then relative import strategy (with ./ prepending).
|
|
5
4
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { resolveStandard } from '../standard.js';
|
|
7
|
+
/**
|
|
8
|
+
* Dart SDK and package: import strategy.
|
|
9
|
+
* Absorbs dart: SDK imports and external packages (returns empty result to stop chain).
|
|
10
|
+
* Returns null for relative imports to let the next strategy handle them.
|
|
11
|
+
*/
|
|
12
|
+
export const dartPackageStrategy = (rawImportPath, _filePath, ctx) => {
|
|
9
13
|
// Strip surrounding quotes from configurable_uri capture
|
|
10
14
|
const stripped = rawImportPath.replace(/^['"]|['"]$/g, '');
|
|
11
15
|
// Skip dart: SDK imports (dart:async, dart:io, etc.)
|
|
12
16
|
if (stripped.startsWith('dart:'))
|
|
13
|
-
return
|
|
17
|
+
return { kind: 'files', files: [] };
|
|
14
18
|
// Local package: imports → resolve to lib/<path>
|
|
15
19
|
if (stripped.startsWith('package:')) {
|
|
16
20
|
const slashIdx = stripped.indexOf('/');
|
|
17
21
|
if (slashIdx === -1)
|
|
18
|
-
return
|
|
22
|
+
return { kind: 'files', files: [] };
|
|
19
23
|
const relPath = stripped.slice(slashIdx + 1);
|
|
20
24
|
const candidates = [`lib/${relPath}`, relPath];
|
|
21
25
|
const files = [];
|
|
@@ -31,14 +35,20 @@ export function resolveDartImport(rawImportPath, filePath, ctx) {
|
|
|
31
35
|
}
|
|
32
36
|
if (files.length > 0)
|
|
33
37
|
return { kind: 'files', files };
|
|
34
|
-
return
|
|
38
|
+
return { kind: 'files', files: [] }; // external package
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Dart relative import strategy — prepends "./" for bare relative paths,
|
|
44
|
+
* then delegates to standard resolution.
|
|
45
|
+
*/
|
|
46
|
+
export const dartRelativeStrategy = (rawImportPath, filePath, ctx) => {
|
|
47
|
+
const stripped = rawImportPath.replace(/^['"]|['"]$/g, '');
|
|
42
48
|
const relPath = stripped.startsWith('.') ? stripped : './' + stripped;
|
|
43
49
|
return resolveStandard(relPath, filePath, ctx, SupportedLanguages.Dart);
|
|
44
|
-
}
|
|
50
|
+
};
|
|
51
|
+
export const dartImportConfig = {
|
|
52
|
+
language: SupportedLanguages.Dart,
|
|
53
|
+
strategies: [dartPackageStrategy, dartRelativeStrategy],
|
|
54
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go import resolution config.
|
|
3
|
+
* Go-specific package strategy (go.mod), then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** Go-specific package resolution strategy — resolves go.mod-based package imports. */
|
|
7
|
+
export declare const goPackageStrategy: ImportResolverStrategy;
|
|
8
|
+
export declare const goImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go import resolution config.
|
|
3
|
+
* Go-specific package strategy (go.mod), then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
import { resolveGoPackageDir, resolveGoPackage } from '../go.js';
|
|
8
|
+
/** Go-specific package resolution strategy — resolves go.mod-based package imports. */
|
|
9
|
+
export const goPackageStrategy = (rawImportPath, _filePath, ctx) => {
|
|
10
|
+
const goModule = ctx.configs.goModule;
|
|
11
|
+
if (goModule && rawImportPath.startsWith(goModule.modulePath)) {
|
|
12
|
+
const pkgSuffix = resolveGoPackageDir(rawImportPath, goModule);
|
|
13
|
+
if (pkgSuffix) {
|
|
14
|
+
const pkgFiles = resolveGoPackage(rawImportPath, goModule, ctx.normalizedFileList, ctx.allFileList);
|
|
15
|
+
if (pkgFiles.length > 0) {
|
|
16
|
+
return { kind: 'package', files: pkgFiles, dirSuffix: pkgSuffix };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Fall through if no files found (package might be external)
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
export const goImportConfig = {
|
|
24
|
+
language: SupportedLanguages.Go,
|
|
25
|
+
strategies: [goPackageStrategy, createStandardStrategy(SupportedLanguages.Go)],
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java / Kotlin import resolution configs.
|
|
3
|
+
* JVM-specific wildcard/member strategy, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** Java JVM resolution strategy — wildcard and member import resolution. */
|
|
7
|
+
export declare const javaJvmStrategy: ImportResolverStrategy;
|
|
8
|
+
/**
|
|
9
|
+
* Kotlin JVM resolution strategy — wildcard/member with Java-interop + top-level function imports.
|
|
10
|
+
*/
|
|
11
|
+
export declare const kotlinJvmStrategy: ImportResolverStrategy;
|
|
12
|
+
export declare const javaImportConfig: ImportResolutionConfig;
|
|
13
|
+
export declare const kotlinImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java / Kotlin import resolution configs.
|
|
3
|
+
* JVM-specific wildcard/member strategy, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
import { resolveJvmWildcard, resolveJvmMemberImport, KOTLIN_EXTENSIONS } from '../jvm.js';
|
|
8
|
+
/** Java JVM resolution strategy — wildcard and member import resolution. */
|
|
9
|
+
export const javaJvmStrategy = (rawImportPath, _filePath, ctx) => {
|
|
10
|
+
if (rawImportPath.endsWith('.*')) {
|
|
11
|
+
const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
12
|
+
if (matchedFiles.length > 0)
|
|
13
|
+
return { kind: 'files', files: matchedFiles };
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
17
|
+
if (memberResolved)
|
|
18
|
+
return { kind: 'files', files: [memberResolved] };
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Kotlin JVM resolution strategy — wildcard/member with Java-interop + top-level function imports.
|
|
24
|
+
*/
|
|
25
|
+
export const kotlinJvmStrategy = (rawImportPath, _filePath, ctx) => {
|
|
26
|
+
if (rawImportPath.endsWith('.*')) {
|
|
27
|
+
const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
28
|
+
if (matchedFiles.length === 0) {
|
|
29
|
+
const javaMatches = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
30
|
+
if (javaMatches.length > 0)
|
|
31
|
+
return { kind: 'files', files: javaMatches };
|
|
32
|
+
}
|
|
33
|
+
if (matchedFiles.length > 0)
|
|
34
|
+
return { kind: 'files', files: matchedFiles };
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
let memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
38
|
+
if (!memberResolved) {
|
|
39
|
+
memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
40
|
+
}
|
|
41
|
+
if (memberResolved)
|
|
42
|
+
return { kind: 'files', files: [memberResolved] };
|
|
43
|
+
// Kotlin: top-level function imports (e.g. import models.getUser) have only 2 segments,
|
|
44
|
+
// which resolveJvmMemberImport skips (requires >=3). Fall back to package-directory scan
|
|
45
|
+
// for lowercase last segments (function/property imports). Uppercase last segments
|
|
46
|
+
// (class imports like models.User) fall through to standard suffix resolution.
|
|
47
|
+
const segments = rawImportPath.split('.');
|
|
48
|
+
const lastSeg = segments[segments.length - 1];
|
|
49
|
+
if (segments.length >= 2 && lastSeg[0] && lastSeg[0] === lastSeg[0].toLowerCase()) {
|
|
50
|
+
const pkgWildcard = segments.slice(0, -1).join('.') + '.*';
|
|
51
|
+
let dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
52
|
+
if (dirFiles.length === 0) {
|
|
53
|
+
dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
54
|
+
}
|
|
55
|
+
if (dirFiles.length > 0)
|
|
56
|
+
return { kind: 'files', files: dirFiles };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
export const javaImportConfig = {
|
|
62
|
+
language: SupportedLanguages.Java,
|
|
63
|
+
strategies: [javaJvmStrategy, createStandardStrategy(SupportedLanguages.Java)],
|
|
64
|
+
};
|
|
65
|
+
export const kotlinImportConfig = {
|
|
66
|
+
language: SupportedLanguages.Kotlin,
|
|
67
|
+
strategies: [kotlinJvmStrategy, createStandardStrategy(SupportedLanguages.Kotlin)],
|
|
68
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PHP import resolution config.
|
|
3
|
+
* PSR-4 strategy via composer.json — no standard fallback (PSR-4 includes its own suffix matching).
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** PHP PSR-4 resolution strategy via composer.json autoload mappings. */
|
|
7
|
+
export declare const phpPsr4Strategy: ImportResolverStrategy;
|
|
8
|
+
export declare const phpImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PHP import resolution config.
|
|
3
|
+
* PSR-4 strategy via composer.json — no standard fallback (PSR-4 includes its own suffix matching).
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { resolvePhpImportInternal } from '../php.js';
|
|
7
|
+
/** PHP PSR-4 resolution strategy via composer.json autoload mappings. */
|
|
8
|
+
export const phpPsr4Strategy = (rawImportPath, _filePath, ctx) => {
|
|
9
|
+
const resolved = resolvePhpImportInternal(rawImportPath, ctx.configs.composerConfig, ctx.allFilePaths, ctx.normalizedFileList, ctx.allFileList, ctx.index);
|
|
10
|
+
return resolved ? { kind: 'files', files: [resolved] } : null;
|
|
11
|
+
};
|
|
12
|
+
export const phpImportConfig = {
|
|
13
|
+
language: SupportedLanguages.PHP,
|
|
14
|
+
strategies: [phpPsr4Strategy],
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python import resolution config.
|
|
3
|
+
* PEP 328 relative + proximity-based strategy, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Python import resolution strategy — PEP 328 relative + proximity-based bare imports.
|
|
8
|
+
* Returns null to continue chain for non-relative imports.
|
|
9
|
+
* Absorbs unresolved relative imports (returns empty result to stop the chain).
|
|
10
|
+
*/
|
|
11
|
+
export declare const pythonImportStrategy: ImportResolverStrategy;
|
|
12
|
+
export declare const pythonImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python import resolution config.
|
|
3
|
+
* PEP 328 relative + proximity-based strategy, then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
import { resolvePythonImportInternal } from '../python.js';
|
|
8
|
+
/**
|
|
9
|
+
* Python import resolution strategy — PEP 328 relative + proximity-based bare imports.
|
|
10
|
+
* Returns null to continue chain for non-relative imports.
|
|
11
|
+
* Absorbs unresolved relative imports (returns empty result to stop the chain).
|
|
12
|
+
*/
|
|
13
|
+
export const pythonImportStrategy = (rawImportPath, filePath, ctx) => {
|
|
14
|
+
const resolved = resolvePythonImportInternal(filePath, rawImportPath, ctx.allFilePaths);
|
|
15
|
+
if (resolved) {
|
|
16
|
+
ctx.resolveCache.set(`${filePath}::${rawImportPath}`, resolved);
|
|
17
|
+
return { kind: 'files', files: [resolved] };
|
|
18
|
+
}
|
|
19
|
+
// PEP 328: unresolved relative imports should not fall through to suffix matching
|
|
20
|
+
if (rawImportPath.startsWith('.'))
|
|
21
|
+
return { kind: 'files', files: [] };
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
export const pythonImportConfig = {
|
|
25
|
+
language: SupportedLanguages.Python,
|
|
26
|
+
strategies: [pythonImportStrategy, createStandardStrategy(SupportedLanguages.Python)],
|
|
27
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby import resolution config.
|
|
3
|
+
* Require/require_relative suffix matching — no standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** Ruby require/require_relative resolution strategy. */
|
|
7
|
+
export declare const rubyRequireStrategy: ImportResolverStrategy;
|
|
8
|
+
export declare const rubyImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby import resolution config.
|
|
3
|
+
* Require/require_relative suffix matching — no standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { suffixResolve } from '../utils.js';
|
|
7
|
+
/** Ruby require/require_relative resolution strategy. */
|
|
8
|
+
export const rubyRequireStrategy = (rawImportPath, _filePath, ctx) => {
|
|
9
|
+
const pathParts = rawImportPath.replace(/^\.\//, '').split('/').filter(Boolean);
|
|
10
|
+
const resolved = suffixResolve(pathParts, ctx.normalizedFileList, ctx.allFileList, ctx.index);
|
|
11
|
+
return resolved ? { kind: 'files', files: [resolved] } : null;
|
|
12
|
+
};
|
|
13
|
+
export const rubyImportConfig = {
|
|
14
|
+
language: SupportedLanguages.Ruby,
|
|
15
|
+
strategies: [rubyRequireStrategy],
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust import resolution config.
|
|
3
|
+
* Rust module strategy (grouped imports, crate/super/self paths), then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** Rust module resolution strategy — handles grouped imports and crate/super/self paths. */
|
|
7
|
+
export declare const rustModuleStrategy: ImportResolverStrategy;
|
|
8
|
+
export declare const rustImportConfig: ImportResolutionConfig;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust import resolution config.
|
|
3
|
+
* Rust module strategy (grouped imports, crate/super/self paths), then standard fallback.
|
|
4
|
+
*/
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
import { createStandardStrategy } from '../standard.js';
|
|
7
|
+
import { resolveRustImportInternal } from '../rust.js';
|
|
8
|
+
/** Rust module resolution strategy — handles grouped imports and crate/super/self paths. */
|
|
9
|
+
export const rustModuleStrategy = (rawImportPath, filePath, ctx) => {
|
|
10
|
+
// Top-level grouped: use {crate::a, crate::b}
|
|
11
|
+
if (rawImportPath.startsWith('{') && rawImportPath.endsWith('}')) {
|
|
12
|
+
const inner = rawImportPath.slice(1, -1);
|
|
13
|
+
const parts = inner
|
|
14
|
+
.split(',')
|
|
15
|
+
.map((p) => p.trim())
|
|
16
|
+
.filter(Boolean);
|
|
17
|
+
const resolved = [];
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
const r = resolveRustImportInternal(filePath, part, ctx.allFilePaths);
|
|
20
|
+
if (r)
|
|
21
|
+
resolved.push(r);
|
|
22
|
+
}
|
|
23
|
+
return resolved.length > 0 ? { kind: 'files', files: resolved } : null;
|
|
24
|
+
}
|
|
25
|
+
// Scoped grouped: use crate::models::{User, Repo}
|
|
26
|
+
const braceIdx = rawImportPath.indexOf('::{');
|
|
27
|
+
if (braceIdx !== -1 && rawImportPath.endsWith('}')) {
|
|
28
|
+
const pathPrefix = rawImportPath.substring(0, braceIdx);
|
|
29
|
+
const braceContent = rawImportPath.substring(braceIdx + 3, rawImportPath.length - 1);
|
|
30
|
+
const items = braceContent
|
|
31
|
+
.split(',')
|
|
32
|
+
.map((s) => s.trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
const resolved = [];
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
// Handle `use crate::models::{User, Repo as R}` — strip alias for resolution
|
|
37
|
+
const itemName = item.includes(' as ') ? item.split(' as ')[0].trim() : item;
|
|
38
|
+
const r = resolveRustImportInternal(filePath, `${pathPrefix}::${itemName}`, ctx.allFilePaths);
|
|
39
|
+
if (r)
|
|
40
|
+
resolved.push(r);
|
|
41
|
+
}
|
|
42
|
+
if (resolved.length > 0)
|
|
43
|
+
return { kind: 'files', files: resolved };
|
|
44
|
+
// Fallback: resolve the prefix path itself (e.g. crate::models -> models.rs)
|
|
45
|
+
const prefixResult = resolveRustImportInternal(filePath, pathPrefix, ctx.allFilePaths);
|
|
46
|
+
if (prefixResult)
|
|
47
|
+
return { kind: 'files', files: [prefixResult] };
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
export const rustImportConfig = {
|
|
52
|
+
language: SupportedLanguages.Rust,
|
|
53
|
+
strategies: [rustModuleStrategy, createStandardStrategy(SupportedLanguages.Rust)],
|
|
54
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift import resolution config.
|
|
3
|
+
* Package.swift target map strategy — no standard fallback (unresolved = external framework).
|
|
4
|
+
*/
|
|
5
|
+
import type { ImportResolutionConfig, ImportResolverStrategy } from '../types.js';
|
|
6
|
+
/** Swift Package.swift target map resolution strategy. */
|
|
7
|
+
export declare const swiftPackageStrategy: ImportResolverStrategy;
|
|
8
|
+
export declare const swiftImportConfig: ImportResolutionConfig;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swift
|
|
3
|
-
*
|
|
2
|
+
* Swift import resolution config.
|
|
3
|
+
* Package.swift target map strategy — no standard fallback (unresolved = external framework).
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
6
|
+
/** Swift Package.swift target map resolution strategy. */
|
|
7
|
+
export const swiftPackageStrategy = (rawImportPath, _filePath, ctx) => {
|
|
7
8
|
const swiftPackageConfig = ctx.configs.swiftPackageConfig;
|
|
8
9
|
if (swiftPackageConfig) {
|
|
9
10
|
const targetDir = swiftPackageConfig.targets.get(rawImportPath);
|
|
@@ -21,4 +22,8 @@ export function resolveSwiftImport(rawImportPath, _filePath, ctx) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
return null; // External framework (Foundation, UIKit, etc.)
|
|
24
|
-
}
|
|
25
|
+
};
|
|
26
|
+
export const swiftImportConfig = {
|
|
27
|
+
language: SupportedLanguages.Swift,
|
|
28
|
+
strategies: [swiftPackageStrategy],
|
|
29
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript / JavaScript / Vue import resolution configs.
|
|
3
|
+
* All use standard resolution — TS/JS with tsconfig path aliases,
|
|
4
|
+
* Vue delegates to TypeScript's resolver.
|
|
5
|
+
*/
|
|
6
|
+
import type { ImportResolutionConfig } from '../types.js';
|
|
7
|
+
export declare const typescriptImportConfig: ImportResolutionConfig;
|
|
8
|
+
export declare const javascriptImportConfig: ImportResolutionConfig;
|
|
9
|
+
export declare const vueImportConfig: ImportResolutionConfig;
|