Hovering a name in a `.prisma` file now shows what it is and, where
available, its documentation.
## What users see
| Hover over | Shows |
|---|---|
| A model, composite type, field, named type or block, at its
declaration or at any reference to it (including from another file) | A
`prisma` code line for the declaration (`model User`, `email String
@unique`, `policy ReadOwn`), followed by the `///` doc comment written
above it |
| A model or field attribute (`@relation`, `@@index`) | The attribute's
signature, the same one signature help shows, followed by its
documentation |
| A contributed type (`pg.Varchar`) | Its documentation, or
`pg.Varchar(length: number)` when it has none |
| A block keyword (`policy`) | The keyword's documentation, or nothing
when it has none |
| A namespace, a cross-space reference, or a name that does not resolve
| Nothing |
```prisma
/// A person who can sign in.
model User {
id Int @id
/// Primary contact address.
email String @unique
}
```
## `///` doc comments
A doc comment is the run of `///` lines directly above a declaration.
The run ends at a blank line or at a plain `//` comment.
It is read by a `docComment()` method on the PSL AST classes that can
carry one: models, composite types, fields, named types and generic
blocks. A `HasDocComment` interface declares the method. The comment is
read when the method is called, so parsing is unchanged. For now the
language server is the only caller; the symbol table, binder symbols and
the contract do not carry the documentation.
## How
Hover reads the binder's resolution for the token under the cursor, so
it describes the same symbol diagnostics use. The binder now also
records each declaration's symbol on its name (models, composite types,
fields, named types and blocks; not namespaces). As a result, hovering
`User` in `model User {` and in `author User` go through the same
lookup. Existing `symbolForNode` callers only ask about reference
positions, so they are unaffected. The SQL and Mongo `create-binder`
tests list every resolution in a sample schema, so their expected lists
now include the declaration-name entries. The attribute signature line
comes from the same code signature help uses. Its label rendering was
extracted, and signature-help behaviour and tests are unchanged.
## Scope
- Changes `@internal/language-server`. In psl-parser it adds
`docComment()` / `HasDocComment` on the AST and makes the binder record
declarations on their name nodes.
- Not included: hover on argument keys (`references:`), function names
(`autoincrement`), constants (`Cascade`) and block attributes. Those
need new binder symbols and come in the next slice.
- Manual QA over the full hover table is planned for that slice, once
every hover kind exists.
## Verification
- `typecheck`, `test` and `lint` pass for `@internal/psl-parser` (1233
tests) and `@internal/language-server` (827 tests). `pnpm lint:deps`
passes. In `pnpm test:packages`, the only failures are three packaging
tarball tests, which fail with `ERR_PNPM_TRUST_DOWNGRADE` during a live
`pnpm install`; they are unrelated to this change.
- `hover.test.ts` covers every row above.
`psl-parser/test/syntax/doc-comment.test.ts` covers `docComment()` on
each class and the cases where a `///` run ends. `server.test.ts`
asserts `hoverProvider: true` and sends one hover request through the
server.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Hover over declarations and references to view relevant names, types,
signatures, and documentation in the language server.
* Hover information is available for models, fields, types, blocks,
attributes, and contributed types where applicable.
* **Improvements**
* Signature help now identifies parameter labels more precisely,
including positional parameters.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>