@shapeshift-labs/frontier-lang-compiler 0.2.29 → 0.2.31
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 +18 -2
- package/bench/smoke.mjs +3 -1
- package/dist/index.d.ts +68 -0
- package/dist/index.js +1484 -82
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -333,7 +333,9 @@ Use injected parser adapters when a real language parser is available but should
|
|
|
333
333
|
import {
|
|
334
334
|
createBabelNativeImporterAdapter,
|
|
335
335
|
createClangAstNativeImporterAdapter,
|
|
336
|
+
createCSharpRoslynNativeImporterAdapter,
|
|
336
337
|
createGoAstNativeImporterAdapter,
|
|
338
|
+
createJavaAstNativeImporterAdapter,
|
|
337
339
|
createPythonAstNativeImporterAdapter,
|
|
338
340
|
createRustSynNativeImporterAdapter,
|
|
339
341
|
importNativeProject,
|
|
@@ -359,6 +361,16 @@ const goAstAdapter = createGoAstNativeImporterAdapter({
|
|
|
359
361
|
parserModule: hostGoAstParser,
|
|
360
362
|
goVersion: '1.22'
|
|
361
363
|
});
|
|
364
|
+
const javaAstAdapter = createJavaAstNativeImporterAdapter({
|
|
365
|
+
parserModule: hostJavaAstParser,
|
|
366
|
+
javaVersion: '21',
|
|
367
|
+
sourceLevel: '21'
|
|
368
|
+
});
|
|
369
|
+
const csharpRoslynAdapter = createCSharpRoslynNativeImporterAdapter({
|
|
370
|
+
parserModule: hostRoslynParser,
|
|
371
|
+
languageVersion: '12',
|
|
372
|
+
nullableContext: 'enabled'
|
|
373
|
+
});
|
|
362
374
|
|
|
363
375
|
const imported = await runNativeImporterAdapter(babelAdapter, {
|
|
364
376
|
sourcePath: 'src/todo.ts',
|
|
@@ -367,13 +379,15 @@ const imported = await runNativeImporterAdapter(babelAdapter, {
|
|
|
367
379
|
|
|
368
380
|
const project = await importNativeProject({
|
|
369
381
|
projectRoot: 'src',
|
|
370
|
-
adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter],
|
|
382
|
+
adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter, javaAstAdapter, csharpRoslynAdapter],
|
|
371
383
|
sources: [
|
|
372
384
|
{ language: 'typescript', adapter: babelAdapter.id, sourcePath: 'src/todo.ts', sourceText },
|
|
373
385
|
{ language: 'python', adapter: pythonAstAdapter.id, sourcePath: 'tools/todo.py', sourceText: pythonSource },
|
|
374
386
|
{ language: 'rust', adapter: rustSynAdapter.id, sourcePath: 'src/todo.rs', sourceText: rustSource },
|
|
375
387
|
{ language: 'c', adapter: clangAstAdapter.id, sourcePath: 'native/todo.c', sourceText: cSource },
|
|
376
|
-
{ language: 'go', adapter: goAstAdapter.id, sourcePath: 'cmd/todo/main.go', sourceText: goSource }
|
|
388
|
+
{ language: 'go', adapter: goAstAdapter.id, sourcePath: 'cmd/todo/main.go', sourceText: goSource },
|
|
389
|
+
{ language: 'java', adapter: javaAstAdapter.id, sourcePath: 'src/main/java/Todo.java', sourceText: javaSource },
|
|
390
|
+
{ language: 'csharp', adapter: csharpRoslynAdapter.id, sourcePath: 'src/Todo.cs', sourceText: csharpSource }
|
|
377
391
|
]
|
|
378
392
|
});
|
|
379
393
|
|
|
@@ -396,6 +410,8 @@ The built-in adapter factories are dependency-light wrappers for caller-owned pa
|
|
|
396
410
|
- `createRustSynNativeImporterAdapter`
|
|
397
411
|
- `createClangAstNativeImporterAdapter`
|
|
398
412
|
- `createGoAstNativeImporterAdapter`
|
|
413
|
+
- `createJavaAstNativeImporterAdapter`
|
|
414
|
+
- `createCSharpRoslynNativeImporterAdapter`
|
|
399
415
|
- `createTreeSitterNativeImporterAdapter`
|
|
400
416
|
|
|
401
417
|
Adapter summaries include a structured `coverage` record so merge queues can distinguish exact parser AST imports from declaration scans. The record declares exactness, parser token/trivia support, diagnostics support, source-range and generated-range support, and semantic coverage. Built-in wrappers normalize native AST/CST nodes and declaration-level semantic indexes; they do not claim resolved references, types, control flow, generated ranges, or token/trivia fidelity unless the host adapter supplies that evidence.
|
package/bench/smoke.mjs
CHANGED
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
compileNativeSource,
|
|
4
4
|
compileFrontierSource,
|
|
5
5
|
createClangAstNativeImporterAdapter,
|
|
6
|
+
createCSharpRoslynNativeImporterAdapter,
|
|
6
7
|
createEstreeNativeImporterAdapter,
|
|
7
8
|
createGoAstNativeImporterAdapter,
|
|
9
|
+
createJavaAstNativeImporterAdapter,
|
|
8
10
|
createNativeImportCoverageMatrix,
|
|
9
11
|
createNativeParserAstFormatMatrix,
|
|
10
12
|
createProjectionTargetLossMatrix,
|
|
@@ -81,7 +83,7 @@ const matrixDurationMs = performance.now() - matrixStart;
|
|
|
81
83
|
const parserFormatMatrixStart = performance.now();
|
|
82
84
|
const parserFormatMatrix = createNativeParserAstFormatMatrix({
|
|
83
85
|
imports: nativeImportResults,
|
|
84
|
-
adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter()]
|
|
86
|
+
adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), createCSharpRoslynNativeImporterAdapter()]
|
|
85
87
|
});
|
|
86
88
|
const parserFormatMatrixDurationMs = performance.now() - parserFormatMatrixStart;
|
|
87
89
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1465,6 +1465,72 @@ export interface GoAstNativeImporterAdapterOptions {
|
|
|
1465
1465
|
readonly maxNodes?: number;
|
|
1466
1466
|
}
|
|
1467
1467
|
|
|
1468
|
+
export interface JavaAstNativeImporterAdapterOptions {
|
|
1469
|
+
readonly id?: string;
|
|
1470
|
+
readonly language?: FrontierSourceLanguage;
|
|
1471
|
+
readonly parser?: string;
|
|
1472
|
+
readonly version?: string;
|
|
1473
|
+
readonly capabilities?: readonly string[];
|
|
1474
|
+
readonly coverage?: NativeImporterAdapterCoverageInput;
|
|
1475
|
+
readonly supportedExtensions?: readonly string[];
|
|
1476
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
1477
|
+
readonly ast?: unknown;
|
|
1478
|
+
readonly compilationUnit?: unknown;
|
|
1479
|
+
readonly unit?: unknown;
|
|
1480
|
+
readonly sourceFile?: unknown;
|
|
1481
|
+
readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
|
|
1482
|
+
readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1483
|
+
readonly javac?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1484
|
+
readonly jdt?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1485
|
+
readonly javaParser?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1486
|
+
readonly parserOptions?: Record<string, unknown>;
|
|
1487
|
+
readonly javaVersion?: string;
|
|
1488
|
+
readonly sourceLevel?: string;
|
|
1489
|
+
readonly classPath?: readonly string[] | string | unknown;
|
|
1490
|
+
readonly modulePath?: readonly string[] | string | unknown;
|
|
1491
|
+
readonly generated?: boolean;
|
|
1492
|
+
readonly annotationProcessing?: unknown;
|
|
1493
|
+
readonly bindingEvidence?: unknown;
|
|
1494
|
+
readonly positionResolver?: (position: unknown) => unknown;
|
|
1495
|
+
readonly lineMap?: unknown;
|
|
1496
|
+
readonly includeAnnotations?: boolean;
|
|
1497
|
+
readonly maxNodes?: number;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
export interface CSharpRoslynNativeImporterAdapterOptions {
|
|
1501
|
+
readonly id?: string;
|
|
1502
|
+
readonly language?: FrontierSourceLanguage;
|
|
1503
|
+
readonly parser?: string;
|
|
1504
|
+
readonly version?: string;
|
|
1505
|
+
readonly capabilities?: readonly string[];
|
|
1506
|
+
readonly coverage?: NativeImporterAdapterCoverageInput;
|
|
1507
|
+
readonly supportedExtensions?: readonly string[];
|
|
1508
|
+
readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
|
|
1509
|
+
readonly ast?: unknown;
|
|
1510
|
+
readonly nativeAst?: unknown;
|
|
1511
|
+
readonly syntaxTree?: unknown;
|
|
1512
|
+
readonly tree?: unknown;
|
|
1513
|
+
readonly root?: unknown;
|
|
1514
|
+
readonly compilationUnit?: unknown;
|
|
1515
|
+
readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
|
|
1516
|
+
readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1517
|
+
readonly roslyn?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1518
|
+
readonly csharpRoslyn?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
|
|
1519
|
+
readonly parserOptions?: Record<string, unknown>;
|
|
1520
|
+
readonly csharpVersion?: string;
|
|
1521
|
+
readonly languageVersion?: string;
|
|
1522
|
+
readonly nullableContext?: string | boolean;
|
|
1523
|
+
readonly sourceCodeKind?: string;
|
|
1524
|
+
readonly generated?: boolean;
|
|
1525
|
+
readonly projectReferences?: unknown;
|
|
1526
|
+
readonly analyzerDiagnostics?: unknown;
|
|
1527
|
+
readonly semanticModelEvidence?: unknown;
|
|
1528
|
+
readonly sourceGeneratorEvidence?: unknown;
|
|
1529
|
+
readonly positionResolver?: (position: unknown) => unknown;
|
|
1530
|
+
readonly lineMap?: unknown;
|
|
1531
|
+
readonly maxNodes?: number;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1468
1534
|
export interface TreeSitterNativeImporterAdapterOptions {
|
|
1469
1535
|
readonly id?: string;
|
|
1470
1536
|
readonly language?: FrontierSourceLanguage;
|
|
@@ -1838,6 +1904,8 @@ export declare function createPythonAstNativeImporterAdapter(options?: PythonAst
|
|
|
1838
1904
|
export declare function createRustSynNativeImporterAdapter(options?: RustSynNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1839
1905
|
export declare function createClangAstNativeImporterAdapter(options?: ClangAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1840
1906
|
export declare function createGoAstNativeImporterAdapter(options?: GoAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1907
|
+
export declare function createJavaAstNativeImporterAdapter(options?: JavaAstNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1908
|
+
export declare function createCSharpRoslynNativeImporterAdapter(options?: CSharpRoslynNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1841
1909
|
export declare function createTreeSitterNativeImporterAdapter(options?: TreeSitterNativeImporterAdapterOptions): NativeImporterAdapter;
|
|
1842
1910
|
export declare function runNativeImporterAdapter(adapter: NativeImporterAdapter, input: RunNativeImporterAdapterOptions): Promise<NativeImporterAdapterImportResult>;
|
|
1843
1911
|
export declare function runNativeTargetProjectionAdapter(adapter: NativeTargetProjectionAdapter, input: NativeTargetProjectionAdapterInput): NativeTargetProjectionResult;
|