import type { SyntaxNode } from '../types.js'; import type { SupportedLanguage } from '../languages/registry.js'; /** * Shared fixture sources + golden-node serialization for the compat * deserializer's regression tests (compat.test.ts) and its fixture * generator (scripts/generate-compat-golden-fixtures.ts). Kept in one place * so the sources used to *generate* __fixtures__/*.json are always the same * ones used to *verify* against them at test time -- if a source here ever * changes, regenerate the fixtures (see that script's header) rather than * hand-editing the JSON. */ export interface Fixture { name: string; lang: SupportedLanguage; source: string; } export declare const TS_SOURCE = "\nimport { helper } from './helper';\n\nexport interface Greeter {\n greet(name: string): string;\n}\n\nexport class Greeting implements Greeter {\n greet(name: string): string {\n return helper(name);\n }\n}\n"; export declare const PYTHON_SOURCE = "import os\n\ndef helper(x):\n return x + 1\n\nclass Greeter:\n def greet(self, name):\n return helper(name)\n"; export declare const KOTLIN_SOURCE = "import kotlinx.coroutines.delay\n\nclass Greeter {\n fun greet(name: String): String {\n return \"hello \" + name\n }\n}\n"; export declare const PHP_SOURCE = " String\n}\n\nclass Greeter: Greeting {\n private let name: String\n\n init(name: String) {\n self.name = name\n }\n\n func message() -> String {\n return \"hello \" + name\n }\n\n func add(a: Int, b: Int) -> Int {\n return a + b\n }\n\n subscript(index: Int) -> String {\n return message()\n }\n}\n"; export declare const FIXTURES: Fixture[]; /** * Field names actually read via childForFieldName across * ast/languages/*.ts and ast/extractors/symbol-helpers.ts. */ export declare const FIELDS_TO_CHECK: readonly ["body", "name", "parameters", "return_type", "condition", "operator", "function", "definition"]; export interface GoldenFieldValue { type: string; text: string; } export interface GoldenNode { type: string; isNamed: boolean; startIndex: number; endIndex: number; startPosition: { row: number; column: number; }; endPosition: { row: number; column: number; }; namedChildCount: number; childCount: number; /** * Only populated for named LEAF nodes (childCount === 0). A non-leaf * node's text is just the concatenation of its descendants' text (already * covered by their own entries), and `text` is itself a pure function of * (source, startIndex, endIndex) -- capturing it on every node would * mostly just re-encode the source string over and over across a deeply * nested tree. Leaf text is kept because it's still a real regression * guard: a bug in CompatSyntaxNode's UTF-16 slicing (the CRLF / non-ascii * fixtures exist specifically to catch that) could shift indices in a * self-consistent way that only shows up by comparing actual sliced text. */ text: string | null; /** Omitted when every FIELDS_TO_CHECK lookup on this node is null. */ fields?: Record; } export interface GoldenTree { hasError: boolean; nodes: GoldenNode[]; } /** * Flattens `root` into a pre-order (DFS over ALL children, named or not -- * matching the original dual-backend test's traversal) array of * GoldenNodes. A flat array keeps the committed JSON fixture reviewable as * a simple list rather than a deeply nested tree. */ export declare function flattenTree(root: SyntaxNode): GoldenNode[]; export declare function toGoldenTree(root: SyntaxNode, hasError: boolean): GoldenTree; /** * Verifies the childForFieldName reference-equality invariant * (native-parser.md section 2.5): a field lookup must return the SAME * object already present in `children`, not a fresh reconstruction. This * is a native-only structural invariant -- it doesn't depend on any * golden/legacy comparison, so it's checked live against the tree under * test rather than baked into the fixture JSON. * * @returns a list of "{path} field \"{field}\"" violation descriptions; * empty means the invariant holds everywhere. */ export declare function findFieldReferenceViolations(root: SyntaxNode, rootPath?: string): string[]; //# sourceMappingURL=compat-fixtures.d.ts.map