1818 Url , WorkspaceEdit , WorkspaceSymbolParams , WorkspaceSymbolResponse ,
1919 notification:: { DidChangeWatchedFiles , Notification } ,
2020 } ,
21- references, rename, tree, utils,
21+ references, rename, symbols , tree, utils,
2222 } ,
2323 async_lsp:: {
2424 ClientSocket , ErrorCode , LanguageClient , LanguageServer , ResponseError ,
@@ -91,9 +91,9 @@ struct ServerState {
9191 base_path : PathBuf ,
9292 document_map : HashMap < PathBuf , Document > ,
9393 /// stores symbolds for all other files
94- document_symbols : HashMap < PathBuf , Vec < Item > > ,
94+ document_items : HashMap < PathBuf , Vec < Item > > ,
9595 /// stores index for all files in R/ folder
96- workspace_symbols : HashMap < PathBuf , Vec < Item > > ,
96+ workspace_items : HashMap < PathBuf , Vec < Item > > ,
9797 parser : Parser ,
9898}
9999
@@ -114,8 +114,8 @@ impl ServerState {
114114 config,
115115 experimental_features,
116116 base_path : std:: env:: current_dir ( ) . unwrap ( ) . join ( "R" ) ,
117- workspace_symbols : HashMap :: new ( ) ,
118- document_symbols : HashMap :: new ( ) ,
117+ workspace_items : HashMap :: new ( ) ,
118+ document_items : HashMap :: new ( ) ,
119119 document_map : HashMap :: new ( ) ,
120120 parser : tree:: new_parser ( ) ,
121121 } )
@@ -133,7 +133,7 @@ impl LanguageServer for ServerState {
133133 tracing:: info!( ?self . experimental_features, "initialize" ) ;
134134
135135 match index:: index_dir ( & self . base_path , & mut self . parser ) {
136- Ok ( symbols ) => self . workspace_symbols . extend ( symbols ) ,
136+ Ok ( items ) => self . workspace_items . extend ( items ) ,
137137 Err ( IndexError ) => self
138138 . client
139139 . show_message ( ShowMessageParams {
@@ -236,12 +236,12 @@ impl LanguageServer for ServerState {
236236
237237 let diagnostics = diagnostics:: analyze_full ( tree. root_node ( ) , & rope, self . config . lint ) ;
238238
239- let symbols = index:: index ( tree. root_node ( ) , & rope, false , false ) ;
239+ let items = index:: index ( tree. root_node ( ) , & rope, false , false ) ;
240240 if path. starts_with ( & self . base_path ) {
241241 // note: we need to insert into workspace in case a new file is created
242- self . workspace_symbols . insert ( path. clone ( ) , symbols ) ;
242+ self . workspace_items . insert ( path. clone ( ) , items ) ;
243243 } else {
244- self . document_symbols . insert ( path. clone ( ) , symbols ) ;
244+ self . document_items . insert ( path. clone ( ) , items ) ;
245245 }
246246
247247 self . document_map . insert ( path, Document { rope, tree } ) ;
@@ -330,14 +330,14 @@ impl LanguageServer for ServerState {
330330 // UPDATE DIAGNOSTICS
331331 let diagnostics = diagnostics:: analyze_fast ( tree. root_node ( ) , rope, self . config . lint ) ;
332332
333- // UPDATE SYMBOLS
333+ // UPDATE ITEMS
334334 // note: We must re-index on every change (not just on save)
335335 // because textDocument/documentSymbol is triggered before textDocument/didSave.
336- let symbols = index:: index ( tree. root_node ( ) , rope, false , false ) ;
336+ let items = index:: index ( tree. root_node ( ) , rope, false , false ) ;
337337 if path. starts_with ( & self . base_path ) {
338- self . workspace_symbols . insert ( path, symbols ) ;
338+ self . workspace_items . insert ( path, items ) ;
339339 } else {
340- self . document_symbols . insert ( path, symbols ) ;
340+ self . document_items . insert ( path, items ) ;
341341 }
342342
343343 if let Err ( error) = self
@@ -403,11 +403,11 @@ impl LanguageServer for ServerState {
403403 match change. typ {
404404 FileChangeType :: CREATED | FileChangeType :: CHANGED => {
405405 // note: potential race condition if the user already has the file open and begins editing immediately.
406- let symbols = index:: index_file ( & path, & mut self . parser ) ;
407- self . workspace_symbols . insert ( path. clone ( ) , symbols ) ;
406+ let items = index:: index_file ( & path, & mut self . parser ) ;
407+ self . workspace_items . insert ( path. clone ( ) , items ) ;
408408 }
409409 FileChangeType :: DELETED => {
410- self . workspace_symbols . remove ( & path) ;
410+ self . workspace_items . remove ( & path) ;
411411 }
412412 _ => unreachable ! ( ) ,
413413 }
@@ -440,7 +440,7 @@ impl LanguageServer for ServerState {
440440 position,
441441 & document. rope ,
442442 & document. tree ,
443- & self . workspace_symbols ,
443+ & self . workspace_items ,
444444 ) ;
445445
446446 box_future ( Ok ( completions) )
@@ -471,7 +471,7 @@ impl LanguageServer for ServerState {
471471 position. character as usize ,
472472 & document. rope ,
473473 & document. tree ,
474- & self . workspace_symbols ,
474+ & self . workspace_items ,
475475 ) ;
476476
477477 box_future ( Ok ( definitions) )
@@ -585,7 +585,7 @@ impl LanguageServer for ServerState {
585585 include_declaration,
586586 & document. rope ,
587587 & document. tree ,
588- & self . workspace_symbols ,
588+ & self . workspace_items ,
589589 ) ;
590590
591591 box_future ( Ok ( references) )
@@ -634,17 +634,17 @@ impl LanguageServer for ServerState {
634634 let uri = params. text_document . uri ;
635635 let path = uri. to_file_path ( ) . unwrap ( ) ;
636636
637- let symbols_map = if path. starts_with ( & self . base_path ) {
638- & self . workspace_symbols
637+ let items_map = if path. starts_with ( & self . base_path ) {
638+ & self . workspace_items
639639 } else {
640- & self . document_symbols
640+ & self . document_items
641641 } ;
642642
643- let Some ( symbols ) = symbols_map . get ( & path) else {
643+ let Some ( items ) = items_map . get ( & path) else {
644644 tracing:: error!( ?path, "symbols not found" ) ;
645645 return box_future ( Err ( path_not_found_error ( & path) ) ) ;
646646 } ;
647- let symbols: Vec < DocumentSymbol > = symbols. iter ( ) . map ( |item| item . to_document_symbol ( ) ) . collect ( ) ;
647+ let symbols: Vec < DocumentSymbol > = symbols:: document ( items ) ;
648648
649649 box_future ( Ok ( Some ( DocumentSymbolResponse :: Nested ( symbols) ) ) )
650650 }
@@ -657,7 +657,7 @@ impl LanguageServer for ServerState {
657657
658658 tracing:: debug!( ?query) ;
659659
660- let symbols = index :: get_workspace_symbols ( & query, & self . workspace_symbols ) ;
660+ let symbols = symbols :: workspace ( & query, & self . workspace_items ) ;
661661
662662 box_future ( Ok ( Some ( WorkspaceSymbolResponse :: Nested ( symbols) ) ) )
663663 }
0 commit comments