@shapeshift-labs/frontier-lang-compiler 0.2.31 → 0.2.32

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 CHANGED
@@ -371,6 +371,11 @@ const csharpRoslynAdapter = createCSharpRoslynNativeImporterAdapter({
371
371
  languageVersion: '12',
372
372
  nullableContext: 'enabled'
373
373
  });
374
+ const swiftSyntaxAdapter = createSwiftSyntaxNativeImporterAdapter({
375
+ parserModule: hostSwiftSyntaxParser,
376
+ swiftVersion: '6',
377
+ sourceKitEvidence: { hash: sourceKitIndexHash }
378
+ });
374
379
 
375
380
  const imported = await runNativeImporterAdapter(babelAdapter, {
376
381
  sourcePath: 'src/todo.ts',
@@ -379,7 +384,7 @@ const imported = await runNativeImporterAdapter(babelAdapter, {
379
384
 
380
385
  const project = await importNativeProject({
381
386
  projectRoot: 'src',
382
- adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter, javaAstAdapter, csharpRoslynAdapter],
387
+ adapters: [babelAdapter, pythonAstAdapter, rustSynAdapter, clangAstAdapter, goAstAdapter, javaAstAdapter, csharpRoslynAdapter, swiftSyntaxAdapter],
383
388
  sources: [
384
389
  { language: 'typescript', adapter: babelAdapter.id, sourcePath: 'src/todo.ts', sourceText },
385
390
  { language: 'python', adapter: pythonAstAdapter.id, sourcePath: 'tools/todo.py', sourceText: pythonSource },
@@ -387,7 +392,8 @@ const project = await importNativeProject({
387
392
  { language: 'c', adapter: clangAstAdapter.id, sourcePath: 'native/todo.c', sourceText: cSource },
388
393
  { language: 'go', adapter: goAstAdapter.id, sourcePath: 'cmd/todo/main.go', sourceText: goSource },
389
394
  { 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 }
395
+ { language: 'csharp', adapter: csharpRoslynAdapter.id, sourcePath: 'src/Todo.cs', sourceText: csharpSource },
396
+ { language: 'swift', adapter: swiftSyntaxAdapter.id, sourcePath: 'Sources/Todo.swift', sourceText: swiftSource }
391
397
  ]
392
398
  });
393
399
 
@@ -412,6 +418,7 @@ The built-in adapter factories are dependency-light wrappers for caller-owned pa
412
418
  - `createGoAstNativeImporterAdapter`
413
419
  - `createJavaAstNativeImporterAdapter`
414
420
  - `createCSharpRoslynNativeImporterAdapter`
421
+ - `createSwiftSyntaxNativeImporterAdapter`
415
422
  - `createTreeSitterNativeImporterAdapter`
416
423
 
417
424
  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.
@@ -459,6 +466,10 @@ The published Frontier package family is generated from one shared package catal
459
466
  - [`@shapeshift-labs/frontier-lang-rust`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-rust): Rust projection adapter for Frontier Lang semantic documents, including structs, aliases, and action stubs.
460
467
  - [`@shapeshift-labs/frontier-lang-python`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-python): Python projection adapter for Frontier Lang semantic documents, including dataclasses, typed patch records, and action stubs.
461
468
  - [`@shapeshift-labs/frontier-lang-c`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-c): C header projection adapter for Frontier Lang semantic documents, including structs and action prototypes.
469
+ - [`@shapeshift-labs/frontier-lang-java`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-java): Java source-language importer package for Frontier Lang semantic documents, including package-level metadata, Java AST adapter helpers, native import results, and semantic sidecar generation for javac/JDT/JavaParser-shaped ASTs.
470
+ - [`@shapeshift-labs/frontier-lang-go`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-go): Go source-language importer package for Frontier Lang semantic documents, including package-level metadata, Go AST adapter helpers, native import results, and semantic sidecar generation for go/ast File or Package trees.
471
+ - [`@shapeshift-labs/frontier-lang-csharp`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-csharp): C# Roslyn source-language importer package for Frontier Lang semantic documents, including package-level metadata, Roslyn adapter helpers, native import results, and semantic sidecar generation for SyntaxTree/SyntaxNode-shaped ASTs.
472
+ - [`@shapeshift-labs/frontier-lang-clang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-clang): Clang AST source-language importer package for Frontier Lang semantic documents, including package-level metadata, Clang AST JSON adapter helpers, native import results, and semantic sidecar generation for C/C++ translation units.
462
473
  - [`@shapeshift-labs/frontier-lang-cli`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-cli): Command line interface for parsing, checking, hashing, and emitting Frontier Lang projects.
463
474
  - [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, and projection adapters.
464
475
  - [`@shapeshift-labs/frontier-kv`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv): Serializable in-memory key/value state for Frontier apps, including TTL, versioned compare-and-set, batched patch mutations, scans, watchers, snapshots, JSONL event evidence, and replay verification.
@@ -546,6 +557,10 @@ Package source repositories:
546
557
  - [`siliconjungle/-shapeshift-labs-frontier-lang-python`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-python)
547
558
  - [`siliconjungle/-shapeshift-labs-frontier-lang-c`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-c)
548
559
  - [`siliconjungle/-shapeshift-labs-frontier-lang-compiler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-compiler)
560
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-java`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-java)
561
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-go`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-go)
562
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-csharp`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-csharp)
563
+ - [`siliconjungle/-shapeshift-labs-frontier-lang-clang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-clang)
549
564
  - [`siliconjungle/-shapeshift-labs-frontier-lang-cli`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang-cli)
550
565
  - [`siliconjungle/-shapeshift-labs-frontier-lang`](https://github.com/siliconjungle/-shapeshift-labs-frontier-lang)
551
566
  - [`siliconjungle/-shapeshift-labs-frontier-kv`](https://github.com/siliconjungle/-shapeshift-labs-frontier-kv)
package/bench/smoke.mjs CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  createNativeSourcePreservation,
14
14
  createPythonAstNativeImporterAdapter,
15
15
  createRustSynNativeImporterAdapter,
16
+ createSwiftSyntaxNativeImporterAdapter,
16
17
  createSemanticImportSidecar,
17
18
  diffNativeSources,
18
19
  importExternalSemanticIndex,
@@ -83,7 +84,7 @@ const matrixDurationMs = performance.now() - matrixStart;
83
84
  const parserFormatMatrixStart = performance.now();
84
85
  const parserFormatMatrix = createNativeParserAstFormatMatrix({
85
86
  imports: nativeImportResults,
86
- adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), createCSharpRoslynNativeImporterAdapter()]
87
+ adapters: [estreeAdapter, createPythonAstNativeImporterAdapter(), createRustSynNativeImporterAdapter(), createClangAstNativeImporterAdapter(), createGoAstNativeImporterAdapter(), createJavaAstNativeImporterAdapter(), createCSharpRoslynNativeImporterAdapter(), createSwiftSyntaxNativeImporterAdapter()]
87
88
  });
88
89
  const parserFormatMatrixDurationMs = performance.now() - parserFormatMatrixStart;
89
90
 
package/dist/index.d.ts CHANGED
@@ -1531,6 +1531,39 @@ export interface CSharpRoslynNativeImporterAdapterOptions {
1531
1531
  readonly maxNodes?: number;
1532
1532
  }
1533
1533
 
1534
+ export interface SwiftSyntaxNativeImporterAdapterOptions {
1535
+ readonly id?: string;
1536
+ readonly language?: FrontierSourceLanguage;
1537
+ readonly parser?: string;
1538
+ readonly version?: string;
1539
+ readonly capabilities?: readonly string[];
1540
+ readonly coverage?: NativeImporterAdapterCoverageInput;
1541
+ readonly supportedExtensions?: readonly string[];
1542
+ readonly diagnostics?: readonly NativeImporterAdapterDiagnostic[];
1543
+ readonly ast?: unknown;
1544
+ readonly nativeAst?: unknown;
1545
+ readonly sourceFile?: unknown;
1546
+ readonly sourceFileSyntax?: unknown;
1547
+ readonly root?: unknown;
1548
+ readonly parse?: (sourceText: string, options: Record<string, unknown>) => unknown;
1549
+ readonly parserModule?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
1550
+ readonly swiftSyntax?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
1551
+ readonly swiftParser?: { readonly parse: (sourceText: string, options: Record<string, unknown>) => unknown };
1552
+ readonly parserOptions?: Record<string, unknown>;
1553
+ readonly swiftVersion?: string;
1554
+ readonly languageMode?: string;
1555
+ readonly enableBareSlashRegex?: boolean;
1556
+ readonly parseTransition?: string;
1557
+ readonly generated?: boolean;
1558
+ readonly sourceKitEvidence?: unknown;
1559
+ readonly macroExpansionEvidence?: unknown;
1560
+ readonly packageResolutionEvidence?: unknown;
1561
+ readonly positionResolver?: (position: unknown) => unknown;
1562
+ readonly lineMap?: unknown;
1563
+ readonly sourceLocationConverter?: unknown;
1564
+ readonly maxNodes?: number;
1565
+ }
1566
+
1534
1567
  export interface TreeSitterNativeImporterAdapterOptions {
1535
1568
  readonly id?: string;
1536
1569
  readonly language?: FrontierSourceLanguage;
@@ -1906,6 +1939,7 @@ export declare function createClangAstNativeImporterAdapter(options?: ClangAstNa
1906
1939
  export declare function createGoAstNativeImporterAdapter(options?: GoAstNativeImporterAdapterOptions): NativeImporterAdapter;
1907
1940
  export declare function createJavaAstNativeImporterAdapter(options?: JavaAstNativeImporterAdapterOptions): NativeImporterAdapter;
1908
1941
  export declare function createCSharpRoslynNativeImporterAdapter(options?: CSharpRoslynNativeImporterAdapterOptions): NativeImporterAdapter;
1942
+ export declare function createSwiftSyntaxNativeImporterAdapter(options?: SwiftSyntaxNativeImporterAdapterOptions): NativeImporterAdapter;
1909
1943
  export declare function createTreeSitterNativeImporterAdapter(options?: TreeSitterNativeImporterAdapterOptions): NativeImporterAdapter;
1910
1944
  export declare function runNativeImporterAdapter(adapter: NativeImporterAdapter, input: RunNativeImporterAdapterOptions): Promise<NativeImporterAdapterImportResult>;
1911
1945
  export declare function runNativeTargetProjectionAdapter(adapter: NativeTargetProjectionAdapter, input: NativeTargetProjectionAdapterInput): NativeTargetProjectionResult;
package/dist/index.js CHANGED
@@ -452,6 +452,19 @@ export const NativeParserAstFormatProfiles = Object.freeze([
452
452
  supportsErrorRecovery: true,
453
453
  notes: ['Roslyn C# syntax trees expose immutable nodes, tokens, trivia, spans, diagnostics, directives, and skipped text; SemanticModel symbols, nullable analysis, generated sources, partial type stitching, analyzer results, and project references remain host-owned evidence.']
454
454
  }),
455
+ nativeParserAstFormatProfile('swift-syntax', {
456
+ aliases: ['swiftsyntax', 'swiftparser', 'swift-parser', 'swift-syntax-json'],
457
+ kind: 'concrete-syntax-tree',
458
+ languages: ['swift'],
459
+ parserAdapters: ['swift-syntax', 'swiftparser'],
460
+ exactness: 'parser-tree',
461
+ sourceRangeModel: 'absolute-position-source-location',
462
+ preservesTokens: true,
463
+ preservesTrivia: true,
464
+ supportsIncremental: false,
465
+ supportsErrorRecovery: true,
466
+ notes: ['SwiftSyntax exposes a source-accurate syntax tree with missing/unexpected nodes and token/trivia structure; SourceKit symbols, macro expansion, conditional compilation branch resolution, type checking, generated sources, and package/module dependency resolution remain host-owned evidence.']
467
+ }),
455
468
  nativeParserAstFormatProfile('tree-sitter', {
456
469
  kind: 'concrete-syntax-tree',
457
470
  languages: ['mixed'],
@@ -3012,6 +3025,67 @@ export function createCSharpRoslynNativeImporterAdapter(options = {}) {
3012
3025
  };
3013
3026
  }
3014
3027
 
3028
+ export function createSwiftSyntaxNativeImporterAdapter(options = {}) {
3029
+ return {
3030
+ id: options.id ?? 'frontier.swift-syntax-native-importer',
3031
+ language: options.language ?? 'swift',
3032
+ parser: options.parser ?? 'swift-syntax',
3033
+ version: options.version,
3034
+ capabilities: uniqueStrings(['nativeAst', 'semanticIndex', 'sourceMaps', 'diagnostics', ...(options.capabilities ?? [])]),
3035
+ coverage: nativeImporterAdapterCoverage({
3036
+ exactness: 'parser-tree',
3037
+ exactAst: true,
3038
+ tokens: true,
3039
+ trivia: true,
3040
+ diagnostics: true,
3041
+ sourceRanges: true,
3042
+ generatedRanges: false,
3043
+ semanticCoverage: declarationSemanticCoverage(),
3044
+ notes: [
3045
+ 'Normalizes caller-owned SwiftSyntax/SwiftParser-shaped SourceFileSyntax trees into native AST nodes and declaration-level semantic index records.',
3046
+ 'SwiftSyntax imports do not resolve SourceKit symbols, type checking, macro expansions, conditional compilation branches, Objective-C bridging, generated sources, package/module dependencies, or control flow by themselves; attach host evidence for those claims.'
3047
+ ]
3048
+ }, options.coverage),
3049
+ supportedExtensions: options.supportedExtensions ?? ['.swift'],
3050
+ diagnostics: options.diagnostics,
3051
+ parse(input) {
3052
+ const parsed = input.options?.ast
3053
+ ?? input.options?.nativeAst
3054
+ ?? input.options?.sourceFile
3055
+ ?? input.options?.sourceFileSyntax
3056
+ ?? input.options?.root
3057
+ ?? options.ast
3058
+ ?? options.sourceFile
3059
+ ?? options.sourceFileSyntax
3060
+ ?? options.root
3061
+ ?? parseSwiftSyntaxSource(input, options);
3062
+ const root = swiftSyntaxRoot(parsed);
3063
+ if (!root) {
3064
+ return missingInjectedParserResult(input, {
3065
+ parser: options.parser ?? 'swift-syntax',
3066
+ adapterId: options.id ?? 'frontier.swift-syntax-native-importer',
3067
+ message: 'createSwiftSyntaxNativeImporterAdapter requires an injected SwiftSyntax SourceFileSyntax-shaped object, parserModule.parse function, parse function, or adapterOptions.ast.'
3068
+ });
3069
+ }
3070
+ const parseDiagnostics = normalizeParserErrors(parsed?.errors ?? parsed?.diagnostics ?? parsed?.parseDiagnostics, input, {
3071
+ parser: options.parser ?? 'swift-syntax'
3072
+ });
3073
+ return createNativeImportFromSwiftSyntax(root, input, {
3074
+ parser: options.parser ?? 'swift-syntax',
3075
+ astFormat: 'swift-syntax',
3076
+ maxNodes: options.maxNodes,
3077
+ diagnostics: parseDiagnostics,
3078
+ swiftVersion: options.swiftVersion ?? input.options?.swiftVersion ?? parsed?.swiftVersion,
3079
+ languageMode: options.languageMode ?? input.options?.languageMode ?? parsed?.languageMode,
3080
+ generated: input.options?.generated ?? options.generated ?? parsed?.generated ?? swiftGeneratedSourcePath(input.sourcePath),
3081
+ sourceKitEvidence: input.options?.sourceKitEvidence ?? options.sourceKitEvidence ?? parsed?.sourceKitEvidence,
3082
+ macroExpansionEvidence: input.options?.macroExpansionEvidence ?? options.macroExpansionEvidence ?? parsed?.macroExpansionEvidence,
3083
+ packageResolutionEvidence: input.options?.packageResolutionEvidence ?? options.packageResolutionEvidence ?? parsed?.packageResolutionEvidence
3084
+ });
3085
+ }
3086
+ };
3087
+ }
3088
+
3015
3089
  export function createTreeSitterNativeImporterAdapter(options = {}) {
3016
3090
  return {
3017
3091
  id: options.id ?? `frontier.tree-sitter-${idFragment(options.language ?? 'source')}-native-importer`,
@@ -7456,6 +7530,7 @@ function parserAstFormatIdForParser(parser) {
7456
7530
  if (text === 'go' || text.includes('go-parser') || text.includes('go-ast') || text.includes('go/parser') || text.includes('go/ast')) return 'go-ast';
7457
7531
  if (text === 'java' || text.includes('javac') || text.includes('jdt') || text.includes('javaparser') || text.includes('java-parser') || text.includes('java-ast')) return 'java-ast';
7458
7532
  if (text === 'csharp' || text === 'c#' || text === 'cs' || text.includes('roslyn') || text.includes('microsoft-codeanalysis-csharp') || text.includes('csharp-syntax')) return 'roslyn-csharp';
7533
+ if (text.includes('swift-syntax') || text.includes('swiftsyntax') || text.includes('swiftparser') || text.includes('swift-parser')) return 'swift-syntax';
7459
7534
  if (text.includes('tree-sitter') || text.includes('treesitter')) return 'tree-sitter';
7460
7535
  if (text.includes('babel')) return 'babel';
7461
7536
  if (text.includes('estree')) return 'estree';
@@ -8570,6 +8645,22 @@ function parseCSharpRoslynSource(input, options) {
8570
8645
  return parse(input.sourceText, parserOptions);
8571
8646
  }
8572
8647
 
8648
+ function parseSwiftSyntaxSource(input, options) {
8649
+ const parse = options.parse ?? options.parserModule?.parse ?? options.swiftSyntax?.parse ?? options.swiftParser?.parse;
8650
+ if (typeof parse !== 'function') return undefined;
8651
+ const parserOptions = {
8652
+ sourcePath: input.sourcePath,
8653
+ filename: input.sourcePath,
8654
+ swiftVersion: options.swiftVersion ?? input.options?.swiftVersion,
8655
+ languageMode: options.languageMode ?? input.options?.languageMode,
8656
+ enableBareSlashRegex: options.enableBareSlashRegex ?? input.options?.enableBareSlashRegex,
8657
+ parseTransition: options.parseTransition ?? input.options?.parseTransition,
8658
+ ...(options.parserOptions ?? {}),
8659
+ ...(input.options?.parserOptions ?? {})
8660
+ };
8661
+ return parse(input.sourceText, parserOptions);
8662
+ }
8663
+
8573
8664
  function createNativeImportFromSyntaxAst(ast, input, options) {
8574
8665
  const root = normalizeSyntaxAstRoot(ast, options.astFormat);
8575
8666
  if (!root) {
@@ -8839,6 +8930,43 @@ function createNativeImportFromCSharpRoslyn(root, input, options) {
8839
8930
  };
8840
8931
  }
8841
8932
 
8933
+ function createNativeImportFromSwiftSyntax(root, input, options) {
8934
+ const context = createAstNormalizationContext(input, options);
8935
+ visitSwiftSyntaxNode(root, context, 'root');
8936
+ if (context.truncated) {
8937
+ context.losses.push(truncatedAstLoss(input, context, options));
8938
+ }
8939
+ if (options.generated && !context.losses.some((loss) => loss.kind === 'generatedCode')) {
8940
+ context.losses.push(swiftGeneratedCodeLoss(input, context.rootId, undefined, options));
8941
+ }
8942
+ const semantic = semanticIndexFromNativeDeclarations(context.declarations, input, options);
8943
+ return {
8944
+ rootId: context.rootId,
8945
+ nodes: context.nodes,
8946
+ semanticIndex: semantic.semanticIndex,
8947
+ mappings: semantic.mappings,
8948
+ losses: mergeNativeLosses(context.losses, options.diagnostics?.map((diagnostic, index) => adapterDiagnosticToLoss(diagnostic, index, {
8949
+ id: input.adapterId,
8950
+ version: input.adapterVersion
8951
+ }, input)) ?? []),
8952
+ evidence: semantic.evidence,
8953
+ diagnostics: options.diagnostics,
8954
+ metadata: {
8955
+ astFormat: options.astFormat,
8956
+ parser: options.parser,
8957
+ swiftVersion: options.swiftVersion,
8958
+ languageMode: options.languageMode,
8959
+ generated: options.generated,
8960
+ sourceKitEvidence: swiftEvidenceSummary(options.sourceKitEvidence),
8961
+ macroExpansionEvidence: swiftEvidenceSummary(options.macroExpansionEvidence),
8962
+ packageResolutionEvidence: swiftEvidenceSummary(options.packageResolutionEvidence),
8963
+ normalizedNodeCount: Object.keys(context.nodes).length,
8964
+ declarationCount: context.declarations.length,
8965
+ truncated: context.truncated
8966
+ }
8967
+ };
8968
+ }
8969
+
8842
8970
  function createNativeImportFromTreeSitter(root, input, options) {
8843
8971
  const context = createAstNormalizationContext(input, options);
8844
8972
  visitTreeSitterNode(root, context, 'root');
@@ -9400,6 +9528,108 @@ function visitCSharpRoslynNode(node, context, propertyPath) {
9400
9528
  return id;
9401
9529
  }
9402
9530
 
9531
+ function visitSwiftSyntaxNode(node, context, propertyPath) {
9532
+ if (!isSwiftSyntaxNode(node) || context.truncated) return undefined;
9533
+ if (context.objectIds.has(node)) return context.objectIds.get(node);
9534
+ if (context.counter >= context.maxNodes) {
9535
+ context.truncated = true;
9536
+ return undefined;
9537
+ }
9538
+ const kind = swiftSyntaxKind(node);
9539
+ const span = spanFromSwiftSyntaxNode(node, context.input, context.options);
9540
+ const id = nativeNodeId(context, kind, { start: { line: span?.startLine, column: span?.startColumn } }, propertyPath);
9541
+ context.objectIds.set(node, id);
9542
+ if (!context.rootId) context.rootId = id;
9543
+ const children = [];
9544
+ for (const [field, value] of swiftSyntaxChildEntries(node, kind)) {
9545
+ if (Array.isArray(value)) {
9546
+ value.forEach((entry, index) => {
9547
+ const childId = visitSwiftSyntaxNode(entry, context, `${propertyPath}.${field}[${index}]`);
9548
+ if (childId) children.push(childId);
9549
+ });
9550
+ } else {
9551
+ const childId = visitSwiftSyntaxNode(value, context, `${propertyPath}.${field}`);
9552
+ if (childId) children.push(childId);
9553
+ }
9554
+ }
9555
+ const declarations = swiftSyntaxDeclarations(node, kind, id, context.input);
9556
+ const declaration = declarations[0];
9557
+ const nativeNode = {
9558
+ id,
9559
+ kind,
9560
+ languageKind: `${context.input.language}.${kind}`,
9561
+ span,
9562
+ value: declaration?.name ?? swiftSyntaxNodeValue(node),
9563
+ fields: primitiveSwiftSyntaxFields(node, kind),
9564
+ children,
9565
+ metadata: {
9566
+ astFormat: context.options.astFormat,
9567
+ propertyPath,
9568
+ positionKind: swiftSyntaxPositionKind(node),
9569
+ parser: context.options.parser
9570
+ }
9571
+ };
9572
+ context.nodes[id] = nativeNode;
9573
+ for (const entry of declarations) {
9574
+ context.declarations.push({ ...entry, nativeNode });
9575
+ }
9576
+ if (swiftSyntaxRecoveredKind(kind) || swiftSyntaxProblemNode(node, kind)) {
9577
+ context.losses.push({
9578
+ id: `loss_${idFragment(id)}_swift_syntax_recovered_node`,
9579
+ severity: 'error',
9580
+ phase: 'parse',
9581
+ sourceFormat: context.input.language,
9582
+ kind: 'unsupportedSyntax',
9583
+ message: 'SwiftSyntax reported missing, unexpected, skipped, or error syntax; semantic import is partial until syntax errors are resolved.',
9584
+ span,
9585
+ nodeId: id,
9586
+ metadata: {
9587
+ parser: context.options.parser,
9588
+ astFormat: context.options.astFormat,
9589
+ nodeKind: kind
9590
+ }
9591
+ });
9592
+ }
9593
+ if (swiftSyntaxConditionalCompilationKind(kind)) {
9594
+ context.losses.push({
9595
+ id: `loss_${idFragment(id)}_swift_conditional_compilation`,
9596
+ severity: 'warning',
9597
+ phase: 'parse',
9598
+ sourceFormat: context.input.language,
9599
+ kind: 'conditionalCompilation',
9600
+ message: 'Swift conditional compilation syntax was imported; active branch selection and inactive branch source ownership require host build-setting evidence.',
9601
+ span,
9602
+ nodeId: id,
9603
+ metadata: {
9604
+ parser: context.options.parser,
9605
+ astFormat: context.options.astFormat,
9606
+ nodeKind: kind
9607
+ }
9608
+ });
9609
+ }
9610
+ if (swiftSyntaxMacroKind(kind)) {
9611
+ context.losses.push({
9612
+ id: `loss_${idFragment(id)}_swift_macro_expansion`,
9613
+ severity: 'warning',
9614
+ phase: 'parse',
9615
+ sourceFormat: context.input.language,
9616
+ kind: 'macroExpansion',
9617
+ message: 'Swift macro syntax was imported, but expansion, generated declarations, and binding effects require host macro-expansion evidence.',
9618
+ span,
9619
+ nodeId: id,
9620
+ metadata: {
9621
+ parser: context.options.parser,
9622
+ astFormat: context.options.astFormat,
9623
+ nodeKind: kind
9624
+ }
9625
+ });
9626
+ }
9627
+ if (swiftGeneratedCodeMarker(node, kind)) {
9628
+ context.losses.push(swiftGeneratedCodeLoss(context.input, id, span, context.options, { nodeKind: kind }));
9629
+ }
9630
+ return id;
9631
+ }
9632
+
9403
9633
  function visitTreeSitterNode(node, context, propertyPath) {
9404
9634
  if (!node || typeof node !== 'object' || context.truncated) return undefined;
9405
9635
  if (context.objectIds.has(node)) return context.objectIds.get(node);
@@ -12609,6 +12839,522 @@ function csharpEvidenceSummary(value) {
12609
12839
  return { present: true };
12610
12840
  }
12611
12841
 
12842
+ function swiftSyntaxRoot(value) {
12843
+ if (!value || typeof value !== 'object') return undefined;
12844
+ if (isSwiftSyntaxNode(value)) return value;
12845
+ if (isSwiftSyntaxNode(value.ast)) return value.ast;
12846
+ if (isSwiftSyntaxNode(value.root)) return value.root;
12847
+ if (isSwiftSyntaxNode(value.rootNode)) return value.rootNode;
12848
+ if (isSwiftSyntaxNode(value.sourceFile)) return value.sourceFile;
12849
+ if (isSwiftSyntaxNode(value.sourceFileSyntax)) return value.sourceFileSyntax;
12850
+ if (isSwiftSyntaxNode(value.tree)) return swiftSyntaxRoot(value.tree);
12851
+ if (Array.isArray(value.statements) || Array.isArray(value.members) || Array.isArray(value.declarations)) {
12852
+ return { kind: 'SourceFile', ...value };
12853
+ }
12854
+ return undefined;
12855
+ }
12856
+
12857
+ function isSwiftSyntaxNode(value) {
12858
+ return Boolean(value && typeof value === 'object' && typeof swiftSyntaxKind(value) === 'string');
12859
+ }
12860
+
12861
+ function swiftSyntaxKind(node) {
12862
+ if (!node || typeof node !== 'object') return undefined;
12863
+ const declared = node.kind ?? node.syntaxKind ?? node.SyntaxKind ?? node._syntaxKind ?? node._type ?? node.type ?? node.nodeType;
12864
+ if (typeof declared === 'string') return normalizeSwiftSyntaxKind(declared);
12865
+ if (Array.isArray(node.statements) || Array.isArray(node.members) || Array.isArray(node.declarations)) return 'SourceFile';
12866
+ if (node.identifier && (node.memberBlock || node.members || node.genericParameterClause || node.inheritanceClause)) return 'ClassDecl';
12867
+ if (node.signature && node.body) return 'FunctionDecl';
12868
+ if (node.importPath || node.path) return 'ImportDecl';
12869
+ return undefined;
12870
+ }
12871
+
12872
+ function normalizeSwiftSyntaxKind(kind) {
12873
+ const text = String(kind)
12874
+ .replace(/^SwiftSyntax\./, '')
12875
+ .replace(/Syntax$/, '');
12876
+ const compact = text.replace(/[_\s.-]+/g, '').toLowerCase();
12877
+ const known = {
12878
+ sourcefile: 'SourceFile',
12879
+ importdecl: 'ImportDecl',
12880
+ classdecl: 'ClassDecl',
12881
+ structdecl: 'StructDecl',
12882
+ enumdecl: 'EnumDecl',
12883
+ protocoldecl: 'ProtocolDecl',
12884
+ actordecl: 'ActorDecl',
12885
+ extensiondecl: 'ExtensionDecl',
12886
+ typealiasdecl: 'TypeAliasDecl',
12887
+ associatedtypedecl: 'AssociatedTypeDecl',
12888
+ functiondecl: 'FunctionDecl',
12889
+ initializerdecl: 'InitializerDecl',
12890
+ initdecl: 'InitializerDecl',
12891
+ deinitializerdecl: 'DeinitializerDecl',
12892
+ deinitdecl: 'DeinitializerDecl',
12893
+ subscriptdecl: 'SubscriptDecl',
12894
+ operatordecl: 'OperatorDecl',
12895
+ precedencegroupdecl: 'PrecedenceGroupDecl',
12896
+ variabledecl: 'VariableDecl',
12897
+ patternbinding: 'PatternBinding',
12898
+ enumcasedecl: 'EnumCaseDecl',
12899
+ enumcaseelement: 'EnumCaseElement',
12900
+ macrodecl: 'MacroDecl',
12901
+ macroexpansiondecl: 'MacroExpansionDecl',
12902
+ freestandingmacroexpansion: 'FreestandingMacroExpansion',
12903
+ freestandingmacroexpansionsyntax: 'FreestandingMacroExpansion',
12904
+ attributemacroexpansion: 'AttributeMacroExpansion',
12905
+ ifconfigdecl: 'IfConfigDecl',
12906
+ ifconfigexpr: 'IfConfigExpr',
12907
+ unexpectednodes: 'UnexpectedNodes',
12908
+ missingtoken: 'MissingToken',
12909
+ skippedtoken: 'SkippedToken',
12910
+ error: 'Error'
12911
+ };
12912
+ if (known[compact]) return known[compact];
12913
+ if (/^[A-Z0-9_]+$/.test(text)) return text.toLowerCase().split('_').map(upperFirst).join('');
12914
+ return text;
12915
+ }
12916
+
12917
+ function ignoredSwiftSyntaxField(key) {
12918
+ return key === '_type'
12919
+ || key === 'type'
12920
+ || key === 'kind'
12921
+ || key === 'syntaxKind'
12922
+ || key === 'SyntaxKind'
12923
+ || key === '_syntaxKind'
12924
+ || key === 'nodeType'
12925
+ || key === 'parent'
12926
+ || key === 'parentKind'
12927
+ || key === 'parentField'
12928
+ || key === 'position'
12929
+ || key === 'absolutePosition'
12930
+ || key === 'endPosition'
12931
+ || key === 'location'
12932
+ || key === 'sourceRange'
12933
+ || key === 'range'
12934
+ || key === 'span'
12935
+ || key === 'identifier'
12936
+ || key === 'name'
12937
+ || key === 'simpleName'
12938
+ || key === 'typeName'
12939
+ || key === 'sourceKitSymbol'
12940
+ || key === 'semanticModel'
12941
+ || key === 'resolvedSymbol'
12942
+ || key === 'typeInfo';
12943
+ }
12944
+
12945
+ function primitiveSwiftSyntaxFields(node, kind) {
12946
+ const fields = { kind };
12947
+ const name = swiftSyntaxDeclarationName(node, kind);
12948
+ if (name) fields.name = name;
12949
+ const importPath = swiftSyntaxImportPath(node);
12950
+ if (importPath) fields.importPath = importPath;
12951
+ const type = swiftSyntaxTypeName(node.type ?? node.typeAnnotation?.type ?? node.returnClause?.type ?? node.extendedType);
12952
+ if (type) fields.type = type;
12953
+ const modifiers = swiftSyntaxModifierNames(node);
12954
+ if (modifiers.length) fields.modifiers = modifiers.join(',');
12955
+ const attributes = swiftSyntaxAttributeNames(node);
12956
+ if (attributes.length) fields.attributes = attributes.join(',');
12957
+ if (node.generated === true || node.isGenerated === true) fields.generated = true;
12958
+ if (node.isMissing === true || node.presence === 'missing') fields.isMissing = true;
12959
+ if (node.hasError === true || node.containsDiagnostics === true) fields.hasError = true;
12960
+ if (Array.isArray(node.genericParameterClause?.parameters ?? node.genericParameters)) fields.genericParameterCount = (node.genericParameterClause?.parameters ?? node.genericParameters).length;
12961
+ if (Array.isArray(node.inheritanceClause?.inheritedTypes ?? node.inheritedTypes)) fields.inheritedTypeCount = (node.inheritanceClause?.inheritedTypes ?? node.inheritedTypes).length;
12962
+ if (Array.isArray(node.signature?.parameterClause?.parameters ?? node.parameters)) fields.parameterCount = (node.signature?.parameterClause?.parameters ?? node.parameters).length;
12963
+ return fields;
12964
+ }
12965
+
12966
+ function spanFromSwiftSyntaxNode(node, input, options = {}) {
12967
+ const direct = spanFromSwiftLineFields(node, input);
12968
+ if (direct) return direct;
12969
+ const range = node.sourceRange ?? node.range ?? node.span;
12970
+ const fromRange = spanFromSwiftRange(range, input);
12971
+ if (fromRange) return fromRange;
12972
+ const start = swiftSyntaxPosition(node.position ?? node.absolutePosition ?? node.start ?? range?.start, options);
12973
+ const end = swiftSyntaxPosition(node.endPosition ?? node.end ?? range?.end, options);
12974
+ if (!start) return undefined;
12975
+ return {
12976
+ sourceId: input.sourceHash,
12977
+ path: start.path ?? end?.path ?? input.sourcePath,
12978
+ startLine: start.line,
12979
+ startColumn: start.column,
12980
+ endLine: end?.line,
12981
+ endColumn: end?.column
12982
+ };
12983
+ }
12984
+
12985
+ function spanFromSwiftLineFields(node, input) {
12986
+ const startLine = node.startLine ?? node.line ?? node.beginLine;
12987
+ if (typeof startLine !== 'number') return undefined;
12988
+ return {
12989
+ sourceId: input.sourceHash,
12990
+ path: node.path ?? node.filePath ?? node.file ?? input.sourcePath,
12991
+ startLine,
12992
+ startColumn: node.startColumn ?? node.column ?? node.beginColumn,
12993
+ endLine: node.endLine,
12994
+ endColumn: node.endColumn
12995
+ };
12996
+ }
12997
+
12998
+ function spanFromSwiftRange(range, input) {
12999
+ if (!range || typeof range !== 'object') return undefined;
13000
+ const start = range.start ?? range.lowerBound ?? range.begin;
13001
+ const end = range.end ?? range.upperBound;
13002
+ const line = start?.line ?? start?.Line;
13003
+ if (typeof line !== 'number') return undefined;
13004
+ const column = start.column ?? start.character ?? start.utf8Column ?? start.Column;
13005
+ const endLine = end?.line ?? end?.Line;
13006
+ const endColumn = end?.column ?? end?.character ?? end?.utf8Column ?? end?.Column;
13007
+ return {
13008
+ sourceId: input.sourceHash,
13009
+ path: range.path ?? range.filePath ?? range.file ?? input.sourcePath,
13010
+ startLine: line,
13011
+ startColumn: typeof column === 'number' ? column : undefined,
13012
+ endLine: typeof endLine === 'number' ? endLine : undefined,
13013
+ endColumn: typeof endColumn === 'number' ? endColumn : undefined
13014
+ };
13015
+ }
13016
+
13017
+ function swiftSyntaxPosition(value, options = {}) {
13018
+ if (value === undefined || value === null) return undefined;
13019
+ if (typeof value === 'object') {
13020
+ const position = value.position ?? value.location ?? value;
13021
+ const line = position.line ?? position.Line;
13022
+ const column = position.column ?? position.character ?? position.utf8Column ?? position.Column;
13023
+ if (typeof line === 'number') {
13024
+ return {
13025
+ path: position.path ?? position.filePath ?? position.file,
13026
+ line,
13027
+ column: typeof column === 'number' ? column : undefined
13028
+ };
13029
+ }
13030
+ }
13031
+ const resolver = typeof options.positionResolver === 'function'
13032
+ ? options.positionResolver
13033
+ : typeof options.lineMap?.position === 'function'
13034
+ ? options.lineMap.position.bind(options.lineMap)
13035
+ : typeof options.sourceLocationConverter?.location === 'function'
13036
+ ? options.sourceLocationConverter.location.bind(options.sourceLocationConverter)
13037
+ : undefined;
13038
+ if (resolver) {
13039
+ const resolved = resolver(value);
13040
+ if (resolved !== value) return swiftSyntaxPosition(resolved, options);
13041
+ }
13042
+ return undefined;
13043
+ }
13044
+
13045
+ function swiftSyntaxPositionKind(node) {
13046
+ if (node.sourceRange || node.range) return 'source-range';
13047
+ if (node.position || node.absolutePosition) return 'absolute-position';
13048
+ if (typeof node.startLine === 'number' || typeof node.line === 'number') return 'line-column-fields';
13049
+ return undefined;
13050
+ }
13051
+
13052
+ function swiftSyntaxDeclarations(node, kind, nativeNodeId, input) {
13053
+ if (kind === 'ImportDecl') {
13054
+ const name = swiftSyntaxImportPath(node);
13055
+ return name ? [declarationRecord(input, nativeNodeId, name, 'module', 'import')] : [];
13056
+ }
13057
+ if (swiftSyntaxTypeDeclarationKind(kind)) {
13058
+ const name = swiftSyntaxDeclarationName(node, kind);
13059
+ return name ? [declarationRecord(input, nativeNodeId, name, swiftSyntaxTypeDeclarationSymbolKind(kind), 'definition')] : [];
13060
+ }
13061
+ if (kind === 'ExtensionDecl') {
13062
+ const name = swiftSyntaxDeclarationName(node, kind);
13063
+ return name ? [declarationRecord(input, nativeNodeId, name, 'type', 'definition')] : [];
13064
+ }
13065
+ if (kind === 'TypeAliasDecl' || kind === 'AssociatedTypeDecl') {
13066
+ const name = swiftSyntaxDeclarationName(node, kind);
13067
+ return name ? [declarationRecord(input, nativeNodeId, name, 'type', 'definition')] : [];
13068
+ }
13069
+ if (swiftSyntaxFunctionLikeKind(kind)) {
13070
+ const name = swiftSyntaxDeclarationName(node, kind) ?? swiftSyntaxOperatorName(node, kind);
13071
+ return name ? [declarationRecord(input, nativeNodeId, name, kind === 'FunctionDecl' ? 'function' : 'method', swiftSyntaxHasBody(node) ? 'definition' : 'declaration')] : [];
13072
+ }
13073
+ if (kind === 'VariableDecl') {
13074
+ return swiftSyntaxVariableNames(node).map((name) => declarationRecord(input, nativeNodeId, name, 'property', 'definition'));
13075
+ }
13076
+ if (kind === 'PatternBinding' && node.parentKind === 'VariableDecl') {
13077
+ const name = swiftSyntaxDeclarationName(node, kind);
13078
+ return name ? [declarationRecord(input, nativeNodeId, name, 'property', 'definition')] : [];
13079
+ }
13080
+ if (kind === 'EnumCaseDecl') {
13081
+ return swiftSyntaxEnumCaseNames(node).map((name) => declarationRecord(input, nativeNodeId, name, 'enumMember', 'definition'));
13082
+ }
13083
+ if (kind === 'EnumCaseElement') {
13084
+ const name = swiftSyntaxDeclarationName(node, kind);
13085
+ return name ? [declarationRecord(input, nativeNodeId, name, 'enumMember', 'definition')] : [];
13086
+ }
13087
+ return [];
13088
+ }
13089
+
13090
+ function swiftSyntaxChildEntries(node, kind = swiftSyntaxKind(node)) {
13091
+ const fieldNames = Object.keys(node).filter((key) => !ignoredSwiftSyntaxField(key));
13092
+ const entries = [];
13093
+ for (const field of fieldNames) {
13094
+ const value = node[field];
13095
+ if (Array.isArray(value)) {
13096
+ entries.push([field, value.map((entry) => swiftSyntaxChildWithParent(entry, kind, field))]);
13097
+ continue;
13098
+ }
13099
+ if (value && typeof value === 'object') {
13100
+ entries.push([field, swiftSyntaxChildWithParent(value, kind, field)]);
13101
+ }
13102
+ }
13103
+ return entries.filter(([, value]) => Array.isArray(value)
13104
+ ? value.some(isSwiftSyntaxNode)
13105
+ : isSwiftSyntaxNode(value));
13106
+ }
13107
+
13108
+ function swiftSyntaxChildWithParent(entry, parentKind, parentField) {
13109
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) return entry;
13110
+ if (!isSwiftSyntaxNode(entry)) return entry;
13111
+ return { parentKind, parentField, ...entry };
13112
+ }
13113
+
13114
+ function swiftSyntaxNodeValue(node) {
13115
+ return swiftSyntaxDeclarationName(node, swiftSyntaxKind(node))
13116
+ ?? swiftSyntaxImportPath(node)
13117
+ ?? swiftSyntaxTypeName(node.type ?? node.returnClause?.type ?? node.extendedType)
13118
+ ?? swiftSyntaxLiteralValue(node);
13119
+ }
13120
+
13121
+ function swiftSyntaxDeclarationName(node, kind = swiftSyntaxKind(node)) {
13122
+ if (!node || typeof node !== 'object') return undefined;
13123
+ if (kind === 'InitializerDecl') return 'init';
13124
+ if (kind === 'DeinitializerDecl') return 'deinit';
13125
+ if (kind === 'SubscriptDecl') return 'subscript';
13126
+ if (kind === 'ExtensionDecl') {
13127
+ const extended = swiftSyntaxTypeName(node.extendedType ?? node.type ?? node.name);
13128
+ return extended ? `extension ${extended}` : undefined;
13129
+ }
13130
+ if (kind === 'OperatorDecl') return swiftSyntaxOperatorName(node, kind);
13131
+ for (const key of ['identifier', 'name', 'simpleName', 'typeName', 'id']) {
13132
+ const name = swiftSyntaxName(node[key]);
13133
+ if (name) return name;
13134
+ }
13135
+ const patternName = swiftSyntaxPatternName(node.pattern);
13136
+ if (patternName) return patternName;
13137
+ return undefined;
13138
+ }
13139
+
13140
+ function swiftSyntaxName(value) {
13141
+ if (!value) return undefined;
13142
+ if (typeof value === 'string') return value;
13143
+ if (typeof value.text === 'string') return value.text;
13144
+ if (typeof value.trimmedDescription === 'string') return value.trimmedDescription;
13145
+ if (typeof value.description === 'string' && !value.description.includes('[object Object]')) return value.description.trim();
13146
+ if (typeof value.identifier === 'string') return value.identifier;
13147
+ if (typeof value.name === 'string') return value.name;
13148
+ if (typeof value.value === 'string') return value.value;
13149
+ if (value.tokenKind && typeof value.tokenKind === 'object') return swiftSyntaxName(value.tokenKind);
13150
+ if (value.identifier && value.identifier !== value) return swiftSyntaxName(value.identifier);
13151
+ if (value.name && value.name !== value) return swiftSyntaxName(value.name);
13152
+ return undefined;
13153
+ }
13154
+
13155
+ function swiftSyntaxImportPath(node) {
13156
+ if (!node || typeof node !== 'object') return undefined;
13157
+ const path = node.importPath ?? node.path ?? node.modulePath ?? node.name;
13158
+ if (typeof path === 'string') return path;
13159
+ if (Array.isArray(path)) {
13160
+ return path.map((entry) => swiftSyntaxName(entry.name ?? entry.identifier ?? entry)).filter(Boolean).join('.');
13161
+ }
13162
+ if (path && typeof path === 'object') {
13163
+ if (Array.isArray(path.components)) return path.components.map((entry) => swiftSyntaxName(entry.name ?? entry.identifier ?? entry)).filter(Boolean).join('.');
13164
+ return swiftSyntaxName(path);
13165
+ }
13166
+ return undefined;
13167
+ }
13168
+
13169
+ function swiftSyntaxTypeName(value) {
13170
+ if (!value) return undefined;
13171
+ if (typeof value === 'string') return value;
13172
+ if (typeof value.trimmedDescription === 'string') return value.trimmedDescription;
13173
+ if (typeof value.description === 'string' && !value.description.includes('[object Object]')) return value.description.trim();
13174
+ if (typeof value.name === 'string') return value.name;
13175
+ if (typeof value.text === 'string') return value.text;
13176
+ if (value.baseType) {
13177
+ const base = swiftSyntaxTypeName(value.baseType);
13178
+ return base && value.name ? `${base}.${swiftSyntaxName(value.name)}` : base;
13179
+ }
13180
+ if (value.argumentList && Array.isArray(value.argumentList)) {
13181
+ const base = swiftSyntaxName(value.name) ?? swiftSyntaxTypeName(value.baseName);
13182
+ const args = value.argumentList.map((entry) => swiftSyntaxTypeName(entry.type ?? entry)).filter(Boolean);
13183
+ return base ? `${base}<${args.join(', ')}>` : undefined;
13184
+ }
13185
+ return swiftSyntaxName(value);
13186
+ }
13187
+
13188
+ function swiftSyntaxModifierNames(node) {
13189
+ const modifiers = node.modifiers ?? node.Modifiers;
13190
+ if (!modifiers) return [];
13191
+ if (Array.isArray(modifiers)) {
13192
+ return uniqueStrings(modifiers.map((entry) => typeof entry === 'string' ? entry : swiftSyntaxName(entry.name ?? entry.modifier ?? entry)).filter(Boolean));
13193
+ }
13194
+ if (typeof modifiers === 'string') return uniqueStrings(modifiers.split(/\s+/).filter(Boolean));
13195
+ if (typeof modifiers === 'object') {
13196
+ return uniqueStrings(Object.entries(modifiers)
13197
+ .filter(([, enabled]) => enabled === true)
13198
+ .map(([key]) => key));
13199
+ }
13200
+ return [];
13201
+ }
13202
+
13203
+ function swiftSyntaxAttributeNames(node) {
13204
+ const attributes = node.attributes ?? node.attributeList;
13205
+ if (!attributes) return [];
13206
+ if (Array.isArray(attributes)) {
13207
+ return uniqueStrings(attributes.map((entry) => typeof entry === 'string' ? entry : swiftSyntaxName(entry.attributeName ?? entry.name ?? entry)).filter(Boolean));
13208
+ }
13209
+ return [];
13210
+ }
13211
+
13212
+ function swiftSyntaxVariableNames(node) {
13213
+ const bindings = node.bindings ?? node.bindingSpecifier?.bindings ?? node.patternBindings;
13214
+ if (Array.isArray(bindings)) return bindings.map((binding) => swiftSyntaxPatternName(binding.pattern ?? binding)).filter(Boolean);
13215
+ const name = swiftSyntaxPatternName(node.pattern) ?? swiftSyntaxDeclarationName(node);
13216
+ return name ? [name] : [];
13217
+ }
13218
+
13219
+ function swiftSyntaxEnumCaseNames(node) {
13220
+ const elements = node.elements ?? node.caseElements ?? node.cases;
13221
+ if (Array.isArray(elements)) return elements.map((entry) => swiftSyntaxDeclarationName(entry, 'EnumCaseElement')).filter(Boolean);
13222
+ const name = swiftSyntaxDeclarationName(node);
13223
+ return name ? [name] : [];
13224
+ }
13225
+
13226
+ function swiftSyntaxPatternName(pattern) {
13227
+ if (!pattern) return undefined;
13228
+ if (typeof pattern === 'string') return pattern;
13229
+ return swiftSyntaxName(pattern.identifier ?? pattern.name ?? pattern.boundName ?? pattern.pattern ?? pattern);
13230
+ }
13231
+
13232
+ function swiftSyntaxTypeDeclarationKind(kind) {
13233
+ return kind === 'ClassDecl'
13234
+ || kind === 'StructDecl'
13235
+ || kind === 'EnumDecl'
13236
+ || kind === 'ProtocolDecl'
13237
+ || kind === 'ActorDecl';
13238
+ }
13239
+
13240
+ function swiftSyntaxTypeDeclarationSymbolKind(kind) {
13241
+ if (kind === 'ClassDecl') return 'class';
13242
+ if (kind === 'StructDecl') return 'struct';
13243
+ if (kind === 'EnumDecl') return 'enum';
13244
+ if (kind === 'ProtocolDecl') return 'protocol';
13245
+ if (kind === 'ActorDecl') return 'class';
13246
+ return 'type';
13247
+ }
13248
+
13249
+ function swiftSyntaxFunctionLikeKind(kind) {
13250
+ return kind === 'FunctionDecl'
13251
+ || kind === 'InitializerDecl'
13252
+ || kind === 'DeinitializerDecl'
13253
+ || kind === 'SubscriptDecl'
13254
+ || kind === 'OperatorDecl'
13255
+ || kind === 'PrecedenceGroupDecl';
13256
+ }
13257
+
13258
+ function swiftSyntaxHasBody(node) {
13259
+ return Boolean(node.body || node.accessorBlock || node.memberBlock || Array.isArray(node.statements));
13260
+ }
13261
+
13262
+ function swiftSyntaxOperatorName(node, kind) {
13263
+ if (kind === 'PrecedenceGroupDecl') return swiftSyntaxDeclarationName(node) ?? 'precedencegroup';
13264
+ const operatorToken = swiftSyntaxName(node.operatorIdentifier ?? node.operatorToken ?? node.name);
13265
+ return operatorToken ? `operator ${operatorToken}` : undefined;
13266
+ }
13267
+
13268
+ function swiftSyntaxLiteralValue(node) {
13269
+ const value = node.value ?? node.literal;
13270
+ if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return value;
13271
+ return undefined;
13272
+ }
13273
+
13274
+ function swiftSyntaxRecoveredKind(kind) {
13275
+ return kind === 'UnexpectedNodes'
13276
+ || kind === 'MissingToken'
13277
+ || kind === 'SkippedToken'
13278
+ || kind === 'Error'
13279
+ || /Unexpected|Missing|Skipped|Error/.test(String(kind));
13280
+ }
13281
+
13282
+ function swiftSyntaxProblemNode(node, kind) {
13283
+ return Boolean(
13284
+ node.isMissing
13285
+ || node.hasError
13286
+ || node.containsDiagnostics
13287
+ || node.containsSkippedText
13288
+ || node.presence === 'missing'
13289
+ || kind === 'UnexpectedNodes'
13290
+ || kind === 'MissingToken'
13291
+ || kind === 'SkippedToken'
13292
+ || kind === 'Error'
13293
+ );
13294
+ }
13295
+
13296
+ function swiftSyntaxConditionalCompilationKind(kind) {
13297
+ return /IfConfig|ConditionalCompilation|PoundIf|PoundElse|PoundElseif|PoundEndif/i.test(String(kind));
13298
+ }
13299
+
13300
+ function swiftSyntaxMacroKind(kind) {
13301
+ return /Macro/i.test(String(kind));
13302
+ }
13303
+
13304
+ function swiftGeneratedCodeMarker(node, kind) {
13305
+ if (node.generated || node.isGenerated) return true;
13306
+ const path = String(node.filePath ?? node.path ?? node.sourcePath ?? '');
13307
+ if (swiftGeneratedSourcePath(path)) return true;
13308
+ if (kind === 'Attribute') {
13309
+ const name = swiftSyntaxDeclarationName(node);
13310
+ if (name && /(^|\.)(Generated|CompilerGenerated|_spi)Attribute?$/.test(name)) return true;
13311
+ }
13312
+ return false;
13313
+ }
13314
+
13315
+ function swiftGeneratedSourcePath(path) {
13316
+ return typeof path === 'string' && /\.(g|generated)\.swift$/i.test(path);
13317
+ }
13318
+
13319
+ function swiftGeneratedCodeLoss(input, nodeId, span, options = {}, metadata = {}) {
13320
+ return {
13321
+ id: `loss_${idFragment(nodeId ?? input.sourcePath ?? 'swift')}_swift_generated_code`,
13322
+ severity: 'warning',
13323
+ phase: 'parse',
13324
+ sourceFormat: input.language,
13325
+ kind: 'generatedCode',
13326
+ message: 'Swift generated-source marker was imported; generated member provenance and source ownership require host evidence.',
13327
+ span,
13328
+ nodeId,
13329
+ metadata: {
13330
+ parser: options.parser,
13331
+ astFormat: options.astFormat,
13332
+ macroExpansionEvidence: swiftEvidenceSummary(options.macroExpansionEvidence),
13333
+ ...metadata
13334
+ }
13335
+ };
13336
+ }
13337
+
13338
+ function swiftEvidenceSummary(value) {
13339
+ if (!value) return undefined;
13340
+ if (Array.isArray(value)) return { entryCount: value.length };
13341
+ if (typeof value === 'string') return { value };
13342
+ if (typeof value === 'object') {
13343
+ const summary = {};
13344
+ if (typeof value.hash === 'string') summary.hash = value.hash;
13345
+ if (typeof value.solver === 'string') summary.solver = value.solver;
13346
+ if (Array.isArray(value.entries)) summary.entryCount = value.entries.length;
13347
+ if (Array.isArray(value.symbols)) summary.symbolCount = value.symbols.length;
13348
+ if (Array.isArray(value.references)) summary.referenceCount = value.references.length;
13349
+ if (Array.isArray(value.types)) summary.typeCount = value.types.length;
13350
+ if (Array.isArray(value.diagnostics)) summary.diagnosticCount = value.diagnostics.length;
13351
+ if (Array.isArray(value.macros)) summary.macroCount = value.macros.length;
13352
+ if (Array.isArray(value.packages)) summary.packageCount = value.packages.length;
13353
+ return Object.keys(summary).length ? summary : { present: true };
13354
+ }
13355
+ return { present: true };
13356
+ }
13357
+
12612
13358
  function declarationRecord(input, nativeNodeId, name, symbolKind, role = 'definition') {
12613
13359
  return {
12614
13360
  name: String(name),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",