From 839217770cfe03f40f12c48c4a24ca96fffe46a8 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:32:41 +0000 Subject: [PATCH] refactor(linter): clean up the runtime after the module record change (#7557) --- crates/oxc_linter/src/service/runtime.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/oxc_linter/src/service/runtime.rs b/crates/oxc_linter/src/service/runtime.rs index d7cabe62b04d6..ac7e0d6cb6295 100644 --- a/crates/oxc_linter/src/service/runtime.rs +++ b/crates/oxc_linter/src/service/runtime.rs @@ -211,22 +211,13 @@ impl Runtime { }; }; - // Build the module record to unblock other threads from waiting for too long. - // The semantic model is not built at this stage. - let semantic_builder = SemanticBuilder::new() - .with_cfg(true) - .with_scope_tree_child_ids(true) - .with_build_jsdoc(true) - .with_check_syntax_error(check_syntax_errors); - - let mut module_record = ModuleRecord::new(path, &ret.module_record); - module_record.resolved_absolute_path = path.to_path_buf(); - let module_record = Arc::new(module_record); + let module_record = Arc::new(ModuleRecord::new(path, &ret.module_record)); + // If import plugin is enabled. if self.resolver.is_some() { self.modules.add_resolved_module(path, Arc::clone(&module_record)); - // Retrieve all dependency modules from this module. + // Retrieve all dependent modules from this module. let dir = path.parent().unwrap(); module_record .requested_modules @@ -291,7 +282,12 @@ impl Runtime { } } - let semantic_ret = semantic_builder.build(&ret.program); + let semantic_ret = SemanticBuilder::new() + .with_cfg(true) + .with_scope_tree_child_ids(true) + .with_build_jsdoc(true) + .with_check_syntax_error(check_syntax_errors) + .build(&ret.program); if !semantic_ret.errors.is_empty() { return semantic_ret.errors.into_iter().map(|err| Message::new(err, None)).collect();