Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "floating comments" to the AST #3544

Open
Tracked by #18561
matthewmueller opened this issue Sep 7, 2020 · 0 comments
Open
Tracked by #18561

Add "floating comments" to the AST #3544

matthewmueller opened this issue Sep 7, 2020 · 0 comments
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

Comments

@matthewmueller
Copy link
Contributor

matthewmueller commented Sep 7, 2020

Problem

In the Prisma Schema, we have two different kinds of comments, attached comments and floating comments.

Attached Comment

// This is attached to the model
model User {

  // This is attached to 
  // the field
  id Int @id

  title String // This is a side comment
}

These are comments that are above or to the side of field or model.

Floating Comment

// I float!

model User {

  // I float!
	
  title String
  // I float

}

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.

// This datamodel powers our recommendation engine.
// 
// Owners: 
//   Mark <mark@prisma.io>
//   Alice <alice@prisma.io>
//   Nicole <nicole@prisma.io>

model User {

}
@matthewmueller matthewmueller added kind/feature A request for a new feature. topic: schema tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema labels Sep 7, 2020
@janpio janpio added team/product tech/engines Issue for tech Engines. and removed tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema labels Sep 7, 2020
@pantharshit00 pantharshit00 added the team/client Issue for team Client. label Apr 22, 2021
@janpio janpio added team/schema Issue for team Schema. team/psl-wg labels Feb 10, 2022
@janpio janpio mentioned this issue Mar 29, 2023
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants