NodeData

Struct NodeData 

Source
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

Source

pub fn new( name: String, node_type: String, start_line: Option<usize>, start_index: Option<usize>, is_body: bool, ) -> Self

Source

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_format module (e.g., BLUE, GREEN).
  • Complex fields like conditions and arguments are printed with nested details.
  • The parent field, 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.

Trait Implementations§

Source§

impl Clone for NodeData

Source§

fn clone(&self) -> NodeData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.