Skip to content

Commit

Permalink
remove lock
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Feb 5, 2025
1 parent 554586f commit 99d41a2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ impl ConfigData {
.await;
match plugin_load_result {
Ok(runner) => {
plugin_runner = Some(Arc::new(Mutex::new(runner)));
plugin_runner = Some(Arc::new(runner));
}
Err(err) => {
lsp_warn!("Failed to load lint plugins: {}", err);
Expand Down
13 changes: 5 additions & 8 deletions cli/tools/lint/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct CliLinterOptions {
pub configured_rules: ConfiguredRules,
pub fix: bool,
pub deno_lint_config: DenoLintConfig,
pub maybe_plugin_runner: Option<Arc<Mutex<PluginHostProxy>>>,
pub maybe_plugin_runner: Option<Arc<PluginHostProxy>>,
}

#[derive(Debug)]
Expand All @@ -48,7 +48,7 @@ pub struct CliLinter {
package_rules: Vec<Box<dyn PackageLintRule>>,
linter: DenoLintLinter,
deno_lint_config: DenoLintConfig,
maybe_plugin_runner: Option<Arc<Mutex<PluginHostProxy>>>,
maybe_plugin_runner: Option<Arc<PluginHostProxy>>,
}

impl CliLinter {
Expand Down Expand Up @@ -368,28 +368,25 @@ fn apply_lint_fixes(
}

fn run_plugins(
plugin_runner: Arc<Mutex<PluginHostProxy>>,
plugin_runner: Arc<PluginHostProxy>,
parsed_source: ParsedSource,
file_path: PathBuf,
maybe_token: Option<CancellationToken>,
) -> Result<ExternalLinterResult, AnyError> {
let source_text_info = parsed_source.text_info_lazy().clone();
let plugin_info = plugin_runner
.lock()
.get_plugin_rules()
.into_iter()
.map(Cow::from)
.collect();

#[allow(clippy::await_holding_lock)]
let fut = async move {
let mut plugin_runner = plugin_runner.lock();
let utf16_map = Utf16Map::new(parsed_source.text().as_ref());
let serialized_ast =
plugin_runner.serialize_ast(&parsed_source, &utf16_map)?;

plugins::run_rules_for_ast(
&mut plugin_runner,
&plugin_runner,
&file_path,
serialized_ast,
source_text_info,
Expand All @@ -415,7 +412,7 @@ struct ExternalLinterContainer {

impl ExternalLinterContainer {
pub fn new(
maybe_plugin_runner: Option<Arc<Mutex<PluginHostProxy>>>,
maybe_plugin_runner: Option<Arc<PluginHostProxy>>,
maybe_token: Option<CancellationToken>,
) -> Self {
let mut s = Self {
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl WorkspaceLinter {
exclude,
)
.await?;
plugin_runner = Some(Arc::new(Mutex::new(runner)));
plugin_runner = Some(Arc::new(runner));
}

let linter = Arc::new(CliLinter::new(CliLinterOptions {
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/lint/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ pub async fn create_runner_and_load_plugins(
}

pub async fn run_rules_for_ast(
host_proxy: &mut PluginHostProxy,
host_proxy: &PluginHostProxy,
specifier: &Path,
serialized_ast: Vec<u8>,
source_text_info: SourceTextInfo,
Expand Down

0 comments on commit 99d41a2

Please sign in to comment.