Trait python_ast::codegen::Node
source · pub trait Node<'a> {
// Provided methods
fn lineno(&self) -> Option<usize> { ... }
fn col_offset(&self) -> Option<usize> { ... }
fn end_lineno(&self) -> Option<usize> { ... }
fn end_col_offset(&self) -> Option<usize> { ... }
fn error_message(&self, mod_name: &'a str, message: &'a str) -> String { ... }
}
Expand description
A trait for AST elements that represent a position in a source file. Implementing this trait allows an ergonomic means of extracting line and column information from an item.
Provided Methods§
sourcefn lineno(&self) -> Option<usize>
fn lineno(&self) -> Option<usize>
A method for getting the starting line number of the node. This may not exist for all node types.
sourcefn col_offset(&self) -> Option<usize>
fn col_offset(&self) -> Option<usize>
A method for getting the starting column of the node. This may not exist for all node types.
sourcefn end_lineno(&self) -> Option<usize>
fn end_lineno(&self) -> Option<usize>
A method for getting the ending line number of the node. This may not exist for all node types.
sourcefn end_col_offset(&self) -> Option<usize>
fn end_col_offset(&self) -> Option<usize>
A method for getting the ending column of the node. This may not exist for all node types.
sourcefn error_message(&self, mod_name: &'a str, message: &'a str) -> String
fn error_message(&self, mod_name: &'a str, message: &'a str) -> String
Generate an error message for the current code, adding line and column number.
Implementations on Foreign Types§
source§impl<'a> Node<'a> for PyAny
impl<'a> Node<'a> for PyAny
source§fn lineno(&self) -> Option<usize>
fn lineno(&self) -> Option<usize>
A method for getting the starting line number of the node. This may not exist for all node types.
source§fn col_offset(&self) -> Option<usize>
fn col_offset(&self) -> Option<usize>
A method for getting the starting column of the node. This may not exist for all node types.
source§fn end_lineno(&self) -> Option<usize>
fn end_lineno(&self) -> Option<usize>
A method for getting the ending line number of the node. This may not exist for all node types.
source§fn end_col_offset(&self) -> Option<usize>
fn end_col_offset(&self) -> Option<usize>
A method for getting the ending column of the node. This may not exist for all node types.