1
1
use std:: {
2
+ collections:: { HashMap , HashSet } ,
2
3
iter,
3
4
ops:: { Bound , Range } ,
4
5
} ;
@@ -35,6 +36,10 @@ pub struct FreeFunctions;
35
36
36
37
pub struct RaSpanServer {
37
38
pub ( crate ) interner : SymbolInternerRef ,
39
+ // FIXME: Report this back to the caller to track as dependencies
40
+ pub tracked_env_vars : HashMap < Box < str > , Option < Box < str > > > ,
41
+ // FIXME: Report this back to the caller to track as dependencies
42
+ pub tracked_paths : HashSet < Box < str > > ,
38
43
pub call_site : Span ,
39
44
pub def_site : Span ,
40
45
pub mixed_site : Span ,
@@ -49,11 +54,12 @@ impl server::Types for RaSpanServer {
49
54
}
50
55
51
56
impl server:: FreeFunctions for RaSpanServer {
52
- fn track_env_var ( & mut self , _var : & str , _value : Option < & str > ) {
53
- // FIXME: track env var accesses
54
- // https://github.com/rust-lang/rust/pull/71858
57
+ fn track_env_var ( & mut self , var : & str , value : Option < & str > ) {
58
+ self . tracked_env_vars . insert ( var. into ( ) , value. map ( Into :: into) ) ;
59
+ }
60
+ fn track_path ( & mut self , path : & str ) {
61
+ self . tracked_paths . insert ( path. into ( ) ) ;
55
62
}
56
- fn track_path ( & mut self , _path : & str ) { }
57
63
58
64
fn literal_from_str (
59
65
& mut self ,
@@ -247,24 +253,38 @@ impl server::Span for RaSpanServer {
247
253
/// See PR:
248
254
/// https://github.com/rust-lang/rust/pull/55780
249
255
fn source_text ( & mut self , _span : Self :: Span ) -> Option < String > {
256
+ // FIXME requires db
250
257
None
251
258
}
252
259
253
260
fn parent ( & mut self , _span : Self :: Span ) -> Option < Self :: Span > {
254
- // FIXME handle span
261
+ // FIXME requires db, looks up the parent call site
255
262
None
256
263
}
257
264
fn source ( & mut self , span : Self :: Span ) -> Self :: Span {
258
- // FIXME handle span
265
+ // FIXME requires db, returns the top level call site
259
266
span
260
267
}
261
- fn byte_range ( & mut self , _span : Self :: Span ) -> Range < usize > {
262
- // FIXME handle span
263
- Range { start : 0 , end : 0 }
268
+ fn byte_range ( & mut self , span : Self :: Span ) -> Range < usize > {
269
+ // FIXME requires db to resolve the ast id, THIS IS NOT INCREMENTAL
270
+ Range { start : span . range . start ( ) . into ( ) , end : span . range . end ( ) . into ( ) }
264
271
}
265
- fn join ( & mut self , first : Self :: Span , _second : Self :: Span ) -> Option < Self :: Span > {
266
- // Just return the first span again, because some macros will unwrap the result.
267
- Some ( first)
272
+ fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
273
+ if first. anchor != second. anchor {
274
+ return None ;
275
+ }
276
+ if first. ctx != second. ctx {
277
+ if first. ctx . is_root ( ) {
278
+ return Some ( second) ;
279
+ } else if second. ctx . is_root ( ) {
280
+ return Some ( first) ;
281
+ }
282
+ }
283
+ Some ( Span {
284
+ range : first. range . cover ( second. range ) ,
285
+ anchor : second. anchor ,
286
+ ctx : second. ctx ,
287
+ } )
268
288
}
269
289
fn subspan (
270
290
& mut self ,
0 commit comments