Skip to content
Kitbay

psl-ast-layers

Apache-2.0Updated on Nov 11, 202647,664GitHub stars

A contributor skill in the Prisma ORM repository for working with the syntax trees produced by its Prisma Schema Language parser, used by schema interpreters, the language server and formatters.

What the skill teaches

A contributor skill in the Prisma ORM repository for working with the syntax trees produced by its Prisma Schema Language parser, used by schema interpreters, the language server and formatters. It explains three layers: an immutable green tree for parser internals only, a red tree that adds offsets and parent links for moving around, and typed AST classes with getters such as name() and fields(), which are the default. Rules say when to move between layers, how to anchor on a cursor offset in the language server, and to add a missing getter to the AST class instead of working around it. It warns against re-stringifying the tree, reading green nodes, building arrays from lazy iterators and hand-written child searches.

Capabilities

  • Choose the right syntax tree layer
  • Navigate the tree with red-tree helpers
  • Resolve a cursor offset to a typed node
  • Add getters to typed AST classes