pub struct FindVariables<'a> { /* private fields */ }
Expand description

A processor to find usage of a given set of identifiers.

Example

The following example illustrate how you can use this processor to find usage of the foo variable.

let variables = vec!["foo".to_owned()];
let mut find_foo = FindVariables::from(&variables);

let mut foo_expression = Expression::identifier("foo");
DefaultVisitor::visit_expression(&mut foo_expression, &mut find_foo);

assert!(find_foo.has_found_usage());

If you pass a node that does not contain the given variable, the processor will return false when calling the has_found_usage() method.

let mut bar_expression = Expression::identifier("bar");
DefaultVisitor::visit_expression(&mut bar_expression, &mut find_foo);

assert!(!find_foo.has_found_usage());

Implementations§

source§

impl<'a> FindVariables<'a>

source

pub fn has_found_usage(&self) -> bool

Trait Implementations§

source§

impl<'a> From<&'a Vec<Identifier, Global>> for FindVariables<'a>

source§

fn from(variables: &'a Vec<Identifier>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<String, Global>> for FindVariables<'a>

source§

fn from(variables: &'a Vec<String>) -> Self

Converts to this type from the input type.
source§

impl<'a> NodeProcessor for FindVariables<'a>

source§

fn process_variable_expression(&mut self, variable: &mut Identifier)

source§

fn process_block(&mut self, _: &mut Block)

source§

fn process_statement(&mut self, _: &mut Statement)

source§

fn process_function_call(&mut self, _: &mut FunctionCall)

source§

fn process_assign_statement(&mut self, _: &mut AssignStatement)

source§

fn process_compound_assign_statement(&mut self, _: &mut CompoundAssignStatement)

source§

fn process_do_statement(&mut self, _: &mut DoStatement)

source§

fn process_function_statement(&mut self, _: &mut FunctionStatement)

source§

fn process_generic_for_statement(&mut self, _: &mut GenericForStatement)

source§

fn process_if_statement(&mut self, _: &mut IfStatement)

source§

fn process_last_statement(&mut self, _: &mut LastStatement)

source§

fn process_local_assign_statement(&mut self, _: &mut LocalAssignStatement)

source§

fn process_local_function_statement(&mut self, _: &mut LocalFunctionStatement)

source§

fn process_numeric_for_statement(&mut self, _: &mut NumericForStatement)

source§

fn process_repeat_statement(&mut self, _: &mut RepeatStatement)

source§

fn process_while_statement(&mut self, _: &mut WhileStatement)

source§

fn process_variable(&mut self, _: &mut Variable)

source§

fn process_expression(&mut self, _: &mut Expression)

source§

fn process_binary_expression(&mut self, _: &mut BinaryExpression)

source§

fn process_field_expression(&mut self, _: &mut FieldExpression)

source§

fn process_function_expression(&mut self, _: &mut FunctionExpression)

source§

fn process_index_expression(&mut self, _: &mut IndexExpression)

source§

fn process_if_expression(&mut self, _: &mut IfExpression)

source§

fn process_number_expression(&mut self, _: &mut NumberExpression)

source§

fn process_prefix_expression(&mut self, _: &mut Prefix)

source§

fn process_parenthese_expression(&mut self, _: &mut ParentheseExpression)

source§

fn process_string_expression(&mut self, _: &mut StringExpression)

source§

fn process_table_expression(&mut self, _: &mut TableExpression)

source§

fn process_unary_expression(&mut self, _: &mut UnaryExpression)

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for FindVariables<'a>

§

impl<'a> Send for FindVariables<'a>

§

impl<'a> Sync for FindVariables<'a>

§

impl<'a> Unpin for FindVariables<'a>

§

impl<'a> UnwindSafe for FindVariables<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<I, T> ExtractContext<I, ()> for T

§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. 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 Twhere 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.

§

impl<I> RecreateContext<I> for I

§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.