Struct syntax::ast_map::MapUnstable [-] [+] [src]

pub struct Map<'ast> {
    // some fields omitted
}

Represents a mapping from Node IDs to AST elements and their parent Node IDs

Methods

impl<'ast> Map<'ast>

fn krate(&self) -> &'ast Crate

fn get(&self, id: NodeId) -> Node<'ast>

Retrieve the Node corresponding to id, panicking if it cannot be found.

fn find(&self, id: NodeId) -> Option<Node<'ast>>

Retrieve the Node corresponding to id, returning None if cannot be found.

fn get_parent(&self, id: NodeId) -> NodeId

Retrieve the parent NodeId for id, or id itself if no parent is registered in this map.

fn get_parent_did(&self, id: NodeId) -> DefId

fn get_foreign_abi(&self, id: NodeId) -> Abi

fn get_foreign_vis(&self, id: NodeId) -> Visibility

fn expect_item(&self, id: NodeId) -> &'ast Item

fn expect_struct(&self, id: NodeId) -> &'ast StructDef

fn expect_variant(&self, id: NodeId) -> &'ast Variant

fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem

fn expect_expr(&self, id: NodeId) -> &'ast Expr

fn get_path_elem(&self, id: NodeId) -> PathElem

returns the name associated with the given NodeId's AST

fn with_path<T, F>(&self, id: NodeId, f: F) -> T where F: FnOnce(PathElems) -> T

fn path_to_string(&self, id: NodeId) -> String

fn with_attrs<T, F>(&self, id: NodeId, f: F) -> T where F: FnOnce(Option<&[Attribute]>) -> T

Given a node ID and a closure, apply the closure to the array of attributes associated with the AST corresponding to the Node ID

fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String]) -> NodesMatchingSuffix<'a, 'ast>

Returns an iterator that yields the node id's with paths that match parts. (Requires parts is non-empty.)

For example, if given parts equal to ["bar", "quux"], then the iterator will produce node id's for items with paths such as foo::bar::quux, bar::quux, other::bar::quux, and any other such items it can find in the map.

fn opt_span(&self, id: NodeId) -> Option<Span>

fn span(&self, id: NodeId) -> Span

fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span

fn node_to_string(&self, id: NodeId) -> String

fn node_to_user_string(&self, id: NodeId) -> String