pub trait NodeUtil<'tree> {
// Required methods
fn text_of(&self, source: &str) -> String;
fn line_span(&self) -> LineSpan;
fn field_text(&self, field: &str, source: &str) -> Option<String>;
fn child_of_kind(&self, kind: &str) -> Option<Node<'tree>>;
fn children_of_kind(&self, kind: &str) -> Vec<Node<'tree>>;
fn descendants_of_kinds(
&self,
kinds: &[&str],
enter_matches: bool,
) -> Vec<Node<'tree>>;
fn first_identifier(&self, source: &str) -> Option<String>;
fn signature_head(&self, body_kinds: &[&str], source: &str) -> String;
}Expand description
Convenience methods every extractor needs on tree-sitter nodes.
Required Methods§
fn text_of(&self, source: &str) -> String
fn line_span(&self) -> LineSpan
fn field_text(&self, field: &str, source: &str) -> Option<String>
fn child_of_kind(&self, kind: &str) -> Option<Node<'tree>>
fn children_of_kind(&self, kind: &str) -> Vec<Node<'tree>>
Sourcefn descendants_of_kinds(
&self,
kinds: &[&str],
enter_matches: bool,
) -> Vec<Node<'tree>>
fn descendants_of_kinds( &self, kinds: &[&str], enter_matches: bool, ) -> Vec<Node<'tree>>
Every descendant (including self) whose kind is in kinds, in
document order. Does not descend into matched nodes when
enter_matches is false.
Sourcefn first_identifier(&self, source: &str) -> Option<String>
fn first_identifier(&self, source: &str) -> Option<String>
The first identifier-like descendant’s text.
Sourcefn signature_head(&self, body_kinds: &[&str], source: &str) -> String
fn signature_head(&self, body_kinds: &[&str], source: &str) -> String
The declaration’s text cut at the start of its body child — the signature head as written, whitespace-normalized.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".