@@ -75,7 +75,7 @@ impl flags::Scip {
75
75
let mut symbols_emitted: HashSet < TokenId > = HashSet :: default ( ) ;
76
76
let mut tokens_to_symbol: HashMap < TokenId , String > = HashMap :: new ( ) ;
77
77
78
- for file in si. files {
78
+ for StaticIndexedFile { file_id , tokens , .. } in si. files {
79
79
let mut local_count = 0 ;
80
80
let mut new_local_symbol = || {
81
81
let new_symbol = scip:: types:: Symbol :: new_local ( local_count) ;
@@ -84,7 +84,6 @@ impl flags::Scip {
84
84
new_symbol
85
85
} ;
86
86
87
- let StaticIndexedFile { file_id, tokens, .. } = file;
88
87
let relative_path = match get_relative_filepath ( & vfs, & rootpath, file_id) {
89
88
Some ( relative_path) => relative_path,
90
89
None => continue ,
@@ -107,28 +106,23 @@ impl flags::Scip {
107
106
108
107
let mut occurrence = scip_types:: Occurrence :: default ( ) ;
109
108
occurrence. range = text_range_to_scip_range ( & line_index, range) ;
110
- occurrence. symbol = match tokens_to_symbol. get ( & id ) {
111
- Some ( symbol ) => symbol . clone ( ) ,
112
- None => {
109
+ occurrence. symbol = tokens_to_symbol
110
+ . entry ( id )
111
+ . or_insert_with ( || {
113
112
let symbol = match & token. moniker {
114
113
Some ( moniker) => moniker_to_symbol ( & moniker) ,
115
114
None => new_local_symbol ( ) ,
116
115
} ;
117
-
118
- let symbol = scip:: symbol:: format_symbol ( symbol) ;
119
- tokens_to_symbol. insert ( id, symbol. clone ( ) ) ;
120
- symbol
121
- }
122
- } ;
116
+ scip:: symbol:: format_symbol ( symbol)
117
+ } )
118
+ . clone ( ) ;
123
119
124
120
if let Some ( def) = token. definition {
125
121
if def. range == range {
126
122
occurrence. symbol_roles |= scip_types:: SymbolRole :: Definition as i32 ;
127
123
}
128
124
129
- if !symbols_emitted. contains ( & id) {
130
- symbols_emitted. insert ( id) ;
131
-
125
+ if symbols_emitted. insert ( id) {
132
126
let mut symbol_info = scip_types:: SymbolInformation :: default ( ) ;
133
127
symbol_info. symbol = occurrence. symbol . clone ( ) ;
134
128
if let Some ( hover) = & token. hover {
0 commit comments