mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
fix: update deno_lint and swc (#21718)
Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
parent
741afc4b94
commit
69959aa01f
14 changed files with 320 additions and 300 deletions
11
cli/cache/module_info.rs
vendored
11
cli/cache/module_info.rs
vendored
|
@ -6,11 +6,9 @@ use deno_ast::MediaType;
|
|||
use deno_ast::ModuleSpecifier;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_graph::CapturingModuleParser;
|
||||
use deno_graph::DefaultModuleAnalyzer;
|
||||
use deno_graph::ModuleInfo;
|
||||
use deno_graph::ModuleParser;
|
||||
use deno_graph::ParsedSourceStore;
|
||||
use deno_runtime::deno_webstorage::rusqlite::params;
|
||||
|
||||
use super::cache_db::CacheDB;
|
||||
|
@ -115,19 +113,18 @@ impl ModuleInfoCache {
|
|||
|
||||
pub fn as_module_analyzer<'a>(
|
||||
&'a self,
|
||||
parser: Option<&'a dyn ModuleParser>,
|
||||
store: &'a dyn ParsedSourceStore,
|
||||
parser: &'a dyn ModuleParser,
|
||||
) -> ModuleInfoCacheModuleAnalyzer<'a> {
|
||||
ModuleInfoCacheModuleAnalyzer {
|
||||
module_info_cache: self,
|
||||
parser: CapturingModuleParser::new(parser, store),
|
||||
parser,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ModuleInfoCacheModuleAnalyzer<'a> {
|
||||
module_info_cache: &'a ModuleInfoCache,
|
||||
parser: CapturingModuleParser<'a>,
|
||||
parser: &'a dyn ModuleParser,
|
||||
}
|
||||
|
||||
impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
|
||||
|
@ -156,7 +153,7 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> {
|
|||
}
|
||||
|
||||
// otherwise, get the module info from the parsed source cache
|
||||
let analyzer = DefaultModuleAnalyzer::new(&self.parser);
|
||||
let analyzer = DefaultModuleAnalyzer::new(self.parser);
|
||||
let module_info = analyzer.analyze(specifier, source, media_type)?;
|
||||
|
||||
// then attempt to cache it
|
||||
|
|
30
cli/cache/parsed_source.rs
vendored
30
cli/cache/parsed_source.rs
vendored
|
@ -9,6 +9,7 @@ use deno_ast::ParsedSource;
|
|||
use deno_core::parking_lot::Mutex;
|
||||
use deno_graph::CapturingModuleParser;
|
||||
use deno_graph::ModuleParser;
|
||||
use deno_graph::ParseOptions;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ParsedSourceCache {
|
||||
|
@ -37,7 +38,13 @@ impl ParsedSourceCache {
|
|||
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
|
||||
let parser = self.as_capturing_parser();
|
||||
// this will conditionally parse because it's using a CapturingModuleParser
|
||||
parser.parse_module(specifier, source, media_type)
|
||||
parser.parse_module(ParseOptions {
|
||||
specifier,
|
||||
source,
|
||||
media_type,
|
||||
// don't bother enabling because this method is currently only used for emitting
|
||||
scope_analysis: false,
|
||||
})
|
||||
}
|
||||
|
||||
/// Frees the parsed source from memory.
|
||||
|
@ -50,10 +57,6 @@ impl ParsedSourceCache {
|
|||
pub fn as_capturing_parser(&self) -> CapturingModuleParser {
|
||||
CapturingModuleParser::new(None, self)
|
||||
}
|
||||
|
||||
pub fn as_store(self: &Arc<Self>) -> Arc<dyn deno_graph::ParsedSourceStore> {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// It's ok that this is racy since in non-LSP situations
|
||||
|
@ -76,4 +79,21 @@ impl deno_graph::ParsedSourceStore for ParsedSourceCache {
|
|||
) -> Option<ParsedSource> {
|
||||
self.sources.lock().get(specifier).cloned()
|
||||
}
|
||||
|
||||
fn get_scope_analysis_parsed_source(
|
||||
&self,
|
||||
specifier: &deno_graph::ModuleSpecifier,
|
||||
) -> Option<ParsedSource> {
|
||||
let mut sources = self.sources.lock();
|
||||
let parsed_source = sources.get(specifier)?;
|
||||
if parsed_source.has_scope_analysis() {
|
||||
Some(parsed_source.clone())
|
||||
} else {
|
||||
// upgrade to have scope analysis
|
||||
let parsed_source = sources.remove(specifier).unwrap();
|
||||
let parsed_source = parsed_source.into_with_scope_analysis();
|
||||
sources.insert(specifier.clone(), parsed_source.clone());
|
||||
Some(parsed_source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue