@@ -18,8 +18,7 @@ use biome_service::{Watcher, WatcherOptions};
1818use futures:: channel:: mpsc:: channel;
1919use std:: collections:: { BTreeMap , HashMap } ;
2020use std:: str:: FromStr ;
21- use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
22- use std:: sync:: { Arc , Barrier } ;
21+ use std:: sync:: Arc ;
2322use std:: time:: Duration ;
2423use tokio:: task:: spawn_blocking;
2524use tokio:: time:: sleep;
@@ -35,60 +34,6 @@ use tower_lsp_server::ls_types::{
3534 WorkspaceFolder ,
3635} ;
3736
38- #[ salsa:: input( debug) ]
39- struct CancellationInput {
40- value : u32 ,
41- }
42-
43- #[ salsa:: tracked]
44- fn cancellable_query ( db : & dyn salsa:: Database , input : CancellationInput ) -> u32 {
45- if CANCELLABLE_QUERY_ATTEMPTS . fetch_add ( 1 , Ordering :: SeqCst ) == 0 {
46- CANCELLABLE_QUERY_STARTED . wait ( ) ;
47- CANCELLABLE_QUERY_CONTINUE . wait ( ) ;
48- db. unwind_if_revision_cancelled ( ) ;
49- }
50-
51- input. value ( db)
52- }
53-
54- #[ salsa:: db]
55- #[ derive( Clone , Default ) ]
56- struct CancellationTestDb {
57- storage : salsa:: Storage < Self > ,
58- }
59-
60- #[ salsa:: db]
61- impl salsa:: Database for CancellationTestDb { }
62-
63- static CANCELLABLE_QUERY_STARTED : Barrier = Barrier :: new ( 2 ) ;
64- static CANCELLABLE_QUERY_CONTINUE : Barrier = Barrier :: new ( 2 ) ;
65- static CANCELLABLE_QUERY_ATTEMPTS : AtomicUsize = AtomicUsize :: new ( 0 ) ;
66-
67- #[ test]
68- fn catches_real_salsa_query_cancellation ( ) {
69- CANCELLABLE_QUERY_ATTEMPTS . store ( 0 , Ordering :: SeqCst ) ;
70-
71- let db = CancellationTestDb :: default ( ) ;
72- let token = salsa:: Database :: cancellation_token ( & db) ;
73- let input = CancellationInput :: new ( & db, 1 ) ;
74-
75- let result = std:: thread:: scope ( |scope| {
76- scope. spawn ( || {
77- CANCELLABLE_QUERY_STARTED . wait ( ) ;
78- token. cancel ( ) ;
79- CANCELLABLE_QUERY_CONTINUE . wait ( ) ;
80- } ) ;
81-
82- super :: catch_lsp_operation ( || cancellable_query ( & db, input) )
83- } ) ;
84-
85- assert ! (
86- matches!( result, Ok ( Err ( salsa:: Cancelled :: Local ) ) ) ,
87- "{result:?}"
88- ) ;
89- assert_eq ! ( CANCELLABLE_QUERY_ATTEMPTS . load( Ordering :: SeqCst ) , 1 ) ;
90- }
91-
9237#[ test]
9338fn catches_regular_panics_as_panic_errors ( ) {
9439 let result: std:: result:: Result <
0 commit comments