pub struct Program {
pub settings: Option<Settings>,
pub global_variables: Vec<Variable>,
pub player_variables: Vec<Variable>,
pub subroutines: Vec<Subroutine>,
pub rules: Vec<Rule>,
/* private fields */
}Expand description
A complete Workshop program built from Workshop concepts.
Fields§
§settings: Option<Settings>§global_variables: Vec<Variable>§player_variables: Vec<Variable>§subroutines: Vec<Subroutine>§rules: Vec<Rule>Implementations§
Source§impl Program
impl Program
Sourcepub fn element_count(
&self,
catalog: &Catalog,
) -> Result<ElementCountReport, ElementCountError>
pub fn element_count( &self, catalog: &Catalog, ) -> Result<ElementCountReport, ElementCountError>
Count the canonical Workshop target represented by this program.
Source§impl Program
impl Program
pub fn new() -> Self
Sourcepub fn add_file(&mut self, file: SourceFile) -> FileId
pub fn add_file(&mut self, file: SourceFile) -> FileId
Register a source file and return its public file identity.
pub fn global_variable(&mut self, variable: Variable) -> &mut Self
pub fn player_variable(&mut self, variable: Variable) -> &mut Self
pub fn subroutine(&mut self, subroutine: Subroutine) -> &mut Self
pub fn rule(&mut self, rule: Rule) -> &mut Self
Sourcepub fn source(&self, file: FileId) -> Option<&SourceDocument>
pub fn source(&self, file: FileId) -> Option<&SourceDocument>
Return the retained source document for a parsed file.
Sourcepub fn set_rule_span(
&mut self,
rule: usize,
span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_rule_span( &mut self, rule: usize, span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored span of a public rule.
Sourcepub fn set_condition_span(
&mut self,
rule: usize,
condition: usize,
span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_condition_span( &mut self, rule: usize, condition: usize, span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored span of a public rule condition value.
Sourcepub fn set_action_span(
&mut self,
rule: usize,
action: usize,
span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_action_span( &mut self, rule: usize, action: usize, span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored span of a public action in its linear rule order.
Sourcepub fn set_action_argument_span(
&mut self,
rule: usize,
action: usize,
argument: usize,
span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_action_argument_span( &mut self, rule: usize, action: usize, argument: usize, span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored span of a direct value argument of a public action.
Sourcepub fn set_global_variable_spans(
&mut self,
variable: usize,
span: Option<Span>,
name_span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_global_variable_spans( &mut self, variable: usize, span: Option<Span>, name_span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored and identifier spans of a global variable.
Sourcepub fn set_player_variable_spans(
&mut self,
variable: usize,
span: Option<Span>,
name_span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_player_variable_spans( &mut self, variable: usize, span: Option<Span>, name_span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored and identifier spans of a player variable.
Sourcepub fn set_subroutine_spans(
&mut self,
subroutine: usize,
span: Option<Span>,
name_span: Option<Span>,
) -> Result<(), ProvenanceError>
pub fn set_subroutine_spans( &mut self, subroutine: usize, span: Option<Span>, name_span: Option<Span>, ) -> Result<(), ProvenanceError>
Attach the authored and identifier spans of a subroutine.
Sourcepub fn rule_span(&self, rule: usize) -> Option<Span>
pub fn rule_span(&self, rule: usize) -> Option<Span>
Return the authored span of a public rule, when source metadata exists.
Sourcepub fn condition_span(&self, rule: usize, condition: usize) -> Option<Span>
pub fn condition_span(&self, rule: usize, condition: usize) -> Option<Span>
Return the authored span of a public rule condition value.
Sourcepub fn action_span(&self, rule: usize, action: usize) -> Option<Span>
pub fn action_span(&self, rule: usize, action: usize) -> Option<Span>
Return the authored span of a public action in its linear rule order.
Sourcepub fn action_argument_span(
&self,
rule: usize,
action: usize,
argument: usize,
) -> Option<Span>
pub fn action_argument_span( &self, rule: usize, action: usize, argument: usize, ) -> Option<Span>
Return the authored span of a direct value argument of a public action.
Sourcepub fn edit_source(
&self,
span: Span,
replacement: impl Into<String>,
) -> Result<SourceEdit, SourceEditError>
pub fn edit_source( &self, span: Span, replacement: impl Into<String>, ) -> Result<SourceEdit, SourceEditError>
Create a checked source edit through the authored source attached to this canonical program.
Sourcepub fn validate(&self) -> Result<(), WorkshopError>
pub fn validate(&self) -> Result<(), WorkshopError>
Validate the structural invariants of the canonical program.
Sourcepub fn semantic_issues(&self, catalog: &Catalog) -> Vec<SemanticIssue>
pub fn semantic_issues(&self, catalog: &Catalog) -> Vec<SemanticIssue>
Report constructs that are structurally preserved but not fully understood by the canonical catalog.