Repository navigation
TML-2893: add qualified-name, single-quote, and enum-block support to the CST parser - #849
Conversation
📝 WalkthroughWalkthroughThe PR introduces ChangesQualifiedName AST, Enum Removal, and String Literal Improvements
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
size-limit report 📦
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/1-framework/2-authoring/psl-parser/src/syntax/ast/declarations.ts`:
- Around line 11-15: The JSDoc comment for the NamespaceMemberAst type
declaration mentions enums as valid namespace members, but enums have been
removed from the type definition. Update the comment to remove the reference to
enums and keep only the items that are actually included in NamespaceMemberAst
(models, composite types, and extension block declarations), ensuring the
documentation accurately reflects what the type currently allows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: a1d2a9a1-e8e0-4ed8-ad37-cc618db11413
📒 Files selected for processing (17)
packages/1-framework/1-core/framework-components/src/shared/psl-extension-block.tspackages/1-framework/2-authoring/psl-parser/src/exports/syntax.tspackages/1-framework/2-authoring/psl-parser/src/parse.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast-helpers.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/attributes.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/declarations.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/expressions.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/identifier.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/qualified-name.tspackages/1-framework/2-authoring/psl-parser/src/syntax/ast/type-annotation.tspackages/1-framework/2-authoring/psl-parser/src/syntax/syntax-kind.tspackages/1-framework/2-authoring/psl-parser/src/tokenizer.tspackages/1-framework/2-authoring/psl-parser/test/parse-diagnostics.test.tspackages/1-framework/2-authoring/psl-parser/test/parse-document.test.tspackages/1-framework/2-authoring/psl-parser/test/parse-leaf.test.tspackages/1-framework/2-authoring/psl-parser/test/support.tspackages/1-framework/2-authoring/psl-parser/test/syntax/ast.test.ts
…) alongside legacy parser Signed-off-by: Serhii Tatarintsev <[email protected]>
…FunctionCallAst.qualifiedName→name Signed-off-by: Serhii Tatarintsev <[email protected]>
Main shipped the 0.14.0 publish bump (#843) and several follow-ups (TML-2916 #838, TML-2503 #839, TML-2787 #683, TML-2893 #849, ci-fix #847) while slice 1 was in review. Merge to pick them up. Resolution: - `skills/extension-author/.../0.13-to-0.14/instructions.md` — union of the slice's TML-2919 entry and main's TML-2916 entry as two distinct HTML-comment blocks, matching the file's per-ticket convention. Per the skill spec's rebase scenario (lines 122-130): existing entries in the just-shipped 0.13-to-0.14 directory may stay in place; we do not relocate the TML-2919 entry to 0.14-to-0.15. - Lockfile + example fixtures + apps + all other non-slice files — take main's side cleanly (the branch hadn't touched them; auto-merge resolved to main's content). `pnpm install` confirms the lockfile is consistent. - No `src/` conflicts — only the one instructions.md conflict above. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
#850) ## What Delivers the **PSL formatter** for Prisma Next, end to end: a deterministic pretty-printer engine plus the `prisma format` CLI command that runs it. **1. Engine** — `@prisma-next/psl-parser/format`: ```ts import { format, type FormatOptions, PslFormatError } from '@prisma-next/psl-parser/format'; format(source); // canonical PSL, LF, 2-space indent format(source, { indent: 'tab', newline: 'CRLF' }); ``` `format(source, options?) -> string` parses via the CST and re-emits canonical PSL. Pure string→string: no file I/O, no node built-ins, no `@prisma-next/config` dependency. **2. CLI** — `prisma format`: Reads `prisma-next.config.ts`; when the contract source is PSL (`config.contract.source.sourceFormat === 'psl'`), formats `config.contract.source.inputs[0]` **in place**. Non-PSL or absent sources are left untouched. Indent/newline come from an optional `formatter` config section; the system newline (`os.EOL`) is resolved at the CLI. Closes TML-2928 (the whole issue — both the engine and the CLI). ## Why Prisma Next authors hand-write and machine-emit PSL, but there was no canonical formatter for the new authoring stack. The new red/green CST preserves all trivia (whitespace, comments, newlines) as tokens, making it the right substrate for a lossless pretty-printer: re-emit a normalized, deterministic layout while retaining comments and the full token stream. ## Engine behaviour - **CST-based** (`parse` + typed AST wrappers); does not touch the legacy `parsePslDocument`. - **`indent`**: positive integer (spaces) or `'tab'`; default 2. - **`newline`**: `'LF'` (default) or `'CRLF'`, applied uniformly. - **Per-block alignment**: field-name→type column and trailing attributes aligned per block. - **Trivia preservation**: leading / trailing / dangling comments and author blank lines (collapsed to one, never adjacent to a brace). - **Blank line before block attributes**: one blank line always separates the last field from the first `@@` attribute (house style). - **Idempotence**: `format(format(x)) === format(x)`. - **Refuses** input that carries parse diagnostics (`PslFormatError`) rather than emitting best-effort output. ## Key decisions - **Engine ships inside `@prisma-next/psl-parser`** via a `./format` subpath — no separate package, no new runtime dependency. Engine option validation is hand-rolled (the option space is two enum-ish fields; a schema lib would have violated the package's no-new-deps constraint). The `formatter` **config** section, by contrast, is arktype-validated — `@prisma-next/config` already depends on arktype. - **`os.EOL` resolution lives only in the CLI.** The engine never reads `os`; the `prisma format` command resolves `config.formatter.newline ?? (os.EOL === '\r\n' ? 'CRLF' : 'LF')` and passes an explicit `newline` into the engine. - **PSL-ness is a structured discriminator, not a filename heuristic.** `ContractSourceProvider` carries an optional `sourceFormat: 'psl' | 'typescript'`; every first-party provider declares it (`prismaContract`/`mongoContract` → `'psl'`; the `typescript*`/`empty` helpers → `'typescript'`). The command formats only `'psl'` sources; anything else (incl. absent) is left untouched. - **Inline `//` comments are a hard break barrier.** `field Type //comment` followed by a continuation `@attribute` preserves the break rather than hoisting the attribute past the comment — matching Prettier, Biome, and rustfmt (a `//` comment runs to end-of-line; joining a later token onto its line is both a correctness and an idempotence hazard). ## Tests — side-by-side fixture pairs The formatter's integration oracle is a set of hand-authored **side-by-side pairs** under `test/format/fixtures/<case>/{input,expected}.prisma` — open a pair to *see* exactly what the formatter does. The test asserts `format(input) === expected`, idempotence, and that formatting actually happened. Cases cover alignment, comment preservation, the inline-comment hard break, blank-line handling, block-attribute spacing, enum/generic blocks, and the namespaced-type round-trip (`space:ns.Type`). The CLI is covered by an e2e journey (`format.e2e.test.ts`) proving format-in-place, leave-untouched, and refuse-on-unparseable, each asserting on-disk file state. ## Validation - `pnpm lint:deps` — no violations (engine takes no node built-ins; the CLI→engine edge is layering-safe). - `@prisma-next/psl-parser` — 529 tests, no type errors; fixture pairs produce no snapshot churn. - `@prisma-next/config` — 29 tests (discriminator + `formatter` section). - `@prisma-next/cli` — `prisma format` operation tests + the e2e journey green. (Note: ~9 pre-existing flakes in `version.test.ts` / `removed-verb-redirects.test.ts` are cold-boot subprocess-timeout fragility, unrelated to this work.) ## Base Targets `main`. The formatter consumes the fault-tolerant CST parser surface, which landed on `main` via #795 and #849; this branch was originally stacked on the pre-merge `psl-cst-parser` branch and has been rebased onto `main` now that the CST work is merged. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added PSL formatter to canonically format Prisma schema language code. * Added `format` CLI command with `--config` option to format PSL files in place. * Added formatter configuration options for indentation and line ending styles (tabs vs. spaces, LF vs. CRLF). * Format command only processes PSL sources; TypeScript contracts are skipped. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Serhii Tatarintsev <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
## Linked issue Refs [TML-2929](https://linear.app/prisma-company/issue/TML-2929) Branches off [#849](#849) (TML-2893, the CST parser `parse` + qualified-name/enum-block support), which is merged to `main`. ## At a glance PSL providers now build a resolved, scope-aware symbol table from the CST parser and hand that to the SQL and Mongo interpreters instead of the legacy line-based parser's pre-resolved AST: ```ts const { document, sourceFile, diagnostics } = parse(schema); const { table: symbolTable, diagnostics: symbolDiagnostics } = buildSymbolTable({ document, sourceFile, scalarTypes: [...scalarTypeDescriptors.keys()], pslBlockDescriptors: authoringContributions.pslBlockDescriptors, }); // symbolTable.topLevel: namespaces / scalars / typeAliases / blocks / models / compositeTypes, // each a keyed record discriminated by `kind`; every symbol carries `.node` (its CST AST node). // Fields and named type bindings carry resolved type/attribute shape; blocks carry their resolved PslExtensionBlock. // Parse diagnostics and symbol-table diagnostics are surfaced together by the providers, not merged at the source. ``` Before this PR, both interpreters consumed `parsePslDocument`'s pre-resolved `PslDocumentAst`. That parser — and its ~3.5k lines — is now gone; the CST `parse` is the only parser in the package, and `buildSymbolTable` owns the resolution layer the old parser used to provide. ## Decision This PR carries four substantive pieces: 1. **A new resolution layer, `buildSymbolTable`,** co-located with the CST `parse` in `@prisma-next/psl-parser`. It turns the CST `DocumentAst` into the keyed, scope-aware symbol table the interpreters need, rebuilt on the CST. It is fault-tolerant, keeps parser diagnostics separate from symbol-table diagnostics, and is the sole owner of `PSL_DUPLICATE_DECLARATION` for same-name collisions (first-wins, collide-regardless-of-kind). 2. **Resolution moved into the symbol table.** Field/named-type resolution and extension-block reconstruction now happen once in `@prisma-next/psl-parser`: fields carry split qualified type references, optional/list/constructor state, rendered attributes, and malformed-type markers; scalar/type-alias bindings carry their resolved shape; block symbols carry descriptor-classified `PslExtensionBlock` values built with the required `pslBlockDescriptors` input. 3. **Both interpreters migrated** (SQL then Mongo) to consume the symbol table directly, reaching diagnostic feature parity with the legacy path. The per-package CST field/view adapters and SQL enum-block reconstruction were removed after their responsibilities moved to `buildSymbolTable`. 4. **`parsePslDocument` deleted** — the function, its ~1.6k-line implementation, its `./parser` export, and its ~1.8k lines of legacy tests. The legacy `PslDocumentAst` types stay because the introspection printer still consumes them; only the legacy parser is removed. ## How it fits together 1. **Build the symbol table** — [`psl-parser/src/symbol-table.ts`](packages/1-framework/2-authoring/psl-parser/src/symbol-table.ts) walks the CST `DocumentAst`, buckets declarations into keyed records discriminated by `kind`, nests namespace members and block fields under their owner, classifies `types {}` bindings as scalar-vs-alias against the target's `scalarTypes`, and emits duplicate-declaration diagnostics. Every symbol references its originating CST node. 2. **Resolve field and named-type shape once** — [`psl-parser/src/resolve.ts`](packages/1-framework/2-authoring/psl-parser/src/resolve.ts) centralizes the qualified-name split, optional/list/constructor handling, attribute rendering, and malformed-type cascade guard that the SQL and Mongo packages used to duplicate in package-local view layers. 3. **Resolve extension blocks once** — [`psl-parser/src/block-reconstruction.ts`](packages/1-framework/2-authoring/psl-parser/src/block-reconstruction.ts) reconstructs descriptor-classified `PslExtensionBlock` values for `BlockSymbol.block`; [`psl-parser/src/extension-block.ts`](packages/1-framework/2-authoring/psl-parser/src/extension-block.ts) keeps descriptor lookup and validation helpers. SQL now reads `BlockSymbol.block` directly, so its old `enum-block.ts` reconstruction is gone. 4. **Walk the table in each interpreter** — [SQL `interpreter.ts`](packages/2-sql/2-authoring/contract-psl/src/interpreter.ts) and [Mongo `interpreter.ts`](packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts) consume the symbol table instead of `document.ast.namespaces`, preserving every diagnostic code while removing the defensive duplicate-model throw and the interpreter-local diagnostic dedupe helpers that existed only because duplicate ownership was not yet clean. 5. **Wire the providers** — [SQL `provider.ts`](packages/2-sql/2-authoring/contract-psl/src/provider.ts) and [Mongo `provider.ts`](packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts) call `parse` + `buildSymbolTable`, pass target scalar descriptors and block descriptors, seed both diagnostic lists into the interpreter, and emit the combined diagnostic set in one run (no fail-before-interpret short-circuit). 6. **Delete the legacy parser** — with no consumer left, `parsePslDocument` and its tests are removed; the printer's round-trip tests are reworked to build their legacy AST inputs without it. ## Reviewer notes - **Largest diff is still subtractive.** The headline deletion removes [`parser.ts`](packages/1-framework/2-authoring/psl-parser/src/parser.ts) (−1642), [`parser.test.ts`](packages/1-framework/2-authoring/psl-parser/test/parser.test.ts) (−1507), and [`parser-enum.test.ts`](packages/1-framework/2-authoring/psl-parser/test/parser-enum.test.ts) (−329). The PR is net negative overall. Spot-check the export prune in [`psl-parser/src/exports/index.ts`](packages/1-framework/2-authoring/psl-parser/src/exports/index.ts): only `parsePslDocument` / `ParsePslDocumentInput` / `ParsePslDocumentResult` and the dead parser subpath were removed; still-used `Psl*` types remain exported. - **The symbol table now owns resolution, not just bucketing.** Earlier slices temporarily let interpreters rebuild field views and enum blocks from raw CST nodes. Follow-up slices deliberately moved those responsibilities into `buildSymbolTable`, matching the old parser's single-resolver shape and deleting the downstream duplication. - **Two diagnostic lists, surfaced together.** `parse` diagnostics and `buildSymbolTable` diagnostics remain separate at the source (deliberate), then providers seed both into the interpreter so callers see one combined result. There is no longer SQL/Mongo interpreter-local diagnostic dedupe; probe-backed validation showed it was collapsing nothing real after `buildSymbolTable` became the sole duplicate-declaration owner. - **`policy_select` is preserved, not dropped.** Descriptor-typed extension blocks reconstruct from the CST via the symbol table and are validated with the framework's standalone `validateExtensionBlock`. The `declarative-policy-select.round-trip.test.ts` rework drives the real `parse → buildSymbolTable → validate → factory → print` pipeline over malformed text; its diagnostic assertions are real, not laundered. - **A few diagnostic spans/wording shifted; codes did not.** Where the CST gives a more precise anchor (for example duplicate enum members or over-qualified types), spans moved, but every diagnostic code a consumer or test keys on is preserved. - **One accepted behavior change:** an over-qualified field type (`a.b.c`) now surfaces both `PSL_INVALID_QUALIFIED_NAME` (from the CST parser, native) and `PSL_INVALID_QUALIFIED_TYPE` (from symbol-table field resolution); legacy emitted only the latter. Both are accurate; collapsing to one remains a noted follow-up. ## Compatibility / migration / risk - No `contract.json` / IR shape change; this is a parser-and-interpreter-internal migration. The legacy `PslDocumentAst` types remain exported for the introspection printer. - The `@prisma-next/psl-parser` `./parser` subpath export is removed. No code consumed it; downstream code should import `parse` and `buildSymbolTable` instead, and pass both target scalar types and `pslBlockDescriptors` when constructing a symbol table. - `buildSymbolTable` is now the single place to look for duplicate-declaration ownership, field/named-type resolution, and block reconstruction. That reduces parity risk between SQL and Mongo, but it also makes symbol-table tests the primary coverage surface for resolution behavior. ## Testing performed Latest validation on final pushed HEAD: - `pnpm --filter @prisma-next/psl-parser test` — clean: 12 files / 368 tests. - `pnpm --filter @prisma-next/sql-contract-psl test` — clean: 17 files / 251 tests. - `pnpm --filter @prisma-next/mongo-contract-psl test` — clean: 4 files / 137 tests. - `pnpm build` — clean: 66/66 tasks. - `pnpm typecheck` — clean: 138/138 tasks. - `pnpm lint:deps` — clean. - `pnpm test:packages` — attempted on final HEAD, but not green in this local environment: Mongo memory-server cannot resolve a `mongod` binary on NixOS (`Unknown/unsupported linux "nixos" id_like's: []`) and several CLI tests hit their 500ms timeout. This matches the already-recorded environmental class; CI with the proper Mongo/CLI environment should be used as the full package-suite authority. - Required cleanup checks on final HEAD: `rg "throw new Error\(.*duplicate model" packages/2-sql/2-authoring/contract-psl/src` empty; `rg "function dedupeDiagnostics" packages` empty. ## Follow-ups - Collapse the doubled qualified-name codes (`PSL_INVALID_QUALIFIED_NAME` + `PSL_INVALID_QUALIFIED_TYPE`) on over-qualified types to a single code — decide which layer owns the rejection (touches the shared CST parser). - Revisit whether `BlockSymbol.block: PslExtensionBlock` is the right long-term carried shape, or whether the symbol table should expose a leaner resolved block representation. This PR restores single ownership of block reconstruction; it does not settle the long-term shape question. ## Alternatives considered - **Pointing the interpreters straight at the raw CST** (no symbol table) — would scatter name-resolution, bucketing, duplicate detection, field resolution, and block reconstruction across both interpreters independently, a parity risk. The symbol table centralizes it in one resolution layer. - **Keeping package-local CST read/view adapters** — initially useful to derisk the SQL canary, but it duplicated the legacy parser's resolved read-set in both interpreter packages. Follow-up slices moved that resolution into `buildSymbolTable` and deleted the adapters. - **Keeping SQL enum-block reconstruction downstream** — rejected after `BlockSymbol.block` became descriptor-classified at symbol-table construction. SQL now consumes the same resolved block shape as every other consumer. - **Merging the two diagnostic lists at the source** inside `buildSymbolTable` — rejected; keeping parser diagnostics and symbol-table diagnostics separate lets callers attribute whether a problem came from parsing or resolution while still surfacing both at the provider boundary. - **Retiring the `policy_select` round-trip test** when it appeared to depend on the deleted parser — rejected; the capability was rebuildable on the CST, so we wired it rather than lose coverage. ## Checklist - [x] Commits are signed off (DCO). - [x] Read CONTRIBUTING.md. - [x] Tests updated / added for the change. - [x] PR title follows the `TML-NNNN: …` convention. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added scope-aware `PSL_DUPLICATE_DECLARATION` diagnostics with first-wins behavior and reporting on the later declaration span. * Updated PSL authoring and contract generation flow to use a provider-driven `parse(...)` + `buildSymbolTable(...)` pipeline. * **Bug Fixes** * Reduced diagnostic cascades by halting downstream processing for malformed type information. * **Documentation** * Refreshed PSL parser public API docs and removed legacy `parsePslDocument` entry points/subpath exports. * **Tests** * Expanded/adjusted PSL symbol-table and SQL/Mongo interpreter test coverage to match the new pipeline. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Serhii Tatarintsev <[email protected]>
Linked issue
Refs TML-2893 — the PSL-parser replacement effort. The fault-tolerant CST parser itself already landed in #795; this PR fills in the parser functionality that was still missing, extending the existing CST parser with qualified names, single-quoted strings, and enum-block parsing.
At a glance
The CST parser already parsed bare names; this PR teaches it the qualified forms every downstream consumer needs — parsed as one
QualifiedNamenode:Before this PR these qualified positions were handled by ad-hoc bounded-lookahead patches; now
parseQualifiedNameproduces a uniformQualifiedNameAst([space ':']? Ident ('.' Ident)*) wherever a qualified name can appear — type references, constructor callees, function-call callees, and@@-attribute names.Decision
This PR extends the existing fault-tolerant CST parser with the functionality it was missing, leaving the legacy
parsePslDocumentuntouched:QualifiedNameCST node +parseQualifiedName. One parser and one AST node (QualifiedNameAst) for every qualified position, replacing the previous per-site lookahead handling. EmitsPSL_INVALID_QUALIFIED_NAMEfor malformed over-qualified names.'…'as well as"…", andisTerminatedStringLiteralhandles both quote styles.parseEnumpath and itsEnumDeclarationAst/EnumValueDeclarationAstnodes are gone; anenumblock now parses as aGenericBlockDeclarationAst(which also gained@@-attribute support inside generic-block members).{ "key": value }), not just identifiers.The CST parser core (
parse,SourceFile, the red/green tree) is not introduced here — it predates this branch. This PR is purely parser-functionality: the legacyparsePslDocumentand its consumers (the SQL/Mongo interpreters) are untouched.How it fits together
QualifiedNamebecomes a first-class node —syntax/ast/qualified-name.tsaddsQualifiedNameAstwithspace/namespace/identifier/path/isOverQualifiedaccessors;syntax-kind.tsadds theQualifiedNamekind;exports/syntax.tsexposes it.parse.tsaddsparseQualifiedName/parseQualifiedSegmentsand rewires type-annotation, function-call, and@@-attribute parsing through it, retiring the bounded-lookahead patch.FieldAttributeAst.name(),ModelAttributeAst.name(), andTypeAnnotationAst.name()now returnQualifiedNameAst;FunctionCallAstgainsname()/path();ObjectFieldAstgains string-literal key support.parseEnumand the enum AST classes are removed;GenericBlockDeclarationAstgainsattributes()soenum(and other extension blocks) parse generically.PSL_INVALID_QUALIFIED_NAMEis added toframework-components'sPslDiagnosticCode(alongside, not replacing, the existingPSL_INVALID_QUALIFIED_TYPEthe legacy parser uses).What lands in this PR
syntax/ast/qualified-name.ts(new)QualifiedNameAst— the unified qualified-name nodeparse.tsparseQualifiedName+ rewiring of type/attribute/call parsing; removal ofparseEnum; string-literal object keystokenizer.tssyntax/ast/{attributes,expressions,type-annotation,declarations,identifier}.tsQualifiedNameAst;GenericBlockDeclarationAst.attributes(); enum AST classes removedsyntax/syntax-kind.ts,exports/syntax.tsQualifiedNamekind; export ofQualifiedNameAst/printSyntaxframework-components/.../psl-extension-block.tsPSL_INVALID_QUALIFIED_NAMEcodetest/parse-*.test.ts,syntax/ast.test.tsparser.ts/parsePslDocumentReviewer notes
parse.ts/tokenizer.ts/syntax/show as modified, not added. The only new file isqualified-name.ts.parsePslDocumentand its consumers (SQL/Mongo interpreters) are untouched; this PR only changes the parser surface.enumno longer has a dedicated AST node; it parses as aGenericBlockDeclarationAst. Tests assert the generic-block shape.PSL_INVALID_QUALIFIED_NAMEis added (alongside the existingPSL_INVALID_QUALIFIED_TYPE); no other diagnostic codes change.aslint info attokenizer.ts:69(info-level on the ratchet, not introduced here).Compatibility / migration / risk
Additive to the parser surface: the new
QualifiedNameAstand the qualified-name handling are new;parsePslDocumentand the./parserentry are unchanged, so no interpreter is migrated and contract output is identical to base. The one behavioral shape change is internal to the CST (enum → generic block), exercised by the parser tests; no contract consumer observes it on this branch.Verification
pnpm --filter @prisma-next/psl-parser build— green.pnpm --filter @prisma-next/psl-parser test— CSTparse-*/syntax/astsuites + the retained legacyparsersuites.pnpm --filter @prisma-next/sql-contract-psl typecheck,@prisma-next/mongo-contract-psl typecheck— green, unchanged (still on the legacy parser).pnpm build(full),pnpm typecheck(full workspace),pnpm lint:deps— green.Alternatives considered
@@-attribute) re-implemented its own lookahead. A singleQualifiedNamenode +parseQualifiedNamecollapses them to one uniform shape.enumAST node. Rejected: enum is being reframed as an extension/generic block elsewhere in the effort; routing it throughGenericBlockDeclarationAstremoves a parallel code path rather than maintaining two.Checklist
$TICKET_ID: <title>convention.