Skip to content

Commit 92e1dda

Browse files
committed
chore: better param typing for get_analyzer_plugins_for_project
1 parent 9c77d21 commit 92e1dda

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

crates/biome_service/src/workspace/server.rs

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ use camino::{Utf8Path, Utf8PathBuf};
5353
use crossbeam::channel::Sender;
5454
use papaya::{Compute, HashMap, HashSet, Operation};
5555
use rustc_hash::{FxBuildHasher, FxHashMap};
56-
use std::borrow::Cow;
5756
use std::panic::RefUnwindSafe;
5857
use std::sync::atomic::{AtomicUsize, Ordering};
5958
use std::sync::{Arc, Mutex};
@@ -579,10 +578,10 @@ impl WorkspaceServer {
579578
fn get_analyzer_plugins_for_project(
580579
&self,
581580
project_key: ProjectKey,
582-
plugins: Cow<Plugins>,
581+
plugins: &Plugins,
583582
) -> Result<AnalyzerPluginVec, Vec<PluginDiagnostic>> {
584583
match self.plugin_caches.pin().get(&project_key) {
585-
Some(cache) => cache.get_analyzer_plugins(&plugins),
584+
Some(cache) => cache.get_analyzer_plugins(plugins),
586585
None => Ok(Vec::new()),
587586
}
588587
}
@@ -1216,50 +1215,52 @@ impl Workspace for WorkspaceServer {
12161215
let parse = self.get_parse(&path)?;
12171216
let language = self.get_file_source(&path);
12181217
let capabilities = self.features.get_capabilities(language);
1219-
let (diagnostics, errors, skipped_diagnostics) = if let Some(lint) =
1220-
capabilities.analyzer.lint
1221-
{
1222-
let settings = self
1223-
.projects
1224-
.get_settings(project_key)
1225-
.ok_or_else(WorkspaceError::no_project)?;
1226-
let plugins = self
1227-
.get_analyzer_plugins_for_project(project_key, settings.get_plugins_for_path(&path))
1228-
.map_err(WorkspaceError::plugin_errors)?;
1229-
let results = lint(LintParams {
1230-
parse,
1231-
workspace: &settings.into(),
1232-
path: &path,
1233-
only,
1234-
skip,
1235-
language,
1236-
categories,
1237-
module_graph: self.module_graph.clone(),
1238-
project_layout: self.project_layout.clone(),
1239-
suppression_reason: None,
1240-
enabled_rules,
1241-
pull_code_actions,
1242-
plugins: if categories.contains(RuleCategory::Lint) {
1243-
plugins
1244-
} else {
1245-
Vec::new()
1246-
},
1247-
});
1218+
let (diagnostics, errors, skipped_diagnostics) =
1219+
if let Some(lint) = capabilities.analyzer.lint {
1220+
let settings = self
1221+
.projects
1222+
.get_settings(project_key)
1223+
.ok_or_else(WorkspaceError::no_project)?;
1224+
let plugins = self
1225+
.get_analyzer_plugins_for_project(
1226+
project_key,
1227+
&settings.get_plugins_for_path(&path),
1228+
)
1229+
.map_err(WorkspaceError::plugin_errors)?;
1230+
let results = lint(LintParams {
1231+
parse,
1232+
workspace: &settings.into(),
1233+
path: &path,
1234+
only,
1235+
skip,
1236+
language,
1237+
categories,
1238+
module_graph: self.module_graph.clone(),
1239+
project_layout: self.project_layout.clone(),
1240+
suppression_reason: None,
1241+
enabled_rules,
1242+
pull_code_actions,
1243+
plugins: if categories.contains(RuleCategory::Lint) {
1244+
plugins
1245+
} else {
1246+
Vec::new()
1247+
},
1248+
});
12481249

1249-
(
1250-
results.diagnostics,
1251-
results.errors,
1252-
results.skipped_diagnostics,
1253-
)
1254-
} else {
1255-
let parse_diagnostics = parse.into_diagnostics();
1256-
let errors = parse_diagnostics
1257-
.iter()
1258-
.filter(|diag| diag.severity() <= Severity::Error)
1259-
.count();
1250+
(
1251+
results.diagnostics,
1252+
results.errors,
1253+
results.skipped_diagnostics,
1254+
)
1255+
} else {
1256+
let parse_diagnostics = parse.into_diagnostics();
1257+
let errors = parse_diagnostics
1258+
.iter()
1259+
.filter(|diag| diag.severity() <= Severity::Error)
1260+
.count();
12601261

1261-
(parse_diagnostics, errors, 0)
1262-
};
1262+
(parse_diagnostics, errors, 0)
1263+
};
12631264

12641265
info!(
12651266
"Pulled {:?} diagnostic(s), skipped {:?} diagnostic(s) from {}",
@@ -1453,7 +1454,7 @@ impl Workspace for WorkspaceServer {
14531454
.get_settings(project_key)
14541455
.ok_or_else(WorkspaceError::no_project)?;
14551456
let plugins = self
1456-
.get_analyzer_plugins_for_project(project_key, settings.get_plugins_for_path(&path))
1457+
.get_analyzer_plugins_for_project(project_key, &settings.get_plugins_for_path(&path))
14571458
.map_err(WorkspaceError::plugin_errors)?;
14581459
let language = self.get_file_source(&path);
14591460
fix_all(FixAllParams {

0 commit comments

Comments
 (0)