From 1afed06282b11333c4172f1892fbb255905d2297 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Wed, 23 Oct 2024 16:54:52 -0400 Subject: [PATCH] refactor(parser/js): rename import assertions to import attributes --- .../src/lint/correctness/no_unused_imports.rs | 8 +- .../src/lint/nursery/use_explicit_type.rs | 6 +- .../src/lint/style/use_import_type.rs | 4 +- .../no_type_only_import_attributes.rs | 12 +- .../src/generated/node_factory.rs | 104 +++---- .../src/generated/syntax_factory.rs | 34 +-- crates/biome_js_formatter/src/comments.rs | 2 +- crates/biome_js_formatter/src/format.rs | 4 +- crates/biome_js_formatter/src/generated.rs | 104 +++---- .../src/js/any/import_assertion_entry.rs | 15 - .../src/js/any/import_attribute_entry.rs | 15 + crates/biome_js_formatter/src/js/any/mod.rs | 2 +- .../js/bogus/bogus_import_assertion_entry.rs | 7 - .../js/bogus/bogus_import_attribute_entry.rs | 5 + crates/biome_js_formatter/src/js/bogus/mod.rs | 2 +- ...list.rs => import_attribute_entry_list.rs} | 8 +- crates/biome_js_formatter/src/js/lists/mod.rs | 2 +- .../src/js/module/export_from_clause.rs | 6 +- .../src/js/module/export_named_from_clause.rs | 6 +- ...mport_assertion.rs => import_attribute.rs} | 20 +- ...ion_entry.rs => import_attribute_entry.rs} | 14 +- .../src/js/module/import_bare_clause.rs | 6 +- .../src/js/module/import_combined_clause.rs | 6 +- .../src/js/module/import_default_clause.rs | 6 +- .../src/js/module/import_named_clause.rs | 6 +- .../src/js/module/import_namespace_clause.rs | 6 +- .../biome_js_formatter/src/js/module/mod.rs | 4 +- crates/biome_js_parser/src/syntax/module.rs | 11 +- .../inline/err/import_attribute_err.rast | 122 ++++---- .../inline/ok/export_from_clause.rast | 6 +- .../inline/ok/export_named_from_clause.rast | 6 +- .../test_data/inline/ok/import_attribute.rast | 38 +-- crates/biome_js_syntax/src/generated/kind.rs | 10 +- .../biome_js_syntax/src/generated/macros.rs | 16 +- crates/biome_js_syntax/src/generated/nodes.rs | 272 +++++++++--------- .../src/generated/nodes_mut.rs | 20 +- crates/biome_js_syntax/src/import_ext.rs | 16 +- crates/biome_js_syntax/src/lib.rs | 4 +- xtask/codegen/js.ungram | 38 +-- xtask/codegen/src/js_kinds_src.rs | 8 +- 40 files changed, 489 insertions(+), 492 deletions(-) delete mode 100644 crates/biome_js_formatter/src/js/any/import_assertion_entry.rs create mode 100644 crates/biome_js_formatter/src/js/any/import_attribute_entry.rs delete mode 100644 crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs create mode 100644 crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs rename crates/biome_js_formatter/src/js/lists/{import_assertion_entry_list.rs => import_attribute_entry_list.rs} (66%) rename crates/biome_js_formatter/src/js/module/{import_assertion.rs => import_attribute.rs} (76%) rename crates/biome_js_formatter/src/js/module/{import_assertion_entry.rs => import_attribute_entry.rs} (77%) diff --git a/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs b/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs index fece37913250..a1b53e044fd9 100644 --- a/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs +++ b/crates/biome_js_analyze/src/lint/correctness/no_unused_imports.rs @@ -178,14 +178,14 @@ fn remove_import_specifier( let default_specifier = default_extra_clause.default_specifier().ok()?; let from_token = default_extra_clause.from_token().ok()?; let source = default_extra_clause.source().ok()?; - let assertion = default_extra_clause.assertion(); + let assertion = default_extra_clause.attribute(); if default_specifier.syntax() == specifier { let new_clause = match default_extra_clause.specifier().ok()? { AnyJsCombinedSpecifier::JsNamedImportSpecifiers(named_specifier) => { let named_clause = make::js_import_named_clause(named_specifier, from_token, source); let named_clause = if let Some(assertion) = assertion { - named_clause.with_assertion(assertion) + named_clause.with_attribute(assertion) } else { named_clause }; @@ -198,7 +198,7 @@ fn remove_import_specifier( source, ); let namespace_clause = if let Some(assertion) = assertion { - namespace_clause.with_assertion(assertion) + namespace_clause.with_attribute(assertion) } else { namespace_clause }; @@ -212,7 +212,7 @@ fn remove_import_specifier( let default_clause = make::js_import_default_clause(default_specifier, from_token, source); let default_clause = if let Some(assertion) = assertion { - default_clause.with_assertion(assertion) + default_clause.with_attribute(assertion) } else { default_clause }; diff --git a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs index e76dcf20e480..ed367de9ddee 100644 --- a/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs +++ b/crates/biome_js_analyze/src/lint/nursery/use_explicit_type.rs @@ -533,7 +533,7 @@ fn is_property_of_object_with_type(syntax: &SyntaxNode) -> bool { /// const castTyped = <() => string>(() => ''); /// ``` fn is_type_assertion(syntax: &SyntaxNode) -> bool { - fn is_assertion_kind(kind: JsSyntaxKind) -> bool { + fn is_attribute_kind(kind: JsSyntaxKind) -> bool { matches!( kind, JsSyntaxKind::TS_AS_EXPRESSION | JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION @@ -544,9 +544,9 @@ fn is_type_assertion(syntax: &SyntaxNode) -> bool { if parent.kind() == JsSyntaxKind::JS_PARENTHESIZED_EXPRESSION { parent .parent() - .is_some_and(|grandparent| is_assertion_kind(grandparent.kind())) + .is_some_and(|grandparent| is_attribute_kind(grandparent.kind())) } else { - is_assertion_kind(parent.kind()) + is_attribute_kind(parent.kind()) } }) } diff --git a/crates/biome_js_analyze/src/lint/style/use_import_type.rs b/crates/biome_js_analyze/src/lint/style/use_import_type.rs index 3bf082d239af..aaf428b27548 100644 --- a/crates/biome_js_analyze/src/lint/style/use_import_type.rs +++ b/crates/biome_js_analyze/src/lint/style/use_import_type.rs @@ -133,11 +133,11 @@ impl Rule for UseImportType { } let import = ctx.query(); let import_clause = import.import_clause().ok()?; - if import_clause.assertion().is_some() { + if import_clause.attribute().is_some() { return None; } // Import attributes and type-only imports are not compatible. - if import_clause.assertion().is_some() { + if import_clause.attribute().is_some() { return None; } let model = ctx.model(); diff --git a/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs b/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs index 84a58e732c90..c1725e5ec78e 100644 --- a/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs +++ b/crates/biome_js_analyze/src/syntax/correctness/no_type_only_import_attributes.rs @@ -56,11 +56,11 @@ impl Rule for NoTypeOnlyImportAttributes { | AnyJsExportClause::TsExportAssignmentClause(_) | AnyJsExportClause::TsExportDeclareClause(_) => None, AnyJsExportClause::JsExportFromClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), AnyJsExportClause::JsExportNamedFromClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = clause.type_token().or_else(|| { clause .specifiers() @@ -77,7 +77,7 @@ impl Rule for NoTypeOnlyImportAttributes { AnyJsModuleItem::JsImport(import) => match import.import_clause().ok()? { AnyJsImportClause::JsImportBareClause(_) => None, AnyJsImportClause::JsImportCombinedClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = find_first_type_token( clause.specifier().ok()?.as_js_named_import_specifiers()?, )?; @@ -87,11 +87,11 @@ impl Rule for NoTypeOnlyImportAttributes { }) } AnyJsImportClause::JsImportDefaultClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), AnyJsImportClause::JsImportNamedClause(clause) => { - let assertion_range = clause.assertion()?.range(); + let assertion_range = clause.attribute()?.range(); let type_token = clause .type_token() .or_else(|| find_first_type_token(&clause.named_specifiers().ok()?))?; @@ -101,7 +101,7 @@ impl Rule for NoTypeOnlyImportAttributes { }) } AnyJsImportClause::JsImportNamespaceClause(clause) => Some(RuleState { - assertion_range: clause.assertion()?.range(), + assertion_range: clause.attribute()?.range(), type_token_range: clause.type_token()?.text_trimmed_range(), }), }, diff --git a/crates/biome_js_factory/src/generated/node_factory.rs b/crates/biome_js_factory/src/generated/node_factory.rs index d4b1b7579a77..be4a75d5ded3 100644 --- a/crates/biome_js_factory/src/generated/node_factory.rs +++ b/crates/biome_js_factory/src/generated/node_factory.rs @@ -1043,7 +1043,7 @@ pub fn js_export_from_clause( source, type_token: None, export_as: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1053,7 +1053,7 @@ pub struct JsExportFromClauseBuilder { source: AnyJsModuleSource, type_token: Option, export_as: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportFromClauseBuilder { @@ -1065,8 +1065,8 @@ impl JsExportFromClauseBuilder { self.export_as = Some(export_as); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1083,7 +1083,7 @@ impl JsExportFromClauseBuilder { .map(|token| SyntaxElement::Node(token.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1148,7 +1148,7 @@ pub fn js_export_named_from_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, semicolon_token: None, } } @@ -1159,7 +1159,7 @@ pub struct JsExportNamedFromClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, semicolon_token: Option, } impl JsExportNamedFromClauseBuilder { @@ -1167,8 +1167,8 @@ impl JsExportNamedFromClauseBuilder { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn with_semicolon_token(mut self, semicolon_token: SyntaxToken) -> Self { @@ -1185,7 +1185,7 @@ impl JsExportNamedFromClauseBuilder { Some(SyntaxElement::Token(self.r_curly_token)), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), self.semicolon_token .map(|token| SyntaxElement::Token(token)), @@ -1987,29 +1987,29 @@ impl JsImportBuilder { )) } } -pub fn js_import_assertion( +pub fn js_import_attribute( with_token: SyntaxToken, l_curly_token: SyntaxToken, - assertions: JsImportAssertionEntryList, + attributes: JsImportAttributeEntryList, r_curly_token: SyntaxToken, -) -> JsImportAssertion { - JsImportAssertion::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION, +) -> JsImportAttribute { + JsImportAttribute::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE, [ Some(SyntaxElement::Token(with_token)), Some(SyntaxElement::Token(l_curly_token)), - Some(SyntaxElement::Node(assertions.into_syntax())), + Some(SyntaxElement::Node(attributes.into_syntax())), Some(SyntaxElement::Token(r_curly_token)), ], )) } -pub fn js_import_assertion_entry( +pub fn js_import_attribute_entry( key_token: SyntaxToken, colon_token: SyntaxToken, value_token: SyntaxToken, -) -> JsImportAssertionEntry { - JsImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY, +) -> JsImportAttributeEntry { + JsImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY, [ Some(SyntaxElement::Token(key_token)), Some(SyntaxElement::Token(colon_token)), @@ -2020,16 +2020,16 @@ pub fn js_import_assertion_entry( pub fn js_import_bare_clause(source: AnyJsModuleSource) -> JsImportBareClauseBuilder { JsImportBareClauseBuilder { source, - assertion: None, + attribute: None, } } pub struct JsImportBareClauseBuilder { source: AnyJsModuleSource, - assertion: Option, + attribute: Option, } impl JsImportBareClauseBuilder { - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportBareClause { @@ -2037,7 +2037,7 @@ impl JsImportBareClauseBuilder { JsSyntaxKind::JS_IMPORT_BARE_CLAUSE, [ Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2068,7 +2068,7 @@ pub fn js_import_combined_clause( specifier, from_token, source, - assertion: None, + attribute: None, } } pub struct JsImportCombinedClauseBuilder { @@ -2077,11 +2077,11 @@ pub struct JsImportCombinedClauseBuilder { specifier: AnyJsCombinedSpecifier, from_token: SyntaxToken, source: AnyJsModuleSource, - assertion: Option, + attribute: Option, } impl JsImportCombinedClauseBuilder { - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportCombinedClause { @@ -2093,7 +2093,7 @@ impl JsImportCombinedClauseBuilder { Some(SyntaxElement::Node(self.specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2109,7 +2109,7 @@ pub fn js_import_default_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportDefaultClauseBuilder { @@ -2117,15 +2117,15 @@ pub struct JsImportDefaultClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportDefaultClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportDefaultClause { @@ -2136,7 +2136,7 @@ impl JsImportDefaultClauseBuilder { Some(SyntaxElement::Node(self.default_specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2166,7 +2166,7 @@ pub fn js_import_named_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportNamedClauseBuilder { @@ -2174,15 +2174,15 @@ pub struct JsImportNamedClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportNamedClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportNamedClause { @@ -2193,7 +2193,7 @@ impl JsImportNamedClauseBuilder { Some(SyntaxElement::Node(self.named_specifiers.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -2209,7 +2209,7 @@ pub fn js_import_namespace_clause( from_token, source, type_token: None, - assertion: None, + attribute: None, } } pub struct JsImportNamespaceClauseBuilder { @@ -2217,15 +2217,15 @@ pub struct JsImportNamespaceClauseBuilder { from_token: SyntaxToken, source: AnyJsModuleSource, type_token: Option, - assertion: Option, + attribute: Option, } impl JsImportNamespaceClauseBuilder { pub fn with_type_token(mut self, type_token: SyntaxToken) -> Self { self.type_token = Some(type_token); self } - pub fn with_assertion(mut self, assertion: JsImportAssertion) -> Self { - self.assertion = Some(assertion); + pub fn with_attribute(mut self, attribute: JsImportAttribute) -> Self { + self.attribute = Some(attribute); self } pub fn build(self) -> JsImportNamespaceClause { @@ -2236,7 +2236,7 @@ impl JsImportNamespaceClauseBuilder { Some(SyntaxElement::Node(self.namespace_specifier.into_syntax())), Some(SyntaxElement::Token(self.from_token)), Some(SyntaxElement::Node(self.source.into_syntax())), - self.assertion + self.attribute .map(|token| SyntaxElement::Node(token.into_syntax())), ], )) @@ -6780,9 +6780,9 @@ where }), )) } -pub fn js_import_assertion_entry_list(items: I, separators: S) -> JsImportAssertionEntryList +pub fn js_import_attribute_entry_list(items: I, separators: S) -> JsImportAttributeEntryList where - I: IntoIterator, + I: IntoIterator, I::IntoIter: ExactSizeIterator, S: IntoIterator, S::IntoIter: ExactSizeIterator, @@ -6790,8 +6790,8 @@ where let mut items = items.into_iter(); let mut separators = separators.into_iter(); let length = items.len() + separators.len(); - JsImportAssertionEntryList::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST, + JsImportAttributeEntryList::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST, (0..length).map(|index| { if index % 2 == 0 { Some(items.next()?.into_syntax().into()) @@ -7300,13 +7300,13 @@ where slots, )) } -pub fn js_bogus_import_assertion_entry(slots: I) -> JsBogusImportAssertionEntry +pub fn js_bogus_import_attribute_entry(slots: I) -> JsBogusImportAttributeEntry where I: IntoIterator>, I::IntoIter: ExactSizeIterator, { - JsBogusImportAssertionEntry::unwrap_cast(SyntaxNode::new_detached( - JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JsBogusImportAttributeEntry::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, slots, )) } diff --git a/crates/biome_js_factory/src/generated/syntax_factory.rs b/crates/biome_js_factory/src/generated/syntax_factory.rs index 04985d8a2bf1..b90c7b506efe 100644 --- a/crates/biome_js_factory/src/generated/syntax_factory.rs +++ b/crates/biome_js_factory/src/generated/syntax_factory.rs @@ -18,7 +18,7 @@ impl SyntaxFactory for JsSyntaxFactory { | JS_BOGUS_ASSIGNMENT | JS_BOGUS_BINDING | JS_BOGUS_EXPRESSION - | JS_BOGUS_IMPORT_ASSERTION_ENTRY + | JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_BOGUS_MEMBER | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_PARAMETER @@ -1666,7 +1666,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -1781,7 +1781,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2799,7 +2799,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.into_node(JS_IMPORT, children) } - JS_IMPORT_ASSERTION => { + JS_IMPORT_ATTRIBUTE => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<4usize> = RawNodeSlots::default(); let mut current_element = elements.next(); @@ -2818,7 +2818,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertionEntryList::can_cast(element.kind()) { + if JsImportAttributeEntryList::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2833,13 +2833,13 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ASSERTION.to_bogus(), + JS_IMPORT_ATTRIBUTE.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ASSERTION, children) + slots.into_node(JS_IMPORT_ATTRIBUTE, children) } - JS_IMPORT_ASSERTION_ENTRY => { + JS_IMPORT_ATTRIBUTE_ENTRY => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<3usize> = RawNodeSlots::default(); let mut current_element = elements.next(); @@ -2866,11 +2866,11 @@ impl SyntaxFactory for JsSyntaxFactory { slots.next_slot(); if current_element.is_some() { return RawSyntaxNode::new( - JS_IMPORT_ASSERTION_ENTRY.to_bogus(), + JS_IMPORT_ATTRIBUTE_ENTRY.to_bogus(), children.into_iter().map(Some), ); } - slots.into_node(JS_IMPORT_ASSERTION_ENTRY, children) + slots.into_node(JS_IMPORT_ATTRIBUTE_ENTRY, children) } JS_IMPORT_BARE_CLAUSE => { let mut elements = (&children).into_iter(); @@ -2884,7 +2884,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -2964,7 +2964,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3011,7 +3011,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3091,7 +3091,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -3138,7 +3138,7 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.next_slot(); if let Some(element) = ¤t_element { - if JsImportAssertion::can_cast(element.kind()) { + if JsImportAttribute::can_cast(element.kind()) { slots.mark_present(); current_element = elements.next(); } @@ -9957,10 +9957,10 @@ impl SyntaxFactory for JsSyntaxFactory { T ! [,], true, ), - JS_IMPORT_ASSERTION_ENTRY_LIST => Self::make_separated_list_syntax( + JS_IMPORT_ATTRIBUTE_ENTRY_LIST => Self::make_separated_list_syntax( kind, children, - AnyJsImportAssertionEntry::can_cast, + AnyJsImportAttributeEntry::can_cast, T ! [,], true, ), diff --git a/crates/biome_js_formatter/src/comments.rs b/crates/biome_js_formatter/src/comments.rs index 21496779d9f8..f22551764541 100644 --- a/crates/biome_js_formatter/src/comments.rs +++ b/crates/biome_js_formatter/src/comments.rs @@ -1248,7 +1248,7 @@ fn handle_import_export_specifier_comment( CommentPlacement::leading(enclosing_node.clone(), comment) } // Make end of line or own line comments in the middle of an import assertion a leading comment of the assertion - JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY => { + JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY => { CommentPlacement::leading(enclosing_node.clone(), comment) } diff --git a/crates/biome_js_formatter/src/format.rs b/crates/biome_js_formatter/src/format.rs index 0b85d670155f..2e7300f23702 100644 --- a/crates/biome_js_formatter/src/format.rs +++ b/crates/biome_js_formatter/src/format.rs @@ -827,7 +827,7 @@ impl Format for biome_js_syntax::JsModuleSource { self.format_node(formatter) } } -impl Format for biome_js_syntax::JsImportAssertion { +impl Format for biome_js_syntax::JsImportAttribute { fn format(&self, formatter: &Formatter) -> FormatResult { self.format_node(formatter) } @@ -862,7 +862,7 @@ impl Format for biome_js_syntax::JsLiteralExportName { self.format_node(formatter) } } -impl Format for biome_js_syntax::JsImportAssertionEntry { +impl Format for biome_js_syntax::JsImportAttributeEntry { fn format(&self, formatter: &Formatter) -> FormatResult { self.format_node(formatter) } diff --git a/crates/biome_js_formatter/src/generated.rs b/crates/biome_js_formatter/src/generated.rs index ec0e5390460c..3452b38b9a42 100644 --- a/crates/biome_js_formatter/src/generated.rs +++ b/crates/biome_js_formatter/src/generated.rs @@ -2572,83 +2572,83 @@ impl IntoFormat for biome_js_syntax::JsImport { FormatOwnedWithRule::new(self, crate::js::module::import::FormatJsImport::default()) } } -impl FormatRule - for crate::js::module::import_assertion::FormatJsImportAssertion +impl FormatRule + for crate::js::module::import_attribute::FormatJsImportAttribute { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsImportAssertion, + node: &biome_js_syntax::JsImportAttribute, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsImportAssertion { +impl AsFormat for biome_js_syntax::JsImportAttribute { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + biome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } -impl IntoFormat for biome_js_syntax::JsImportAssertion { +impl IntoFormat for biome_js_syntax::JsImportAttribute { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertion, - crate::js::module::import_assertion::FormatJsImportAssertion, + biome_js_syntax::JsImportAttribute, + crate::js::module::import_attribute::FormatJsImportAttribute, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::module::import_assertion::FormatJsImportAssertion::default(), + crate::js::module::import_attribute::FormatJsImportAttribute::default(), ) } } -impl FormatRule - for crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry +impl FormatRule + for crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsImportAssertionEntry, + node: &biome_js_syntax::JsImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatNodeRule::::fmt(self, node, f) + FormatNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsImportAssertionEntry { +impl AsFormat for biome_js_syntax::JsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + biome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } -impl IntoFormat for biome_js_syntax::JsImportAssertionEntry { +impl IntoFormat for biome_js_syntax::JsImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertionEntry, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry, + biome_js_syntax::JsImportAttributeEntry, + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::module::import_assertion_entry::FormatJsImportAssertionEntry::default(), + crate::js::module::import_attribute_entry::FormatJsImportAttributeEntry::default(), ) } } @@ -10707,25 +10707,25 @@ impl IntoFormat for biome_js_syntax::JsExportNamedSpecifierList FormatOwnedWithRule :: new (self , crate :: js :: lists :: export_named_specifier_list :: FormatJsExportNamedSpecifierList :: default ()) } } -impl AsFormat for biome_js_syntax::JsImportAssertionEntryList { +impl AsFormat for biome_js_syntax::JsImportAttributeEntryList { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + biome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] - FormatRefWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) + FormatRefWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) } } -impl IntoFormat for biome_js_syntax::JsImportAssertionEntryList { +impl IntoFormat for biome_js_syntax::JsImportAttributeEntryList { type Format = FormatOwnedWithRule< - biome_js_syntax::JsImportAssertionEntryList, - crate::js::lists::import_assertion_entry_list::FormatJsImportAssertionEntryList, + biome_js_syntax::JsImportAttributeEntryList, + crate::js::lists::import_attribute_entry_list::FormatJsImportAttributeEntryList, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] - FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_assertion_entry_list :: FormatJsImportAssertionEntryList :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: lists :: import_attribute_entry_list :: FormatJsImportAttributeEntryList :: default ()) } } impl AsFormat for biome_js_syntax::JsMethodModifierList { @@ -11555,38 +11555,38 @@ impl IntoFormat for biome_js_syntax::JsBogusExpression { ) } } -impl FormatRule - for crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry +impl FormatRule + for crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry { type Context = JsFormatContext; #[inline(always)] fn fmt( &self, - node: &biome_js_syntax::JsBogusImportAssertionEntry, + node: &biome_js_syntax::JsBogusImportAttributeEntry, f: &mut JsFormatter, ) -> FormatResult<()> { - FormatBogusNodeRule::::fmt(self, node, f) + FormatBogusNodeRule::::fmt(self, node, f) } } -impl AsFormat for biome_js_syntax::JsBogusImportAssertionEntry { +impl AsFormat for biome_js_syntax::JsBogusImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + biome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] - FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) + FormatRefWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) } } -impl IntoFormat for biome_js_syntax::JsBogusImportAssertionEntry { +impl IntoFormat for biome_js_syntax::JsBogusImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::JsBogusImportAssertionEntry, - crate::js::bogus::bogus_import_assertion_entry::FormatJsBogusImportAssertionEntry, + biome_js_syntax::JsBogusImportAttributeEntry, + crate::js::bogus::bogus_import_attribute_entry::FormatJsBogusImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] - FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_assertion_entry :: FormatJsBogusImportAssertionEntry :: default ()) + FormatOwnedWithRule :: new (self , crate :: js :: bogus :: bogus_import_attribute_entry :: FormatJsBogusImportAttributeEntry :: default ()) } } impl FormatRule @@ -12442,30 +12442,30 @@ impl IntoFormat for biome_js_syntax::AnyJsFunctionBody { ) } } -impl AsFormat for biome_js_syntax::AnyJsImportAssertionEntry { +impl AsFormat for biome_js_syntax::AnyJsImportAttributeEntry { type Format<'a> = FormatRefWithRule< 'a, - biome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + biome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn format(&self) -> Self::Format<'_> { #![allow(clippy::default_constructed_unit_structs)] FormatRefWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } -impl IntoFormat for biome_js_syntax::AnyJsImportAssertionEntry { +impl IntoFormat for biome_js_syntax::AnyJsImportAttributeEntry { type Format = FormatOwnedWithRule< - biome_js_syntax::AnyJsImportAssertionEntry, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry, + biome_js_syntax::AnyJsImportAttributeEntry, + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry, >; fn into_format(self) -> Self::Format { #![allow(clippy::default_constructed_unit_structs)] FormatOwnedWithRule::new( self, - crate::js::any::import_assertion_entry::FormatAnyJsImportAssertionEntry::default(), + crate::js::any::import_attribute_entry::FormatAnyJsImportAttributeEntry::default(), ) } } diff --git a/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs b/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs deleted file mode 100644 index 3fc7fe563492..000000000000 --- a/crates/biome_js_formatter/src/js/any/import_assertion_entry.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. - -use crate::prelude::*; -use biome_js_syntax::AnyJsImportAssertionEntry; -#[derive(Debug, Clone, Default)] -pub(crate) struct FormatAnyJsImportAssertionEntry; -impl FormatRule for FormatAnyJsImportAssertionEntry { - type Context = JsFormatContext; - fn fmt(&self, node: &AnyJsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> { - match node { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) => node.format().fmt(f), - AnyJsImportAssertionEntry::JsImportAssertionEntry(node) => node.format().fmt(f), - } - } -} diff --git a/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs b/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs new file mode 100644 index 000000000000..5472594ec99b --- /dev/null +++ b/crates/biome_js_formatter/src/js/any/import_attribute_entry.rs @@ -0,0 +1,15 @@ +//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. + +use crate::prelude::*; +use biome_js_syntax::AnyJsImportAttributeEntry; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatAnyJsImportAttributeEntry; +impl FormatRule for FormatAnyJsImportAttributeEntry { + type Context = JsFormatContext; + fn fmt(&self, node: &AnyJsImportAttributeEntry, f: &mut JsFormatter) -> FormatResult<()> { + match node { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) => node.format().fmt(f), + AnyJsImportAttributeEntry::JsImportAttributeEntry(node) => node.format().fmt(f), + } + } +} diff --git a/crates/biome_js_formatter/src/js/any/mod.rs b/crates/biome_js_formatter/src/js/any/mod.rs index 95a61e6efc03..2abe553ddaf5 100644 --- a/crates/biome_js_formatter/src/js/any/mod.rs +++ b/crates/biome_js_formatter/src/js/any/mod.rs @@ -26,7 +26,7 @@ pub(crate) mod for_initializer; pub(crate) mod formal_parameter; pub(crate) mod function; pub(crate) mod function_body; -pub(crate) mod import_assertion_entry; +pub(crate) mod import_attribute_entry; pub(crate) mod import_clause; pub(crate) mod in_property; pub(crate) mod literal_expression; diff --git a/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs b/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs deleted file mode 100644 index fb0529211351..000000000000 --- a/crates/biome_js_formatter/src/js/bogus/bogus_import_assertion_entry.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::FormatBogusNodeRule; -use biome_js_syntax::JsBogusImportAssertionEntry; - -#[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsBogusImportAssertionEntry; - -impl FormatBogusNodeRule for FormatJsBogusImportAssertionEntry {} diff --git a/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs b/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs new file mode 100644 index 000000000000..ca66b4674b0e --- /dev/null +++ b/crates/biome_js_formatter/src/js/bogus/bogus_import_attribute_entry.rs @@ -0,0 +1,5 @@ +use crate::FormatBogusNodeRule; +use biome_js_syntax::JsBogusImportAttributeEntry; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatJsBogusImportAttributeEntry; +impl FormatBogusNodeRule for FormatJsBogusImportAttributeEntry {} diff --git a/crates/biome_js_formatter/src/js/bogus/mod.rs b/crates/biome_js_formatter/src/js/bogus/mod.rs index 217dc033ce43..98c448f420c0 100644 --- a/crates/biome_js_formatter/src/js/bogus/mod.rs +++ b/crates/biome_js_formatter/src/js/bogus/mod.rs @@ -5,7 +5,7 @@ pub(crate) mod bogus; pub(crate) mod bogus_assignment; pub(crate) mod bogus_binding; pub(crate) mod bogus_expression; -pub(crate) mod bogus_import_assertion_entry; +pub(crate) mod bogus_import_attribute_entry; pub(crate) mod bogus_member; pub(crate) mod bogus_named_import_specifier; pub(crate) mod bogus_parameter; diff --git a/crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs b/crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs similarity index 66% rename from crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs rename to crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs index 9e437778533b..9a5476913227 100644 --- a/crates/biome_js_formatter/src/js/lists/import_assertion_entry_list.rs +++ b/crates/biome_js_formatter/src/js/lists/import_attribute_entry_list.rs @@ -1,14 +1,14 @@ use crate::context::trailing_commas::FormatTrailingCommas; use crate::prelude::*; -use biome_js_syntax::JsImportAssertionEntryList; +use biome_js_syntax::JsImportAttributeEntryList; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertionEntryList; +pub(crate) struct FormatJsImportAttributeEntryList; -impl FormatRule for FormatJsImportAssertionEntryList { +impl FormatRule for FormatJsImportAttributeEntryList { type Context = JsFormatContext; - fn fmt(&self, node: &JsImportAssertionEntryList, f: &mut JsFormatter) -> FormatResult<()> { + fn fmt(&self, node: &JsImportAttributeEntryList, f: &mut JsFormatter) -> FormatResult<()> { let trailing_separator = FormatTrailingCommas::ES5.trailing_separator(f.options()); f.join_with(&soft_line_break_or_space()) diff --git a/crates/biome_js_formatter/src/js/lists/mod.rs b/crates/biome_js_formatter/src/js/lists/mod.rs index 445d4d707c91..a89124f9e2c1 100644 --- a/crates/biome_js_formatter/src/js/lists/mod.rs +++ b/crates/biome_js_formatter/src/js/lists/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod decorator_list; pub(crate) mod directive_list; pub(crate) mod export_named_from_specifier_list; pub(crate) mod export_named_specifier_list; -pub(crate) mod import_assertion_entry_list; +pub(crate) mod import_attribute_entry_list; pub(crate) mod method_modifier_list; pub(crate) mod module_item_list; pub(crate) mod named_import_specifier_list; diff --git a/crates/biome_js_formatter/src/js/module/export_from_clause.rs b/crates/biome_js_formatter/src/js/module/export_from_clause.rs index f06c7e16fa82..82735c56cc85 100644 --- a/crates/biome_js_formatter/src/js/module/export_from_clause.rs +++ b/crates/biome_js_formatter/src/js/module/export_from_clause.rs @@ -17,7 +17,7 @@ impl FormatNodeRule for FormatJsExportFromClause { export_as, from_token, source, - assertion, + attribute, semicolon_token, } = node.as_fields(); @@ -33,8 +33,8 @@ impl FormatNodeRule for FormatJsExportFromClause { write!(f, [from_token.format(), space(), source.format()])?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } FormatStatementSemicolon::new(semicolon_token.as_ref()).fmt(f) diff --git a/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs b/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs index afd6aca8862d..d8fbe87c91d7 100644 --- a/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs +++ b/crates/biome_js_formatter/src/js/module/export_named_from_clause.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { r_curly_token, from_token, source, - assertion, + attribute, semicolon_token, } = node.as_fields(); let should_insert_space_around_brackets = f.options().bracket_spacing().value(); @@ -74,8 +74,8 @@ impl FormatNodeRule for FormatJsExportNamedFromClause { ] ]?; - if let Some(assertion) = &assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = &attribute { + write!(f, [attribute.format()])?; } write!(f, [FormatStatementSemicolon::new(semicolon_token.as_ref())]) diff --git a/crates/biome_js_formatter/src/js/module/import_assertion.rs b/crates/biome_js_formatter/src/js/module/import_attribute.rs similarity index 76% rename from crates/biome_js_formatter/src/js/module/import_assertion.rs rename to crates/biome_js_formatter/src/js/module/import_attribute.rs index d7a132968ba0..ccf35f79a2c4 100644 --- a/crates/biome_js_formatter/src/js/module/import_assertion.rs +++ b/crates/biome_js_formatter/src/js/module/import_attribute.rs @@ -1,21 +1,21 @@ use crate::prelude::*; use biome_formatter::write; -use biome_js_syntax::JsImportAssertion; -use biome_js_syntax::JsImportAssertionFields; +use biome_js_syntax::JsImportAttribute; +use biome_js_syntax::JsImportAttributeFields; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertion; +pub(crate) struct FormatJsImportAttribute; -impl FormatNodeRule for FormatJsImportAssertion { - fn fmt_fields(&self, node: &JsImportAssertion, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAssertionFields { +impl FormatNodeRule for FormatJsImportAttribute { + fn fmt_fields(&self, node: &JsImportAttribute, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAttributeFields { l_curly_token, - assertions, + attributes, r_curly_token, with_token, } = node.as_fields(); - if assertions.is_empty() { + if attributes.is_empty() { let has_dangling = f.comments().has_dangling_comments(node.syntax()); write!( f, @@ -37,7 +37,7 @@ impl FormatNodeRule for FormatJsImportAssertion { space(), l_curly_token.format(), group(&soft_block_indent_with_maybe_space( - &assertions.format(), + &attributes.format(), should_insert_space_around_brackets )), r_curly_token.format() @@ -48,7 +48,7 @@ impl FormatNodeRule for FormatJsImportAssertion { fn fmt_dangling_comments( &self, - _: &JsImportAssertion, + _: &JsImportAttribute, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled as part of `fmt_fields` diff --git a/crates/biome_js_formatter/src/js/module/import_assertion_entry.rs b/crates/biome_js_formatter/src/js/module/import_attribute_entry.rs similarity index 77% rename from crates/biome_js_formatter/src/js/module/import_assertion_entry.rs rename to crates/biome_js_formatter/src/js/module/import_attribute_entry.rs index 3a4ee5a770dc..96d79ca39d88 100644 --- a/crates/biome_js_formatter/src/js/module/import_assertion_entry.rs +++ b/crates/biome_js_formatter/src/js/module/import_attribute_entry.rs @@ -3,15 +3,15 @@ use biome_formatter::write; use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind}; -use biome_js_syntax::JsImportAssertionEntryFields; -use biome_js_syntax::{JsImportAssertionEntry, JsSyntaxKind}; +use biome_js_syntax::JsImportAttributeEntryFields; +use biome_js_syntax::{JsImportAttributeEntry, JsSyntaxKind}; #[derive(Debug, Clone, Default)] -pub(crate) struct FormatJsImportAssertionEntry; +pub(crate) struct FormatJsImportAttributeEntry; -impl FormatNodeRule for FormatJsImportAssertionEntry { - fn fmt_fields(&self, node: &JsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportAssertionEntryFields { +impl FormatNodeRule for FormatJsImportAttributeEntry { + fn fmt_fields(&self, node: &JsImportAttributeEntry, f: &mut JsFormatter) -> FormatResult<()> { + let JsImportAttributeEntryFields { key, colon_token, value_token, @@ -54,7 +54,7 @@ impl FormatNodeRule for FormatJsImportAssertionEntry { fn fmt_dangling_comments( &self, - _: &JsImportAssertionEntry, + _: &JsImportAttributeEntry, _: &mut JsFormatter, ) -> FormatResult<()> { // Handled inside `fmt_fields` diff --git a/crates/biome_js_formatter/src/js/module/import_bare_clause.rs b/crates/biome_js_formatter/src/js/module/import_bare_clause.rs index b0fb3be3e459..5aed6cf29746 100644 --- a/crates/biome_js_formatter/src/js/module/import_bare_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_bare_clause.rs @@ -9,12 +9,12 @@ pub(crate) struct FormatJsImportBareClause; impl FormatNodeRule for FormatJsImportBareClause { fn fmt_fields(&self, node: &JsImportBareClause, f: &mut JsFormatter) -> FormatResult<()> { - let JsImportBareClauseFields { source, assertion } = node.as_fields(); + let JsImportBareClauseFields { source, attribute } = node.as_fields(); write!(f, [source.format()])?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_combined_clause.rs b/crates/biome_js_formatter/src/js/module/import_combined_clause.rs index 8b202726cf33..8d5910ddbd01 100644 --- a/crates/biome_js_formatter/src/js/module/import_combined_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_combined_clause.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatJsImportCombinedClause { specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); write![ f, @@ -31,8 +31,8 @@ impl FormatNodeRule for FormatJsImportCombinedClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_default_clause.rs b/crates/biome_js_formatter/src/js/module/import_default_clause.rs index 5097d00a6467..3a8dd103a773 100644 --- a/crates/biome_js_formatter/src/js/module/import_default_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_default_clause.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatJsImportDefaultClause { default_specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -32,8 +32,8 @@ impl FormatNodeRule for FormatJsImportDefaultClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_named_clause.rs b/crates/biome_js_formatter/src/js/module/import_named_clause.rs index 1e274aa664d8..fc80da4f53b2 100644 --- a/crates/biome_js_formatter/src/js/module/import_named_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_named_clause.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatJsImportNamedClause { named_specifiers, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -88,8 +88,8 @@ impl FormatNodeRule for FormatJsImportNamedClause { write![f, [space(), from_token.format(), space(), source.format(),]]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs b/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs index 0ddc63937025..4dd42bc21319 100644 --- a/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs +++ b/crates/biome_js_formatter/src/js/module/import_namespace_clause.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { namespace_specifier, from_token, source, - assertion, + attribute, } = node.as_fields(); if let Some(type_token) = type_token { @@ -32,8 +32,8 @@ impl FormatNodeRule for FormatJsImportNamespaceClause { ] ]?; - if let Some(assertion) = assertion { - write!(f, [assertion.format()])?; + if let Some(attribute) = attribute { + write!(f, [attribute.format()])?; } Ok(()) diff --git a/crates/biome_js_formatter/src/js/module/mod.rs b/crates/biome_js_formatter/src/js/module/mod.rs index 2cb017088f1c..14bcacb5b85f 100644 --- a/crates/biome_js_formatter/src/js/module/mod.rs +++ b/crates/biome_js_formatter/src/js/module/mod.rs @@ -12,8 +12,8 @@ pub(crate) mod export_named_from_specifier; pub(crate) mod export_named_shorthand_specifier; pub(crate) mod export_named_specifier; pub(crate) mod import; -pub(crate) mod import_assertion; -pub(crate) mod import_assertion_entry; +pub(crate) mod import_attribute; +pub(crate) mod import_attribute_entry; pub(crate) mod import_bare_clause; pub(crate) mod import_combined_clause; pub(crate) mod import_default_clause; diff --git a/crates/biome_js_parser/src/syntax/module.rs b/crates/biome_js_parser/src/syntax/module.rs index f170f37b396f..408b513a16c8 100644 --- a/crates/biome_js_parser/src/syntax/module.rs +++ b/crates/biome_js_parser/src/syntax/module.rs @@ -556,13 +556,12 @@ fn parse_import_assertion(p: &mut JsParser) -> ParsedSyntax { } }; - // bump assert or with + // bump "with" p.expect(T!['{']); ImportAssertionList::default().parse_list(p); - p.expect(T!['}']); - Present(m.complete(p, JS_IMPORT_ASSERTION)) + Present(m.complete(p, JS_IMPORT_ATTRIBUTE)) } #[derive(Default)] @@ -574,7 +573,7 @@ impl ParseSeparatedList for ImportAssertionList { type Kind = JsSyntaxKind; type Parser<'source> = JsParser<'source>; - const LIST_KIND: Self::Kind = JS_IMPORT_ASSERTION_ENTRY_LIST; + const LIST_KIND: Self::Kind = JS_IMPORT_ATTRIBUTE_ENTRY_LIST; fn parse_element(&mut self, p: &mut JsParser) -> ParsedSyntax { parse_import_assertion_entry(p, &mut self.assertion_keys) @@ -588,7 +587,7 @@ impl ParseSeparatedList for ImportAssertionList { parsed_element.or_recover_with_token_set( p, &ParseRecoveryTokenSet::new( - JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, STMT_RECOVERY_SET.union(token_set![T![,], T!['}']]), ) .enable_recovery_on_line_break(), @@ -656,7 +655,7 @@ fn parse_import_assertion_entry( p.expect(T![:]); p.expect(JS_STRING_LITERAL); - let mut entry = m.complete(p, JS_IMPORT_ASSERTION_ENTRY); + let mut entry = m.complete(p, JS_IMPORT_ATTRIBUTE_ENTRY); if !valid { entry.change_to_bogus(p); diff --git a/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast b/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast index a4d8e7650b52..bd5cca0709da 100644 --- a/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast +++ b/crates/biome_js_parser/test_data/inline/err/import_attribute_err.rast @@ -9,17 +9,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..13 "\"foo\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@13..18 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@18..20 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@20..24 "type" [] [], colon_token: missing (required), value_token: missing (required), }, COMMA@24..26 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: JS_STRING_LITERAL@26..33 "\"json\"" [] [Whitespace(" ")], colon_token: missing (required), value_token: missing (required), @@ -48,11 +48,11 @@ JsModule { }, from_token: missing (required), source: missing (required), - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@51..56 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@56..58 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@58..62 "type" [] [], colon_token: COLON@62..64 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@64..71 "\"json\"" [] [Whitespace(" ")], @@ -76,17 +76,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@91..102 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@102..107 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@107..109 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: JS_STRING_LITERAL@109..115 "\"type\"" [] [], colon_token: COLON@115..117 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@117..123 "\"json\"" [] [], }, COMMA@123..125 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ IDENT@125..129 "type" [] [], COLON@129..131 ":" [] [Whitespace(" ")], @@ -94,7 +94,7 @@ JsModule { ], }, COMMA@137..139 "," [] [Whitespace(" ")], - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ JS_STRING_LITERAL@139..145 "\"type\"" [] [], COLON@145..147 ":" [] [Whitespace(" ")], @@ -113,10 +113,10 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@162..166 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@166..170 "with" [] [], l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], + assertions: JsImportAttributeEntryList [], r_curly_token: missing (required), }, }, @@ -135,35 +135,35 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@190..203 "\"ipsum.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@210..214 "type" [] [], colon_token: COLON@214..216 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@216..222 "\"json\"" [] [], }, COMMA@222..224 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@224..228 "lazy" [] [], colon_token: COLON@228..230 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@230..234 "true" [] [], colon_token: missing (required), value_token: missing (required), }, COMMA@234..236 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@236..247 "startAtLine" [] [], colon_token: COLON@247..249 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, - JsBogusImportAssertionEntry { + JsBogusImportAttributeEntry { items: [ JS_NUMBER_LITERAL@249..251 "1" [] [Whitespace(" ")], ], @@ -194,10 +194,10 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@272..281 "\"a.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@281..285 "with" [] [], l_curly_token: missing (required), - assertions: JsImportAssertionEntryList [], + assertions: JsImportAttributeEntryList [], r_curly_token: missing (required), }, }, @@ -361,142 +361,142 @@ JsModule { import_attribute_err.js:1:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `:` but instead found `,` - + > 1 │ import "foo" with { type, "json" }; │ ^ 2 │ import { foo } with { type: "json" }; 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - + i Remove , - + -- import_attribute_err.js:1:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `:` but instead found `}` - + > 1 │ import "foo" with { type, "json" }; │ ^ 2 │ import { foo } with { type: "json" }; 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - + i Remove } - + -- import_attribute_err.js:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `from` but instead found `with` - + 1 │ import "foo" with { type, "json" }; > 2 │ import { foo } with { type: "json" }; │ ^^^^ 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 4 │ import "x" with; - + i Remove with - + -- import_attribute_err.js:3:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Duplicate assertion keys are not allowed - + 1 │ import "foo" with { type, "json" }; 2 │ import { foo } with { type: "json" }; > 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^^^ 4 │ import "x" with; 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; - + i First use of the key `type` - + 1 │ import "foo" with { type, "json" }; 2 │ import { foo } with { type: "json" }; > 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^^^ 4 │ import "x" with; 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; - + i second use here - + 1 │ import "foo" with { type, "json" }; 2 │ import { foo } with { type: "json" }; > 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^ 4 │ import "x" with; 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; - + -- import_attribute_err.js:4:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `{` but instead found `;` - + 2 │ import { foo } with { type: "json" }; 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; > 4 │ import "x" with; │ ^ 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; 6 │ import { a } from "a.json" with - + i Remove ; - + -- import_attribute_err.js:5:59 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `string literal` but instead found `true` - + 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 4 │ import "x" with; > 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; │ ^^^^ 6 │ import { a } from "a.json" with - 7 │ - + 7 │ + i Remove true - + -- import_attribute_err.js:5:63 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `:` but instead found `,` - + 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 4 │ import "x" with; > 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; │ ^ 6 │ import { a } from "a.json" with - 7 │ - + 7 │ + i Remove , - + -- import_attribute_err.js:5:78 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `string literal` but instead found `1` - + 3 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 4 │ import "x" with; > 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; │ ^ 6 │ import { a } from "a.json" with - 7 │ - + 7 │ + i Remove 1 - + -- import_attribute_err.js:7:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `{` but instead the file ends - + 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; 6 │ import { a } from "a.json" with - > 7 │ - │ - + > 7 │ + │ + i the file ends here - + 5 │ import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; 6 │ import { a } from "a.json" with - > 7 │ - │ - + > 7 │ + │ + -- import "foo" with { type, "json" }; import { foo } with { type: "json" }; diff --git a/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast b/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast index 8351215a7ebf..90ea406e04c0 100644 --- a/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/export_from_clause.rast @@ -127,11 +127,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@158..164 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@164..169 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@169..171 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@171..175 "type" [] [], colon_token: COLON@175..177 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@177..184 "\"json\"" [] [Whitespace(" ")], diff --git a/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast b/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast index e08b7b4e321d..63c9d60b88a2 100644 --- a/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast +++ b/crates/biome_js_parser/test_data/inline/ok/export_named_from_clause.rast @@ -192,11 +192,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@201..207 "\"mod\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@207..212 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@212..214 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@214..218 "type" [] [], colon_token: COLON@218..220 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@220..227 "\"json\"" [] [Whitespace(" ")], diff --git a/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast b/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast index b609e41d264f..1e270e589e11 100644 --- a/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast +++ b/crates/biome_js_parser/test_data/inline/ok/import_attribute.rast @@ -9,11 +9,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@7..11 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@11..16 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@16..18 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@18..22 "type" [] [], colon_token: COLON@22..24 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@24..31 "\"json\"" [] [Whitespace(" ")], @@ -30,11 +30,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@40..46 "\"foo\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@46..51 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@51..53 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: JS_STRING_LITERAL@53..59 "\"type\"" [] [], colon_token: COLON@59..61 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@61..68 "\"json\"" [] [Whitespace(" ")], @@ -58,11 +58,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@87..98 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@98..103 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@103..105 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@105..109 "type" [] [], colon_token: COLON@109..111 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@111..118 "\"json\"" [] [Whitespace(" ")], @@ -93,11 +93,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@140..151 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@151..156 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@156..158 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@158..161 "for" [] [], colon_token: COLON@161..163 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@163..169 "\"for\"" [] [Whitespace(" ")], @@ -121,17 +121,17 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@192..203 "\"foo.json\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@203..208 "with" [] [Whitespace(" ")], l_curly_token: L_CURLY@208..210 "{" [] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@210..214 "type" [] [], colon_token: COLON@214..216 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@216..222 "\"json\"" [] [], }, COMMA@222..224 "," [] [Whitespace(" ")], - JsImportAssertionEntry { + JsImportAttributeEntry { key: IDENT@224..238 "hasOwnProperty" [] [], colon_token: COLON@238..240 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@240..247 "\"true\"" [] [Whitespace(" ")], @@ -148,11 +148,11 @@ JsModule { source: JsModuleSource { value_token: JS_STRING_LITERAL@257..261 "\"x\"" [] [Whitespace(" ")], }, - assertion: JsImportAssertion { + assertion: JsImportAttribute { with_token: WITH_KW@261..265 "with" [] [], l_curly_token: L_CURLY@265..268 "{" [Newline("\n")] [Whitespace(" ")], - assertions: JsImportAssertionEntryList [ - JsImportAssertionEntry { + assertions: JsImportAttributeEntryList [ + JsImportAttributeEntry { key: IDENT@268..272 "type" [] [], colon_token: COLON@272..274 ":" [] [Whitespace(" ")], value_token: JS_STRING_LITERAL@274..281 "\"json\"" [] [Whitespace(" ")], diff --git a/crates/biome_js_syntax/src/generated/kind.rs b/crates/biome_js_syntax/src/generated/kind.rs index febf32803792..b7cf00982349 100644 --- a/crates/biome_js_syntax/src/generated/kind.rs +++ b/crates/biome_js_syntax/src/generated/kind.rs @@ -349,9 +349,9 @@ pub enum JsSyntaxKind { JS_DEFAULT_IMPORT_SPECIFIER, JS_NAMED_IMPORT_SPECIFIER, JS_SHORTHAND_NAMED_IMPORT_SPECIFIER, - JS_IMPORT_ASSERTION, - JS_IMPORT_ASSERTION_ENTRY_LIST, - JS_IMPORT_ASSERTION_ENTRY, + JS_IMPORT_ATTRIBUTE, + JS_IMPORT_ATTRIBUTE_ENTRY_LIST, + JS_IMPORT_ATTRIBUTE_ENTRY, JS_MODULE_SOURCE, JS_EXPORT, JS_EXPORT_NAMED_CLAUSE, @@ -508,7 +508,7 @@ pub enum JsSyntaxKind { JS_BOGUS_MEMBER, JS_BOGUS_BINDING, JS_BOGUS_PARAMETER, - JS_BOGUS_IMPORT_ASSERTION_ENTRY, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, JS_BOGUS_NAMED_IMPORT_SPECIFIER, JS_BOGUS_ASSIGNMENT, TS_BOGUS_TYPE, @@ -559,7 +559,7 @@ impl JsSyntaxKind { | JS_ARRAY_ASSIGNMENT_PATTERN_ELEMENT_LIST | JS_OBJECT_ASSIGNMENT_PATTERN_PROPERTY_LIST | JS_NAMED_IMPORT_SPECIFIER_LIST - | JS_IMPORT_ASSERTION_ENTRY_LIST + | JS_IMPORT_ATTRIBUTE_ENTRY_LIST | JS_EXPORT_NAMED_SPECIFIER_LIST | JS_EXPORT_NAMED_FROM_SPECIFIER_LIST | JS_DECORATOR_LIST diff --git a/crates/biome_js_syntax/src/generated/macros.rs b/crates/biome_js_syntax/src/generated/macros.rs index 1ddeda95d8a8..760796f8858c 100644 --- a/crates/biome_js_syntax/src/generated/macros.rs +++ b/crates/biome_js_syntax/src/generated/macros.rs @@ -315,12 +315,12 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsImport::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION => { - let $pattern = unsafe { $crate::JsImportAssertion::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE => { + let $pattern = unsafe { $crate::JsImportAttribute::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY => { - let $pattern = unsafe { $crate::JsImportAssertionEntry::new_unchecked(node) }; + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY => { + let $pattern = unsafe { $crate::JsImportAttributeEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_IMPORT_BARE_CLAUSE => { @@ -1252,9 +1252,9 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsBogusExpression::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ASSERTION_ENTRY => { + $crate::JsSyntaxKind::JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { let $pattern = - unsafe { $crate::JsBogusImportAssertionEntry::new_unchecked(node) }; + unsafe { $crate::JsBogusImportAttributeEntry::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_BOGUS_MEMBER => { @@ -1328,9 +1328,9 @@ macro_rules! map_syntax_node { unsafe { $crate::JsExportNamedSpecifierList::new_unchecked(node) }; $body } - $crate::JsSyntaxKind::JS_IMPORT_ASSERTION_ENTRY_LIST => { + $crate::JsSyntaxKind::JS_IMPORT_ATTRIBUTE_ENTRY_LIST => { let $pattern = - unsafe { $crate::JsImportAssertionEntryList::new_unchecked(node) }; + unsafe { $crate::JsImportAttributeEntryList::new_unchecked(node) }; $body } $crate::JsSyntaxKind::JS_METHOD_MODIFIER_LIST => { diff --git a/crates/biome_js_syntax/src/generated/nodes.rs b/crates/biome_js_syntax/src/generated/nodes.rs index 241e831ba045..2eddddd503c5 100644 --- a/crates/biome_js_syntax/src/generated/nodes.rs +++ b/crates/biome_js_syntax/src/generated/nodes.rs @@ -2121,7 +2121,7 @@ impl JsExportFromClause { export_as: self.export_as(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), semicolon_token: self.semicolon_token(), } } @@ -2140,7 +2140,7 @@ impl JsExportFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn semicolon_token(&self) -> Option { @@ -2162,7 +2162,7 @@ pub struct JsExportFromClauseFields { pub export_as: Option, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -2242,7 +2242,7 @@ impl JsExportNamedFromClause { r_curly_token: self.r_curly_token(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), semicolon_token: self.semicolon_token(), } } @@ -2264,7 +2264,7 @@ impl JsExportNamedFromClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 5usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 6usize) } pub fn semicolon_token(&self) -> Option { @@ -2287,7 +2287,7 @@ pub struct JsExportNamedFromClauseFields { pub r_curly_token: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] @@ -3494,10 +3494,10 @@ pub struct JsImportFields { pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAssertion { +pub struct JsImportAttribute { pub(crate) syntax: SyntaxNode, } -impl JsImportAssertion { +impl JsImportAttribute { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3507,11 +3507,11 @@ impl JsImportAssertion { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } - pub fn as_fields(&self) -> JsImportAssertionFields { - JsImportAssertionFields { + pub fn as_fields(&self) -> JsImportAttributeFields { + JsImportAttributeFields { with_token: self.with_token(), l_curly_token: self.l_curly_token(), - assertions: self.assertions(), + attributes: self.attributes(), r_curly_token: self.r_curly_token(), } } @@ -3521,14 +3521,14 @@ impl JsImportAssertion { pub fn l_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 1usize) } - pub fn assertions(&self) -> JsImportAssertionEntryList { + pub fn attributes(&self) -> JsImportAttributeEntryList { support::list(&self.syntax, 2usize) } pub fn r_curly_token(&self) -> SyntaxResult { support::required_token(&self.syntax, 3usize) } } -impl Serialize for JsImportAssertion { +impl Serialize for JsImportAttribute { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3537,17 +3537,17 @@ impl Serialize for JsImportAssertion { } } #[derive(Serialize)] -pub struct JsImportAssertionFields { +pub struct JsImportAttributeFields { pub with_token: SyntaxResult, pub l_curly_token: SyntaxResult, - pub assertions: JsImportAssertionEntryList, + pub attributes: JsImportAttributeEntryList, pub r_curly_token: SyntaxResult, } #[derive(Clone, PartialEq, Eq, Hash)] -pub struct JsImportAssertionEntry { +pub struct JsImportAttributeEntry { pub(crate) syntax: SyntaxNode, } -impl JsImportAssertionEntry { +impl JsImportAttributeEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -3557,8 +3557,8 @@ impl JsImportAssertionEntry { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } - pub fn as_fields(&self) -> JsImportAssertionEntryFields { - JsImportAssertionEntryFields { + pub fn as_fields(&self) -> JsImportAttributeEntryFields { + JsImportAttributeEntryFields { key: self.key(), colon_token: self.colon_token(), value_token: self.value_token(), @@ -3574,7 +3574,7 @@ impl JsImportAssertionEntry { support::required_token(&self.syntax, 2usize) } } -impl Serialize for JsImportAssertionEntry { +impl Serialize for JsImportAttributeEntry { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -3583,7 +3583,7 @@ impl Serialize for JsImportAssertionEntry { } } #[derive(Serialize)] -pub struct JsImportAssertionEntryFields { +pub struct JsImportAttributeEntryFields { pub key: SyntaxResult, pub colon_token: SyntaxResult, pub value_token: SyntaxResult, @@ -3605,13 +3605,13 @@ impl JsImportBareClause { pub fn as_fields(&self) -> JsImportBareClauseFields { JsImportBareClauseFields { source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 0usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 1usize) } } @@ -3626,7 +3626,7 @@ impl Serialize for JsImportBareClause { #[derive(Serialize)] pub struct JsImportBareClauseFields { pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportCallExpression { @@ -3689,7 +3689,7 @@ impl JsImportCombinedClause { specifier: self.specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn default_specifier(&self) -> SyntaxResult { @@ -3707,7 +3707,7 @@ impl JsImportCombinedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 4usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 5usize) } } @@ -3726,7 +3726,7 @@ pub struct JsImportCombinedClauseFields { pub specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportDefaultClause { @@ -3748,7 +3748,7 @@ impl JsImportDefaultClause { default_specifier: self.default_specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3763,7 +3763,7 @@ impl JsImportDefaultClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3781,7 +3781,7 @@ pub struct JsImportDefaultClauseFields { pub default_specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportMetaExpression { @@ -3848,7 +3848,7 @@ impl JsImportNamedClause { named_specifiers: self.named_specifiers(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3863,7 +3863,7 @@ impl JsImportNamedClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3881,7 +3881,7 @@ pub struct JsImportNamedClauseFields { pub named_specifiers: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsImportNamespaceClause { @@ -3903,7 +3903,7 @@ impl JsImportNamespaceClause { namespace_specifier: self.namespace_specifier(), from_token: self.from_token(), source: self.source(), - assertion: self.assertion(), + attribute: self.attribute(), } } pub fn type_token(&self) -> Option { @@ -3918,7 +3918,7 @@ impl JsImportNamespaceClause { pub fn source(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { support::node(&self.syntax, 4usize) } } @@ -3936,7 +3936,7 @@ pub struct JsImportNamespaceClauseFields { pub namespace_specifier: SyntaxResult, pub from_token: SyntaxResult, pub source: SyntaxResult, - pub assertion: Option, + pub attribute: Option, } #[derive(Clone, PartialEq, Eq, Hash)] pub struct JsInExpression { @@ -14421,20 +14421,20 @@ impl AnyJsFunctionBody { } } #[derive(Clone, PartialEq, Eq, Hash, Serialize)] -pub enum AnyJsImportAssertionEntry { - JsBogusImportAssertionEntry(JsBogusImportAssertionEntry), - JsImportAssertionEntry(JsImportAssertionEntry), +pub enum AnyJsImportAttributeEntry { + JsBogusImportAttributeEntry(JsBogusImportAttributeEntry), + JsImportAttributeEntry(JsImportAttributeEntry), } -impl AnyJsImportAssertionEntry { - pub fn as_js_bogus_import_assertion_entry(&self) -> Option<&JsBogusImportAssertionEntry> { +impl AnyJsImportAttributeEntry { + pub fn as_js_bogus_import_attribute_entry(&self) -> Option<&JsBogusImportAttributeEntry> { match &self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(item) => Some(item), + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(item) => Some(item), _ => None, } } - pub fn as_js_import_assertion_entry(&self) -> Option<&JsImportAssertionEntry> { + pub fn as_js_import_attribute_entry(&self) -> Option<&JsImportAttributeEntry> { match &self { - AnyJsImportAssertionEntry::JsImportAssertionEntry(item) => Some(item), + AnyJsImportAttributeEntry::JsImportAttributeEntry(item) => Some(item), _ => None, } } @@ -18303,8 +18303,8 @@ impl std::fmt::Debug for JsExportFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .field( "semicolon_token", @@ -18417,8 +18417,8 @@ impl std::fmt::Debug for JsExportNamedFromClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .field( "semicolon_token", @@ -19559,12 +19559,12 @@ impl From for SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAssertion { +impl AstNode for JsImportAttribute { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION + kind == JS_IMPORT_ATTRIBUTE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -19580,15 +19580,15 @@ impl AstNode for JsImportAssertion { self.syntax } } -impl std::fmt::Debug for JsImportAssertion { +impl std::fmt::Debug for JsImportAttribute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAssertion") + f.debug_struct("JsImportAttribute") .field("with_token", &support::DebugSyntaxResult(self.with_token())) .field( "l_curly_token", &support::DebugSyntaxResult(self.l_curly_token()), ) - .field("assertions", &self.assertions()) + .field("attributes", &self.attributes()) .field( "r_curly_token", &support::DebugSyntaxResult(self.r_curly_token()), @@ -19596,22 +19596,22 @@ impl std::fmt::Debug for JsImportAssertion { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertion) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsImportAttribute) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertion) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsImportAttribute) -> SyntaxElement { n.syntax.into() } } -impl AstNode for JsImportAssertionEntry { +impl AstNode for JsImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION_ENTRY as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION_ENTRY + kind == JS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -19627,9 +19627,9 @@ impl AstNode for JsImportAssertionEntry { self.syntax } } -impl std::fmt::Debug for JsImportAssertionEntry { +impl std::fmt::Debug for JsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsImportAssertionEntry") + f.debug_struct("JsImportAttributeEntry") .field("key", &support::DebugSyntaxResult(self.key())) .field( "colon_token", @@ -19642,13 +19642,13 @@ impl std::fmt::Debug for JsImportAssertionEntry { .finish() } } -impl From for SyntaxNode { - fn from(n: JsImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } @@ -19678,8 +19678,8 @@ impl std::fmt::Debug for JsImportBareClause { f.debug_struct("JsImportBareClause") .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19772,8 +19772,8 @@ impl std::fmt::Debug for JsImportCombinedClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19823,8 +19823,8 @@ impl std::fmt::Debug for JsImportDefaultClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19917,8 +19917,8 @@ impl std::fmt::Debug for JsImportNamedClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -19968,8 +19968,8 @@ impl std::fmt::Debug for JsImportNamespaceClause { .field("from_token", &support::DebugSyntaxResult(self.from_token())) .field("source", &support::DebugSyntaxResult(self.source())) .field( - "assertion", - &support::DebugOptionalElement(self.assertion()), + "attribute", + &support::DebugOptionalElement(self.attribute()), ) .finish() } @@ -32452,35 +32452,35 @@ impl From for SyntaxElement { node.into() } } -impl From for AnyJsImportAssertionEntry { - fn from(node: JsBogusImportAssertionEntry) -> AnyJsImportAssertionEntry { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) +impl From for AnyJsImportAttributeEntry { + fn from(node: JsBogusImportAttributeEntry) -> AnyJsImportAttributeEntry { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(node) } } -impl From for AnyJsImportAssertionEntry { - fn from(node: JsImportAssertionEntry) -> AnyJsImportAssertionEntry { - AnyJsImportAssertionEntry::JsImportAssertionEntry(node) +impl From for AnyJsImportAttributeEntry { + fn from(node: JsImportAttributeEntry) -> AnyJsImportAttributeEntry { + AnyJsImportAttributeEntry::JsImportAttributeEntry(node) } } -impl AstNode for AnyJsImportAssertionEntry { +impl AstNode for AnyJsImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - JsBogusImportAssertionEntry::KIND_SET.union(JsImportAssertionEntry::KIND_SET); + JsBogusImportAttributeEntry::KIND_SET.union(JsImportAttributeEntry::KIND_SET); fn can_cast(kind: SyntaxKind) -> bool { matches!( kind, - JS_BOGUS_IMPORT_ASSERTION_ENTRY | JS_IMPORT_ASSERTION_ENTRY + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_IMPORT_ATTRIBUTE_ENTRY ) } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - JS_BOGUS_IMPORT_ASSERTION_ENTRY => { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry( - JsBogusImportAssertionEntry { syntax }, + JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY => { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry( + JsBogusImportAttributeEntry { syntax }, ) } - JS_IMPORT_ASSERTION_ENTRY => { - AnyJsImportAssertionEntry::JsImportAssertionEntry(JsImportAssertionEntry { syntax }) + JS_IMPORT_ATTRIBUTE_ENTRY => { + AnyJsImportAttributeEntry::JsImportAttributeEntry(JsImportAttributeEntry { syntax }) } _ => return None, }; @@ -32488,37 +32488,37 @@ impl AstNode for AnyJsImportAssertionEntry { } fn syntax(&self) -> &SyntaxNode { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => &it.syntax, - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => &it.syntax, + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => &it.syntax, + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => &it.syntax, } } fn into_syntax(self) -> SyntaxNode { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.syntax, - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.syntax, + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.syntax, + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.syntax, } } } -impl std::fmt::Debug for AnyJsImportAssertionEntry { +impl std::fmt::Debug for AnyJsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => { + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => { std::fmt::Debug::fmt(it, f) } - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => std::fmt::Debug::fmt(it, f), + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => std::fmt::Debug::fmt(it, f), } } } -impl From for SyntaxNode { - fn from(n: AnyJsImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: AnyJsImportAttributeEntry) -> SyntaxNode { match n { - AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(it) => it.into(), - AnyJsImportAssertionEntry::JsImportAssertionEntry(it) => it.into(), + AnyJsImportAttributeEntry::JsBogusImportAttributeEntry(it) => it.into(), + AnyJsImportAttributeEntry::JsImportAttributeEntry(it) => it.into(), } } } -impl From for SyntaxElement { - fn from(n: AnyJsImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: AnyJsImportAttributeEntry) -> SyntaxElement { let node: SyntaxNode = n.into(); node.into() } @@ -37332,7 +37332,7 @@ impl std::fmt::Display for AnyJsFunctionBody { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AnyJsImportAssertionEntry { +impl std::fmt::Display for AnyJsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -37922,12 +37922,12 @@ impl std::fmt::Display for JsImport { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAssertion { +impl std::fmt::Display for JsImportAttribute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for JsImportAssertionEntry { +impl std::fmt::Display for JsImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -39227,10 +39227,10 @@ impl From for SyntaxElement { } } #[derive(Clone, PartialEq, Eq, Hash, Serialize)] -pub struct JsBogusImportAssertionEntry { +pub struct JsBogusImportAttributeEntry { syntax: SyntaxNode, } -impl JsBogusImportAssertionEntry { +impl JsBogusImportAttributeEntry { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -39244,12 +39244,12 @@ impl JsBogusImportAssertionEntry { support::elements(&self.syntax) } } -impl AstNode for JsBogusImportAssertionEntry { +impl AstNode for JsBogusImportAttributeEntry { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ASSERTION_ENTRY as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_BOGUS_IMPORT_ASSERTION_ENTRY + kind == JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { @@ -39265,20 +39265,20 @@ impl AstNode for JsBogusImportAssertionEntry { self.syntax } } -impl std::fmt::Debug for JsBogusImportAssertionEntry { +impl std::fmt::Debug for JsBogusImportAttributeEntry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("JsBogusImportAssertionEntry") + f.debug_struct("JsBogusImportAttributeEntry") .field("items", &DebugSyntaxElementChildren(self.items())) .finish() } } -impl From for SyntaxNode { - fn from(n: JsBogusImportAssertionEntry) -> SyntaxNode { +impl From for SyntaxNode { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxNode { n.syntax } } -impl From for SyntaxElement { - fn from(n: JsBogusImportAssertionEntry) -> SyntaxElement { +impl From for SyntaxElement { + fn from(n: JsBogusImportAttributeEntry) -> SyntaxElement { n.syntax.into() } } @@ -40466,10 +40466,10 @@ impl IntoIterator for &JsExportNamedSpecifierList { } } #[derive(Clone, Eq, PartialEq, Hash)] -pub struct JsImportAssertionEntryList { +pub struct JsImportAttributeEntryList { syntax_list: SyntaxList, } -impl JsImportAssertionEntryList { +impl JsImportAttributeEntryList { #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] #[doc = r""] #[doc = r" # Safety"] @@ -40482,16 +40482,16 @@ impl JsImportAssertionEntryList { } } } -impl AstNode for JsImportAssertionEntryList { +impl AstNode for JsImportAttributeEntryList { type Language = Language; const KIND_SET: SyntaxKindSet = - SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ASSERTION_ENTRY_LIST as u16)); + SyntaxKindSet::from_raw(RawSyntaxKind(JS_IMPORT_ATTRIBUTE_ENTRY_LIST as u16)); fn can_cast(kind: SyntaxKind) -> bool { - kind == JS_IMPORT_ASSERTION_ENTRY_LIST + kind == JS_IMPORT_ATTRIBUTE_ENTRY_LIST } - fn cast(syntax: SyntaxNode) -> Option { + fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { - Some(JsImportAssertionEntryList { + Some(JsImportAttributeEntryList { syntax_list: syntax.into_list(), }) } else { @@ -40505,7 +40505,7 @@ impl AstNode for JsImportAssertionEntryList { self.syntax_list.into_node() } } -impl Serialize for JsImportAssertionEntryList { +impl Serialize for JsImportAttributeEntryList { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -40517,9 +40517,9 @@ impl Serialize for JsImportAssertionEntryList { seq.end() } } -impl AstSeparatedList for JsImportAssertionEntryList { +impl AstSeparatedList for JsImportAttributeEntryList { type Language = Language; - type Node = AnyJsImportAssertionEntry; + type Node = AnyJsImportAttributeEntry; fn syntax_list(&self) -> &SyntaxList { &self.syntax_list } @@ -40527,22 +40527,22 @@ impl AstSeparatedList for JsImportAssertionEntryList { self.syntax_list } } -impl Debug for JsImportAssertionEntryList { +impl Debug for JsImportAttributeEntryList { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_str("JsImportAssertionEntryList ")?; + f.write_str("JsImportAttributeEntryList ")?; f.debug_list().entries(self.elements()).finish() } } -impl IntoIterator for JsImportAssertionEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for JsImportAttributeEntryList { + type Item = SyntaxResult; + type IntoIter = AstSeparatedListNodesIterator; fn into_iter(self) -> Self::IntoIter { self.iter() } } -impl IntoIterator for &JsImportAssertionEntryList { - type Item = SyntaxResult; - type IntoIter = AstSeparatedListNodesIterator; +impl IntoIterator for &JsImportAttributeEntryList { + type Item = SyntaxResult; + type IntoIter = AstSeparatedListNodesIterator; fn into_iter(self) -> Self::IntoIter { self.iter() } diff --git a/crates/biome_js_syntax/src/generated/nodes_mut.rs b/crates/biome_js_syntax/src/generated/nodes_mut.rs index d13ffe2d37cd..e53641b072c5 100644 --- a/crates/biome_js_syntax/src/generated/nodes_mut.rs +++ b/crates/biome_js_syntax/src/generated/nodes_mut.rs @@ -999,7 +999,7 @@ impl JsExportFromClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1081,7 +1081,7 @@ impl JsExportNamedFromClause { .splice_slots(5usize..=5usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 6usize..=6usize, once(element.map(|element| element.into_syntax().into())), @@ -1758,7 +1758,7 @@ impl JsImport { ) } } -impl JsImportAssertion { +impl JsImportAttribute { pub fn with_with_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1771,7 +1771,7 @@ impl JsImportAssertion { .splice_slots(1usize..=1usize, once(Some(element.into()))), ) } - pub fn with_assertions(self, element: JsImportAssertionEntryList) -> Self { + pub fn with_attributes(self, element: JsImportAttributeEntryList) -> Self { Self::unwrap_cast( self.syntax .splice_slots(2usize..=2usize, once(Some(element.into_syntax().into()))), @@ -1784,7 +1784,7 @@ impl JsImportAssertion { ) } } -impl JsImportAssertionEntry { +impl JsImportAttributeEntry { pub fn with_key_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax @@ -1811,7 +1811,7 @@ impl JsImportBareClause { .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 1usize..=1usize, once(element.map(|element| element.into_syntax().into())), @@ -1863,7 +1863,7 @@ impl JsImportCombinedClause { .splice_slots(4usize..=4usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), @@ -1895,7 +1895,7 @@ impl JsImportDefaultClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), @@ -1947,7 +1947,7 @@ impl JsImportNamedClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), @@ -1979,7 +1979,7 @@ impl JsImportNamespaceClause { .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } - pub fn with_assertion(self, element: Option) -> Self { + pub fn with_attribute(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), diff --git a/crates/biome_js_syntax/src/import_ext.rs b/crates/biome_js_syntax/src/import_ext.rs index f7bc740cb06a..fb39356041a1 100644 --- a/crates/biome_js_syntax/src/import_ext.rs +++ b/crates/biome_js_syntax/src/import_ext.rs @@ -1,7 +1,7 @@ use crate::{ inner_string_text, AnyJsBinding, AnyJsImportClause, AnyJsModuleSource, AnyJsNamedImportSpecifier, JsCallExpression, JsDefaultImportSpecifier, JsImport, - JsImportAssertion, JsImportCallExpression, JsModuleSource, JsNamedImportSpecifier, + JsImportAttribute, JsImportCallExpression, JsModuleSource, JsNamedImportSpecifier, JsNamespaceImportSpecifier, JsShorthandNamedImportSpecifier, JsSyntaxKind, JsSyntaxToken, }; use biome_rowan::{ @@ -75,7 +75,7 @@ impl AnyJsImportClause { }) } - /// Assertion of this import clause. + /// Attribute of this import clause. /// /// ``` /// use biome_js_factory::make; @@ -88,13 +88,13 @@ impl AnyJsImportClause { /// /// assert_eq!(clause.source().unwrap().as_js_module_source().unwrap().inner_string_text().unwrap().text(), "react"); /// ``` - pub fn assertion(&self) -> Option { + pub fn attribute(&self) -> Option { match self { - Self::JsImportBareClause(clause) => clause.assertion(), - Self::JsImportDefaultClause(clause) => clause.assertion(), - Self::JsImportNamedClause(clause) => clause.assertion(), - Self::JsImportNamespaceClause(clause) => clause.assertion(), - Self::JsImportCombinedClause(clause) => clause.assertion(), + Self::JsImportBareClause(clause) => clause.attribute(), + Self::JsImportDefaultClause(clause) => clause.attribute(), + Self::JsImportNamedClause(clause) => clause.attribute(), + Self::JsImportNamespaceClause(clause) => clause.attribute(), + Self::JsImportCombinedClause(clause) => clause.attribute(), } } } diff --git a/crates/biome_js_syntax/src/lib.rs b/crates/biome_js_syntax/src/lib.rs index fe5db8221d59..adbd584e6dd7 100644 --- a/crates/biome_js_syntax/src/lib.rs +++ b/crates/biome_js_syntax/src/lib.rs @@ -108,7 +108,7 @@ impl biome_rowan::SyntaxKind for JsSyntaxKind { | JS_BOGUS_BINDING | JS_BOGUS_MEMBER | JS_BOGUS_EXPRESSION - | JS_BOGUS_IMPORT_ASSERTION_ENTRY + | JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY | JS_BOGUS_NAMED_IMPORT_SPECIFIER | JS_BOGUS_ASSIGNMENT | TS_BOGUS_TYPE @@ -125,7 +125,7 @@ impl biome_rowan::SyntaxKind for JsSyntaxKind { } kind if AnyJsAssignment::can_cast(*kind) => JS_BOGUS_ASSIGNMENT, kind if AnyJsNamedImportSpecifier::can_cast(*kind) => JS_BOGUS_NAMED_IMPORT_SPECIFIER, - kind if AnyJsImportAssertionEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ASSERTION_ENTRY, + kind if AnyJsImportAttributeEntry::can_cast(*kind) => JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY, kind if AnyJsParameter::can_cast(*kind) => JS_BOGUS_PARAMETER, kind if AnyTsType::can_cast(*kind) => TS_BOGUS_TYPE, diff --git a/xtask/codegen/js.ungram b/xtask/codegen/js.ungram index 5d96f46deca8..917a7796b272 100644 --- a/xtask/codegen/js.ungram +++ b/xtask/codegen/js.ungram @@ -44,7 +44,7 @@ JsBogusMember = SyntaxElement* JsBogusBinding = SyntaxElement* JsBogusAssignment = SyntaxElement* JsBogusParameter = SyntaxElement* -JsBogusImportAssertionEntry = SyntaxElement* +JsBogusImportAttributeEntry = SyntaxElement* JsBogusNamedImportSpecifier = SyntaxElement* TsBogusType = SyntaxElement* @@ -1237,7 +1237,7 @@ AnyJsImportClause = // import "abcd" assert ... JsImportBareClause = source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import foo from "mod" // import type foo from "mod" @@ -1246,7 +1246,7 @@ JsImportDefaultClause = default_specifier: JsDefaultImportSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import * as foo from "mod"; // import type * as foo from "mod"; @@ -1255,7 +1255,7 @@ JsImportNamespaceClause = namespace_specifier: JsNamespaceImportSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import { a, b: c } from "d"; // ^^^^^^^^^^^^^^^^^^^^ @@ -1268,7 +1268,7 @@ JsImportNamedClause = named_specifiers: JsNamedImportSpecifiers 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? // import c, { b } from "c" // ^^^^^^^^^^^^^^^^^ @@ -1282,7 +1282,7 @@ JsImportCombinedClause = specifier: AnyJsCombinedSpecifier 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? AnyJsCombinedSpecifier = JsNamedImportSpecifiers | JsNamespaceImportSpecifier @@ -1328,23 +1328,23 @@ JsShorthandNamedImportSpecifier = 'type'? local_name: AnyJsBinding -// import a from "mod" assert { type: "json" } -// ^^^^^^^^^^^^^^^^^^^^^^^ -JsImportAssertion = +// import a from "mod" with { type: "json" } +// ^^^^^^^^^^^^^^^^^^^^^ +JsImportAttribute = 'with' '{' - assertions: JsImportAssertionEntryList + attributes: JsImportAttributeEntryList '}' -JsImportAssertionEntryList = (AnyJsImportAssertionEntry (',' AnyJsImportAssertionEntry)* ','?) +JsImportAttributeEntryList = (AnyJsImportAttributeEntry (',' AnyJsImportAttributeEntry)* ','?) -AnyJsImportAssertionEntry = - JsImportAssertionEntry - | JsBogusImportAssertionEntry +AnyJsImportAttributeEntry = + JsImportAttributeEntry + | JsBogusImportAttributeEntry -// import a from "mod" assert { type: "json" } -// ^^^^^^^^^^^^ -JsImportAssertionEntry = +// import a from "mod" with { type: "json" } +// ^^^^^^^^^^^^ +JsImportAttributeEntry = key: ('ident' | 'js_string_literal') ':' value: 'js_string_literal' @@ -1483,7 +1483,7 @@ JsExportFromClause = export_as: JsExportAsClause? 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? // export { a } from "b"; @@ -1497,7 +1497,7 @@ JsExportNamedFromClause = '}' 'from' source: AnyJsModuleSource - assertion: JsImportAssertion? + attribute: JsImportAttribute? ';'? AnyJsModuleSource = diff --git a/xtask/codegen/src/js_kinds_src.rs b/xtask/codegen/src/js_kinds_src.rs index 09f05a304392..9102e0a5e6e0 100644 --- a/xtask/codegen/src/js_kinds_src.rs +++ b/xtask/codegen/src/js_kinds_src.rs @@ -356,9 +356,9 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_DEFAULT_IMPORT_SPECIFIER", "JS_NAMED_IMPORT_SPECIFIER", "JS_SHORTHAND_NAMED_IMPORT_SPECIFIER", - "JS_IMPORT_ASSERTION", - "JS_IMPORT_ASSERTION_ENTRY_LIST", - "JS_IMPORT_ASSERTION_ENTRY", + "JS_IMPORT_ATTRIBUTE", + "JS_IMPORT_ATTRIBUTE_ENTRY_LIST", + "JS_IMPORT_ATTRIBUTE_ENTRY", "JS_MODULE_SOURCE", "JS_EXPORT", "JS_EXPORT_NAMED_CLAUSE", @@ -519,7 +519,7 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "JS_BOGUS_MEMBER", "JS_BOGUS_BINDING", "JS_BOGUS_PARAMETER", - "JS_BOGUS_IMPORT_ASSERTION_ENTRY", + "JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY", "JS_BOGUS_NAMED_IMPORT_SPECIFIER", "JS_BOGUS_ASSIGNMENT", "TS_BOGUS_TYPE",