Struct ast_grep_napi::SgNode

source ·
pub struct SgNode { /* private fields */ }

Implementations§

source§

impl SgNode

source

pub fn instance_of<V: NapiRaw>(env: Env, value: V) -> Result<bool>

source§

impl SgNode

source§

impl SgNode

source

pub fn range(&self) -> Range

source

pub fn is_leaf(&self) -> bool

source

pub fn kind(&self) -> String

source

pub fn text(&self) -> String

source§

impl SgNode

source

pub fn matches(&self, m: String) -> bool

source

pub fn inside(&self, m: String) -> bool

source

pub fn has(&self, m: String) -> bool

source

pub fn precedes(&self, m: String) -> bool

source

pub fn follows(&self, m: String) -> bool

source

pub fn get_match(
&self,
reference: Reference<SgNode>,
env: Env,
m: String
) -> Result<Option<SgNode>>

source

pub fn get_multiple_matches(
&self,
reference: Reference<SgNode>,
env: Env,
m: String
) -> Result<Vec<SgNode>>

source§

impl SgNode

tree traversal API

source

pub fn children(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Vec<SgNode>>

source

pub fn find(
&self,
reference: Reference<SgNode>,
env: Env,
matcher: Either3<String, u16, NapiConfig>
) -> Result<Option<SgNode>>

source

pub fn find_all(
&self,
reference: Reference<SgNode>,
env: Env,
matcher: Either3<String, u16, NapiConfig>
) -> Result<Vec<SgNode>>

source

pub fn field(
&self,
reference: Reference<SgNode>,
env: Env,
name: String
) -> Result<Option<SgNode>>

source

pub fn parent(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Option<SgNode>>

source

pub fn child(
&self,
reference: Reference<SgNode>,
env: Env,
nth: u32
) -> Result<Option<SgNode>>

source

pub fn ancestors(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Vec<SgNode>>

source

pub fn next(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Option<SgNode>>

source

pub fn next_all(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Vec<SgNode>>

source

pub fn prev(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Option<SgNode>>

source

pub fn prev_all(
&self,
reference: Reference<SgNode>,
env: Env
) -> Result<Vec<SgNode>>

Trait Implementations§

source§

impl FromNapiMutRef for SgNode

source§

unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value
) -> Result<&'static mut Self>

Safety Read more
source§

impl FromNapiRef for SgNode

source§

unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value
) -> Result<&'static Self>

Safety Read more
source§

impl FromNapiValue for &SgNode

source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

source§

impl FromNapiValue for &mut SgNode

source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

source§

impl NapiRaw for &SgNode

source§

unsafe fn raw(&self) -> napi_value

source§

impl NapiRaw for &mut SgNode

source§

unsafe fn raw(&self) -> napi_value

source§

impl ObjectFinalize for SgNode

source§

fn finalize(self, env: Env) -> Result<(), Error>

source§

impl ToNapiValue for SgNode

source§

unsafe fn to_napi_value(env: napi_env, val: SgNode) -> Result<napi_value>

Safety Read more
source§

impl TypeName for &SgNode

source§

impl TypeName for &mut SgNode

source§

impl TypeName for SgNode

source§

impl ValidateNapiValue for &SgNode

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more
source§

impl ValidateNapiValue for &mut SgNode

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for SgNode

§

impl !Send for SgNode

§

impl !Sync for SgNode

§

impl Unpin for SgNode

§

impl !UnwindSafe for SgNode

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

source§

impl<T> JsValuesTupleIntoVec for Twhere
T: ToNapiValue,

source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.