pub struct ModelBuilder { /* private fields */ }Expand description
Mutable model under construction. Entities are keyed: frontends that
meet the same symbol (tree-sitter, then SCIP) share one entity.
Relations are deduplicated on (from, kind, to, provenance); each
occurrence site is kept.
Ids passed to the setters must come from this builder.
Implementations§
Source§impl ModelBuilder
impl ModelBuilder
pub fn new() -> Self
Sourcepub fn entity(&mut self, key: &str, kind: EntityKind, name: &str) -> EntityId
pub fn entity(&mut self, key: &str, kind: EntityKind, name: &str) -> EntityId
Entity with key, created with kind and name if absent. An
existing entity keeps its kind and name.
pub fn get(&self, key: &str) -> Option<EntityId>
Sourcepub fn ids(&self) -> impl ExactSizeIterator<Item = EntityId> + use<>
pub fn ids(&self) -> impl ExactSizeIterator<Item = EntityId> + use<>
Ids of every entity, in creation order.
Sourcepub fn rekey(&mut self, id: EntityId, key: &str) -> Result<(), EntityId>
pub fn rekey(&mut self, id: EntityId, key: &str) -> Result<(), EntityId>
Gives id the key key (e.g. its SCIP symbol, found after a
syntactic frontend created it). Fails with the entity already
holding key, if another one does.
pub fn name(&self, id: EntityId) -> &str
pub fn parent(&self, id: EntityId) -> Option<EntityId>
pub fn file(&self, id: EntityId) -> Option<&str>
pub fn range(&self, id: EntityId) -> Option<Range>
pub fn name_range(&self, id: EntityId) -> Option<Range>
pub fn external(&self, id: EntityId) -> bool
pub fn key(&self, id: EntityId) -> &str
pub fn kind(&self, id: EntityId) -> EntityKind
pub fn set_kind(&mut self, id: EntityId, kind: EntityKind)
pub fn set_parent(&mut self, id: EntityId, parent: Option<EntityId>)
pub fn set_language(&mut self, id: EntityId, language: &LanguageId)
pub fn set_external(&mut self, id: EntityId, external: bool)
Sourcepub fn set_source(
&mut self,
id: EntityId,
file: &str,
range: Range,
name_range: Option<Range>,
)
pub fn set_source( &mut self, id: EntityId, file: &str, range: Range, name_range: Option<Range>, )
Where the entity is written; file relative to the analysed root.
pub fn set_prop(&mut self, id: EntityId, key: &str, value: impl Into<Value>)
pub fn props_mut(&mut self, id: EntityId) -> &mut Props
Sourcepub fn relate(
&mut self,
kind: &RelationKind,
from: EntityId,
to: EntityId,
provenance: Provenance,
)
pub fn relate( &mut self, kind: &RelationKind, from: EntityId, to: EntityId, provenance: Provenance, )
Asserts a relation without a site (inheritance read from metadata…).
Sourcepub fn occurrence(
&mut self,
kind: &RelationKind,
from: EntityId,
to: EntityId,
provenance: Provenance,
site: Range,
)
pub fn occurrence( &mut self, kind: &RelationKind, from: EntityId, to: EntityId, provenance: Provenance, site: Range, )
Asserts a relation at site, a range in from’s file: sites are
attributed to their innermost enclosing entity, so they share its file.