Add "floating comments" to the AST #3544
Labels
kind/feature
A request for a new feature.
team/client
Issue for team Client.
team/psl-wg
team/schema
Issue for team Schema.
tech/engines
Issue for tech Engines.
topic: comments
topic: dmmf
topic: schema
Problem
In the Prisma Schema, we have two different kinds of comments, attached comments and floating comments.
Attached Comment
These are comments that are above or to the side of field or model.
Floating Comment
Floating comments are comments that are not above or to the side of a field or model.
Currently floating comments aren't added to the AST. This means they are lost when we write tools that operate on the Prisma Schema. Today, we're running into this with re-introspect, but this is a general problem.
Note: we have another dimension to this with triple comments
///
. In this specific context, they would behave the same way as//
. They can be ignored for this issue.Suggested solution
My preference would be to fix the AST with a distinct Comment node for floating comments. Since our Schema language is rather simple, we'd need Comment nodes in only two places: outside the blocks and inside.
Alternatives
Warning about free-floating comments has also been suggested. prisma/language-tools#446
I'd prefer we didn't go this way because 1. it's surprising and 2. there are valid use cases for floating comments.
The text was updated successfully, but these errors were encountered: