gitnexus 1.6.2-rc.2 → 1.6.2-rc.21
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/_shared/lbug/schema-constants.d.ts +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +1 -0
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/cli/analyze.js +3 -0
- package/dist/core/embeddings/ast-utils.d.ts +22 -0
- package/dist/core/embeddings/ast-utils.js +105 -0
- package/dist/core/embeddings/character-chunk.d.ts +12 -0
- package/dist/core/embeddings/character-chunk.js +43 -0
- package/dist/core/embeddings/chunker.d.ts +14 -0
- package/dist/core/embeddings/chunker.js +234 -0
- package/dist/core/embeddings/embedder.js +5 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +29 -24
- package/dist/core/embeddings/embedding-pipeline.js +244 -125
- package/dist/core/embeddings/line-index.d.ts +7 -0
- package/dist/core/embeddings/line-index.js +42 -0
- package/dist/core/embeddings/server-mapping.d.ts +15 -0
- package/dist/core/embeddings/server-mapping.js +33 -0
- package/dist/core/embeddings/structural-extractor.d.ts +15 -0
- package/dist/core/embeddings/structural-extractor.js +58 -0
- package/dist/core/embeddings/text-generator.d.ts +20 -13
- package/dist/core/embeddings/text-generator.js +151 -119
- package/dist/core/embeddings/types.d.ts +81 -3
- package/dist/core/embeddings/types.js +105 -3
- package/dist/core/group/extractors/http-patterns/node.js +130 -0
- package/dist/core/group/extractors/manifest-extractor.js +20 -5
- package/dist/core/group/sync.js +49 -1
- package/dist/core/ingestion/call-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/c-cpp.js +8 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.js +6 -0
- package/dist/core/ingestion/call-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/dart.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/go.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.js +51 -0
- package/dist/core/ingestion/call-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/php.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/python.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/rust.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/swift.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.js +8 -0
- package/dist/core/ingestion/call-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/call-extractors/generic.js +59 -0
- package/dist/core/ingestion/call-processor.d.ts +1 -3
- package/dist/core/ingestion/call-processor.js +49 -47
- package/dist/core/ingestion/call-types.d.ts +60 -0
- package/dist/core/ingestion/call-types.js +2 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +11 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.js +21 -0
- package/dist/core/ingestion/class-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/dart.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/go.js +20 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.js +35 -0
- package/dist/core/ingestion/class-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/php.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/python.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/rust.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/swift.js +18 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.d.ts +4 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.js +28 -0
- package/dist/core/ingestion/field-types.d.ts +1 -1
- 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 +41 -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/language-provider.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +15 -12
- package/dist/core/ingestion/languages/csharp.js +11 -21
- package/dist/core/ingestion/languages/dart.js +11 -7
- package/dist/core/ingestion/languages/go.js +11 -20
- package/dist/core/ingestion/languages/java.js +11 -18
- package/dist/core/ingestion/languages/kotlin.js +11 -13
- package/dist/core/ingestion/languages/php.js +11 -7
- package/dist/core/ingestion/languages/python.js +11 -7
- package/dist/core/ingestion/languages/ruby.js +11 -7
- package/dist/core/ingestion/languages/rust.js +11 -7
- package/dist/core/ingestion/languages/swift.js +11 -18
- package/dist/core/ingestion/languages/typescript.js +15 -23
- package/dist/core/ingestion/languages/vue.js +11 -17
- package/dist/core/ingestion/model/index.d.ts +2 -2
- package/dist/core/ingestion/model/index.js +1 -1
- package/dist/core/ingestion/model/resolve.d.ts +3 -0
- package/dist/core/ingestion/model/resolve.js +6 -2
- package/dist/core/ingestion/parsing-processor.d.ts +1 -2
- package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
- package/dist/core/ingestion/tree-sitter-queries.js +81 -0
- package/dist/core/ingestion/type-env.d.ts +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +1 -1
- package/dist/core/ingestion/utils/ast-helpers.js +3 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +81 -0
- package/dist/core/ingestion/variable-extractors/configs/csharp.d.ts +9 -0
- package/dist/core/ingestion/variable-extractors/configs/csharp.js +63 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +94 -0
- package/dist/core/ingestion/variable-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/go.js +83 -0
- package/dist/core/ingestion/variable-extractors/configs/jvm.d.ts +18 -0
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +115 -0
- package/dist/core/ingestion/variable-extractors/configs/php.d.ts +14 -0
- package/dist/core/ingestion/variable-extractors/configs/php.js +58 -0
- package/dist/core/ingestion/variable-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/python.js +101 -0
- package/dist/core/ingestion/variable-extractors/configs/ruby.d.ts +11 -0
- package/dist/core/ingestion/variable-extractors/configs/ruby.js +52 -0
- package/dist/core/ingestion/variable-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/rust.js +76 -0
- package/dist/core/ingestion/variable-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/variable-extractors/configs/swift.js +88 -0
- package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/variable-extractors/configs/typescript-javascript.js +83 -0
- package/dist/core/ingestion/variable-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/variable-extractors/generic.js +80 -0
- package/dist/core/ingestion/variable-types.d.ts +82 -0
- package/dist/core/ingestion/variable-types.js +2 -0
- package/dist/core/ingestion/workers/parse-worker.js +196 -166
- package/dist/core/ingestion/workers/worker-pool.js +3 -0
- package/dist/core/lbug/csv-generator.js +1 -0
- package/dist/core/lbug/lbug-adapter.d.ts +13 -4
- package/dist/core/lbug/lbug-adapter.js +166 -81
- package/dist/core/lbug/schema.d.ts +9 -1
- package/dist/core/lbug/schema.js +19 -2
- package/dist/core/run-analyze.js +17 -4
- package/dist/core/tree-sitter/parser-loader.d.ts +3 -0
- package/dist/core/tree-sitter/parser-loader.js +17 -8
- package/dist/mcp/core/embedder.js +5 -0
- package/dist/mcp/local/local-backend.js +29 -19
- package/dist/server/api.js +10 -21
- package/package.json +5 -3
- package/scripts/build-tree-sitter-proto.cjs +82 -0
- package/vendor/node_modules/node-addon-api/node_addon_api.Makefile +6 -0
- package/vendor/node_modules/node-addon-api/node_addon_api.target.mk +104 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_except.target.mk +108 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_except_all.target.mk +104 -0
- package/vendor/node_modules/node-addon-api/node_addon_api_maybe.target.mk +104 -0
- package/vendor/tree-sitter-proto/package.json +1 -7
- package/dist/core/ingestion/call-sites/extract-language-call-site.d.ts +0 -10
- package/dist/core/ingestion/call-sites/extract-language-call-site.js +0 -22
- package/dist/core/ingestion/call-sites/java.d.ts +0 -9
- package/dist/core/ingestion/call-sites/java.js +0 -30
- 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
|
@@ -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,41 @@
|
|
|
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
|
+
// External dotted imports like `django.apps` should not fall through to generic
|
|
23
|
+
// suffix matching when the repo has unrelated local files such as `accounts/apps.py`.
|
|
24
|
+
// Keep suffix fallback only when the leading segment appears somewhere in-repo,
|
|
25
|
+
// which preserves existing internal absolute-import behavior like `accounts.models`.
|
|
26
|
+
const pathLike = rawImportPath.replace(/\./g, '/');
|
|
27
|
+
if (pathLike.includes('/')) {
|
|
28
|
+
const [leadingSegment] = pathLike.split('/').filter(Boolean);
|
|
29
|
+
const hasRepoCandidate = !!leadingSegment &&
|
|
30
|
+
(ctx.index.get(`${leadingSegment}.py`) !== undefined ||
|
|
31
|
+
ctx.index.get(`${leadingSegment}/__init__.py`) !== undefined ||
|
|
32
|
+
ctx.index.getFilesInDir(leadingSegment, '.py').length > 0);
|
|
33
|
+
if (!hasRepoCandidate)
|
|
34
|
+
return { kind: 'files', files: [] };
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
export const pythonImportConfig = {
|
|
39
|
+
language: SupportedLanguages.Python,
|
|
40
|
+
strategies: [pythonImportStrategy, createStandardStrategy(SupportedLanguages.Python)],
|
|
41
|
+
};
|
|
@@ -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;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { SupportedLanguages } from '../../../../_shared/index.js';
|
|
7
|
+
import { createStandardStrategy } from '../standard.js';
|
|
8
|
+
export const typescriptImportConfig = {
|
|
9
|
+
language: SupportedLanguages.TypeScript,
|
|
10
|
+
strategies: [createStandardStrategy(SupportedLanguages.TypeScript)],
|
|
11
|
+
};
|
|
12
|
+
export const javascriptImportConfig = {
|
|
13
|
+
language: SupportedLanguages.JavaScript,
|
|
14
|
+
strategies: [createStandardStrategy(SupportedLanguages.JavaScript)],
|
|
15
|
+
};
|
|
16
|
+
// Vue SFCs are preprocessed into TypeScript upstream of import resolution,
|
|
17
|
+
// so the resolver intentionally runs as TypeScript. `language: Vue` here is
|
|
18
|
+
// documentation-only metadata (see `ImportResolutionConfig.language` JSDoc
|
|
19
|
+
// and ARCHITECTURE.md §Vue); it is not consumed by `createImportResolver`.
|
|
20
|
+
export const vueImportConfig = {
|
|
21
|
+
language: SupportedLanguages.Vue,
|
|
22
|
+
strategies: [createStandardStrategy(SupportedLanguages.TypeScript)],
|
|
23
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* C# namespace import resolution.
|
|
3
|
-
*
|
|
2
|
+
* C# namespace import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/csharp.ts.
|
|
5
|
+
* This file contains shared helpers for namespace-based resolution.
|
|
4
6
|
*/
|
|
5
7
|
import type { SuffixIndex } from './utils.js';
|
|
6
|
-
import type { ImportResult, ResolveCtx } from './types.js';
|
|
7
8
|
import type { CSharpProjectConfig } from '../language-config.js';
|
|
8
9
|
/**
|
|
9
10
|
* Resolve a C# using-directive import path to matching .cs files (low-level helper).
|
|
@@ -15,5 +16,3 @@ export declare function resolveCSharpImportInternal(importPath: string, csharpCo
|
|
|
15
16
|
* Returns a suffix like "/ProjectDir/Models/" or null if no config matches.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resolveCSharpNamespaceDir(importPath: string, csharpConfigs: CSharpProjectConfig[]): string | null;
|
|
18
|
-
/** C#: namespace-based resolution via .csproj configs, with suffix-match fallback. */
|
|
19
|
-
export declare function resolveCSharpImport(rawImportPath: string, filePath: string, ctx: ResolveCtx): ImportResult;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* C# namespace import resolution.
|
|
3
|
-
*
|
|
2
|
+
* C# namespace import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/csharp.ts.
|
|
5
|
+
* This file contains shared helpers for namespace-based resolution.
|
|
4
6
|
*/
|
|
5
7
|
import { suffixResolve } from './utils.js';
|
|
6
|
-
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
7
|
-
import { resolveStandard } from './standard.js';
|
|
8
8
|
/**
|
|
9
9
|
* Resolve a C# using-directive import path to matching .cs files (low-level helper).
|
|
10
10
|
* Tries single-file match first, then directory match for namespace imports.
|
|
@@ -113,19 +113,3 @@ export function resolveCSharpNamespaceDir(importPath, csharpConfigs) {
|
|
|
113
113
|
}
|
|
114
114
|
return null;
|
|
115
115
|
}
|
|
116
|
-
/** C#: namespace-based resolution via .csproj configs, with suffix-match fallback. */
|
|
117
|
-
export function resolveCSharpImport(rawImportPath, filePath, ctx) {
|
|
118
|
-
const csharpConfigs = ctx.configs.csharpConfigs;
|
|
119
|
-
if (csharpConfigs.length > 0) {
|
|
120
|
-
const resolvedFiles = resolveCSharpImportInternal(rawImportPath, csharpConfigs, ctx.normalizedFileList, ctx.allFileList, ctx.index);
|
|
121
|
-
if (resolvedFiles.length > 1) {
|
|
122
|
-
const dirSuffix = resolveCSharpNamespaceDir(rawImportPath, csharpConfigs);
|
|
123
|
-
if (dirSuffix) {
|
|
124
|
-
return { kind: 'package', files: resolvedFiles, dirSuffix };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (resolvedFiles.length > 0)
|
|
128
|
-
return { kind: 'files', files: resolvedFiles };
|
|
129
|
-
}
|
|
130
|
-
return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.CSharp);
|
|
131
|
-
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Go package import resolution.
|
|
3
|
-
*
|
|
2
|
+
* Go package import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/go.ts.
|
|
5
|
+
* This file contains the shared helpers used by the strategy.
|
|
4
6
|
*/
|
|
5
|
-
import type { ImportResult, ResolveCtx } from './types.js';
|
|
6
7
|
import type { GoModuleConfig } from '../language-config.js';
|
|
7
8
|
/**
|
|
8
9
|
* Extract the package directory suffix from a Go import path.
|
|
@@ -14,5 +15,3 @@ export declare function resolveGoPackageDir(importPath: string, goModule: GoModu
|
|
|
14
15
|
* Returns an array of file paths.
|
|
15
16
|
*/
|
|
16
17
|
export declare function resolveGoPackage(importPath: string, goModule: GoModuleConfig, normalizedFileList: string[], allFileList: string[]): string[];
|
|
17
|
-
/** Go: package-level imports via go.mod module path. */
|
|
18
|
-
export declare function resolveGoImport(rawImportPath: string, filePath: string, ctx: ResolveCtx): ImportResult;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Go package import resolution.
|
|
3
|
-
*
|
|
2
|
+
* Go package import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/go.ts.
|
|
5
|
+
* This file contains the shared helpers used by the strategy.
|
|
4
6
|
*/
|
|
5
|
-
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
6
|
-
import { resolveStandard } from './standard.js';
|
|
7
7
|
/**
|
|
8
8
|
* Extract the package directory suffix from a Go import path.
|
|
9
9
|
* Returns the suffix string (e.g., "/internal/auth/") or null if invalid.
|
|
@@ -44,18 +44,3 @@ export function resolveGoPackage(importPath, goModule, normalizedFileList, allFi
|
|
|
44
44
|
}
|
|
45
45
|
return matches;
|
|
46
46
|
}
|
|
47
|
-
/** Go: package-level imports via go.mod module path. */
|
|
48
|
-
export function resolveGoImport(rawImportPath, filePath, ctx) {
|
|
49
|
-
const goModule = ctx.configs.goModule;
|
|
50
|
-
if (goModule && rawImportPath.startsWith(goModule.modulePath)) {
|
|
51
|
-
const pkgSuffix = resolveGoPackageDir(rawImportPath, goModule);
|
|
52
|
-
if (pkgSuffix) {
|
|
53
|
-
const pkgFiles = resolveGoPackage(rawImportPath, goModule, ctx.normalizedFileList, ctx.allFileList);
|
|
54
|
-
if (pkgFiles.length > 0) {
|
|
55
|
-
return { kind: 'package', files: pkgFiles, dirSuffix: pkgSuffix };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Fall through if no files found (package might be external)
|
|
59
|
-
}
|
|
60
|
-
return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Go);
|
|
61
|
-
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JVM import resolution (Java + Kotlin).
|
|
3
|
-
*
|
|
2
|
+
* JVM import resolution — internal helpers (Java + Kotlin).
|
|
3
|
+
*
|
|
4
|
+
* Strategies live in configs/jvm.ts.
|
|
5
|
+
* This file contains shared helpers for wildcard/member resolution
|
|
6
|
+
* and the Kotlin wildcard preprocessor.
|
|
4
7
|
*/
|
|
5
8
|
import type { SuffixIndex } from './utils.js';
|
|
6
9
|
import type { SyntaxNode } from '../utils/ast-helpers.js';
|
|
7
|
-
import type { ImportResult, ResolveCtx } from './types.js';
|
|
8
10
|
/** Kotlin file extensions for JVM resolver reuse */
|
|
9
11
|
export declare const KOTLIN_EXTENSIONS: readonly string[];
|
|
10
12
|
/**
|
|
@@ -23,10 +25,3 @@ export declare function resolveJvmWildcard(importPath: string, normalizedFileLis
|
|
|
23
25
|
* Kotlin: "com.example.Constants.VALUE" -> resolve "com.example.Constants"
|
|
24
26
|
*/
|
|
25
27
|
export declare function resolveJvmMemberImport(importPath: string, normalizedFileList: string[], allFileList: string[], extensions: readonly string[], index?: SuffixIndex): string | null;
|
|
26
|
-
/** Java: JVM wildcard -> member import -> standard fallthrough */
|
|
27
|
-
export declare function resolveJavaImport(rawImportPath: string, filePath: string, ctx: ResolveCtx): ImportResult;
|
|
28
|
-
/**
|
|
29
|
-
* Kotlin: JVM wildcard/member with Java-interop fallback -> top-level function imports -> standard.
|
|
30
|
-
* Kotlin can import from .kt/.kts files OR from .java files (Java interop).
|
|
31
|
-
*/
|
|
32
|
-
export declare function resolveKotlinImport(rawImportPath: string, filePath: string, ctx: ResolveCtx): ImportResult;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JVM import resolution (Java + Kotlin).
|
|
3
|
-
*
|
|
2
|
+
* JVM import resolution — internal helpers (Java + Kotlin).
|
|
3
|
+
*
|
|
4
|
+
* Strategies live in configs/jvm.ts.
|
|
5
|
+
* This file contains shared helpers for wildcard/member resolution
|
|
6
|
+
* and the Kotlin wildcard preprocessor.
|
|
4
7
|
*/
|
|
5
|
-
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
6
|
-
import { resolveStandard } from './standard.js';
|
|
7
8
|
/** Kotlin file extensions for JVM resolver reuse */
|
|
8
9
|
export const KOTLIN_EXTENSIONS = ['.kt', '.kts'];
|
|
9
10
|
/**
|
|
@@ -103,57 +104,3 @@ export function resolveJvmMemberImport(importPath, normalizedFileList, allFileLi
|
|
|
103
104
|
}
|
|
104
105
|
return null;
|
|
105
106
|
}
|
|
106
|
-
/** Java: JVM wildcard -> member import -> standard fallthrough */
|
|
107
|
-
export function resolveJavaImport(rawImportPath, filePath, ctx) {
|
|
108
|
-
if (rawImportPath.endsWith('.*')) {
|
|
109
|
-
const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
110
|
-
if (matchedFiles.length > 0)
|
|
111
|
-
return { kind: 'files', files: matchedFiles };
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
115
|
-
if (memberResolved)
|
|
116
|
-
return { kind: 'files', files: [memberResolved] };
|
|
117
|
-
}
|
|
118
|
-
return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Java);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Kotlin: JVM wildcard/member with Java-interop fallback -> top-level function imports -> standard.
|
|
122
|
-
* Kotlin can import from .kt/.kts files OR from .java files (Java interop).
|
|
123
|
-
*/
|
|
124
|
-
export function resolveKotlinImport(rawImportPath, filePath, ctx) {
|
|
125
|
-
if (rawImportPath.endsWith('.*')) {
|
|
126
|
-
const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
127
|
-
if (matchedFiles.length === 0) {
|
|
128
|
-
const javaMatches = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
129
|
-
if (javaMatches.length > 0)
|
|
130
|
-
return { kind: 'files', files: javaMatches };
|
|
131
|
-
}
|
|
132
|
-
if (matchedFiles.length > 0)
|
|
133
|
-
return { kind: 'files', files: matchedFiles };
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
let memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
137
|
-
if (!memberResolved) {
|
|
138
|
-
memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
139
|
-
}
|
|
140
|
-
if (memberResolved)
|
|
141
|
-
return { kind: 'files', files: [memberResolved] };
|
|
142
|
-
// Kotlin: top-level function imports (e.g. import models.getUser) have only 2 segments,
|
|
143
|
-
// which resolveJvmMemberImport skips (requires >=3). Fall back to package-directory scan
|
|
144
|
-
// for lowercase last segments (function/property imports). Uppercase last segments
|
|
145
|
-
// (class imports like models.User) fall through to standard suffix resolution.
|
|
146
|
-
const segments = rawImportPath.split('.');
|
|
147
|
-
const lastSeg = segments[segments.length - 1];
|
|
148
|
-
if (segments.length >= 2 && lastSeg[0] && lastSeg[0] === lastSeg[0].toLowerCase()) {
|
|
149
|
-
const pkgWildcard = segments.slice(0, -1).join('.') + '.*';
|
|
150
|
-
let dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
|
|
151
|
-
if (dirFiles.length === 0) {
|
|
152
|
-
dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
|
|
153
|
-
}
|
|
154
|
-
if (dirFiles.length > 0)
|
|
155
|
-
return { kind: 'files', files: dirFiles };
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Kotlin);
|
|
159
|
-
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PHP PSR-4 import resolution.
|
|
3
|
-
*
|
|
2
|
+
* PHP PSR-4 import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/php.ts.
|
|
5
|
+
* This file contains the shared helper for PSR-4 resolution via composer.json.
|
|
4
6
|
*/
|
|
5
7
|
import type { SuffixIndex } from './utils.js';
|
|
6
|
-
import type { ImportResult, ResolveCtx } from './types.js';
|
|
7
8
|
import type { ComposerConfig } from '../language-config.js';
|
|
8
9
|
/**
|
|
9
10
|
* Resolve a PHP use-statement import path using PSR-4 mappings (low-level helper).
|
|
@@ -21,5 +22,3 @@ import type { ComposerConfig } from '../language-config.js';
|
|
|
21
22
|
* without parsing all candidate files.
|
|
22
23
|
*/
|
|
23
24
|
export declare function resolvePhpImportInternal(importPath: string, composerConfig: ComposerConfig | null, allFiles: Set<string>, normalizedFileList: string[], allFileList: string[], index?: SuffixIndex): string | null;
|
|
24
|
-
/** PHP: namespace-based resolution via composer.json PSR-4. */
|
|
25
|
-
export declare function resolvePhpImport(rawImportPath: string, _filePath: string, ctx: ResolveCtx): ImportResult;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PHP PSR-4 import resolution.
|
|
3
|
-
*
|
|
2
|
+
* PHP PSR-4 import resolution — internal helpers.
|
|
3
|
+
*
|
|
4
|
+
* Strategy lives in configs/php.ts.
|
|
5
|
+
* This file contains the shared helper for PSR-4 resolution via composer.json.
|
|
4
6
|
*/
|
|
5
7
|
import { suffixResolve } from './utils.js';
|
|
6
8
|
/** Get or compute the sorted PSR-4 entries (cached after first call). */
|
|
@@ -73,8 +75,3 @@ export function resolvePhpImportInternal(importPath, composerConfig, allFiles, n
|
|
|
73
75
|
const pathParts = normalized.split('/').filter(Boolean);
|
|
74
76
|
return suffixResolve(pathParts, normalizedFileList, allFileList, index);
|
|
75
77
|
}
|
|
76
|
-
/** PHP: namespace-based resolution via composer.json PSR-4. */
|
|
77
|
-
export function resolvePhpImport(rawImportPath, _filePath, ctx) {
|
|
78
|
-
const resolved = resolvePhpImportInternal(rawImportPath, ctx.configs.composerConfig, ctx.allFilePaths, ctx.normalizedFileList, ctx.allFileList, ctx.index);
|
|
79
|
-
return resolved ? { kind: 'files', files: [resolved] } : null;
|
|
80
|
-
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Python import resolution — PEP 328 relative imports and proximity-based bare imports.
|
|
3
3
|
* Import system spec: PEP 302 (original), PEP 451 (current).
|
|
4
|
+
*
|
|
5
|
+
* Strategy lives in configs/python.ts.
|
|
6
|
+
* This file contains the shared internal helper used by the strategy and tests.
|
|
4
7
|
*/
|
|
5
|
-
import type { ImportResult, ResolveCtx } from './types.js';
|
|
6
8
|
/**
|
|
7
9
|
* Resolve a Python import to a file path (low-level helper).
|
|
8
10
|
*
|
|
@@ -18,8 +20,3 @@ import type { ImportResult, ResolveCtx } from './types.js';
|
|
|
18
20
|
* Returns null to let the caller fall through to suffixResolve.
|
|
19
21
|
*/
|
|
20
22
|
export declare function resolvePythonImportInternal(currentFile: string, importPath: string, allFiles: Set<string>): string | null;
|
|
21
|
-
/**
|
|
22
|
-
* Python: relative imports (PEP 328) + proximity-based bare imports.
|
|
23
|
-
* Falls through to standard suffix resolution when proximity finds no match.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolvePythonImport(rawImportPath: string, filePath: string, ctx: ResolveCtx): ImportResult;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Python import resolution — PEP 328 relative imports and proximity-based bare imports.
|
|
3
3
|
* Import system spec: PEP 302 (original), PEP 451 (current).
|
|
4
|
+
*
|
|
5
|
+
* Strategy lives in configs/python.ts.
|
|
6
|
+
* This file contains the shared internal helper used by the strategy and tests.
|
|
4
7
|
*/
|
|
5
8
|
import { tryResolveWithExtensions } from './utils.js';
|
|
6
|
-
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
7
|
-
import { resolveStandard } from './standard.js';
|
|
8
9
|
/**
|
|
9
10
|
* Resolve a Python import to a file path (low-level helper).
|
|
10
11
|
*
|
|
@@ -66,19 +67,3 @@ export function resolvePythonImportInternal(currentFile, importPath, allFiles) {
|
|
|
66
67
|
}
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Python: relative imports (PEP 328) + proximity-based bare imports.
|
|
71
|
-
* Falls through to standard suffix resolution when proximity finds no match.
|
|
72
|
-
*/
|
|
73
|
-
export function resolvePythonImport(rawImportPath, filePath, ctx) {
|
|
74
|
-
const resolved = resolvePythonImportInternal(filePath, rawImportPath, ctx.allFilePaths);
|
|
75
|
-
if (resolved) {
|
|
76
|
-
// Store in resolveCache so other files importing the same module skip the
|
|
77
|
-
// ancestor walk. The cache key matches resolveStandard's convention.
|
|
78
|
-
ctx.resolveCache.set(`${filePath}::${rawImportPath}`, resolved);
|
|
79
|
-
return { kind: 'files', files: [resolved] };
|
|
80
|
-
}
|
|
81
|
-
if (rawImportPath.startsWith('.'))
|
|
82
|
-
return null; // relative but unresolved -- don't suffix-match
|
|
83
|
-
return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Python);
|
|
84
|
-
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import resolver factory — creates a composable import resolver from
|
|
3
|
+
* an ordered list of strategies.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the method-extractors/generic.ts and call-extractors/generic.ts
|
|
6
|
+
* pattern: declare a config per language, produce a runtime resolver via factory.
|
|
7
|
+
*
|
|
8
|
+
* Each strategy is tried in order. The first non-null result wins.
|
|
9
|
+
* A result with an empty `files` array is treated as "handled but unresolved"
|
|
10
|
+
* (stops the chain without producing import edges).
|
|
11
|
+
*/
|
|
12
|
+
import type { ImportResolverFn, ImportResolutionConfig } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create an ImportResolverFn from a declarative config.
|
|
15
|
+
*
|
|
16
|
+
* Chains strategies in declaration order — first non-null result wins.
|
|
17
|
+
* Returns null only if every strategy returns null.
|
|
18
|
+
*
|
|
19
|
+
* Error behaviour: if a strategy throws, the error propagates immediately
|
|
20
|
+
* and remaining strategies are not tried. Strategies are expected to be
|
|
21
|
+
* pure data transforms that never throw; any unexpected exception indicates
|
|
22
|
+
* a bug in the strategy implementation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createImportResolver(config: ImportResolutionConfig): ImportResolverFn;
|