Trait ast_grep_core::source::Doc

source ·
pub trait Doc: Clone {
    type Source: Content;
    type Lang: Language;

    // Required methods
    fn get_lang(&self) -> &Self::Lang;
    fn get_source(&self) -> &Self::Source;
    fn get_source_mut(&mut self) -> &mut Self::Source;
    fn from_str(src: &str, lang: Self::Lang) -> Self;

    // Provided method
    fn parse(&self, old_tree: Option<&Tree>) -> Result<Tree, TSParseError> { ... }
}

Required Associated Types§

Required Methods§

source

fn get_lang(&self) -> &Self::Lang

source

fn get_source(&self) -> &Self::Source

source

fn get_source_mut(&mut self) -> &mut Self::Source

source

fn from_str(src: &str, lang: Self::Lang) -> Self

TODO: are we paying too much to support str as Pattern/Replacer?? this method converts string to Doc, so that we can support using string as replacer/searcher. Natively.

Provided Methods§

source

fn parse(&self, old_tree: Option<&Tree>) -> Result<Tree, TSParseError>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<L: Language> Doc for StrDoc<L>

§

type Source = String

§

type Lang = L