Struct biome_js_syntax::JsxOpeningElement
source · pub struct JsxOpeningElement { /* private fields */ }
Implementations§
source§impl JsxOpeningElement
impl JsxOpeningElement
sourcepub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self
pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self
Create an AstNode from a SyntaxNode without checking its kind
§Safety
This function must be guarded with a call to AstNode::can_cast or a match on SyntaxNode::kind
pub fn as_fields(&self) -> JsxOpeningElementFields
pub fn l_angle_token(&self) -> SyntaxResult<SyntaxToken>
pub fn name(&self) -> SyntaxResult<AnyJsxElementName>
pub fn type_arguments(&self) -> Option<TsTypeArguments>
pub fn attributes(&self) -> JsxAttributeList
pub fn r_angle_token(&self) -> SyntaxResult<SyntaxToken>
source§impl JsxOpeningElement
impl JsxOpeningElement
pub fn with_l_angle_token(self, element: SyntaxToken) -> Self
pub fn with_name(self, element: AnyJsxElementName) -> Self
pub fn with_type_arguments(self, element: Option<TsTypeArguments>) -> Self
pub fn with_attributes(self, element: JsxAttributeList) -> Self
pub fn with_r_angle_token(self, element: SyntaxToken) -> Self
source§impl JsxOpeningElement
impl JsxOpeningElement
sourcepub fn find_attribute_by_name(
&self,
name_to_lookup: &str
) -> SyntaxResult<Option<JsxAttribute>>
pub fn find_attribute_by_name( &self, name_to_lookup: &str ) -> SyntaxResult<Option<JsxAttribute>>
Find and return the JsxAttribute
that matches the given name
§Examples
use biome_js_factory::make;
use biome_js_factory::make::{ident, jsx_attribute, jsx_name, jsx_opening_element, token, jsx_attribute_list};
use biome_js_syntax::{AnyJsxAttribute, AnyJsxAttributeName, AnyJsxElementName, T};
let div = AnyJsxAttribute::JsxAttribute(jsx_attribute(
AnyJsxAttributeName::JsxName(
jsx_name(ident("div"))
)
).build());
let img = AnyJsxAttribute::JsxAttribute(jsx_attribute(
AnyJsxAttributeName::JsxName(
jsx_name(ident("img"))
)
).build());
let attributes = jsx_attribute_list(vec![
div,
img
]);
let opening_element = jsx_opening_element(
token(T![<]),
AnyJsxElementName::JsxName(
jsx_name(ident("Test"))
),
attributes,
token(T![>]),
).build();
assert_eq!(opening_element.find_attribute_by_name("div").unwrap().is_some(), true);
assert_eq!(opening_element.find_attribute_by_name("img").unwrap().is_some(), true);
assert_eq!(opening_element.find_attribute_by_name("p").unwrap().is_some(), false);
sourcepub fn has_trailing_spread_prop(&self, current_attribute: &JsxAttribute) -> bool
pub fn has_trailing_spread_prop(&self, current_attribute: &JsxAttribute) -> bool
It checks if current attribute has a trailing spread props
§Examples
use biome_js_factory::make;
use biome_js_factory::make::{ident, jsx_attribute, jsx_name, jsx_opening_element, token, jsx_attribute_list, jsx_self_closing_element, jsx_spread_attribute, jsx_ident, js_identifier_expression, js_reference_identifier};
use biome_js_syntax::{AnyJsExpression, AnyJsxAttribute, AnyJsxAttributeName, AnyJsxElementName, T};
let div = jsx_attribute(
AnyJsxAttributeName::JsxName(
jsx_name(ident("div"))
)
).build();
let spread = AnyJsxAttribute::from(jsx_spread_attribute(
token(T!['{']),
token(T![...]),
AnyJsExpression::JsIdentifierExpression(js_identifier_expression(
js_reference_identifier(ident("spread"))
)),
token(T!['}']),
));
let attributes = jsx_attribute_list(vec![
AnyJsxAttribute::from(div.clone()),
spread
]);
let opening_element = jsx_opening_element(
token(T![<]),
AnyJsxElementName::JsxName(
jsx_name(ident("Test"))
),
attributes,
token(T![>]),
).build();
let div = opening_element.find_attribute_by_name("div").unwrap().unwrap();
assert!(opening_element.has_trailing_spread_prop(&div));
sourcepub fn has_accessible_child(&self) -> bool
pub fn has_accessible_child(&self) -> bool
Check if jsx element has a child that is accessible
Trait Implementations§
source§impl AstNode for JsxOpeningElement
impl AstNode for JsxOpeningElement
type Language = JsLanguage
const KIND_SET: SyntaxKindSet<Language> = _
source§fn can_cast(kind: SyntaxKind) -> bool
fn can_cast(kind: SyntaxKind) -> bool
Returns
true
if a node with the given kind can be cased to this AST node.source§fn cast(syntax: SyntaxNode) -> Option<Self>
fn cast(syntax: SyntaxNode) -> Option<Self>
Tries to cast the passed syntax node to this AST node. Read more
source§fn syntax(&self) -> &SyntaxNode
fn syntax(&self) -> &SyntaxNode
Returns the underlying syntax node.
source§fn into_syntax(self) -> SyntaxNode
fn into_syntax(self) -> SyntaxNode
Returns the underlying syntax node.
source§fn cast_ref(syntax: &SyntaxNode<Self::Language>) -> Option<Self>where
Self: Sized,
fn cast_ref(syntax: &SyntaxNode<Self::Language>) -> Option<Self>where
Self: Sized,
Takes a reference of a syntax node and tries to cast it to this AST node. Read more
source§fn try_cast(
syntax: SyntaxNode<Self::Language>
) -> Result<Self, SyntaxNode<Self::Language>>
fn try_cast( syntax: SyntaxNode<Self::Language> ) -> Result<Self, SyntaxNode<Self::Language>>
Tries to cast the passed syntax node to this AST node. Read more
source§fn try_cast_node<T>(node: T) -> Result<Self, T>
fn try_cast_node<T>(node: T) -> Result<Self, T>
Tries to cast the AST
node
into this node. Read moresource§fn unwrap_cast(syntax: SyntaxNode<Self::Language>) -> Selfwhere
Self: Sized,
fn unwrap_cast(syntax: SyntaxNode<Self::Language>) -> Selfwhere
Self: Sized,
Cast this node to this AST node Read more
source§fn text(&self) -> String
fn text(&self) -> String
Returns the string representation of this node without the leading and trailing trivia
fn range(&self) -> TextRange
fn clone_subtree(&self) -> Selfwhere
Self: Sized,
fn parent<T>(&self) -> Option<T>
source§fn with_leading_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
fn with_leading_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Return a new version of this node with the leading trivia of its first token replaced with
trivia
.source§fn with_trailing_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
fn with_trailing_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Return a new version of this node with the trailing trivia of its last token replaced with
trivia
.fn prepend_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
fn append_trivia_pieces<I>(self, trivia: I) -> Option<Self>where
I: IntoIterator<Item = SyntaxTriviaPiece<Self::Language>>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
source§fn trim_trivia(self) -> Option<Self>
fn trim_trivia(self) -> Option<Self>
Return a new version of this node without leading and trailing newlines and whitespaces.
source§fn trim_leading_trivia(self) -> Option<Self>
fn trim_leading_trivia(self) -> Option<Self>
Return a new version of this node without leading newlines and whitespaces.
source§fn trim_trailing_trivia(self) -> Option<Self>
fn trim_trailing_trivia(self) -> Option<Self>
Return a new version of this node without trailing newlines and whitespaces.
source§impl Clone for JsxOpeningElement
impl Clone for JsxOpeningElement
source§fn clone(&self) -> JsxOpeningElement
fn clone(&self) -> JsxOpeningElement
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for JsxOpeningElement
impl Debug for JsxOpeningElement
source§impl Display for JsxOpeningElement
impl Display for JsxOpeningElement
source§impl From<JsxOpeningElement> for AnyJsxElement
impl From<JsxOpeningElement> for AnyJsxElement
source§fn from(node: JsxOpeningElement) -> Self
fn from(node: JsxOpeningElement) -> Self
Converts to this type from the input type.
source§impl From<JsxOpeningElement> for JsSyntaxElement
impl From<JsxOpeningElement> for JsSyntaxElement
source§fn from(n: JsxOpeningElement) -> SyntaxElement
fn from(n: JsxOpeningElement) -> SyntaxElement
Converts to this type from the input type.
source§impl From<JsxOpeningElement> for JsSyntaxNode
impl From<JsxOpeningElement> for JsSyntaxNode
source§fn from(n: JsxOpeningElement) -> SyntaxNode
fn from(n: JsxOpeningElement) -> SyntaxNode
Converts to this type from the input type.
source§impl Hash for JsxOpeningElement
impl Hash for JsxOpeningElement
source§impl PartialEq for JsxOpeningElement
impl PartialEq for JsxOpeningElement
source§fn eq(&self, other: &JsxOpeningElement) -> bool
fn eq(&self, other: &JsxOpeningElement) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for JsxOpeningElement
impl StructuralPartialEq for JsxOpeningElement
Auto Trait Implementations§
impl Freeze for JsxOpeningElement
impl RefUnwindSafe for JsxOpeningElement
impl !Send for JsxOpeningElement
impl !Sync for JsxOpeningElement
impl Unpin for JsxOpeningElement
impl UnwindSafe for JsxOpeningElement
Blanket Implementations§
source§impl<T> AstNodeExt for Twhere
T: AstNode,
impl<T> AstNodeExt for Twhere
T: AstNode,
source§fn replace_node_discard_trivia<N>(self, prev_node: N, next_node: N) -> Option<T>
fn replace_node_discard_trivia<N>(self, prev_node: N, next_node: N) -> Option<T>
source§fn replace_node<N>(self, prev_node: N, next_node: N) -> Option<T>
fn replace_node<N>(self, prev_node: N, next_node: N) -> Option<T>
Return a new version of this node with the node
prev_node
replaced with next_node
,
transfering the leading and trailing trivia of prev_node
to next_node
Read moresource§fn replace_token_discard_trivia(
self,
prev_token: SyntaxToken<<T as AstNode>::Language>,
next_token: SyntaxToken<<T as AstNode>::Language>
) -> Option<T>
fn replace_token_discard_trivia( self, prev_token: SyntaxToken<<T as AstNode>::Language>, next_token: SyntaxToken<<T as AstNode>::Language> ) -> Option<T>
source§fn replace_token(
self,
prev_token: SyntaxToken<<T as AstNode>::Language>,
next_token: SyntaxToken<<T as AstNode>::Language>
) -> Option<T>
fn replace_token( self, prev_token: SyntaxToken<<T as AstNode>::Language>, next_token: SyntaxToken<<T as AstNode>::Language> ) -> Option<T>
Return a new version of this node with the token
prev_token
replaced with next_token
,
transfering the leading and trailing trivia of prev_token
to next_token
Read morefn detach(self) -> T
source§impl<L, T> BatchMutationExt<L> for T
impl<L, T> BatchMutationExt<L> for T
source§fn begin(self) -> BatchMutation<L>
fn begin(self) -> BatchMutation<L>
It starts a BatchMutation
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.