#[non_exhaustive]#[repr(C)]pub struct MethodDefinition<'a> {
pub span: Span,
pub node_id: Cell<NodeId>,
pub type: MethodDefinitionType,
pub kind: MethodDefinitionKind,
pub computed: bool,
pub static: bool,
pub decorators: Vec<'a, Decorator<'a>>,
pub key: PropertyKey<'a>,
pub value: Box<'a, Function<'a>>,
pub override: bool,
pub optional: bool,
pub accessibility: Option<TSAccessibility>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.span: Span§node_id: Cell<NodeId>§type: MethodDefinitionTypeMethod definition type
This will always be true when an abstract modifier is used on the method.
kind: MethodDefinitionKind§computed: bool§static: bool§decorators: Vec<'a, Decorator<'a>>§key: PropertyKey<'a>§value: Box<'a, Function<'a>>§override: bool§optional: bool§accessibility: Option<TSAccessibility>Implementations§
Source§impl<'a> MethodDefinition<'a>
impl<'a> MethodDefinition<'a>
Sourcepub fn new(
span: Span,
type: MethodDefinitionType,
decorators: impl IntoIn<'a, Vec<'a, Decorator<'a>>>,
key: PropertyKey<'a>,
value: Box<'a, Function<'a>>,
kind: MethodDefinitionKind,
computed: bool,
static: bool,
override: bool,
optional: bool,
accessibility: Option<TSAccessibility>,
builder: &impl GetAstBuilder<'a>,
) -> MethodDefinition<'a>
pub fn new( span: Span, type: MethodDefinitionType, decorators: impl IntoIn<'a, Vec<'a, Decorator<'a>>>, key: PropertyKey<'a>, value: Box<'a, Function<'a>>, kind: MethodDefinitionKind, computed: bool, static: bool, override: bool, optional: bool, accessibility: Option<TSAccessibility>, builder: &impl GetAstBuilder<'a>, ) -> MethodDefinition<'a>
Build a MethodDefinition.
If you want the built node to be allocated in the memory arena,
use MethodDefinition::boxed instead.
§Parameters
span: TheSpancovering this nodetype: Method definition typedecoratorskeyvaluekindcomputedstaticoverrideoptionalaccessibility
Sourcepub fn boxed(
span: Span,
type: MethodDefinitionType,
decorators: impl IntoIn<'a, Vec<'a, Decorator<'a>>>,
key: PropertyKey<'a>,
value: Box<'a, Function<'a>>,
kind: MethodDefinitionKind,
computed: bool,
static: bool,
override: bool,
optional: bool,
accessibility: Option<TSAccessibility>,
builder: &impl GetAstBuilder<'a>,
) -> Box<'a, MethodDefinition<'a>>
pub fn boxed( span: Span, type: MethodDefinitionType, decorators: impl IntoIn<'a, Vec<'a, Decorator<'a>>>, key: PropertyKey<'a>, value: Box<'a, Function<'a>>, kind: MethodDefinitionKind, computed: bool, static: bool, override: bool, optional: bool, accessibility: Option<TSAccessibility>, builder: &impl GetAstBuilder<'a>, ) -> Box<'a, MethodDefinition<'a>>
Build a MethodDefinition, and store it in the memory arena.
Returns a Box containing the newly-allocated node.
If you want a stack-allocated node, use MethodDefinition::new instead.
§Parameters
span: TheSpancovering this nodetype: Method definition typedecoratorskeyvaluekindcomputedstaticoverrideoptionalaccessibility
Source§impl MethodDefinition<'_>
impl MethodDefinition<'_>
Sourcepub fn node_id(&self) -> NodeId
pub fn node_id(&self) -> NodeId
Get NodeId of MethodDefinition.
Only use this method on a post-semantic AST where NodeIds are always defined.
Sourcepub fn set_node_id(&self, node_id: NodeId)
pub fn set_node_id(&self, node_id: NodeId)
Set NodeId of MethodDefinition.
Trait Implementations§
Source§impl<'new_alloc> CloneIn<'new_alloc> for MethodDefinition<'_>
impl<'new_alloc> CloneIn<'new_alloc> for MethodDefinition<'_>
Source§type Cloned = MethodDefinition<'new_alloc>
type Cloned = MethodDefinition<'new_alloc>
The type of the cloned object. Read more
Source§fn clone_in_impl(
&self,
with_semantic_ids: CloneInSemanticIds,
allocator: &'new_alloc Allocator,
) -> <MethodDefinition<'_> as CloneIn<'new_alloc>>::Cloned
fn clone_in_impl( &self, with_semantic_ids: CloneInSemanticIds, allocator: &'new_alloc Allocator, ) -> <MethodDefinition<'_> as CloneIn<'new_alloc>>::Cloned
Clone
self into allocator, threading whether semantic ids should be preserved as a
runtime with_semantic_ids flag rather than as two separate methods. Read moreSource§fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned
Clone
self into the given allocator. allocator may be the same one
that self is already in.Source§fn clone_in_with_semantic_ids(
&self,
allocator: &'new_alloc Allocator,
) -> Self::Cloned
fn clone_in_with_semantic_ids( &self, allocator: &'new_alloc Allocator, ) -> Self::Cloned
Almost identical as
clone_in, but for some special type, it will also clone the semantic ids.
Please use this method only if you make sure semantic info is synced with the ast node.Source§impl ContentEq for MethodDefinition<'_>
impl ContentEq for MethodDefinition<'_>
Source§fn content_eq(&self, other: &MethodDefinition<'_>) -> bool
fn content_eq(&self, other: &MethodDefinition<'_>) -> bool
This method tests for contents of
self and other to be equal.Source§fn content_ne(&self, other: &Self) -> bool
fn content_ne(&self, other: &Self) -> bool
This method tests for contents of
self and other not to be equal.
The default implementation is almost always
sufficient, and should not be overridden without very good reason.Source§impl<'a> Debug for MethodDefinition<'a>
impl<'a> Debug for MethodDefinition<'a>
Source§impl<'a> Dummy<'a> for MethodDefinition<'a>
impl<'a> Dummy<'a> for MethodDefinition<'a>
Source§fn dummy(allocator: &'a Allocator) -> MethodDefinition<'a>
fn dummy(allocator: &'a Allocator) -> MethodDefinition<'a>
Create a dummy MethodDefinition.
Has cost of making 3 allocations (160 bytes).
Source§impl<'a> GatherNodeParts<'a> for MethodDefinition<'a>
impl<'a> GatherNodeParts<'a> for MethodDefinition<'a>
Source§impl Gen for MethodDefinition<'_>
impl Gen for MethodDefinition<'_>
Source§impl GetNodeId for MethodDefinition<'_>
impl GetNodeId for MethodDefinition<'_>
Source§impl GetSpan for MethodDefinition<'_>
impl GetSpan for MethodDefinition<'_>
Source§impl GetSpanMut for MethodDefinition<'_>
impl GetSpanMut for MethodDefinition<'_>
Source§impl PrivateBoundIdentifiers for MethodDefinition<'_>
impl PrivateBoundIdentifiers for MethodDefinition<'_>
fn private_bound_identifiers(&self) -> Option<PrivateIdentifier<'_>>
Source§impl<'a> ReplaceWith<'a> for MethodDefinition<'a>
impl<'a> ReplaceWith<'a> for MethodDefinition<'a>
Source§fn replace_with(&mut self, replacer: impl FnOnce(Self) -> Self)
fn replace_with(&mut self, replacer: impl FnOnce(Self) -> Self)
Replace the node in place with the value returned by
replacer. Read moreSource§impl<'a> TakeIn<'a> for MethodDefinition<'a>
impl<'a> TakeIn<'a> for MethodDefinition<'a>
Source§fn take_in(&mut self, allocator_accessor: &impl GetAllocator<'a>) -> Self
fn take_in(&mut self, allocator_accessor: &impl GetAllocator<'a>) -> Self
Replace node with a dummy, and return the original. Read more
Source§fn take_in_box(
&mut self,
allocator_accessor: &impl GetAllocator<'a>,
) -> Box<'a, Self>
fn take_in_box( &mut self, allocator_accessor: &impl GetAllocator<'a>, ) -> Box<'a, Self>
Source§impl UnstableAddress for MethodDefinition<'_>
impl UnstableAddress for MethodDefinition<'_>
Auto Trait Implementations§
impl<'a> !Freeze for MethodDefinition<'a>
impl<'a> !RefUnwindSafe for MethodDefinition<'a>
impl<'a> !Send for MethodDefinition<'a>
impl<'a> !Sync for MethodDefinition<'a>
impl<'a> !UnwindSafe for MethodDefinition<'a>
impl<'a> Forget for MethodDefinition<'a>
impl<'a> Move for MethodDefinition<'a>
impl<'a> Unpin for MethodDefinition<'a>
impl<'a> UnsafeUnpin for MethodDefinition<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more