Skip to content

Commit

Permalink
fixup for rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 5, 2024
1 parent cb117a7 commit b69558e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 1 addition & 3 deletions crates/swc_ecma_parser/src/parser/class_and_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,8 @@ impl<I: Tokens> Parser<I> {

fn is_class_property(&mut self, asi: bool) -> bool {
(self.input.syntax().typescript() && is!(self, '!' | ':'))
|| is!(self, '=' | '}')
(self.input.syntax().typescript() && is_one_of!(self, '!', ':'))
|| (self.input.syntax().flow() && is!(self, ':'))
|| is_one_of!(self, '=', '}')
|| is!(self, '=' | '}')
|| if asi {
is!(self, ';')
} else {
Expand Down
31 changes: 17 additions & 14 deletions crates/swc_ecma_parser/src/parser/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where
I: Tokens,
{
pub(super) fn may_consume_flow_type_param_decls(&mut self) -> PResult<()> {
if !is_one_of!(self, '<', JSXTagStart) {
if !is!(self, '<' | JSXTagStart) {
return Ok(());
}

Expand Down Expand Up @@ -240,7 +240,7 @@ where
let start_pos = self.input.cur_pos();
self.consume_flow_primary_type()?;

while is_one_of!(self, '[', '?') && !self.input.had_line_break_before_cur() {
while is!(self, '[' | '?') && !self.input.had_line_break_before_cur() {
let optional = eat!(self, '?');

expect!(self, '[');
Expand Down Expand Up @@ -338,14 +338,17 @@ where
return Ok(());
}

if is_one_of!(self, Str, Num, BigInt, "true", "false", "null", "this", '*') {
if is!(
self,
Str | Num | BigInt | "true" | "false" | "null" | "this" | '*'
) {
self.input.bump();
return Ok(());
}

if is_one_of!(self, '+', '-') {
if is!(self, '+' | '-') {
self.input.bump();
if is_one_of!(self, Num, BigInt) {
if is!(self, Num | BigInt) {
self.input.bump();
return Ok(());
}
Expand Down Expand Up @@ -598,7 +601,7 @@ where
} else {
p.parse_flow_object_type_indexer((), is_static, variance)?
}
} else if is_one_of!(p, '(', '<') {
} else if is!(p, '(' | '<') {
if proto_start_loc.is_some() {
unexpected!(p, "( after proto")
}
Expand Down Expand Up @@ -666,7 +669,7 @@ where
) -> PResult<Option<()>> {
if eat!(self, "...") {
// TODO: braceBarR
let is_inexact_token = is_one_of!(self, ',', ';', '}');
let is_inexact_token = is!(self, ',' | ';' | '}');

if is_inexact_token {
if !allow_spread {
Expand Down Expand Up @@ -700,7 +703,7 @@ where

let mut optional = false;

if is_one_of!(self, '<', '(') {
if is!(self, '<' | '(') {
// This is a method property

if proto_start_loc.is_some() {
Expand Down Expand Up @@ -761,7 +764,7 @@ where
/// Ported from `flowParseObjectPropertyKey`
#[cfg_attr(feature = "tracing-spans", tracing::instrument(skip_all))]
fn consume_flow_object_property_key(&mut self) -> PResult<()> {
if is_one_of!(self, Str, Num) {
if is!(self, Str | Num) {
self.input.bump();
} else {
self.parse_ident_name()?;
Expand Down Expand Up @@ -847,7 +850,7 @@ where
expect!(self, ']');
expect!(self, ']');

if is_one_of!(self, '<', '(') {
if is!(self, '<' | '(') {
self.consume_flow_object_type_methodish(())?;
} else {
eat!(self, '?');
Expand Down Expand Up @@ -961,7 +964,7 @@ where
return Ok(Some(()));
}

if is_one_of!(p, "var", "const", "let") {
if is!(p, "var" | "const" | "let") {
p.parse_var_stmt(false)?;
return Ok(Some(()));
}
Expand Down Expand Up @@ -995,7 +998,7 @@ where

let type_only = is!(self, "type");

if is_one_of!(self, '{', '*') || (is!(self, "type") && peeked_is!(self, '*')) {
if is!(self, '{' | '*') || (is!(self, "type") && peeked_is!(self, '*')) {
self.parse_reexports(start, type_only, None, start)?;
return Ok(Some(()));
}
Expand All @@ -1010,7 +1013,7 @@ where
return Ok(Some(()));
}

if is_one_of!(self, "var", "const", "let") {
if is!(self, "var" | "const" | "let") {
self.parse_var_stmt(false)?;
return Ok(Some(()));
}
Expand Down Expand Up @@ -1070,7 +1073,7 @@ where
fn consume_flow_module_declaration(&mut self) -> PResult<()> {
assert_and_bump!(self, "module");

if is_one_of!(self, IdentName, Str) {
if is!(self, IdentName | Str) {
bump!(self);
} else {
unexpected!(self, "module name")
Expand Down
4 changes: 0 additions & 4 deletions crates/swc_ecma_parser/src/parser/stmt/module_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ impl<I: Tokens> Parser<I> {

if self.input.syntax().typescript() && local.sym == "type" {
if is!(self, '*' | '{') {
if (self.input.syntax().typescript() || self.input.syntax().flow())
&& local.sym == "type"
{
if is_one_of!(self, '*', '{') {
type_only = true;
break 'import_maybe_ident;
}
Expand Down

0 comments on commit b69558e

Please sign in to comment.