Struct parser_database::ast::SchemaAst
source · pub struct SchemaAst {
pub tops: Vec<Top>,
}
Expand description
AST representation of a prisma schema.
This module is used internally to represent an AST. The AST’s nodes can be used during validation of a schema, especially when implementing custom attributes.
The AST is not validated, also fields and attributes are not resolved. Every node is annotated with its location in the text representation. Basically, the AST is an object oriented representation of the datamodel’s text. Schema = Datamodel + Generators + Datasources
Fields§
§tops: Vec<Top>
All models, enums, composite types, datasources, generators and type aliases.
Implementations§
source§impl SchemaAst
impl SchemaAst
sourcepub fn find_at_position(&self, position: usize) -> SchemaPosition<'_>
pub fn find_at_position(&self, position: usize) -> SchemaPosition<'_>
Find the AST node at the given position (byte offset).
sourcepub fn find_top_at_position(&self, position: usize) -> Option<TopId>
pub fn find_top_at_position(&self, position: usize) -> Option<TopId>
Do a binary search for the Top
at the given byte offset.
source§impl SchemaAst
impl SchemaAst
sourcepub fn iter_tops(&self) -> impl Iterator<Item = (TopId, &Top)>
pub fn iter_tops(&self) -> impl Iterator<Item = (TopId, &Top)>
Iterate over all the top-level items in the schema.
sourcepub fn sources(&self) -> impl Iterator<Item = &SourceConfig>
pub fn sources(&self) -> impl Iterator<Item = &SourceConfig>
Iterate over all the datasource blocks in the schema.
sourcepub fn generators(&self) -> impl Iterator<Item = &GeneratorConfig>
pub fn generators(&self) -> impl Iterator<Item = &GeneratorConfig>
Iterate over all the generator blocks in the schema.
Trait Implementations§
source§impl Index<AttributeContainer> for SchemaAst
impl Index<AttributeContainer> for SchemaAst
source§impl Index<AttributeId> for SchemaAst
impl Index<AttributeId> for SchemaAst
source§impl Index<CompositeTypeId> for SchemaAst
impl Index<CompositeTypeId> for SchemaAst
§type Output = CompositeType
type Output = CompositeType
source§fn index(
&self,
index: CompositeTypeId
) -> &<SchemaAst as Index<CompositeTypeId>>::Output
fn index( &self, index: CompositeTypeId ) -> &<SchemaAst as Index<CompositeTypeId>>::Output
container[index]
) operation. Read more