diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 38 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs (renamed from crates/rust-analyzer/src/main_loop/handlers.rs) | 75 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lib.rs | 12 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 10 | ||||
-rw-r--r-- | crates/rust-analyzer/src/request_metrics.rs (renamed from crates/rust-analyzer/src/main_loop/request_metrics.rs) | 0 |
5 files changed, 68 insertions, 67 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index e7eeb60ee..9a75cb2ab 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | diagnostics::{CheckFixes, DiagnosticCollection}, | 20 | diagnostics::{CheckFixes, DiagnosticCollection}, |
21 | from_proto, | 21 | from_proto, |
22 | line_endings::LineEndings, | 22 | line_endings::LineEndings, |
23 | main_loop::request_metrics::{LatestRequests, RequestMetrics}, | 23 | request_metrics::{LatestRequests, RequestMetrics}, |
24 | to_proto::url_from_abs_path, | 24 | to_proto::url_from_abs_path, |
25 | Result, | 25 | Result, |
26 | }; | 26 | }; |
@@ -46,32 +46,32 @@ fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> | |||
46 | /// snapshot of the file systems, and `analysis_host`, which stores our | 46 | /// snapshot of the file systems, and `analysis_host`, which stores our |
47 | /// incremental salsa database. | 47 | /// incremental salsa database. |
48 | #[derive(Debug)] | 48 | #[derive(Debug)] |
49 | pub struct GlobalState { | 49 | pub(crate) struct GlobalState { |
50 | pub config: Config, | 50 | pub(crate) config: Config, |
51 | pub workspaces: Arc<Vec<ProjectWorkspace>>, | 51 | pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, |
52 | pub analysis_host: AnalysisHost, | 52 | pub(crate) analysis_host: AnalysisHost, |
53 | pub loader: Box<dyn vfs::loader::Handle>, | 53 | pub(crate) loader: Box<dyn vfs::loader::Handle>, |
54 | pub task_receiver: Receiver<vfs::loader::Message>, | 54 | pub(crate) task_receiver: Receiver<vfs::loader::Message>, |
55 | pub flycheck: Option<Flycheck>, | 55 | pub(crate) flycheck: Option<Flycheck>, |
56 | pub diagnostics: DiagnosticCollection, | 56 | pub(crate) diagnostics: DiagnosticCollection, |
57 | pub proc_macro_client: ProcMacroClient, | 57 | pub(crate) proc_macro_client: ProcMacroClient, |
58 | pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, | 58 | pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, |
59 | pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, | 59 | pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, |
60 | source_root_config: SourceRootConfig, | 60 | source_root_config: SourceRootConfig, |
61 | } | 61 | } |
62 | 62 | ||
63 | /// An immutable snapshot of the world's state at a point in time. | 63 | /// An immutable snapshot of the world's state at a point in time. |
64 | pub struct GlobalStateSnapshot { | 64 | pub(crate) struct GlobalStateSnapshot { |
65 | pub config: Config, | 65 | pub(crate) config: Config, |
66 | pub workspaces: Arc<Vec<ProjectWorkspace>>, | 66 | pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, |
67 | pub analysis: Analysis, | 67 | pub(crate) analysis: Analysis, |
68 | pub check_fixes: CheckFixes, | 68 | pub(crate) check_fixes: CheckFixes, |
69 | pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, | 69 | pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, |
70 | vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, | 70 | vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, |
71 | } | 71 | } |
72 | 72 | ||
73 | impl GlobalState { | 73 | impl GlobalState { |
74 | pub fn new( | 74 | pub(crate) fn new( |
75 | workspaces: Vec<ProjectWorkspace>, | 75 | workspaces: Vec<ProjectWorkspace>, |
76 | lru_capacity: Option<usize>, | 76 | lru_capacity: Option<usize>, |
77 | config: Config, | 77 | config: Config, |
@@ -241,7 +241,7 @@ impl GlobalStateSnapshot { | |||
241 | self.vfs.read().1[&id] | 241 | self.vfs.read().1[&id] |
242 | } | 242 | } |
243 | 243 | ||
244 | pub fn anchored_path(&self, file_id: FileId, path: &str) -> Url { | 244 | pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url { |
245 | let mut base = self.vfs.read().0.file_path(file_id); | 245 | let mut base = self.vfs.read().0.file_path(file_id); |
246 | base.pop(); | 246 | base.pop(); |
247 | let path = base.join(path); | 247 | let path = base.join(path); |
@@ -264,7 +264,7 @@ impl GlobalStateSnapshot { | |||
264 | }) | 264 | }) |
265 | } | 265 | } |
266 | 266 | ||
267 | pub fn status(&self) -> String { | 267 | pub(crate) fn status(&self) -> String { |
268 | let mut buf = String::new(); | 268 | let mut buf = String::new(); |
269 | if self.workspaces.is_empty() { | 269 | if self.workspaces.is_empty() { |
270 | buf.push_str("no workspaces\n") | 270 | buf.push_str("no workspaces\n") |
@@ -349,7 +349,7 @@ pub(crate) struct SourceRootConfig { | |||
349 | } | 349 | } |
350 | 350 | ||
351 | impl SourceRootConfig { | 351 | impl SourceRootConfig { |
352 | pub fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> { | 352 | pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> { |
353 | self.fsc | 353 | self.fsc |
354 | .partition(vfs) | 354 | .partition(vfs) |
355 | .into_iter() | 355 | .into_iter() |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/handlers.rs index a1e2432cf..b38755b79 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -38,7 +38,7 @@ use crate::{ | |||
38 | to_proto, LspError, Result, | 38 | to_proto, LspError, Result, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | pub fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> { | 41 | pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> { |
42 | let _p = profile("handle_analyzer_status"); | 42 | let _p = profile("handle_analyzer_status"); |
43 | let mut buf = snap.status(); | 43 | let mut buf = snap.status(); |
44 | format_to!(buf, "\n\nrequests:\n"); | 44 | format_to!(buf, "\n\nrequests:\n"); |
@@ -50,7 +50,7 @@ pub fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String | |||
50 | Ok(buf) | 50 | Ok(buf) |
51 | } | 51 | } |
52 | 52 | ||
53 | pub fn handle_syntax_tree( | 53 | pub(crate) fn handle_syntax_tree( |
54 | snap: GlobalStateSnapshot, | 54 | snap: GlobalStateSnapshot, |
55 | params: lsp_ext::SyntaxTreeParams, | 55 | params: lsp_ext::SyntaxTreeParams, |
56 | ) -> Result<String> { | 56 | ) -> Result<String> { |
@@ -62,7 +62,7 @@ pub fn handle_syntax_tree( | |||
62 | Ok(res) | 62 | Ok(res) |
63 | } | 63 | } |
64 | 64 | ||
65 | pub fn handle_expand_macro( | 65 | pub(crate) fn handle_expand_macro( |
66 | snap: GlobalStateSnapshot, | 66 | snap: GlobalStateSnapshot, |
67 | params: lsp_ext::ExpandMacroParams, | 67 | params: lsp_ext::ExpandMacroParams, |
68 | ) -> Result<Option<lsp_ext::ExpandedMacro>> { | 68 | ) -> Result<Option<lsp_ext::ExpandedMacro>> { |
@@ -75,7 +75,7 @@ pub fn handle_expand_macro( | |||
75 | Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion })) | 75 | Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion })) |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn handle_selection_range( | 78 | pub(crate) fn handle_selection_range( |
79 | snap: GlobalStateSnapshot, | 79 | snap: GlobalStateSnapshot, |
80 | params: lsp_types::SelectionRangeParams, | 80 | params: lsp_types::SelectionRangeParams, |
81 | ) -> Result<Option<Vec<lsp_types::SelectionRange>>> { | 81 | ) -> Result<Option<Vec<lsp_types::SelectionRange>>> { |
@@ -118,7 +118,7 @@ pub fn handle_selection_range( | |||
118 | Ok(Some(res?)) | 118 | Ok(Some(res?)) |
119 | } | 119 | } |
120 | 120 | ||
121 | pub fn handle_matching_brace( | 121 | pub(crate) fn handle_matching_brace( |
122 | snap: GlobalStateSnapshot, | 122 | snap: GlobalStateSnapshot, |
123 | params: lsp_ext::MatchingBraceParams, | 123 | params: lsp_ext::MatchingBraceParams, |
124 | ) -> Result<Vec<Position>> { | 124 | ) -> Result<Vec<Position>> { |
@@ -140,7 +140,7 @@ pub fn handle_matching_brace( | |||
140 | Ok(res) | 140 | Ok(res) |
141 | } | 141 | } |
142 | 142 | ||
143 | pub fn handle_join_lines( | 143 | pub(crate) fn handle_join_lines( |
144 | snap: GlobalStateSnapshot, | 144 | snap: GlobalStateSnapshot, |
145 | params: lsp_ext::JoinLinesParams, | 145 | params: lsp_ext::JoinLinesParams, |
146 | ) -> Result<Vec<lsp_types::TextEdit>> { | 146 | ) -> Result<Vec<lsp_types::TextEdit>> { |
@@ -163,7 +163,7 @@ pub fn handle_join_lines( | |||
163 | Ok(res) | 163 | Ok(res) |
164 | } | 164 | } |
165 | 165 | ||
166 | pub fn handle_on_enter( | 166 | pub(crate) fn handle_on_enter( |
167 | snap: GlobalStateSnapshot, | 167 | snap: GlobalStateSnapshot, |
168 | params: lsp_types::TextDocumentPositionParams, | 168 | params: lsp_types::TextDocumentPositionParams, |
169 | ) -> Result<Option<Vec<lsp_ext::SnippetTextEdit>>> { | 169 | ) -> Result<Option<Vec<lsp_ext::SnippetTextEdit>>> { |
@@ -180,7 +180,7 @@ pub fn handle_on_enter( | |||
180 | } | 180 | } |
181 | 181 | ||
182 | // Don't forget to add new trigger characters to `ServerCapabilities` in `caps.rs`. | 182 | // Don't forget to add new trigger characters to `ServerCapabilities` in `caps.rs`. |
183 | pub fn handle_on_type_formatting( | 183 | pub(crate) fn handle_on_type_formatting( |
184 | snap: GlobalStateSnapshot, | 184 | snap: GlobalStateSnapshot, |
185 | params: lsp_types::DocumentOnTypeFormattingParams, | 185 | params: lsp_types::DocumentOnTypeFormattingParams, |
186 | ) -> Result<Option<Vec<lsp_types::TextEdit>>> { | 186 | ) -> Result<Option<Vec<lsp_types::TextEdit>>> { |
@@ -219,7 +219,7 @@ pub fn handle_on_type_formatting( | |||
219 | Ok(Some(change)) | 219 | Ok(Some(change)) |
220 | } | 220 | } |
221 | 221 | ||
222 | pub fn handle_document_symbol( | 222 | pub(crate) fn handle_document_symbol( |
223 | snap: GlobalStateSnapshot, | 223 | snap: GlobalStateSnapshot, |
224 | params: lsp_types::DocumentSymbolParams, | 224 | params: lsp_types::DocumentSymbolParams, |
225 | ) -> Result<Option<lsp_types::DocumentSymbolResponse>> { | 225 | ) -> Result<Option<lsp_types::DocumentSymbolResponse>> { |
@@ -287,7 +287,7 @@ pub fn handle_document_symbol( | |||
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | pub fn handle_workspace_symbol( | 290 | pub(crate) fn handle_workspace_symbol( |
291 | snap: GlobalStateSnapshot, | 291 | snap: GlobalStateSnapshot, |
292 | params: lsp_types::WorkspaceSymbolParams, | 292 | params: lsp_types::WorkspaceSymbolParams, |
293 | ) -> Result<Option<Vec<SymbolInformation>>> { | 293 | ) -> Result<Option<Vec<SymbolInformation>>> { |
@@ -331,7 +331,7 @@ pub fn handle_workspace_symbol( | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | pub fn handle_goto_definition( | 334 | pub(crate) fn handle_goto_definition( |
335 | snap: GlobalStateSnapshot, | 335 | snap: GlobalStateSnapshot, |
336 | params: lsp_types::GotoDefinitionParams, | 336 | params: lsp_types::GotoDefinitionParams, |
337 | ) -> Result<Option<lsp_types::GotoDefinitionResponse>> { | 337 | ) -> Result<Option<lsp_types::GotoDefinitionResponse>> { |
@@ -346,7 +346,7 @@ pub fn handle_goto_definition( | |||
346 | Ok(Some(res)) | 346 | Ok(Some(res)) |
347 | } | 347 | } |
348 | 348 | ||
349 | pub fn handle_goto_implementation( | 349 | pub(crate) fn handle_goto_implementation( |
350 | snap: GlobalStateSnapshot, | 350 | snap: GlobalStateSnapshot, |
351 | params: lsp_types::request::GotoImplementationParams, | 351 | params: lsp_types::request::GotoImplementationParams, |
352 | ) -> Result<Option<lsp_types::request::GotoImplementationResponse>> { | 352 | ) -> Result<Option<lsp_types::request::GotoImplementationResponse>> { |
@@ -361,7 +361,7 @@ pub fn handle_goto_implementation( | |||
361 | Ok(Some(res)) | 361 | Ok(Some(res)) |
362 | } | 362 | } |
363 | 363 | ||
364 | pub fn handle_goto_type_definition( | 364 | pub(crate) fn handle_goto_type_definition( |
365 | snap: GlobalStateSnapshot, | 365 | snap: GlobalStateSnapshot, |
366 | params: lsp_types::request::GotoTypeDefinitionParams, | 366 | params: lsp_types::request::GotoTypeDefinitionParams, |
367 | ) -> Result<Option<lsp_types::request::GotoTypeDefinitionResponse>> { | 367 | ) -> Result<Option<lsp_types::request::GotoTypeDefinitionResponse>> { |
@@ -376,7 +376,7 @@ pub fn handle_goto_type_definition( | |||
376 | Ok(Some(res)) | 376 | Ok(Some(res)) |
377 | } | 377 | } |
378 | 378 | ||
379 | pub fn handle_parent_module( | 379 | pub(crate) fn handle_parent_module( |
380 | snap: GlobalStateSnapshot, | 380 | snap: GlobalStateSnapshot, |
381 | params: lsp_types::TextDocumentPositionParams, | 381 | params: lsp_types::TextDocumentPositionParams, |
382 | ) -> Result<Option<lsp_types::GotoDefinitionResponse>> { | 382 | ) -> Result<Option<lsp_types::GotoDefinitionResponse>> { |
@@ -387,7 +387,7 @@ pub fn handle_parent_module( | |||
387 | Ok(Some(res)) | 387 | Ok(Some(res)) |
388 | } | 388 | } |
389 | 389 | ||
390 | pub fn handle_runnables( | 390 | pub(crate) fn handle_runnables( |
391 | snap: GlobalStateSnapshot, | 391 | snap: GlobalStateSnapshot, |
392 | params: lsp_ext::RunnablesParams, | 392 | params: lsp_ext::RunnablesParams, |
393 | ) -> Result<Vec<lsp_ext::Runnable>> { | 393 | ) -> Result<Vec<lsp_ext::Runnable>> { |
@@ -446,7 +446,7 @@ pub fn handle_runnables( | |||
446 | Ok(res) | 446 | Ok(res) |
447 | } | 447 | } |
448 | 448 | ||
449 | pub fn handle_completion( | 449 | pub(crate) fn handle_completion( |
450 | snap: GlobalStateSnapshot, | 450 | snap: GlobalStateSnapshot, |
451 | params: lsp_types::CompletionParams, | 451 | params: lsp_types::CompletionParams, |
452 | ) -> Result<Option<lsp_types::CompletionResponse>> { | 452 | ) -> Result<Option<lsp_types::CompletionResponse>> { |
@@ -488,7 +488,7 @@ pub fn handle_completion( | |||
488 | Ok(Some(items.into())) | 488 | Ok(Some(items.into())) |
489 | } | 489 | } |
490 | 490 | ||
491 | pub fn handle_folding_range( | 491 | pub(crate) fn handle_folding_range( |
492 | snap: GlobalStateSnapshot, | 492 | snap: GlobalStateSnapshot, |
493 | params: FoldingRangeParams, | 493 | params: FoldingRangeParams, |
494 | ) -> Result<Option<Vec<FoldingRange>>> { | 494 | ) -> Result<Option<Vec<FoldingRange>>> { |
@@ -505,7 +505,7 @@ pub fn handle_folding_range( | |||
505 | Ok(Some(res)) | 505 | Ok(Some(res)) |
506 | } | 506 | } |
507 | 507 | ||
508 | pub fn handle_signature_help( | 508 | pub(crate) fn handle_signature_help( |
509 | snap: GlobalStateSnapshot, | 509 | snap: GlobalStateSnapshot, |
510 | params: lsp_types::SignatureHelpParams, | 510 | params: lsp_types::SignatureHelpParams, |
511 | ) -> Result<Option<lsp_types::SignatureHelp>> { | 511 | ) -> Result<Option<lsp_types::SignatureHelp>> { |
@@ -529,7 +529,7 @@ pub fn handle_signature_help( | |||
529 | })) | 529 | })) |
530 | } | 530 | } |
531 | 531 | ||
532 | pub fn handle_hover( | 532 | pub(crate) fn handle_hover( |
533 | snap: GlobalStateSnapshot, | 533 | snap: GlobalStateSnapshot, |
534 | params: lsp_types::HoverParams, | 534 | params: lsp_types::HoverParams, |
535 | ) -> Result<Option<lsp_ext::Hover>> { | 535 | ) -> Result<Option<lsp_ext::Hover>> { |
@@ -555,7 +555,7 @@ pub fn handle_hover( | |||
555 | Ok(Some(hover)) | 555 | Ok(Some(hover)) |
556 | } | 556 | } |
557 | 557 | ||
558 | pub fn handle_prepare_rename( | 558 | pub(crate) fn handle_prepare_rename( |
559 | snap: GlobalStateSnapshot, | 559 | snap: GlobalStateSnapshot, |
560 | params: lsp_types::TextDocumentPositionParams, | 560 | params: lsp_types::TextDocumentPositionParams, |
561 | ) -> Result<Option<PrepareRenameResponse>> { | 561 | ) -> Result<Option<PrepareRenameResponse>> { |
@@ -573,7 +573,7 @@ pub fn handle_prepare_rename( | |||
573 | Ok(Some(PrepareRenameResponse::Range(range))) | 573 | Ok(Some(PrepareRenameResponse::Range(range))) |
574 | } | 574 | } |
575 | 575 | ||
576 | pub fn handle_rename( | 576 | pub(crate) fn handle_rename( |
577 | snap: GlobalStateSnapshot, | 577 | snap: GlobalStateSnapshot, |
578 | params: RenameParams, | 578 | params: RenameParams, |
579 | ) -> Result<Option<WorkspaceEdit>> { | 579 | ) -> Result<Option<WorkspaceEdit>> { |
@@ -597,7 +597,7 @@ pub fn handle_rename( | |||
597 | Ok(Some(workspace_edit)) | 597 | Ok(Some(workspace_edit)) |
598 | } | 598 | } |
599 | 599 | ||
600 | pub fn handle_references( | 600 | pub(crate) fn handle_references( |
601 | snap: GlobalStateSnapshot, | 601 | snap: GlobalStateSnapshot, |
602 | params: lsp_types::ReferenceParams, | 602 | params: lsp_types::ReferenceParams, |
603 | ) -> Result<Option<Vec<Location>>> { | 603 | ) -> Result<Option<Vec<Location>>> { |
@@ -624,7 +624,7 @@ pub fn handle_references( | |||
624 | Ok(Some(locations)) | 624 | Ok(Some(locations)) |
625 | } | 625 | } |
626 | 626 | ||
627 | pub fn handle_formatting( | 627 | pub(crate) fn handle_formatting( |
628 | snap: GlobalStateSnapshot, | 628 | snap: GlobalStateSnapshot, |
629 | params: DocumentFormattingParams, | 629 | params: DocumentFormattingParams, |
630 | ) -> Result<Option<Vec<lsp_types::TextEdit>>> { | 630 | ) -> Result<Option<Vec<lsp_types::TextEdit>>> { |
@@ -739,7 +739,7 @@ fn handle_fixes( | |||
739 | Ok(()) | 739 | Ok(()) |
740 | } | 740 | } |
741 | 741 | ||
742 | pub fn handle_code_action( | 742 | pub(crate) fn handle_code_action( |
743 | snap: GlobalStateSnapshot, | 743 | snap: GlobalStateSnapshot, |
744 | params: lsp_types::CodeActionParams, | 744 | params: lsp_types::CodeActionParams, |
745 | ) -> Result<Option<Vec<lsp_ext::CodeAction>>> { | 745 | ) -> Result<Option<Vec<lsp_ext::CodeAction>>> { |
@@ -774,7 +774,7 @@ pub fn handle_code_action( | |||
774 | Ok(Some(res)) | 774 | Ok(Some(res)) |
775 | } | 775 | } |
776 | 776 | ||
777 | pub fn handle_resolve_code_action( | 777 | pub(crate) fn handle_resolve_code_action( |
778 | snap: GlobalStateSnapshot, | 778 | snap: GlobalStateSnapshot, |
779 | params: lsp_ext::ResolveCodeActionParams, | 779 | params: lsp_ext::ResolveCodeActionParams, |
780 | ) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> { | 780 | ) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> { |
@@ -792,7 +792,7 @@ pub fn handle_resolve_code_action( | |||
792 | Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) | 792 | Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) |
793 | } | 793 | } |
794 | 794 | ||
795 | pub fn handle_code_lens( | 795 | pub(crate) fn handle_code_lens( |
796 | snap: GlobalStateSnapshot, | 796 | snap: GlobalStateSnapshot, |
797 | params: lsp_types::CodeLensParams, | 797 | params: lsp_types::CodeLensParams, |
798 | ) -> Result<Option<Vec<CodeLens>>> { | 798 | ) -> Result<Option<Vec<CodeLens>>> { |
@@ -873,7 +873,7 @@ enum CodeLensResolveData { | |||
873 | Impls(lsp_types::request::GotoImplementationParams), | 873 | Impls(lsp_types::request::GotoImplementationParams), |
874 | } | 874 | } |
875 | 875 | ||
876 | pub fn handle_code_lens_resolve( | 876 | pub(crate) fn handle_code_lens_resolve( |
877 | snap: GlobalStateSnapshot, | 877 | snap: GlobalStateSnapshot, |
878 | code_lens: CodeLens, | 878 | code_lens: CodeLens, |
879 | ) -> Result<CodeLens> { | 879 | ) -> Result<CodeLens> { |
@@ -910,7 +910,7 @@ pub fn handle_code_lens_resolve( | |||
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | pub fn handle_document_highlight( | 913 | pub(crate) fn handle_document_highlight( |
914 | snap: GlobalStateSnapshot, | 914 | snap: GlobalStateSnapshot, |
915 | params: lsp_types::DocumentHighlightParams, | 915 | params: lsp_types::DocumentHighlightParams, |
916 | ) -> Result<Option<Vec<DocumentHighlight>>> { | 916 | ) -> Result<Option<Vec<DocumentHighlight>>> { |
@@ -937,7 +937,7 @@ pub fn handle_document_highlight( | |||
937 | Ok(Some(res)) | 937 | Ok(Some(res)) |
938 | } | 938 | } |
939 | 939 | ||
940 | pub fn handle_ssr( | 940 | pub(crate) fn handle_ssr( |
941 | snap: GlobalStateSnapshot, | 941 | snap: GlobalStateSnapshot, |
942 | params: lsp_ext::SsrParams, | 942 | params: lsp_ext::SsrParams, |
943 | ) -> Result<lsp_types::WorkspaceEdit> { | 943 | ) -> Result<lsp_types::WorkspaceEdit> { |
@@ -947,7 +947,10 @@ pub fn handle_ssr( | |||
947 | to_proto::workspace_edit(&snap, source_change) | 947 | to_proto::workspace_edit(&snap, source_change) |
948 | } | 948 | } |
949 | 949 | ||
950 | pub fn publish_diagnostics(snap: &GlobalStateSnapshot, file_id: FileId) -> Result<DiagnosticTask> { | 950 | pub(crate) fn publish_diagnostics( |
951 | snap: &GlobalStateSnapshot, | ||
952 | file_id: FileId, | ||
953 | ) -> Result<DiagnosticTask> { | ||
951 | let _p = profile("publish_diagnostics"); | 954 | let _p = profile("publish_diagnostics"); |
952 | let line_index = snap.analysis().file_line_index(file_id)?; | 955 | let line_index = snap.analysis().file_line_index(file_id)?; |
953 | let diagnostics: Vec<Diagnostic> = snap | 956 | let diagnostics: Vec<Diagnostic> = snap |
@@ -967,7 +970,7 @@ pub fn publish_diagnostics(snap: &GlobalStateSnapshot, file_id: FileId) -> Resul | |||
967 | Ok(DiagnosticTask::SetNative(file_id, diagnostics)) | 970 | Ok(DiagnosticTask::SetNative(file_id, diagnostics)) |
968 | } | 971 | } |
969 | 972 | ||
970 | pub fn handle_inlay_hints( | 973 | pub(crate) fn handle_inlay_hints( |
971 | snap: GlobalStateSnapshot, | 974 | snap: GlobalStateSnapshot, |
972 | params: InlayHintsParams, | 975 | params: InlayHintsParams, |
973 | ) -> Result<Vec<InlayHint>> { | 976 | ) -> Result<Vec<InlayHint>> { |
@@ -982,7 +985,7 @@ pub fn handle_inlay_hints( | |||
982 | .collect()) | 985 | .collect()) |
983 | } | 986 | } |
984 | 987 | ||
985 | pub fn handle_call_hierarchy_prepare( | 988 | pub(crate) fn handle_call_hierarchy_prepare( |
986 | snap: GlobalStateSnapshot, | 989 | snap: GlobalStateSnapshot, |
987 | params: CallHierarchyPrepareParams, | 990 | params: CallHierarchyPrepareParams, |
988 | ) -> Result<Option<Vec<CallHierarchyItem>>> { | 991 | ) -> Result<Option<Vec<CallHierarchyItem>>> { |
@@ -1004,7 +1007,7 @@ pub fn handle_call_hierarchy_prepare( | |||
1004 | Ok(Some(res)) | 1007 | Ok(Some(res)) |
1005 | } | 1008 | } |
1006 | 1009 | ||
1007 | pub fn handle_call_hierarchy_incoming( | 1010 | pub(crate) fn handle_call_hierarchy_incoming( |
1008 | snap: GlobalStateSnapshot, | 1011 | snap: GlobalStateSnapshot, |
1009 | params: CallHierarchyIncomingCallsParams, | 1012 | params: CallHierarchyIncomingCallsParams, |
1010 | ) -> Result<Option<Vec<CallHierarchyIncomingCall>>> { | 1013 | ) -> Result<Option<Vec<CallHierarchyIncomingCall>>> { |
@@ -1039,7 +1042,7 @@ pub fn handle_call_hierarchy_incoming( | |||
1039 | Ok(Some(res)) | 1042 | Ok(Some(res)) |
1040 | } | 1043 | } |
1041 | 1044 | ||
1042 | pub fn handle_call_hierarchy_outgoing( | 1045 | pub(crate) fn handle_call_hierarchy_outgoing( |
1043 | snap: GlobalStateSnapshot, | 1046 | snap: GlobalStateSnapshot, |
1044 | params: CallHierarchyOutgoingCallsParams, | 1047 | params: CallHierarchyOutgoingCallsParams, |
1045 | ) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> { | 1048 | ) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> { |
@@ -1074,7 +1077,7 @@ pub fn handle_call_hierarchy_outgoing( | |||
1074 | Ok(Some(res)) | 1077 | Ok(Some(res)) |
1075 | } | 1078 | } |
1076 | 1079 | ||
1077 | pub fn handle_semantic_tokens( | 1080 | pub(crate) fn handle_semantic_tokens( |
1078 | snap: GlobalStateSnapshot, | 1081 | snap: GlobalStateSnapshot, |
1079 | params: SemanticTokensParams, | 1082 | params: SemanticTokensParams, |
1080 | ) -> Result<Option<SemanticTokensResult>> { | 1083 | ) -> Result<Option<SemanticTokensResult>> { |
@@ -1089,7 +1092,7 @@ pub fn handle_semantic_tokens( | |||
1089 | Ok(Some(semantic_tokens.into())) | 1092 | Ok(Some(semantic_tokens.into())) |
1090 | } | 1093 | } |
1091 | 1094 | ||
1092 | pub fn handle_semantic_tokens_range( | 1095 | pub(crate) fn handle_semantic_tokens_range( |
1093 | snap: GlobalStateSnapshot, | 1096 | snap: GlobalStateSnapshot, |
1094 | params: SemanticTokensRangeParams, | 1097 | params: SemanticTokensRangeParams, |
1095 | ) -> Result<Option<SemanticTokensRangeResult>> { | 1098 | ) -> Result<Option<SemanticTokensRangeResult>> { |
diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index b38067079..9757a16a3 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs | |||
@@ -17,18 +17,20 @@ macro_rules! eprintln { | |||
17 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | 17 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; |
18 | } | 18 | } |
19 | 19 | ||
20 | mod global_state; | ||
21 | mod main_loop; | ||
22 | mod handlers; | ||
20 | mod caps; | 23 | mod caps; |
21 | mod cargo_target_spec; | 24 | mod cargo_target_spec; |
22 | mod to_proto; | 25 | mod to_proto; |
23 | mod from_proto; | 26 | mod from_proto; |
24 | mod main_loop; | 27 | mod semantic_tokens; |
25 | mod markdown; | 28 | mod markdown; |
26 | pub mod lsp_ext; | ||
27 | pub mod config; | ||
28 | mod global_state; | ||
29 | mod diagnostics; | 29 | mod diagnostics; |
30 | mod semantic_tokens; | ||
31 | mod line_endings; | 30 | mod line_endings; |
31 | mod request_metrics; | ||
32 | pub mod lsp_ext; | ||
33 | pub mod config; | ||
32 | 34 | ||
33 | use serde::de::DeserializeOwned; | 35 | use serde::de::DeserializeOwned; |
34 | 36 | ||
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index b55d45cd3..c8819c3b0 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -1,9 +1,5 @@ | |||
1 | //! The main loop of `rust-analyzer` responsible for dispatching LSP | 1 | //! The main loop of `rust-analyzer` responsible for dispatching LSP |
2 | //! requests/replies and notifications back to the client. | 2 | //! requests/replies and notifications back to the client. |
3 | |||
4 | mod handlers; | ||
5 | pub(crate) mod request_metrics; | ||
6 | |||
7 | use std::{ | 3 | use std::{ |
8 | env, | 4 | env, |
9 | error::Error, | 5 | error::Error, |
@@ -19,6 +15,7 @@ use lsp_server::{ | |||
19 | Connection, ErrorCode, Message, Notification, ReqQueue, Request, RequestId, Response, | 15 | Connection, ErrorCode, Message, Notification, ReqQueue, Request, RequestId, Response, |
20 | }; | 16 | }; |
21 | use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent}; | 17 | use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent}; |
18 | use ra_db::VfsPath; | ||
22 | use ra_flycheck::CheckTask; | 19 | use ra_flycheck::CheckTask; |
23 | use ra_ide::{Canceled, FileId, LineIndex}; | 20 | use ra_ide::{Canceled, FileId, LineIndex}; |
24 | use ra_prof::profile; | 21 | use ra_prof::profile; |
@@ -32,11 +29,10 @@ use crate::{ | |||
32 | diagnostics::DiagnosticTask, | 29 | diagnostics::DiagnosticTask, |
33 | from_proto, | 30 | from_proto, |
34 | global_state::{file_id_to_url, GlobalState, GlobalStateSnapshot}, | 31 | global_state::{file_id_to_url, GlobalState, GlobalStateSnapshot}, |
35 | lsp_ext, | 32 | handlers, lsp_ext, |
36 | main_loop::request_metrics::RequestMetrics, | 33 | request_metrics::RequestMetrics, |
37 | Result, | 34 | Result, |
38 | }; | 35 | }; |
39 | use ra_db::VfsPath; | ||
40 | 36 | ||
41 | #[derive(Debug)] | 37 | #[derive(Debug)] |
42 | pub struct LspError { | 38 | pub struct LspError { |
diff --git a/crates/rust-analyzer/src/main_loop/request_metrics.rs b/crates/rust-analyzer/src/request_metrics.rs index b1019e2d6..b1019e2d6 100644 --- a/crates/rust-analyzer/src/main_loop/request_metrics.rs +++ b/crates/rust-analyzer/src/request_metrics.rs | |||