Skip to main content

Visitor

Trait Visitor 

Source
pub trait Visitor: Sized {
    // Provided methods
    fn visit_source_file(&mut self, source_file: &SourceFile) { ... }
    fn visit_decl(&mut self, decl: &AstDecl) { ... }
    fn visit_package_spec(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_package_body(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_procedure(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_function(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_trigger(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_view(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_type_spec(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_type_body(&mut self, _name: &str, _span: &Span) { ... }
    fn visit_ddl(&mut self, _kind: &str, _span: &Span) { ... }
    fn visit_unknown(&mut self, _span: &Span) { ... }
}
Expand description

Trait for visiting AST nodes.

Every method has a default implementation that recurses into children via the corresponding walk_* function. Override only the methods you care about.

§Example

use plsql_parser::visit::{Visitor, walk};
use plsql_parser::ast::{SourceFile, AstDecl};

struct DeclCounter {
    count: usize,
}

impl Visitor for DeclCounter {
    fn visit_decl(&mut self, decl: &AstDecl) {
        self.count += 1;
        walk::walk_decl(self, decl);
    }
}

Provided Methods§

Source

fn visit_source_file(&mut self, source_file: &SourceFile)

Visit a source file (the root of the AST).

Default: walk all declarations.

Source

fn visit_decl(&mut self, decl: &AstDecl)

Visit a top-level declaration.

Default: walk the specific declaration variant.

Source

fn visit_package_spec(&mut self, _name: &str, _span: &Span)

Visit a package specification.

Source

fn visit_package_body(&mut self, _name: &str, _span: &Span)

Visit a package body.

Source

fn visit_procedure(&mut self, _name: &str, _span: &Span)

Visit a standalone procedure.

Source

fn visit_function(&mut self, _name: &str, _span: &Span)

Visit a standalone function.

Source

fn visit_trigger(&mut self, _name: &str, _span: &Span)

Visit a trigger.

Source

fn visit_view(&mut self, _name: &str, _span: &Span)

Visit a view.

Source

fn visit_type_spec(&mut self, _name: &str, _span: &Span)

Visit a type specification.

Source

fn visit_type_body(&mut self, _name: &str, _span: &Span)

Visit a type body.

Source

fn visit_ddl(&mut self, _kind: &str, _span: &Span)

Visit a DDL statement.

Source

fn visit_unknown(&mut self, _span: &Span)

Visit an unknown/unclassified declaration (R13).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§