mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
refactor(es/parser): Remove duplicate (#4750)
This commit is contained in:
parent
4d606effdf
commit
b7a195a1cf
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3470,7 +3470,6 @@ dependencies = [
|
||||
"testing",
|
||||
"tracing",
|
||||
"typed-arena",
|
||||
"unicode-id",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
|
@ -150,6 +150,7 @@ impl Ident {
|
||||
}
|
||||
|
||||
/// Returns true if `c` is a valid character for an identifier start.
|
||||
#[inline]
|
||||
pub fn is_valid_start(c: char) -> bool {
|
||||
c == '$' || c == '_' || c.is_ascii_alphabetic() || {
|
||||
if c.is_ascii() {
|
||||
@ -162,6 +163,7 @@ impl Ident {
|
||||
|
||||
/// Returns true if `c` is a valid character for an identifier part after
|
||||
/// start.
|
||||
#[inline]
|
||||
pub fn is_valid_continue(c: char) -> bool {
|
||||
c == '$' || c == '_' || c == '\u{200c}' || c == '\u{200d}' || c.is_ascii_alphanumeric() || {
|
||||
if c.is_ascii() {
|
||||
|
@ -36,7 +36,6 @@ swc_ecma_ast = { version = "0.78.0", path = "../swc_ecma_ast" }
|
||||
swc_ecma_visit = { version = "0.64.0", path = "../swc_ecma_visit", optional = true }
|
||||
tracing = "0.1.32"
|
||||
typed-arena = "2.0.1"
|
||||
unicode-id = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
@ -8,8 +8,8 @@ use swc_common::{
|
||||
comments::{Comment, CommentKind},
|
||||
BytePos, Span, SyntaxContext,
|
||||
};
|
||||
use swc_ecma_ast::Ident;
|
||||
use tracing::warn;
|
||||
use unicode_id::UnicodeID;
|
||||
|
||||
use super::{comments_buffer::BufferedComment, input::Input, Char, LexResult, Lexer};
|
||||
use crate::{
|
||||
@ -351,13 +351,7 @@ pub trait CharExt: Copy {
|
||||
Some(c) => c,
|
||||
None => return false,
|
||||
};
|
||||
c == '$' || c == '_' || c.is_ascii_alphabetic() || {
|
||||
if c.is_ascii() {
|
||||
false
|
||||
} else {
|
||||
UnicodeID::is_id_start(c)
|
||||
}
|
||||
}
|
||||
Ident::is_valid_start(c)
|
||||
}
|
||||
|
||||
/// Test whether a given character is part of an identifier.
|
||||
@ -367,13 +361,7 @@ pub trait CharExt: Copy {
|
||||
Some(c) => c,
|
||||
None => return false,
|
||||
};
|
||||
c == '$' || c == '_' || c == '\u{200c}' || c == '\u{200d}' || c.is_ascii_alphanumeric() || {
|
||||
if c.is_ascii() {
|
||||
false
|
||||
} else {
|
||||
UnicodeID::is_id_continue(c)
|
||||
}
|
||||
}
|
||||
Ident::is_valid_continue(c)
|
||||
}
|
||||
|
||||
/// See https://tc39.github.io/ecma262/#sec-line-terminators
|
||||
|
Loading…
Reference in New Issue
Block a user