Skip to content

Commit

Permalink
feat: upgrade to swc_ecma_parser 0.148 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jul 25, 2024
1 parent 1d6f9f1 commit ab71d25
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 120 deletions.
163 changes: 88 additions & 75 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion generation/generate/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function writeType(writer: Writer, analysisResult: AnalysisResult, type:
}

function writeReference(type: TypeReferenceDefinition) {
const path = type.path.join("::").replace(/^swc_ecma_ast::/, "");
const path = type.path.join("::").replace(/^swc_ecma_ast::/, "").replace("swc_common::syntax_pos::hygiene::SyntaxContext", "swc_common::SyntaxContext");
if (
type.path[0] === "swc_ecma_ast"
&& (analysisResult.astEnums.some(e => e.name === type.name) || analysisResult.astStructs.some(s => s.name === type.name))
Expand Down Expand Up @@ -77,6 +77,10 @@ export function getIsReferenceType(analysisResult: AnalysisResult, type: TypeDef
return getIsReferenceType(analysisResult, type.genericArgs[0]);
}

if (type.name === "SyntaxContext") {
return false;
}

const isSwcPlainEnumType = type != null && type.kind === "Reference" && analysisResult.plainEnums.some(e => e.name === type.name);
if (isSwcPlainEnumType) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions rs-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ bumpalo = { version = "3.16.0", optional = true, features = ["collections", "all
num-bigint = "0.4"
rustc-hash = "1.1.0"
swc_atoms = "0.6.7"
swc_common = "0.34.4"
swc_ecma_ast = "0.115.1"
swc_ecma_parser = "0.146.12"
swc_common = "0.36.2"
swc_ecma_ast = "0.117.4"
swc_ecma_parser = "0.148.1"
text_lines = "0.6.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rs-lib/src/common/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<T: Into<SourcePos> + Clone + Copy> SourceRanged for SourceRange<T> {
#[allow(clippy::from_over_into)]
impl Into<Span> for SourceRange {
fn into(self) -> Span {
Span::new(self.start.as_byte_pos(), self.end.as_byte_pos(), Default::default())
Span::new(self.start.as_byte_pos(), self.end.as_byte_pos())
}
}

Expand Down
2 changes: 1 addition & 1 deletion rs-lib/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn get_swc_module(file_path: &Path, file_text: &str) -> (Module, Vec<TokenAn

let comments: SingleThreadedComments = Default::default();
return {
let ts_config = crate::swc::parser::TsConfig {
let ts_config = crate::swc::parser::TsSyntax {
tsx: should_parse_as_jsx(file_path),
decorators: true,
..Default::default()
Expand Down
4 changes: 0 additions & 4 deletions rs-lib/src/view/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ impl<'a> Ident<'a> {
pub fn to_id(&self) -> Id {
(self.sym().clone(), self.ctxt())
}

pub fn ctxt(&self) -> SyntaxContext {
self.inner.span.ctxt
}
}

impl<'a> BindingIdent<'a> {
Expand Down
Loading

0 comments on commit ab71d25

Please # to comment.