pub struct NodeData {Show 26 fields
pub name: String,
pub node_type: String,
pub start_line: Option<usize>,
pub end_line: Option<usize>,
pub start_index: Option<usize>,
pub end_index: Option<usize>,
pub column: Option<usize>,
pub is_body: Option<bool>,
pub pkg_name: Option<String>,
pub category_type: Option<String>,
pub arguments: Option<Vec<ArgumentData>>,
pub return_type: Option<ReturnKeywordData>,
pub type_kind: Option<String>,
pub base_type: Option<String>,
pub tuple_values: Option<Vec<String>>,
pub conditions: Option<ConditionExpr>,
pub iterator: Option<String>,
pub range_start: Option<String>,
pub range_end: Option<String>,
pub direction: Option<String>,
pub range_var: Option<String>,
pub iterator_type: Option<String>,
pub switch_expression: Option<String>,
pub cases: Option<Vec<String>>,
pub parent: Option<Box<NodeData>>,
pub body_start: Option<usize>,
}Expand description
Creates a new NodeData instance with specified attributes.
Initializes a node with the given name, type, start position, and body status, setting
other fields to None. This constructor is used during node extraction (e.g., for packages,
procedures, or case statements) to capture essential metadata before further processing.
§Parameters
name: The identifier or name of the Ada construct (e.g., “MyPackage”).node_type: The type of construct (e.g., “PackageNode”, “CaseStatement”).start_line: The line number where the construct begins, if known.start_index: The character index where the construct begins, if known.is_body: Whether the construct is a body (e.g.,package body) or specification.
§Returns
A NodeData instance with initialized fields and others set to None.
§Examples
use ADA_Standards::NodeData;
let node = NodeData::new(
"MyProcedure".to_string(),
"ProcedureNode".to_string(),
Some(10),
Some(15),
false,
);
assert_eq!(node.name, "MyProcedure");
assert_eq!(node.is_body, Some(false));
assert_eq!(node.start_line, Some(10));Fields§
§name: String§node_type: String§start_line: Option<usize>§end_line: Option<usize>§start_index: Option<usize>§end_index: Option<usize>§column: Option<usize>§is_body: Option<bool>§pkg_name: Option<String>§category_type: Option<String>§arguments: Option<Vec<ArgumentData>>§return_type: Option<ReturnKeywordData>§type_kind: Option<String>§base_type: Option<String>§tuple_values: Option<Vec<String>>§conditions: Option<ConditionExpr>§iterator: Option<String>§range_start: Option<String>§range_end: Option<String>§direction: Option<String>§range_var: Option<String>§iterator_type: Option<String>§switch_expression: Option<String>§cases: Option<Vec<String>>§parent: Option<Box<NodeData>>§body_start: Option<usize>Implementations§
Source§impl NodeData
impl NodeData
pub fn new( name: String, node_type: String, start_line: Option<usize>, start_index: Option<usize>, is_body: bool, ) -> Self
Sourcepub fn print_info(&self)
pub fn print_info(&self)
Prints detailed information about the node in a color-coded format.
Displays all relevant fields of the node, such as name, type, position, conditions, and cases, using color formatting to distinguish field types (e.g., blue for metadata, green for conditions). This method is primarily used for debugging or inspecting the AST during development or analysis. Optional fields are only printed if they contain values, and nested structures (e.g., arguments, conditions) are formatted with indentation for clarity.
§Notes
- The output uses ANSI color codes from the
text_formatmodule (e.g.,BLUE,GREEN). - Complex fields like
conditionsandargumentsare printed with nested details. - The
parentfield, if present, is included to show hierarchical relationships. - This method is I/O-bound and may be slow for large ASTs; consider using a verbosity flag for production.