@@ -17,12 +17,12 @@ use crate::document::{FileRangeExt, ToRangeExt};
1717use crate :: session:: DocumentSnapshot ;
1818use crate :: session:: client:: Client ;
1919use crate :: system:: { AnySystemPath , file_to_url} ;
20- use crate :: { DocumentRef , PositionEncoding , Session } ;
20+ use crate :: { NotebookDocument , PositionEncoding , Session } ;
2121
2222pub ( super ) struct Diagnostics < ' a > {
2323 items : Vec < ruff_db:: diagnostic:: Diagnostic > ,
2424 encoding : PositionEncoding ,
25- document : & ' a DocumentRef ,
25+ notebook : Option < & ' a NotebookDocument > ,
2626}
2727
2828impl Diagnostics < ' _ > {
@@ -53,7 +53,7 @@ impl Diagnostics<'_> {
5353 }
5454
5555 pub ( super ) fn to_lsp_diagnostics ( & self , db : & ProjectDatabase ) -> LspDiagnostics {
56- if let Some ( notebook) = self . document . as_notebook ( ) {
56+ if let Some ( notebook) = self . notebook {
5757 let mut cell_diagnostics: FxHashMap < Url , Vec < Diagnostic > > = FxHashMap :: default ( ) ;
5858
5959 // Populates all relevant URLs with an empty diagnostic list. This ensures that documents
@@ -151,7 +151,7 @@ pub(super) fn publish_diagnostics(session: &Session, url: &lsp_types::Url, clien
151151 }
152152 } ;
153153
154- let db = session. project_db ( snapshot. file_path ( ) ) ;
154+ let db = session. project_db ( & snapshot. to_file_path ( ) ) ;
155155
156156 let Some ( diagnostics) = compute_diagnostics ( db, & snapshot) else {
157157 return ;
@@ -253,8 +253,11 @@ pub(super) fn compute_diagnostics<'a>(
253253 db : & ProjectDatabase ,
254254 snapshot : & ' a DocumentSnapshot ,
255255) -> Option < Diagnostics < ' a > > {
256- let Some ( file) = snapshot. file ( db) else {
257- tracing:: info!( "No file found for snapshot for `{}`" , snapshot. file_path( ) ) ;
256+ let Some ( file) = snapshot. to_file ( db) else {
257+ tracing:: info!(
258+ "No file found for snapshot for `{}`" ,
259+ snapshot. to_file_path( )
260+ ) ;
258261 return None ;
259262 } ;
260263
@@ -263,7 +266,7 @@ pub(super) fn compute_diagnostics<'a>(
263266 Some ( Diagnostics {
264267 items : diagnostics,
265268 encoding : snapshot. encoding ( ) ,
266- document : snapshot. document ( ) ,
269+ notebook : snapshot. notebook ( ) ,
267270 } )
268271}
269272
0 commit comments