pub enum DocumentItem<N: TreeNode = SyntaxNode> {
Import(ImportStatement<N>),
Struct(StructDefinition<N>),
Task(TaskDefinition<N>),
Workflow(WorkflowDefinition<N>),
}Expand description
Represents a document item.
Variants§
Import(ImportStatement<N>)
The item is an import statement.
Struct(StructDefinition<N>)
The item is a struct definition.
Task(TaskDefinition<N>)
The item is a task definition.
Workflow(WorkflowDefinition<N>)
The item is a workflow definition.
Implementations§
Source§impl<N: TreeNode> DocumentItem<N>
impl<N: TreeNode> DocumentItem<N>
Sourcepub fn can_cast(kind: SyntaxKind) -> boolwhere
Self: Sized,
pub fn can_cast(kind: SyntaxKind) -> boolwhere
Self: Sized,
Sourcepub fn cast(inner: N) -> Option<Self>
pub fn cast(inner: N) -> Option<Self>
Casts the given node to DocumentItem.
Returns None if the node cannot be cast.
Sourcepub fn as_import_statement(&self) -> Option<&ImportStatement<N>>
pub fn as_import_statement(&self) -> Option<&ImportStatement<N>>
Attempts to get a reference to the inner ImportStatement.
- If
selfis aDocumentItem::Import, then a reference to the innerImportStatementis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_import_statement(self) -> Option<ImportStatement<N>>
pub fn into_import_statement(self) -> Option<ImportStatement<N>>
Consumes self and attempts to return the inner ImportStatement.
- If
selfis aDocumentItem::Import, then the innerImportStatementis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_struct_definition(&self) -> Option<&StructDefinition<N>>
pub fn as_struct_definition(&self) -> Option<&StructDefinition<N>>
Attempts to get a reference to the inner StructDefinition.
- If
selfis aDocumentItem::Struct, then a reference to the innerStructDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_struct_definition(self) -> Option<StructDefinition<N>>
pub fn into_struct_definition(self) -> Option<StructDefinition<N>>
Consumes self and attempts to return the inner StructDefinition.
- If
selfis aDocumentItem::Struct, then the innerStructDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_task_definition(&self) -> Option<&TaskDefinition<N>>
pub fn as_task_definition(&self) -> Option<&TaskDefinition<N>>
Attempts to get a reference to the inner TaskDefinition.
- If
selfis aDocumentItem::Task, then a reference to the innerTaskDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_task_definition(self) -> Option<TaskDefinition<N>>
pub fn into_task_definition(self) -> Option<TaskDefinition<N>>
Consumes self and attempts to return the inner TaskDefinition.
- If
selfis aDocumentItem::Task, then the innerTaskDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_workflow_definition(&self) -> Option<&WorkflowDefinition<N>>
pub fn as_workflow_definition(&self) -> Option<&WorkflowDefinition<N>>
Attempts to get a reference to the inner WorkflowDefinition.
- If
selfis aDocumentItem::Workflow, then a reference to the innerWorkflowDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_workflow_definition(self) -> Option<WorkflowDefinition<N>>
pub fn into_workflow_definition(self) -> Option<WorkflowDefinition<N>>
Consumes self and attempts to return the inner WorkflowDefinition.
- If
selfis aDocumentItem::Workflow, then the innerWorkflowDefinitionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn child(node: &N) -> Option<Self>
pub fn child(node: &N) -> Option<Self>
Finds the first child that can be cast to a DocumentItem.
Sourcepub fn children(node: &N) -> impl Iterator<Item = Self> + use<'_, N>
pub fn children(node: &N) -> impl Iterator<Item = Self> + use<'_, N>
Finds all children that can be cast to a DocumentItem.
Trait Implementations§
Source§impl<N: Clone + TreeNode> Clone for DocumentItem<N>
impl<N: Clone + TreeNode> Clone for DocumentItem<N>
Source§fn clone(&self) -> DocumentItem<N>
fn clone(&self) -> DocumentItem<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more