@@ -7,8 +7,8 @@ use std::{
7
7
} ;
8
8
9
9
use ide:: {
10
- LineCol , MonikerDescriptorKind , StaticIndex , StaticIndexedFile , TextRange , TokenId ,
11
- TokenStaticData ,
10
+ LineCol , MonikerDescriptorKind , MonikerResult , StaticIndex , StaticIndexedFile , TextRange ,
11
+ TokenId ,
12
12
} ;
13
13
use ide_db:: LineIndexDatabase ;
14
14
use load_cargo:: { load_workspace_at, LoadCargoConfig , ProcMacroServerChoice } ;
@@ -109,7 +109,11 @@ impl flags::Scip {
109
109
let symbol = tokens_to_symbol
110
110
. entry ( id)
111
111
. or_insert_with ( || {
112
- let symbol = token_to_symbol ( token) . unwrap_or_else ( & mut new_local_symbol) ;
112
+ let symbol = token
113
+ . moniker
114
+ . as_ref ( )
115
+ . map ( moniker_to_symbol)
116
+ . unwrap_or_else ( & mut new_local_symbol) ;
113
117
scip:: symbol:: format_symbol ( symbol)
114
118
} )
115
119
. clone ( ) ;
@@ -228,15 +232,9 @@ fn new_descriptor(name: &str, suffix: scip_types::descriptor::Suffix) -> scip_ty
228
232
}
229
233
}
230
234
231
- /// Loosely based on `def_to_moniker`
232
- ///
233
- /// Only returns a Symbol when it's a non-local symbol.
234
- /// So if the visibility isn't outside of a document, then it will return None
235
- fn token_to_symbol ( token : & TokenStaticData ) -> Option < scip_types:: Symbol > {
235
+ fn moniker_to_symbol ( moniker : & MonikerResult ) -> scip_types:: Symbol {
236
236
use scip_types:: descriptor:: Suffix :: * ;
237
237
238
- let moniker = token. moniker . as_ref ( ) ?;
239
-
240
238
let package_name = moniker. package_information . name . clone ( ) ;
241
239
let version = moniker. package_information . version . clone ( ) ;
242
240
let descriptors = moniker
@@ -260,7 +258,7 @@ fn token_to_symbol(token: &TokenStaticData) -> Option<scip_types::Symbol> {
260
258
} )
261
259
. collect ( ) ;
262
260
263
- Some ( scip_types:: Symbol {
261
+ scip_types:: Symbol {
264
262
scheme : "rust-analyzer" . into ( ) ,
265
263
package : Some ( scip_types:: Package {
266
264
manager : "cargo" . to_string ( ) ,
@@ -271,7 +269,7 @@ fn token_to_symbol(token: &TokenStaticData) -> Option<scip_types::Symbol> {
271
269
. into ( ) ,
272
270
descriptors,
273
271
special_fields : Default :: default ( ) ,
274
- } )
272
+ }
275
273
}
276
274
277
275
#[ cfg( test) ]
@@ -309,7 +307,7 @@ mod test {
309
307
for & ( range, id) in & file. tokens {
310
308
if range. contains ( offset - TextSize :: from ( 1 ) ) {
311
309
let token = si. tokens . get ( id) . unwrap ( ) ;
312
- found_symbol = token_to_symbol ( token) ;
310
+ found_symbol = token. moniker . as_ref ( ) . map ( moniker_to_symbol ) ;
313
311
break ;
314
312
}
315
313
}
0 commit comments