aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/config.rs3
-rw-r--r--crates/rust-analyzer/src/main_loop.rs20
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs35
-rw-r--r--crates/rust-analyzer/src/req.rs32
4 files changed, 3 insertions, 87 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 3c8f55f1e..602423919 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -16,7 +16,6 @@ use serde::Deserialize;
16#[derive(Debug, Clone)] 16#[derive(Debug, Clone)]
17pub struct Config { 17pub struct Config {
18 pub client_caps: ClientCapsConfig, 18 pub client_caps: ClientCapsConfig,
19 pub publish_decorations: bool,
20 pub publish_diagnostics: bool, 19 pub publish_diagnostics: bool,
21 pub notifications: NotificationsConfig, 20 pub notifications: NotificationsConfig,
22 pub inlay_hints: InlayHintsConfig, 21 pub inlay_hints: InlayHintsConfig,
@@ -60,7 +59,6 @@ pub struct ClientCapsConfig {
60impl Default for Config { 59impl Default for Config {
61 fn default() -> Self { 60 fn default() -> Self {
62 Config { 61 Config {
63 publish_decorations: false,
64 publish_diagnostics: true, 62 publish_diagnostics: true,
65 notifications: NotificationsConfig { 63 notifications: NotificationsConfig {
66 workspace_loaded: true, 64 workspace_loaded: true,
@@ -105,7 +103,6 @@ impl Config {
105 *self = Default::default(); 103 *self = Default::default();
106 self.client_caps = client_caps; 104 self.client_caps = client_caps;
107 105
108 set(value, "/publishDecorations", &mut self.publish_decorations);
109 set(value, "/excludeGlobs", &mut self.exclude_globs); 106 set(value, "/excludeGlobs", &mut self.exclude_globs);
110 set(value, "/useClientWatching", &mut self.use_client_watching); 107 set(value, "/useClientWatching", &mut self.use_client_watching);
111 set(value, "/lruCapacity", &mut self.lru_capacity); 108 set(value, "/lruCapacity", &mut self.lru_capacity);
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 45ae0ad9d..47fef59d4 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -250,9 +250,7 @@ impl fmt::Debug for Event {
250 } 250 }
251 } 251 }
252 Event::Task(Task::Notify(not)) => { 252 Event::Task(Task::Notify(not)) => {
253 if notification_is::<req::PublishDecorations>(not) 253 if notification_is::<req::PublishDiagnostics>(not) {
254 || notification_is::<req::PublishDiagnostics>(not)
255 {
256 return debug_verbose_not(not, f); 254 return debug_verbose_not(not, f);
257 } 255 }
258 } 256 }
@@ -427,7 +425,6 @@ fn loop_turn(
427 update_file_notifications_on_threadpool( 425 update_file_notifications_on_threadpool(
428 pool, 426 pool,
429 world_state.snapshot(), 427 world_state.snapshot(),
430 world_state.config.publish_decorations,
431 task_sender.clone(), 428 task_sender.clone(),
432 loop_state.subscriptions.subscriptions(), 429 loop_state.subscriptions.subscriptions(),
433 ) 430 )
@@ -508,7 +505,6 @@ fn on_request(
508 .on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)? 505 .on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)?
509 .on::<req::ParentModule>(handlers::handle_parent_module)? 506 .on::<req::ParentModule>(handlers::handle_parent_module)?
510 .on::<req::Runnables>(handlers::handle_runnables)? 507 .on::<req::Runnables>(handlers::handle_runnables)?
511 .on::<req::DecorationsRequest>(handlers::handle_decorations)?
512 .on::<req::Completion>(handlers::handle_completion)? 508 .on::<req::Completion>(handlers::handle_completion)?
513 .on::<req::CodeActionRequest>(handlers::handle_code_action)? 509 .on::<req::CodeActionRequest>(handlers::handle_code_action)?
514 .on::<req::CodeLensRequest>(handlers::handle_code_lens)? 510 .on::<req::CodeLensRequest>(handlers::handle_code_lens)?
@@ -884,7 +880,6 @@ where
884fn update_file_notifications_on_threadpool( 880fn update_file_notifications_on_threadpool(
885 pool: &ThreadPool, 881 pool: &ThreadPool,
886 world: WorldSnapshot, 882 world: WorldSnapshot,
887 publish_decorations: bool,
888 task_sender: Sender<Task>, 883 task_sender: Sender<Task>,
889 subscriptions: Vec<FileId>, 884 subscriptions: Vec<FileId>,
890) { 885) {
@@ -904,19 +899,6 @@ fn update_file_notifications_on_threadpool(
904 } 899 }
905 } 900 }
906 } 901 }
907 if publish_decorations {
908 match handlers::publish_decorations(&world, file_id) {
909 Err(e) => {
910 if !is_canceled(&e) {
911 log::error!("failed to compute decorations: {:?}", e);
912 }
913 }
914 Ok(params) => {
915 let not = notification_new::<req::PublishDecorations>(params);
916 task_sender.send(Task::Notify(not)).unwrap();
917 }
918 }
919 }
920 } 902 }
921 }); 903 });
922} 904}
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 23e48c089..db620dca3 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -38,7 +38,7 @@ use crate::{
38 }, 38 },
39 diagnostics::DiagnosticTask, 39 diagnostics::DiagnosticTask,
40 from_json, 40 from_json,
41 req::{self, Decoration, InlayHint, InlayHintsParams}, 41 req::{self, InlayHint, InlayHintsParams},
42 semantic_tokens::SemanticTokensBuilder, 42 semantic_tokens::SemanticTokensBuilder,
43 world::WorldSnapshot, 43 world::WorldSnapshot,
44 LspError, Result, 44 LspError, Result,
@@ -389,15 +389,6 @@ pub fn handle_runnables(
389 Ok(res) 389 Ok(res)
390} 390}
391 391
392pub fn handle_decorations(
393 world: WorldSnapshot,
394 params: TextDocumentIdentifier,
395) -> Result<Vec<Decoration>> {
396 let _p = profile("handle_decorations");
397 let file_id = params.try_conv_with(&world)?;
398 highlight(&world, file_id)
399}
400
401pub fn handle_completion( 392pub fn handle_completion(
402 world: WorldSnapshot, 393 world: WorldSnapshot,
403 params: req::CompletionParams, 394 params: req::CompletionParams,
@@ -970,15 +961,6 @@ pub fn publish_diagnostics(world: &WorldSnapshot, file_id: FileId) -> Result<Dia
970 Ok(DiagnosticTask::SetNative(file_id, diagnostics)) 961 Ok(DiagnosticTask::SetNative(file_id, diagnostics))
971} 962}
972 963
973pub fn publish_decorations(
974 world: &WorldSnapshot,
975 file_id: FileId,
976) -> Result<req::PublishDecorationsParams> {
977 let _p = profile("publish_decorations");
978 let uri = world.file_id_to_uri(file_id)?;
979 Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? })
980}
981
982fn to_lsp_runnable( 964fn to_lsp_runnable(
983 world: &WorldSnapshot, 965 world: &WorldSnapshot,
984 file_id: FileId, 966 file_id: FileId,
@@ -1008,21 +990,6 @@ fn to_lsp_runnable(
1008 }) 990 })
1009} 991}
1010 992
1011fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>> {
1012 let line_index = world.analysis().file_line_index(file_id)?;
1013 let res = world
1014 .analysis()
1015 .highlight(file_id)?
1016 .into_iter()
1017 .map(|h| Decoration {
1018 range: h.range.conv_with(&line_index),
1019 tag: h.highlight.to_string(),
1020 binding_hash: h.binding_hash.map(|x| x.to_string()),
1021 })
1022 .collect();
1023 Ok(res)
1024}
1025
1026pub fn handle_inlay_hints( 993pub fn handle_inlay_hints(
1027 world: WorldSnapshot, 994 world: WorldSnapshot,
1028 params: InlayHintsParams, 995 params: InlayHintsParams,
diff --git a/crates/rust-analyzer/src/req.rs b/crates/rust-analyzer/src/req.rs
index 994f0ed61..ce799a683 100644
--- a/crates/rust-analyzer/src/req.rs
+++ b/crates/rust-analyzer/src/req.rs
@@ -1,6 +1,6 @@
1//! Defines `rust-analyzer` specific custom messages. 1//! Defines `rust-analyzer` specific custom messages.
2 2
3use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url}; 3use lsp_types::{Location, Position, Range, TextDocumentIdentifier};
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
6 6
@@ -86,36 +86,6 @@ pub struct FindMatchingBraceParams {
86 pub offsets: Vec<Position>, 86 pub offsets: Vec<Position>,
87} 87}
88 88
89pub enum DecorationsRequest {}
90
91impl Request for DecorationsRequest {
92 type Params = TextDocumentIdentifier;
93 type Result = Vec<Decoration>;
94 const METHOD: &'static str = "rust-analyzer/decorationsRequest";
95}
96
97pub enum PublishDecorations {}
98
99impl Notification for PublishDecorations {
100 type Params = PublishDecorationsParams;
101 const METHOD: &'static str = "rust-analyzer/publishDecorations";
102}
103
104#[derive(Deserialize, Serialize, Debug)]
105#[serde(rename_all = "camelCase")]
106pub struct PublishDecorationsParams {
107 pub uri: Url,
108 pub decorations: Vec<Decoration>,
109}
110
111#[derive(Deserialize, Serialize, Debug)]
112#[serde(rename_all = "camelCase")]
113pub struct Decoration {
114 pub range: Range,
115 pub tag: String,
116 pub binding_hash: Option<String>,
117}
118
119pub enum ParentModule {} 89pub enum ParentModule {}
120 90
121impl Request for ParentModule { 91impl Request for ParentModule {