Skip to content

Commit 59f3d6a

Browse files
committed
refactor(language_server): Worker::did_change_configuration consume serde_json::Value (#15344)
1 parent b84baf7 commit 59f3d6a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

crates/oxc_language_server/src/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl LanguageServer for Backend {
312312
};
313313

314314
let (diagnostics, registrations, unregistrations, formatter_activated) =
315-
worker.did_change_configuration(&option.options).await;
315+
worker.did_change_configuration(option.options).await;
316316

317317
if formatter_activated && self.capabilities.get().is_some_and(|c| c.dynamic_formatting)
318318
{

crates/oxc_language_server/src/worker.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl WorkspaceWorker {
351351
/// Panics if the root URI cannot be converted to a file path.
352352
pub async fn did_change_configuration(
353353
&self,
354-
changed_options_json: &serde_json::Value,
354+
changed_options_json: serde_json::Value,
355355
) -> (
356356
// Diagnostic reports that need to be revalidated
357357
Option<Vec<(String, Vec<Diagnostic>)>>,
@@ -451,7 +451,7 @@ impl WorkspaceWorker {
451451
.map(|linter: &ServerLinter| linter.get_cached_files_of_diagnostics())
452452
};
453453

454-
self.refresh_server_linter(changed_options_json.clone()).await;
454+
self.refresh_server_linter(changed_options_json).await;
455455

456456
// Get the Watch patterns (including the files from oxlint `extends`)
457457
let patterns = {
@@ -582,7 +582,7 @@ mod test_watchers {
582582

583583
fn did_change_configuration(
584584
&self,
585-
options: &serde_json::Value,
585+
options: serde_json::Value,
586586
) -> (Vec<Registration>, Vec<Unregistration>) {
587587
let (_, registration, unregistration, _) = tokio::runtime::Runtime::new()
588588
.unwrap()
@@ -743,15 +743,15 @@ mod test_watchers {
743743
#[test]
744744
fn test_no_change() {
745745
let tester = Tester::new("fixtures/watcher/default", &json!({}));
746-
let (registration, unregistrations) = tester.did_change_configuration(&json!({}));
746+
let (registration, unregistrations) = tester.did_change_configuration(json!({}));
747747
assert!(registration.is_empty());
748748
assert!(unregistrations.is_empty());
749749
}
750750

751751
#[test]
752752
fn test_lint_config_path_change() {
753753
let tester = Tester::new("fixtures/watcher/default", &json!({}));
754-
let (registration, unregistrations) = tester.did_change_configuration(&json!( {
754+
let (registration, unregistrations) = tester.did_change_configuration(json!( {
755755
"configPath": "configs/lint.json"
756756
}));
757757

@@ -771,7 +771,7 @@ mod test_watchers {
771771
#[test]
772772
fn test_lint_other_option_change() {
773773
let tester = Tester::new("fixtures/watcher/default", &json!({}));
774-
let (registration, unregistrations) = tester.did_change_configuration(&json!({
774+
let (registration, unregistrations) = tester.did_change_configuration(json!({
775775
// run is the only option that does not require a restart
776776
"run": "onSave"
777777
}));
@@ -787,7 +787,7 @@ mod test_watchers {
787787
"fmt.experimental": true,
788788
}),
789789
);
790-
let (registration, unregistrations) = tester.did_change_configuration(&json!({
790+
let (registration, unregistrations) = tester.did_change_configuration(json!({
791791
"fmt.experimental": true
792792
}));
793793

@@ -803,7 +803,7 @@ mod test_watchers {
803803
"fmt.experimental": true
804804
}),
805805
);
806-
let (registration, unregistrations) = tester.did_change_configuration(&json!( {
806+
let (registration, unregistrations) = tester.did_change_configuration(json!( {
807807
"configPath": "configs/lint.json",
808808
"fmt.experimental": true
809809
}));
@@ -822,7 +822,7 @@ mod test_watchers {
822822
#[test]
823823
fn test_formatter_experimental_enabled() {
824824
let tester = Tester::new("fixtures/watcher/default", &json!({}));
825-
let (registration, unregistrations) = tester.did_change_configuration(&json!({
825+
let (registration, unregistrations) = tester.did_change_configuration(json!({
826826
"fmt.experimental": true
827827
}));
828828

@@ -843,7 +843,7 @@ mod test_watchers {
843843
"fmt.experimental": true
844844
}),
845845
);
846-
let (registration, unregistrations) = tester.did_change_configuration(&json!({
846+
let (registration, unregistrations) = tester.did_change_configuration(json!({
847847
"fmt.experimental": true,
848848
"fmt.configPath": "configs/formatter.json"
849849
}));
@@ -873,7 +873,7 @@ mod test_watchers {
873873
"fmt.experimental": true
874874
}),
875875
);
876-
let (registration, unregistrations) = tester.did_change_configuration(&json!({
876+
let (registration, unregistrations) = tester.did_change_configuration(json!({
877877
"fmt.experimental": false
878878
}));
879879

0 commit comments

Comments
 (0)