Struct biome_js_syntax::JsTemplateExpression
source · pub struct JsTemplateExpression { /* private fields */ }
Implementations§
source§impl JsTemplateExpression
impl JsTemplateExpression
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) -> JsTemplateExpressionFields
pub fn tag(&self) -> Option<AnyJsExpression>
pub fn type_arguments(&self) -> Option<TsTypeArguments>
pub fn l_tick_token(&self) -> SyntaxResult<SyntaxToken>
pub fn elements(&self) -> JsTemplateElementList
pub fn r_tick_token(&self) -> SyntaxResult<SyntaxToken>
source§impl JsTemplateExpression
impl JsTemplateExpression
pub fn with_tag(self, element: Option<AnyJsExpression>) -> Self
pub fn with_type_arguments(self, element: Option<TsTypeArguments>) -> Self
pub fn with_l_tick_token(self, element: SyntaxToken) -> Self
pub fn with_elements(self, element: JsTemplateElementList) -> Self
pub fn with_r_tick_token(self, element: SyntaxToken) -> Self
source§impl JsTemplateExpression
impl JsTemplateExpression
sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Returns true if self
is a template expression without a tag and without template elements.
§Examples
use biome_js_factory::make;
use biome_js_syntax::{AnyJsExpression, AnyJsTemplateElement, JsSyntaxKind, JsSyntaxToken};
use std::iter;
let tick = make::token(JsSyntaxKind::BACKTICK);
let empty_str = make::js_template_expression(
tick.clone(),
make::js_template_element_list([]),
tick.clone(),
).build();
let chunk = AnyJsTemplateElement::JsTemplateChunkElement(
make::js_template_chunk_element(
JsSyntaxToken::new_detached(JsSyntaxKind::TEMPLATE_CHUNK, "text", [], [])
)
);
let constant_str = make::js_template_expression(
tick.clone(),
make::js_template_element_list([chunk.clone()]),
tick.clone(),
).build();
let constant_str2 = make::js_template_expression(
tick.clone(),
make::js_template_element_list([chunk.clone(), chunk]),
tick.clone(),
).build();
let template_elt = AnyJsTemplateElement::JsTemplateElement(
make::js_template_element(
JsSyntaxToken::new_detached(JsSyntaxKind::DOLLAR_CURLY, "${", [], []),
AnyJsExpression::JsIdentifierExpression(
make::js_identifier_expression(
make::js_reference_identifier(make::ident("var")),
),
),
make::token(JsSyntaxKind::R_CURLY),
)
);
let template_str = make::js_template_expression(
tick.clone(),
make::js_template_element_list([template_elt]),
tick,
).build();
assert!(empty_str.is_constant());
assert!(constant_str.is_constant());
assert!(constant_str2.is_constant());
assert!(!template_str.is_constant());
sourcepub fn quasis(&self) -> impl Iterator<Item = JsSyntaxToken>
pub fn quasis(&self) -> impl Iterator<Item = JsSyntaxToken>
The string chunks of the template. aka:
foo ${bar} foo
breaks down into:
QUASIS ELEMENT{EXPR} QUASIS
pub fn template_range(&self) -> Option<TextRange>
pub fn is_test_each_pattern(&self) -> bool
sourcepub fn is_test_each_pattern_callee(&self) -> bool
pub fn is_test_each_pattern_callee(&self) -> bool
This function checks if a call expressions has one of the following members:
-
describe.each
-
describe.only.each
-
describe.skip.each
-
test.concurrent.each
-
test.concurrent.only.each
-
test.concurrent.skip.each
-
test.each
-
test.only.each
-
test.skip.each
-
test.failing.each
-
it.concurrent.each
-
it.concurrent.only.each
-
it.concurrent.skip.each
-
it.each
-
it.only.each
-
it.skip.each
-
it.failing.each
-
xdescribe.each
-
xdescribe.only.each
-
xdescribe.skip.each
-
xtest.concurrent.each
-
xtest.concurrent.only.each
-
xtest.concurrent.skip.each
-
xtest.each
-
xtest.only.each
-
xtest.skip.each
-
xtest.failing.each
-
xit.concurrent.each
-
xit.concurrent.only.each
-
xit.concurrent.skip.each
-
xit.each
-
xit.only.each
-
xit.skip.each
-
xit.failing.each
-
fdescribe.each
-
fdescribe.only.each
-
fdescribe.skip.each
-
ftest.concurrent.each
-
ftest.concurrent.only.each
-
ftest.concurrent.skip.each
-
ftest.each
-
ftest.only.each
-
ftest.skip.each
-
ftest.failing.each
-
fit.concurrent.each
-
fit.concurrent.only.each
-
fit.concurrent.skip.each
-
fit.each
-
fit.only.each
-
fit.skip.each
-
xit.failing.each
Based on this article
Trait Implementations§
source§impl AstNode for JsTemplateExpression
impl AstNode for JsTemplateExpression
type Language = JsLanguage
const KIND_SET: SyntaxKindSet<Language> = _
source§fn can_cast(kind: SyntaxKind) -> bool
fn can_cast(kind: SyntaxKind) -> bool
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>
source§fn syntax(&self) -> &SyntaxNode
fn syntax(&self) -> &SyntaxNode
source§fn into_syntax(self) -> SyntaxNode
fn into_syntax(self) -> SyntaxNode
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,
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>>
source§fn try_cast_node<T>(node: T) -> Result<Self, T>
fn try_cast_node<T>(node: T) -> Result<Self, T>
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,
source§fn text(&self) -> String
fn text(&self) -> String
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,
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,
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>
source§fn trim_leading_trivia(self) -> Option<Self>
fn trim_leading_trivia(self) -> Option<Self>
source§fn trim_trailing_trivia(self) -> Option<Self>
fn trim_trailing_trivia(self) -> Option<Self>
source§impl Clone for JsTemplateExpression
impl Clone for JsTemplateExpression
source§fn clone(&self) -> JsTemplateExpression
fn clone(&self) -> JsTemplateExpression
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for JsTemplateExpression
impl Debug for JsTemplateExpression
source§impl Display for JsTemplateExpression
impl Display for JsTemplateExpression
source§impl From<JsTemplateExpression> for AnyJsExpression
impl From<JsTemplateExpression> for AnyJsExpression
source§fn from(node: JsTemplateExpression) -> AnyJsExpression
fn from(node: JsTemplateExpression) -> AnyJsExpression
source§impl From<JsTemplateExpression> for JsSyntaxElement
impl From<JsTemplateExpression> for JsSyntaxElement
source§fn from(n: JsTemplateExpression) -> SyntaxElement
fn from(n: JsTemplateExpression) -> SyntaxElement
source§impl From<JsTemplateExpression> for JsSyntaxNode
impl From<JsTemplateExpression> for JsSyntaxNode
source§fn from(n: JsTemplateExpression) -> SyntaxNode
fn from(n: JsTemplateExpression) -> SyntaxNode
source§impl Hash for JsTemplateExpression
impl Hash for JsTemplateExpression
source§impl PartialEq for JsTemplateExpression
impl PartialEq for JsTemplateExpression
source§fn eq(&self, other: &JsTemplateExpression) -> bool
fn eq(&self, other: &JsTemplateExpression) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for JsTemplateExpression
impl StructuralPartialEq for JsTemplateExpression
Auto Trait Implementations§
impl Freeze for JsTemplateExpression
impl RefUnwindSafe for JsTemplateExpression
impl !Send for JsTemplateExpression
impl !Sync for JsTemplateExpression
impl Unpin for JsTemplateExpression
impl UnwindSafe for JsTemplateExpression
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>
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>
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>
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
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
key
and return true
if they are equal.