lib-ruby-parser 0.7.0

Ruby parser
Documentation
use crate::nodes::InnerNode;
use crate::nodes::InspectVec;
use crate::source::Range;
/// Represents access to class variable (i.e. `@@var`)
#[derive(Debug, Clone, PartialEq)]
pub struct Cvar {
    /// Name of the class variable, `String("@@foo")` for `@@foo`
    pub name: String,
    /// Location of the full expression
    ///
    /// ```text
    /// @@foo
    /// ~~~~~
    /// ```
    pub expression_l: Range,
}


impl InnerNode for Cvar {
    fn expression(&self) -> &Range {
        &self.expression_l
    }

    fn inspected_children(&self, indent: usize) -> Vec<String> {
        let mut result = InspectVec::new(indent);
        result.push_str(&self.name);
        result.strings()
    }

    fn str_type(&self) -> &'static str {
        "cvar"
    }

    fn print_with_locs(&self) {
        println!("{}", self.inspect(0));
        self.expression_l.print("expression");
    }
}