ast: remove all of the as_foo functions from Node

Kind has subsumed these.
This commit is contained in:
Peter Ammon
2025-04-28 10:51:23 -07:00
parent dfac66082a
commit ccc75d08f3

View File

@@ -314,219 +314,6 @@ pub fn cast<T: Castable>(&self) -> Option<&T> {
pub trait ConcreteNode: NodeSubTraits {
fn kind(&self) -> Kind;
fn kind_mut(&mut self) -> KindMut;
// Cast to any node type.
fn as_redirection(&self) -> Option<&Redirection> {
match self.kind() {
Kind::Redirection(node) => Some(node),
_ => None,
}
}
fn as_variable_assignment(&self) -> Option<&VariableAssignment> {
match self.kind() {
Kind::VariableAssignment(node) => Some(node),
_ => None,
}
}
fn as_variable_assignment_list(&self) -> Option<&VariableAssignmentList> {
match self.kind() {
Kind::VariableAssignmentList(node) => Some(node),
_ => None,
}
}
fn as_argument_or_redirection(&self) -> Option<&ArgumentOrRedirection> {
match self.kind() {
Kind::ArgumentOrRedirection(node) => Some(node),
_ => None,
}
}
fn as_argument_or_redirection_list(&self) -> Option<&ArgumentOrRedirectionList> {
match self.kind() {
Kind::ArgumentOrRedirectionList(node) => Some(node),
_ => None,
}
}
fn as_statement(&self) -> Option<&Statement> {
match self.kind() {
Kind::Statement(node) => Some(node),
_ => None,
}
}
fn as_job_pipeline(&self) -> Option<&JobPipeline> {
match self.kind() {
Kind::JobPipeline(node) => Some(node),
_ => None,
}
}
fn as_job_conjunction(&self) -> Option<&JobConjunction> {
match self.kind() {
Kind::JobConjunction(node) => Some(node),
_ => None,
}
}
fn as_for_header(&self) -> Option<&ForHeader> {
match self.kind() {
Kind::ForHeader(node) => Some(node),
_ => None,
}
}
fn as_while_header(&self) -> Option<&WhileHeader> {
match self.kind() {
Kind::WhileHeader(node) => Some(node),
_ => None,
}
}
fn as_function_header(&self) -> Option<&FunctionHeader> {
match self.kind() {
Kind::FunctionHeader(node) => Some(node),
_ => None,
}
}
fn as_begin_header(&self) -> Option<&BeginHeader> {
match self.kind() {
Kind::BeginHeader(node) => Some(node),
_ => None,
}
}
fn as_block_statement(&self) -> Option<&BlockStatement> {
match self.kind() {
Kind::BlockStatement(node) => Some(node),
_ => None,
}
}
fn as_brace_statement(&self) -> Option<&BraceStatement> {
match self.kind() {
Kind::BraceStatement(node) => Some(node),
_ => None,
}
}
fn as_if_clause(&self) -> Option<&IfClause> {
match self.kind() {
Kind::IfClause(node) => Some(node),
_ => None,
}
}
fn as_elseif_clause(&self) -> Option<&ElseifClause> {
match self.kind() {
Kind::ElseifClause(node) => Some(node),
_ => None,
}
}
fn as_elseif_clause_list(&self) -> Option<&ElseifClauseList> {
match self.kind() {
Kind::ElseifClauseList(node) => Some(node),
_ => None,
}
}
fn as_else_clause(&self) -> Option<&ElseClause> {
match self.kind() {
Kind::ElseClause(node) => Some(node),
_ => None,
}
}
fn as_if_statement(&self) -> Option<&IfStatement> {
match self.kind() {
Kind::IfStatement(node) => Some(node),
_ => None,
}
}
fn as_case_item(&self) -> Option<&CaseItem> {
match self.kind() {
Kind::CaseItem(node) => Some(node),
_ => None,
}
}
fn as_switch_statement(&self) -> Option<&SwitchStatement> {
match self.kind() {
Kind::SwitchStatement(node) => Some(node),
_ => None,
}
}
fn as_decorated_statement(&self) -> Option<&DecoratedStatement> {
match self.kind() {
Kind::DecoratedStatement(node) => Some(node),
_ => None,
}
}
fn as_not_statement(&self) -> Option<&NotStatement> {
match self.kind() {
Kind::NotStatement(node) => Some(node),
_ => None,
}
}
fn as_job_continuation(&self) -> Option<&JobContinuation> {
match self.kind() {
Kind::JobContinuation(node) => Some(node),
_ => None,
}
}
fn as_job_continuation_list(&self) -> Option<&JobContinuationList> {
match self.kind() {
Kind::JobContinuationList(node) => Some(node),
_ => None,
}
}
fn as_job_conjunction_continuation(&self) -> Option<&JobConjunctionContinuation> {
match self.kind() {
Kind::JobConjunctionContinuation(node) => Some(node),
_ => None,
}
}
fn as_andor_job(&self) -> Option<&AndorJob> {
match self.kind() {
Kind::AndorJob(node) => Some(node),
_ => None,
}
}
fn as_andor_job_list(&self) -> Option<&AndorJobList> {
match self.kind() {
Kind::AndorJobList(node) => Some(node),
_ => None,
}
}
fn as_freestanding_argument_list(&self) -> Option<&FreestandingArgumentList> {
match self.kind() {
Kind::FreestandingArgumentList(node) => Some(node),
_ => None,
}
}
fn as_job_conjunction_continuation_list(&self) -> Option<&JobConjunctionContinuationList> {
match self.kind() {
Kind::JobConjunctionContinuationList(node) => Some(node),
_ => None,
}
}
fn as_maybe_newlines(&self) -> Option<&MaybeNewlines> {
match self.kind() {
Kind::MaybeNewlines(node) => Some(node),
_ => None,
}
}
fn as_case_item_list(&self) -> Option<&CaseItemList> {
match self.kind() {
Kind::CaseItemList(node) => Some(node),
_ => None,
}
}
fn as_argument(&self) -> Option<&Argument> {
match self.kind() {
Kind::Argument(node) => Some(node),
_ => None,
}
}
fn as_argument_list(&self) -> Option<&ArgumentList> {
match self.kind() {
Kind::ArgumentList(node) => Some(node),
_ => None,
}
}
fn as_job_list(&self) -> Option<&JobList> {
match self.kind() {
Kind::JobList(node) => Some(node),
_ => None,
}
}
}
/// Trait for all "leaf" nodes: nodes with no ast children.