AST: implement try_source_range for union fields

Still not sure where the union fields are going.
I don't think they should implement Node.
This commit is contained in:
Johannes Altmanninger 2023-04-22 00:47:07 +02:00
parent 4c46faea99
commit 19fe0f6a91

View file

@ -1952,6 +1952,9 @@ impl ArgumentOrRedirectionVariant {
pub fn typ(&self) -> Type {
self.embedded_node().typ()
}
pub fn try_source_range(&self) -> Option<SourceRange> {
self.embedded_node().try_source_range()
}
fn embedded_node(&self) -> &dyn NodeMut {
match self {
ArgumentOrRedirectionVariant::Argument(node) => node,
@ -2045,6 +2048,9 @@ impl StatementVariant {
pub fn typ(&self) -> Type {
self.embedded_node().typ()
}
pub fn try_source_range(&self) -> Option<SourceRange> {
self.embedded_node().try_source_range()
}
fn embedded_node(&self) -> &dyn NodeMut {
match self {
StatementVariant::None => panic!("cannot visit null statement"),
@ -2129,6 +2135,9 @@ impl BlockStatementHeaderVariant {
pub fn typ(&self) -> Type {
self.embedded_node().typ()
}
pub fn try_source_range(&self) -> Option<SourceRange> {
self.embedded_node().try_source_range()
}
fn embedded_node(&self) -> &dyn NodeMut {
match self {
BlockStatementHeaderVariant::None => panic!("cannot visit null block header"),