gitnexus 1.4.7 → 1.4.9
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 +29 -1
- package/dist/cli/ai-context.d.ts +1 -1
- package/dist/cli/ai-context.js +1 -1
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +54 -21
- package/dist/cli/index-repo.d.ts +15 -0
- package/dist/cli/index-repo.js +115 -0
- package/dist/cli/index.js +13 -3
- package/dist/cli/setup.js +90 -10
- package/dist/cli/wiki.d.ts +4 -0
- package/dist/cli/wiki.js +174 -53
- package/dist/config/supported-languages.d.ts +33 -1
- package/dist/config/supported-languages.js +32 -0
- package/dist/core/embeddings/embedder.d.ts +6 -1
- package/dist/core/embeddings/embedder.js +65 -5
- package/dist/core/embeddings/embedding-pipeline.js +11 -9
- package/dist/core/embeddings/http-client.d.ts +31 -0
- package/dist/core/embeddings/http-client.js +179 -0
- package/dist/core/embeddings/index.d.ts +1 -0
- package/dist/core/embeddings/index.js +1 -0
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/graph.js +9 -1
- package/dist/core/graph/types.d.ts +11 -2
- package/dist/core/ingestion/call-processor.d.ts +66 -2
- package/dist/core/ingestion/call-processor.js +650 -30
- package/dist/core/ingestion/call-routing.d.ts +9 -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 +52 -28
- 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 +97 -2
- package/dist/core/ingestion/framework-detection.js +114 -14
- package/dist/core/ingestion/heritage-processor.js +62 -66
- package/dist/core/ingestion/import-processor.d.ts +9 -10
- package/dist/core/ingestion/import-processor.js +150 -196
- 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 +10 -1
- package/dist/core/ingestion/import-resolvers/jvm.js +159 -0
- package/dist/core/ingestion/import-resolvers/php.d.ts +25 -0
- package/dist/core/ingestion/import-resolvers/php.js +80 -0
- 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 +2 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +7 -0
- package/dist/core/ingestion/language-config.d.ts +6 -0
- package/dist/core/ingestion/language-config.js +13 -0
- 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/markdown-processor.d.ts +17 -0
- package/dist/core/ingestion/markdown-processor.js +124 -0
- package/dist/core/ingestion/mro-processor.js +22 -18
- package/dist/core/ingestion/named-binding-processor.d.ts +18 -0
- 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 +6 -2
- package/dist/core/ingestion/parsing-processor.js +125 -85
- package/dist/core/ingestion/pipeline.d.ts +10 -0
- package/dist/core/ingestion/pipeline.js +1235 -317
- package/dist/core/ingestion/resolution-context.d.ts +5 -0
- package/dist/core/ingestion/resolution-context.js +8 -5
- 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/symbol-table.d.ts +16 -0
- package/dist/core/ingestion/symbol-table.js +20 -6
- package/dist/core/ingestion/tree-sitter-queries.d.ts +10 -9
- package/dist/core/ingestion/tree-sitter-queries.js +274 -11
- package/dist/core/ingestion/type-env.d.ts +42 -18
- package/dist/core/ingestion/type-env.js +481 -106
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +5 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +119 -0
- package/dist/core/ingestion/type-extractors/csharp.js +149 -16
- 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 +169 -66
- package/dist/core/ingestion/type-extractors/rust.js +35 -1
- package/dist/core/ingestion/type-extractors/shared.d.ts +1 -15
- package/dist/core/ingestion/type-extractors/shared.js +14 -112
- package/dist/core/ingestion/type-extractors/swift.js +338 -7
- package/dist/core/ingestion/type-extractors/types.d.ts +40 -8
- package/dist/core/ingestion/type-extractors/typescript.js +141 -9
- package/dist/core/ingestion/utils/ast-helpers.d.ts +83 -0
- package/dist/core/ingestion/utils/ast-helpers.js +817 -0
- package/dist/core/ingestion/utils/call-analysis.d.ts +73 -0
- package/dist/core/ingestion/utils/call-analysis.js +527 -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 +55 -5
- package/dist/core/ingestion/workers/parse-worker.js +415 -225
- package/dist/core/lbug/csv-generator.js +51 -1
- package/dist/core/lbug/lbug-adapter.d.ts +10 -0
- package/dist/core/lbug/lbug-adapter.js +75 -4
- package/dist/core/lbug/schema.d.ts +8 -4
- package/dist/core/lbug/schema.js +65 -4
- 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/embedder.js +11 -3
- package/dist/mcp/core/lbug-adapter.d.ts +5 -0
- package/dist/mcp/core/lbug-adapter.js +23 -2
- package/dist/mcp/local/local-backend.d.ts +38 -5
- package/dist/mcp/local/local-backend.js +804 -63
- package/dist/mcp/resources.js +2 -0
- package/dist/mcp/tools.js +73 -4
- package/dist/server/api.d.ts +19 -1
- package/dist/server/api.js +66 -6
- package/dist/storage/git.d.ts +12 -0
- package/dist/storage/git.js +21 -0
- package/dist/storage/repo-manager.d.ts +3 -0
- package/package.json +25 -16
- package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
- package/dist/core/ingestion/named-binding-extraction.js +0 -363
- package/dist/core/ingestion/resolvers/index.d.ts +0 -18
- package/dist/core/ingestion/resolvers/index.js +0 -13
- package/dist/core/ingestion/resolvers/jvm.js +0 -87
- package/dist/core/ingestion/resolvers/php.d.ts +0 -15
- package/dist/core/ingestion/resolvers/php.js +0 -35
- 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 -138
- package/dist/core/ingestion/utils.js +0 -1290
- package/scripts/patch-tree-sitter-swift.cjs +0 -74
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import resolution types — shared across all per-language resolvers.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from import-resolution.ts to co-locate types with their consumers.
|
|
5
|
+
*/
|
|
6
|
+
import type { TsconfigPaths, GoModuleConfig, CSharpProjectConfig, ComposerConfig } from '../language-config.js';
|
|
7
|
+
import type { SwiftPackageConfig } from '../language-config.js';
|
|
8
|
+
import type { SuffixIndex } from './utils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Result of resolving an import via language-specific dispatch.
|
|
11
|
+
* - 'files': resolved to one or more files -> add to ImportMap
|
|
12
|
+
* - 'package': resolved to a directory -> add graph edges + store dirSuffix in PackageMap
|
|
13
|
+
* - null: no resolution (external dependency, etc.)
|
|
14
|
+
*/
|
|
15
|
+
export type ImportResult = {
|
|
16
|
+
kind: 'files';
|
|
17
|
+
files: string[];
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'package';
|
|
20
|
+
files: string[];
|
|
21
|
+
dirSuffix: string;
|
|
22
|
+
} | null;
|
|
23
|
+
/** Bundled language-specific configs loaded once per ingestion run. */
|
|
24
|
+
export interface ImportConfigs {
|
|
25
|
+
tsconfigPaths: TsconfigPaths | null;
|
|
26
|
+
goModule: GoModuleConfig | null;
|
|
27
|
+
composerConfig: ComposerConfig | null;
|
|
28
|
+
swiftPackageConfig: SwiftPackageConfig | null;
|
|
29
|
+
csharpConfigs: CSharpProjectConfig[];
|
|
30
|
+
}
|
|
31
|
+
/** Pre-built lookup structures for import resolution. Build once, reuse across chunks. */
|
|
32
|
+
export interface ImportResolutionContext {
|
|
33
|
+
allFilePaths: Set<string>;
|
|
34
|
+
allFileList: string[];
|
|
35
|
+
normalizedFileList: string[];
|
|
36
|
+
index: SuffixIndex;
|
|
37
|
+
resolveCache: Map<string, string | null>;
|
|
38
|
+
}
|
|
39
|
+
/** Full context for import resolution: file lookups + language configs. */
|
|
40
|
+
export interface ResolveCtx extends ImportResolutionContext {
|
|
41
|
+
configs: ImportConfigs;
|
|
42
|
+
}
|
|
43
|
+
/** Per-language import resolver -- function alias matching ExportChecker/CallRouter pattern. */
|
|
44
|
+
export type ImportResolverFn = (rawImportPath: string, filePath: string, resolveCtx: ResolveCtx) => ImportResult;
|
|
@@ -26,6 +26,8 @@ export interface SuffixIndex {
|
|
|
26
26
|
/** Get all files in a directory suffix */
|
|
27
27
|
getFilesInDir(dirSuffix: string, extension: string): string[];
|
|
28
28
|
}
|
|
29
|
+
/** Sentinel index that returns no results. Used to release memory after import resolution. */
|
|
30
|
+
export declare const EMPTY_INDEX: SuffixIndex;
|
|
29
31
|
export declare function buildSuffixIndex(normalizedFileList: string[], allFileList: string[]): SuffixIndex;
|
|
30
32
|
/**
|
|
31
33
|
* Suffix-based resolution using index. O(1) per lookup instead of O(files).
|
|
@@ -40,6 +40,13 @@ export function tryResolveWithExtensions(basePath, allFiles) {
|
|
|
40
40
|
}
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
+
const FROZEN_EMPTY_ARRAY = Object.freeze([]);
|
|
44
|
+
/** Sentinel index that returns no results. Used to release memory after import resolution. */
|
|
45
|
+
export const EMPTY_INDEX = Object.freeze({
|
|
46
|
+
get: () => undefined,
|
|
47
|
+
getInsensitive: () => undefined,
|
|
48
|
+
getFilesInDir: () => FROZEN_EMPTY_ARRAY,
|
|
49
|
+
});
|
|
43
50
|
export function buildSuffixIndex(normalizedFileList, allFileList) {
|
|
44
51
|
// Map: normalized suffix -> original file path
|
|
45
52
|
const exactMap = new Map();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ImportConfigs } from './import-resolvers/types.js';
|
|
1
2
|
/** TypeScript path alias config parsed from tsconfig.json */
|
|
2
3
|
export interface TsconfigPaths {
|
|
3
4
|
/** Map of alias prefix -> target prefix (e.g., "@/" -> "src/") */
|
|
@@ -14,6 +15,9 @@ export interface GoModuleConfig {
|
|
|
14
15
|
export interface ComposerConfig {
|
|
15
16
|
/** Map of namespace prefix -> directory (e.g., "App\\" -> "app/") */
|
|
16
17
|
psr4: Map<string, string>;
|
|
18
|
+
/** PSR-4 entries sorted by namespace length descending (longest match wins).
|
|
19
|
+
* Cached once at config load time to avoid re-sorting on every import. */
|
|
20
|
+
psr4Sorted?: readonly [string, string][];
|
|
17
21
|
}
|
|
18
22
|
/** C# project config parsed from .csproj files */
|
|
19
23
|
export interface CSharpProjectConfig {
|
|
@@ -44,3 +48,5 @@ export declare function loadComposerConfig(repoRoot: string): Promise<ComposerCo
|
|
|
44
48
|
*/
|
|
45
49
|
export declare function loadCSharpProjectConfig(repoRoot: string): Promise<CSharpProjectConfig[]>;
|
|
46
50
|
export declare function loadSwiftPackageConfig(repoRoot: string): Promise<SwiftPackageConfig | null>;
|
|
51
|
+
/** Load all language-specific configs once for an ingestion run. */
|
|
52
|
+
export declare function loadImportConfigs(repoRoot: string): Promise<ImportConfigs>;
|
|
@@ -165,3 +165,16 @@ export async function loadSwiftPackageConfig(repoRoot) {
|
|
|
165
165
|
}
|
|
166
166
|
return null;
|
|
167
167
|
}
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// BUNDLED CONFIG LOADER
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/** Load all language-specific configs once for an ingestion run. */
|
|
172
|
+
export async function loadImportConfigs(repoRoot) {
|
|
173
|
+
return {
|
|
174
|
+
tsconfigPaths: await loadTsconfigPaths(repoRoot),
|
|
175
|
+
goModule: await loadGoModulePath(repoRoot),
|
|
176
|
+
composerConfig: await loadComposerConfig(repoRoot),
|
|
177
|
+
swiftPackageConfig: await loadSwiftPackageConfig(repoRoot),
|
|
178
|
+
csharpConfigs: await loadCSharpProjectConfig(repoRoot),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language Provider interface — the complete capability contract for a supported language.
|
|
3
|
+
*
|
|
4
|
+
* Each language implements this interface in a single file under `languages/`.
|
|
5
|
+
* The pipeline accesses all per-language behavior through this interface.
|
|
6
|
+
*
|
|
7
|
+
* Design pattern: Strategy pattern with compile-time exhaustiveness.
|
|
8
|
+
* The providers table in `languages/index.ts` uses `satisfies Record<SupportedLanguages, LanguageProvider>`
|
|
9
|
+
* so adding a language to the enum without creating a provider is a compiler error.
|
|
10
|
+
*/
|
|
11
|
+
import type { SupportedLanguages } from '../../config/supported-languages.js';
|
|
12
|
+
import type { LanguageTypeConfig } from './type-extractors/types.js';
|
|
13
|
+
import type { CallRouter } from './call-routing.js';
|
|
14
|
+
import type { ExportChecker } from './export-detection.js';
|
|
15
|
+
import type { FieldExtractor } from './field-extractor.js';
|
|
16
|
+
import type { ImportResolverFn } from './import-resolvers/types.js';
|
|
17
|
+
import type { NamedBindingExtractorFn } from './named-bindings/types.js';
|
|
18
|
+
import type { SyntaxNode } from './utils/ast-helpers.js';
|
|
19
|
+
import type { NodeLabel } from '../graph/types.js';
|
|
20
|
+
/** Tree-sitter query captures: capture name → AST node (or undefined if not captured). */
|
|
21
|
+
export type CaptureMap = Record<string, SyntaxNode | undefined>;
|
|
22
|
+
/** MRO strategy for multiple inheritance resolution. */
|
|
23
|
+
export type MroStrategy = 'first-wins' | 'c3' | 'leftmost-base' | 'implements-split' | 'qualified-syntax';
|
|
24
|
+
/** How a language handles imports — determines wildcard synthesis behavior. */
|
|
25
|
+
export type ImportSemantics = 'named' | 'wildcard' | 'namespace';
|
|
26
|
+
/**
|
|
27
|
+
* Everything a language needs to provide.
|
|
28
|
+
* Required fields must be explicitly set; optional fields have defaults
|
|
29
|
+
* applied by defineLanguage().
|
|
30
|
+
*/
|
|
31
|
+
interface LanguageProviderConfig {
|
|
32
|
+
readonly id: SupportedLanguages;
|
|
33
|
+
/** File extensions that map to this language (e.g., ['.ts', '.tsx']) */
|
|
34
|
+
readonly extensions: readonly string[];
|
|
35
|
+
/** Parse strategy: 'tree-sitter' (default) uses AST parsing via tree-sitter.
|
|
36
|
+
* 'standalone' means the language has its own regex-based processor and
|
|
37
|
+
* should be skipped by the tree-sitter pipeline (e.g., COBOL, Markdown). */
|
|
38
|
+
readonly parseStrategy?: 'tree-sitter' | 'standalone';
|
|
39
|
+
/** Tree-sitter query strings for definitions, imports, calls, heritage.
|
|
40
|
+
* Required for tree-sitter languages; empty string for standalone processors. */
|
|
41
|
+
readonly treeSitterQueries: string;
|
|
42
|
+
/** Type extraction: declarations, initializers, for-loop bindings */
|
|
43
|
+
readonly typeConfig: LanguageTypeConfig;
|
|
44
|
+
/** Export detection: is this AST node a public/exported symbol? */
|
|
45
|
+
readonly exportChecker: ExportChecker;
|
|
46
|
+
/** Import resolution: resolves raw import path to file system path */
|
|
47
|
+
readonly importResolver: ImportResolverFn;
|
|
48
|
+
/** Call routing for languages that express imports/heritage as calls (e.g., Ruby).
|
|
49
|
+
* Default: no routing (all calls are normal call expressions). */
|
|
50
|
+
readonly callRouter?: CallRouter;
|
|
51
|
+
/** Named binding extraction from import statements.
|
|
52
|
+
* Default: undefined (language uses wildcard/whole-module imports). */
|
|
53
|
+
readonly namedBindingExtractor?: NamedBindingExtractorFn;
|
|
54
|
+
/** How this language handles imports.
|
|
55
|
+
* - 'named': per-symbol imports (JS/TS, Java, C#, Rust, PHP, Kotlin)
|
|
56
|
+
* - 'wildcard': whole-module imports, needs synthesis (Go, Ruby, C/C++, Swift)
|
|
57
|
+
* - 'namespace': namespace imports, needs moduleAliasMap (Python)
|
|
58
|
+
* Default: 'named'. */
|
|
59
|
+
readonly importSemantics?: ImportSemantics;
|
|
60
|
+
/** Language-specific transformation of raw import path text before resolution.
|
|
61
|
+
* Called after sanitization. E.g., Kotlin appends wildcard suffixes.
|
|
62
|
+
* Default: undefined (no preprocessing). */
|
|
63
|
+
readonly importPathPreprocessor?: (cleaned: string, importNode: SyntaxNode) => string;
|
|
64
|
+
/** Wire implicit inter-file imports for languages where all files in a module
|
|
65
|
+
* see each other (e.g., Swift targets, C header inclusion units).
|
|
66
|
+
* Called with only THIS language's files (pre-grouped by the processor).
|
|
67
|
+
* Default: undefined (no implicit imports). */
|
|
68
|
+
readonly implicitImportWirer?: (languageFiles: string[], importMap: ReadonlyMap<string, ReadonlySet<string>>, addImportEdge: (src: string, target: string) => void, projectConfig: unknown) => void;
|
|
69
|
+
/** Resolve the enclosing function name + label from an AST ancestor node
|
|
70
|
+
* that is NOT a standard FUNCTION_NODE_TYPE. For languages where the
|
|
71
|
+
* function body is a sibling of the signature (e.g. Dart: function_body ↔
|
|
72
|
+
* function_signature are siblings under program/class_body), the default
|
|
73
|
+
* parent walk cannot find the enclosing function. This hook lets the
|
|
74
|
+
* language provider inspect each ancestor and return the resolved result.
|
|
75
|
+
* Return null to continue the default walk.
|
|
76
|
+
* Default: undefined (standard parent walk only). */
|
|
77
|
+
readonly enclosingFunctionFinder?: (ancestorNode: SyntaxNode) => {
|
|
78
|
+
funcName: string;
|
|
79
|
+
label: NodeLabel;
|
|
80
|
+
} | null;
|
|
81
|
+
/** Override the default node label for definition.function captures.
|
|
82
|
+
* Return null to skip (C/C++ duplicate), a different label to reclassify
|
|
83
|
+
* (e.g., 'Method' for Kotlin), or defaultLabel to keep as-is.
|
|
84
|
+
* Default: undefined (standard label assignment). */
|
|
85
|
+
readonly labelOverride?: (functionNode: SyntaxNode, defaultLabel: NodeLabel) => NodeLabel | null;
|
|
86
|
+
/** Default edge type when parent symbol is ambiguous (interface vs class).
|
|
87
|
+
* Default: 'EXTENDS'. */
|
|
88
|
+
readonly heritageDefaultEdge?: 'EXTENDS' | 'IMPLEMENTS';
|
|
89
|
+
/** Regex to detect interface names by convention (e.g., /^I[A-Z]/ for C#/Java).
|
|
90
|
+
* When matched, IMPLEMENTS edge is used instead of heritageDefaultEdge. */
|
|
91
|
+
readonly interfaceNamePattern?: RegExp;
|
|
92
|
+
/** MRO strategy for multiple inheritance resolution.
|
|
93
|
+
* Default: 'first-wins'. */
|
|
94
|
+
readonly mroStrategy?: MroStrategy;
|
|
95
|
+
/** Field extractor for extracting field/property definitions from class/struct
|
|
96
|
+
* declarations. Produces FieldInfo[] with name, type, visibility, static,
|
|
97
|
+
* readonly metadata. Default: undefined (no field extraction). */
|
|
98
|
+
readonly fieldExtractor?: FieldExtractor;
|
|
99
|
+
/** Extract a semantic description for a definition node (e.g., PHP Eloquent
|
|
100
|
+
* property arrays, relation method descriptions).
|
|
101
|
+
* Default: undefined (no description extraction). */
|
|
102
|
+
readonly descriptionExtractor?: (nodeLabel: NodeLabel, nodeName: string, captureMap: CaptureMap) => string | undefined;
|
|
103
|
+
/** Detect if a file contains framework route definitions (e.g., Laravel routes.php).
|
|
104
|
+
* When true, the worker extracts routes via the language's route extraction logic.
|
|
105
|
+
* Default: undefined (no route files). */
|
|
106
|
+
readonly isRouteFile?: (filePath: string) => boolean;
|
|
107
|
+
/** Built-in/stdlib names that should be filtered from the call graph for this language.
|
|
108
|
+
* Default: undefined (no language-specific filtering). */
|
|
109
|
+
readonly builtInNames?: ReadonlySet<string>;
|
|
110
|
+
}
|
|
111
|
+
/** Runtime type — same as LanguageProviderConfig but with defaults guaranteed present. */
|
|
112
|
+
export interface LanguageProvider extends Omit<LanguageProviderConfig, 'importSemantics' | 'heritageDefaultEdge' | 'mroStrategy'> {
|
|
113
|
+
readonly importSemantics: ImportSemantics;
|
|
114
|
+
readonly heritageDefaultEdge: 'EXTENDS' | 'IMPLEMENTS';
|
|
115
|
+
readonly mroStrategy: MroStrategy;
|
|
116
|
+
/** Check if a name is a built-in/stdlib function that should be filtered from the call graph. */
|
|
117
|
+
readonly isBuiltInName: (name: string) => boolean;
|
|
118
|
+
}
|
|
119
|
+
/** Define a language provider — required fields must be supplied, optional fields get sensible defaults. */
|
|
120
|
+
export declare function defineLanguage(config: LanguageProviderConfig): LanguageProvider;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language Provider interface — the complete capability contract for a supported language.
|
|
3
|
+
*
|
|
4
|
+
* Each language implements this interface in a single file under `languages/`.
|
|
5
|
+
* The pipeline accesses all per-language behavior through this interface.
|
|
6
|
+
*
|
|
7
|
+
* Design pattern: Strategy pattern with compile-time exhaustiveness.
|
|
8
|
+
* The providers table in `languages/index.ts` uses `satisfies Record<SupportedLanguages, LanguageProvider>`
|
|
9
|
+
* so adding a language to the enum without creating a provider is a compiler error.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULTS = {
|
|
12
|
+
importSemantics: 'named',
|
|
13
|
+
heritageDefaultEdge: 'EXTENDS',
|
|
14
|
+
mroStrategy: 'first-wins',
|
|
15
|
+
};
|
|
16
|
+
/** Define a language provider — required fields must be supplied, optional fields get sensible defaults. */
|
|
17
|
+
export function defineLanguage(config) {
|
|
18
|
+
const builtIns = config.builtInNames;
|
|
19
|
+
return {
|
|
20
|
+
...DEFAULTS,
|
|
21
|
+
...config,
|
|
22
|
+
isBuiltInName: builtIns ? (name) => builtIns.has(name) : () => false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C and C++ language providers.
|
|
3
|
+
*
|
|
4
|
+
* Both languages use wildcard import semantics (headers expose all symbols
|
|
5
|
+
* via #include). Neither language has named binding extraction.
|
|
6
|
+
*
|
|
7
|
+
* C uses 'first-wins' MRO (no inheritance). C++ uses 'leftmost-base' MRO
|
|
8
|
+
* for its left-to-right multiple inheritance resolution order.
|
|
9
|
+
*/
|
|
10
|
+
import type { LanguageProvider } from '../language-provider.js';
|
|
11
|
+
export declare const cProvider: LanguageProvider;
|
|
12
|
+
export declare const cppProvider: LanguageProvider;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C and C++ language providers.
|
|
3
|
+
*
|
|
4
|
+
* Both languages use wildcard import semantics (headers expose all symbols
|
|
5
|
+
* via #include). Neither language has named binding extraction.
|
|
6
|
+
*
|
|
7
|
+
* C uses 'first-wins' MRO (no inheritance). C++ uses 'leftmost-base' MRO
|
|
8
|
+
* for its left-to-right multiple inheritance resolution order.
|
|
9
|
+
*/
|
|
10
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
11
|
+
import { defineLanguage } from '../language-provider.js';
|
|
12
|
+
import { typeConfig as cCppConfig } from '../type-extractors/c-cpp.js';
|
|
13
|
+
import { cCppExportChecker } from '../export-detection.js';
|
|
14
|
+
import { resolveCImport, resolveCppImport } from '../import-resolvers/standard.js';
|
|
15
|
+
import { C_QUERIES, CPP_QUERIES } from '../tree-sitter-queries.js';
|
|
16
|
+
import { isCppInsideClassOrStruct } from '../utils/ast-helpers.js';
|
|
17
|
+
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
18
|
+
import { cConfig as cFieldConfig, cppConfig as cppFieldConfig } from '../field-extractors/configs/c-cpp.js';
|
|
19
|
+
const C_BUILT_INS = new Set([
|
|
20
|
+
'printf', 'fprintf', 'sprintf', 'snprintf', 'vprintf', 'vfprintf', 'vsprintf', 'vsnprintf',
|
|
21
|
+
'scanf', 'fscanf', 'sscanf',
|
|
22
|
+
'malloc', 'calloc', 'realloc', 'free', 'memcpy', 'memmove', 'memset', 'memcmp',
|
|
23
|
+
'strlen', 'strcpy', 'strncpy', 'strcat', 'strncat', 'strcmp', 'strncmp', 'strstr', 'strchr', 'strrchr',
|
|
24
|
+
'atoi', 'atol', 'atof', 'strtol', 'strtoul', 'strtoll', 'strtoull', 'strtod',
|
|
25
|
+
'sizeof', 'offsetof', 'typeof',
|
|
26
|
+
'assert', 'abort', 'exit', '_exit',
|
|
27
|
+
'fopen', 'fclose', 'fread', 'fwrite', 'fseek', 'ftell', 'rewind', 'fflush', 'fgets', 'fputs',
|
|
28
|
+
'likely', 'unlikely', 'BUG', 'BUG_ON', 'WARN', 'WARN_ON', 'WARN_ONCE',
|
|
29
|
+
'IS_ERR', 'PTR_ERR', 'ERR_PTR', 'IS_ERR_OR_NULL',
|
|
30
|
+
'ARRAY_SIZE', 'container_of', 'list_for_each_entry', 'list_for_each_entry_safe',
|
|
31
|
+
'min', 'max', 'clamp', 'abs', 'swap',
|
|
32
|
+
'pr_info', 'pr_warn', 'pr_err', 'pr_debug', 'pr_notice', 'pr_crit', 'pr_emerg',
|
|
33
|
+
'printk', 'dev_info', 'dev_warn', 'dev_err', 'dev_dbg',
|
|
34
|
+
'GFP_KERNEL', 'GFP_ATOMIC',
|
|
35
|
+
'spin_lock', 'spin_unlock', 'spin_lock_irqsave', 'spin_unlock_irqrestore',
|
|
36
|
+
'mutex_lock', 'mutex_unlock', 'mutex_init',
|
|
37
|
+
'kfree', 'kmalloc', 'kzalloc', 'kcalloc', 'krealloc', 'kvmalloc', 'kvfree',
|
|
38
|
+
'get', 'put',
|
|
39
|
+
]);
|
|
40
|
+
/** Label override shared by C and C++: skip function_definition captures inside class/struct
|
|
41
|
+
* bodies (they're duplicates of definition.method captures). */
|
|
42
|
+
const cppLabelOverride = (functionNode, defaultLabel) => {
|
|
43
|
+
if (defaultLabel !== 'Function')
|
|
44
|
+
return defaultLabel;
|
|
45
|
+
return isCppInsideClassOrStruct(functionNode) ? null : defaultLabel;
|
|
46
|
+
};
|
|
47
|
+
export const cProvider = defineLanguage({
|
|
48
|
+
id: SupportedLanguages.C,
|
|
49
|
+
extensions: ['.c'],
|
|
50
|
+
treeSitterQueries: C_QUERIES,
|
|
51
|
+
typeConfig: cCppConfig,
|
|
52
|
+
exportChecker: cCppExportChecker,
|
|
53
|
+
importResolver: resolveCImport,
|
|
54
|
+
importSemantics: 'wildcard',
|
|
55
|
+
fieldExtractor: createFieldExtractor(cFieldConfig),
|
|
56
|
+
labelOverride: cppLabelOverride,
|
|
57
|
+
builtInNames: C_BUILT_INS,
|
|
58
|
+
});
|
|
59
|
+
export const cppProvider = defineLanguage({
|
|
60
|
+
id: SupportedLanguages.CPlusPlus,
|
|
61
|
+
extensions: ['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx', '.hh'],
|
|
62
|
+
treeSitterQueries: CPP_QUERIES,
|
|
63
|
+
typeConfig: cCppConfig,
|
|
64
|
+
exportChecker: cCppExportChecker,
|
|
65
|
+
importResolver: resolveCppImport,
|
|
66
|
+
importSemantics: 'wildcard',
|
|
67
|
+
mroStrategy: 'leftmost-base',
|
|
68
|
+
fieldExtractor: createFieldExtractor(cppFieldConfig),
|
|
69
|
+
labelOverride: cppLabelOverride,
|
|
70
|
+
builtInNames: C_BUILT_INS,
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cobolProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBOL Language Provider
|
|
3
|
+
*
|
|
4
|
+
* Standalone regex-based processor — no tree-sitter grammar.
|
|
5
|
+
* COBOL files (.cbl, .cob, .cobol, .cpy, .copybook) are detected and
|
|
6
|
+
* processed by cobol-processor.ts in pipeline Phase 2.6, not by the
|
|
7
|
+
* tree-sitter pipeline.
|
|
8
|
+
*
|
|
9
|
+
* This provider exists to satisfy the SupportedLanguages exhaustiveness
|
|
10
|
+
* checks and to declare parseStrategy: 'standalone'.
|
|
11
|
+
*/
|
|
12
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
13
|
+
import { defineLanguage } from '../language-provider.js';
|
|
14
|
+
export const cobolProvider = defineLanguage({
|
|
15
|
+
id: SupportedLanguages.Cobol,
|
|
16
|
+
parseStrategy: 'standalone',
|
|
17
|
+
extensions: [], // COBOL files detected by cobol-processor's isCobolFile/isJclFile
|
|
18
|
+
treeSitterQueries: '',
|
|
19
|
+
typeConfig: {
|
|
20
|
+
declarationNodeTypes: new Set(),
|
|
21
|
+
extractDeclaration: () => null,
|
|
22
|
+
extractParameter: () => null,
|
|
23
|
+
},
|
|
24
|
+
exportChecker: () => false,
|
|
25
|
+
importResolver: () => null,
|
|
26
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# language provider.
|
|
3
|
+
*
|
|
4
|
+
* C# uses named imports (using directives), modifier-based export detection,
|
|
5
|
+
* and an implements-split MRO strategy for multiple interface implementation.
|
|
6
|
+
* Interface names follow the I-prefix convention (e.g., IDisposable).
|
|
7
|
+
*/
|
|
8
|
+
export declare const csharpProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C# language provider.
|
|
3
|
+
*
|
|
4
|
+
* C# uses named imports (using directives), modifier-based export detection,
|
|
5
|
+
* and an implements-split MRO strategy for multiple interface implementation.
|
|
6
|
+
* Interface names follow the I-prefix convention (e.g., IDisposable).
|
|
7
|
+
*/
|
|
8
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
9
|
+
import { defineLanguage } from '../language-provider.js';
|
|
10
|
+
import { typeConfig as csharpConfig } from '../type-extractors/csharp.js';
|
|
11
|
+
import { csharpExportChecker } from '../export-detection.js';
|
|
12
|
+
import { resolveCSharpImport } from '../import-resolvers/csharp.js';
|
|
13
|
+
import { extractCSharpNamedBindings } from '../named-bindings/csharp.js';
|
|
14
|
+
import { CSHARP_QUERIES } from '../tree-sitter-queries.js';
|
|
15
|
+
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
16
|
+
import { csharpConfig as csharpFieldConfig } from '../field-extractors/configs/csharp.js';
|
|
17
|
+
const BUILT_INS = new Set([
|
|
18
|
+
'Console', 'WriteLine', 'ReadLine', 'Write',
|
|
19
|
+
'Task', 'Run', 'Wait', 'WhenAll', 'WhenAny', 'FromResult', 'Delay', 'ContinueWith',
|
|
20
|
+
'ConfigureAwait', 'GetAwaiter', 'GetResult',
|
|
21
|
+
'ToString', 'GetType', 'Equals', 'GetHashCode', 'ReferenceEquals',
|
|
22
|
+
'Add', 'Remove', 'Contains', 'Clear', 'Count', 'Any', 'All',
|
|
23
|
+
'Where', 'Select', 'SelectMany', 'OrderBy', 'OrderByDescending', 'GroupBy',
|
|
24
|
+
'First', 'FirstOrDefault', 'Single', 'SingleOrDefault', 'Last', 'LastOrDefault',
|
|
25
|
+
'ToList', 'ToArray', 'ToDictionary', 'AsEnumerable', 'AsQueryable',
|
|
26
|
+
'Aggregate', 'Sum', 'Average', 'Min', 'Max', 'Distinct', 'Skip', 'Take',
|
|
27
|
+
'String', 'Format', 'IsNullOrEmpty', 'IsNullOrWhiteSpace', 'Concat', 'Join',
|
|
28
|
+
'Trim', 'TrimStart', 'TrimEnd', 'Split', 'Replace', 'StartsWith', 'EndsWith',
|
|
29
|
+
'Convert', 'ToInt32', 'ToDouble', 'ToBoolean', 'ToByte',
|
|
30
|
+
'Math', 'Abs', 'Ceiling', 'Floor', 'Round', 'Pow', 'Sqrt',
|
|
31
|
+
'Dispose', 'Close',
|
|
32
|
+
'TryParse', 'Parse',
|
|
33
|
+
'AddRange', 'RemoveAt', 'RemoveAll', 'FindAll', 'Exists', 'TrueForAll',
|
|
34
|
+
'ContainsKey', 'TryGetValue', 'AddOrUpdate',
|
|
35
|
+
'Throw', 'ThrowIfNull',
|
|
36
|
+
]);
|
|
37
|
+
export const csharpProvider = defineLanguage({
|
|
38
|
+
id: SupportedLanguages.CSharp,
|
|
39
|
+
extensions: ['.cs'],
|
|
40
|
+
treeSitterQueries: CSHARP_QUERIES,
|
|
41
|
+
typeConfig: csharpConfig,
|
|
42
|
+
exportChecker: csharpExportChecker,
|
|
43
|
+
importResolver: resolveCSharpImport,
|
|
44
|
+
namedBindingExtractor: extractCSharpNamedBindings,
|
|
45
|
+
interfaceNamePattern: /^I[A-Z]/,
|
|
46
|
+
mroStrategy: 'implements-split',
|
|
47
|
+
fieldExtractor: createFieldExtractor(csharpFieldConfig),
|
|
48
|
+
builtInNames: BUILT_INS,
|
|
49
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dart Language Provider
|
|
3
|
+
*
|
|
4
|
+
* Dart traits:
|
|
5
|
+
* - importSemantics: 'wildcard' (Dart imports bring everything public into scope)
|
|
6
|
+
* - exportChecker: public if no leading underscore
|
|
7
|
+
* - Dart SDK imports (dart:*) and external packages are skipped
|
|
8
|
+
* - enclosingFunctionFinder: Dart's tree-sitter grammar places function_body
|
|
9
|
+
* as a sibling of function_signature/method_signature (not as a child).
|
|
10
|
+
* The hook resolves the enclosing function by inspecting the previous sibling.
|
|
11
|
+
*/
|
|
12
|
+
export declare const dartProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dart Language Provider
|
|
3
|
+
*
|
|
4
|
+
* Dart traits:
|
|
5
|
+
* - importSemantics: 'wildcard' (Dart imports bring everything public into scope)
|
|
6
|
+
* - exportChecker: public if no leading underscore
|
|
7
|
+
* - Dart SDK imports (dart:*) and external packages are skipped
|
|
8
|
+
* - enclosingFunctionFinder: Dart's tree-sitter grammar places function_body
|
|
9
|
+
* as a sibling of function_signature/method_signature (not as a child).
|
|
10
|
+
* The hook resolves the enclosing function by inspecting the previous sibling.
|
|
11
|
+
*/
|
|
12
|
+
import { FUNCTION_NODE_TYPES, extractFunctionName } from '../utils/ast-helpers.js';
|
|
13
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
14
|
+
import { defineLanguage } from '../language-provider.js';
|
|
15
|
+
import { typeConfig as dartConfig } from '../type-extractors/dart.js';
|
|
16
|
+
import { dartExportChecker } from '../export-detection.js';
|
|
17
|
+
import { resolveDartImport } from '../import-resolvers/dart.js';
|
|
18
|
+
import { DART_QUERIES } from '../tree-sitter-queries.js';
|
|
19
|
+
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
20
|
+
import { dartConfig as dartFieldConfig } from '../field-extractors/configs/dart.js';
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the enclosing function from a `function_body` node by looking at its
|
|
23
|
+
* previous sibling. In Dart's tree-sitter grammar, function_signature and
|
|
24
|
+
* function_body are siblings under program or class_body, unlike most languages
|
|
25
|
+
* where the function declaration wraps both.
|
|
26
|
+
*
|
|
27
|
+
* Delegates name extraction to the shared `extractFunctionName` which already
|
|
28
|
+
* handles Dart's function_signature and method_signature node types.
|
|
29
|
+
*/
|
|
30
|
+
const dartEnclosingFunctionFinder = (node) => {
|
|
31
|
+
if (node.type !== 'function_body')
|
|
32
|
+
return null;
|
|
33
|
+
const prev = node.previousSibling;
|
|
34
|
+
if (!prev || !FUNCTION_NODE_TYPES.has(prev.type))
|
|
35
|
+
return null;
|
|
36
|
+
const { funcName, label } = extractFunctionName(prev);
|
|
37
|
+
return funcName ? { funcName, label } : null;
|
|
38
|
+
};
|
|
39
|
+
const BUILT_INS = new Set([
|
|
40
|
+
'setState', 'mounted', 'debugPrint',
|
|
41
|
+
'runApp', 'showDialog', 'showModalBottomSheet',
|
|
42
|
+
'Navigator', 'push', 'pushNamed', 'pushReplacement', 'pop', 'maybePop',
|
|
43
|
+
'ScaffoldMessenger', 'showSnackBar',
|
|
44
|
+
'deactivate', 'reassemble', 'debugDumpApp', 'debugDumpRenderTree',
|
|
45
|
+
'then', 'catchError', 'whenComplete', 'listen',
|
|
46
|
+
]);
|
|
47
|
+
export const dartProvider = defineLanguage({
|
|
48
|
+
id: SupportedLanguages.Dart,
|
|
49
|
+
extensions: ['.dart'],
|
|
50
|
+
treeSitterQueries: DART_QUERIES,
|
|
51
|
+
typeConfig: dartConfig,
|
|
52
|
+
exportChecker: dartExportChecker,
|
|
53
|
+
importResolver: resolveDartImport,
|
|
54
|
+
importSemantics: 'wildcard',
|
|
55
|
+
fieldExtractor: createFieldExtractor(dartFieldConfig),
|
|
56
|
+
enclosingFunctionFinder: dartEnclosingFunctionFinder,
|
|
57
|
+
builtInNames: BUILT_INS,
|
|
58
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Language Provider
|
|
3
|
+
*
|
|
4
|
+
* Assembles all Go-specific ingestion capabilities into a single
|
|
5
|
+
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Key Go traits:
|
|
8
|
+
* - importSemantics: 'wildcard' (Go imports entire packages)
|
|
9
|
+
* - callRouter: present (Go method calls may need routing)
|
|
10
|
+
*/
|
|
11
|
+
export declare const goProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Language Provider
|
|
3
|
+
*
|
|
4
|
+
* Assembles all Go-specific ingestion capabilities into a single
|
|
5
|
+
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Key Go traits:
|
|
8
|
+
* - importSemantics: 'wildcard' (Go imports entire packages)
|
|
9
|
+
* - callRouter: present (Go method calls may need routing)
|
|
10
|
+
*/
|
|
11
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
12
|
+
import { defineLanguage } from '../language-provider.js';
|
|
13
|
+
import { typeConfig as goConfig } from '../type-extractors/go.js';
|
|
14
|
+
import { goExportChecker } from '../export-detection.js';
|
|
15
|
+
import { resolveGoImport } from '../import-resolvers/go.js';
|
|
16
|
+
import { GO_QUERIES } from '../tree-sitter-queries.js';
|
|
17
|
+
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
18
|
+
import { goConfig as goFieldConfig } from '../field-extractors/configs/go.js';
|
|
19
|
+
export const goProvider = defineLanguage({
|
|
20
|
+
id: SupportedLanguages.Go,
|
|
21
|
+
extensions: ['.go'],
|
|
22
|
+
treeSitterQueries: GO_QUERIES,
|
|
23
|
+
typeConfig: goConfig,
|
|
24
|
+
exportChecker: goExportChecker,
|
|
25
|
+
importResolver: resolveGoImport,
|
|
26
|
+
importSemantics: 'wildcard',
|
|
27
|
+
fieldExtractor: createFieldExtractor(goFieldConfig),
|
|
28
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language Provider Registry — compile-time exhaustive provider table.
|
|
3
|
+
*
|
|
4
|
+
* To add a new language:
|
|
5
|
+
* 1. Add enum member to SupportedLanguages
|
|
6
|
+
* 2. Create `languages/<lang>.ts` exporting a LanguageProvider
|
|
7
|
+
* 3. Add one line to the `providers` table below
|
|
8
|
+
* 4. Run `tsc --noEmit` to verify
|
|
9
|
+
*/
|
|
10
|
+
import { SupportedLanguages } from '../../../config/supported-languages.js';
|
|
11
|
+
import type { LanguageProvider } from '../language-provider.js';
|
|
12
|
+
export declare const providers: {
|
|
13
|
+
javascript: LanguageProvider;
|
|
14
|
+
typescript: LanguageProvider;
|
|
15
|
+
python: LanguageProvider;
|
|
16
|
+
java: LanguageProvider;
|
|
17
|
+
kotlin: LanguageProvider;
|
|
18
|
+
go: LanguageProvider;
|
|
19
|
+
rust: LanguageProvider;
|
|
20
|
+
csharp: LanguageProvider;
|
|
21
|
+
c: LanguageProvider;
|
|
22
|
+
cpp: LanguageProvider;
|
|
23
|
+
php: LanguageProvider;
|
|
24
|
+
ruby: LanguageProvider;
|
|
25
|
+
swift: LanguageProvider;
|
|
26
|
+
dart: LanguageProvider;
|
|
27
|
+
cobol: LanguageProvider;
|
|
28
|
+
};
|
|
29
|
+
/** Get provider by language enum (always succeeds for SupportedLanguages). */
|
|
30
|
+
export declare function getProvider(language: SupportedLanguages): LanguageProvider;
|
|
31
|
+
/** Look up a language provider from a file path by extension.
|
|
32
|
+
* Returns null if the file extension is not recognized. */
|
|
33
|
+
export declare function getProviderForFile(filePath: string): LanguageProvider | null;
|
|
34
|
+
/** Pre-computed list of providers that have implicit import wiring (e.g., Swift).
|
|
35
|
+
* Built once at module load — avoids iterating all 13 providers per call. */
|
|
36
|
+
export declare const providersWithImplicitWiring: (LanguageProvider & {
|
|
37
|
+
implicitImportWirer: NonNullable<LanguageProvider["implicitImportWirer"]>;
|
|
38
|
+
})[];
|