-
-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(biome_js_parser): support defer attribute in import statements #4301
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,6 +294,28 @@ fn parse_import_clause(p: &mut JsParser) -> ParsedSyntax { | |
p.eat(T![type]); | ||
} | ||
|
||
// test js import_defer_clause | ||
// import defer * as yNamespace from "y"; | ||
Comment on lines
+297
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this case maybe need to be an error. |
||
let is_defer = 'is_defer: { | ||
if !p.at(T![defer]) { | ||
break 'is_defer false; | ||
} | ||
|
||
if matches!(p.nth(1), T![*] | T!['{']) { | ||
ah-yu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break 'is_defer true; | ||
} | ||
|
||
if !is_nth_at_identifier_binding(p, 1) { | ||
break 'is_defer false; | ||
} | ||
|
||
!p.nth_at(1, T![from]) || p.nth_at(2, T![from]) | ||
}; | ||
|
||
if is_defer { | ||
p.eat(T![defer]); | ||
} | ||
|
||
let clause = match p.cur() { | ||
T![*] => parse_import_namespace_clause_rest(p, m), | ||
T!['{'] => parse_import_named_clause_rest(p, m), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import defer * as yNamespace from "y"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
JsModule { | ||
bom_token: missing (optional), | ||
interpreter_token: missing (optional), | ||
directives: JsDirectiveList [], | ||
items: JsModuleItemList [ | ||
JsImport { | ||
import_token: IMPORT_KW@0..7 "import" [] [Whitespace(" ")], | ||
import_clause: JsImportNamespaceClause { | ||
type_token: missing (optional), | ||
defer_token: DEFER_KW@7..13 "defer" [] [Whitespace(" ")], | ||
namespace_specifier: JsNamespaceImportSpecifier { | ||
star_token: STAR@13..15 "*" [] [Whitespace(" ")], | ||
as_token: AS_KW@15..18 "as" [] [Whitespace(" ")], | ||
local_name: JsIdentifierBinding { | ||
name_token: IDENT@18..29 "yNamespace" [] [Whitespace(" ")], | ||
}, | ||
}, | ||
from_token: FROM_KW@29..34 "from" [] [Whitespace(" ")], | ||
source: JsModuleSource { | ||
value_token: JS_STRING_LITERAL@34..37 "\"y\"" [] [], | ||
}, | ||
assertion: missing (optional), | ||
}, | ||
semicolon_token: SEMICOLON@37..38 ";" [] [], | ||
}, | ||
], | ||
eof_token: EOF@38..39 "" [Newline("\n")] [], | ||
} | ||
|
||
0: JS_MODULE@0..39 | ||
0: (empty) | ||
1: (empty) | ||
2: JS_DIRECTIVE_LIST@0..0 | ||
3: JS_MODULE_ITEM_LIST@0..38 | ||
0: JS_IMPORT@0..38 | ||
0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] | ||
1: JS_IMPORT_NAMESPACE_CLAUSE@7..37 | ||
0: (empty) | ||
1: DEFER_KW@7..13 "defer" [] [Whitespace(" ")] | ||
2: JS_NAMESPACE_IMPORT_SPECIFIER@13..29 | ||
0: STAR@13..15 "*" [] [Whitespace(" ")] | ||
1: AS_KW@15..18 "as" [] [Whitespace(" ")] | ||
2: JS_IDENTIFIER_BINDING@18..29 | ||
0: IDENT@18..29 "yNamespace" [] [Whitespace(" ")] | ||
3: FROM_KW@29..34 "from" [] [Whitespace(" ")] | ||
4: JS_MODULE_SOURCE@34..37 | ||
0: JS_STRING_LITERAL@34..37 "\"y\"" [] [] | ||
5: (empty) | ||
2: SEMICOLON@37..38 ";" [] [] | ||
4: EOF@38..39 "" [Newline("\n")] [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.