diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 9 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 143 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 48 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 65 | ||||
-rw-r--r-- | crates/rust-analyzer/src/req.rs | 36 |
5 files changed, 125 insertions, 176 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index c1b6e1ddc..b50cda06f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -75,7 +75,7 @@ pub type Target = Idx<TargetData>; | |||
75 | 75 | ||
76 | #[derive(Debug, Clone)] | 76 | #[derive(Debug, Clone)] |
77 | pub struct PackageData { | 77 | pub struct PackageData { |
78 | pub id: String, | 78 | pub version: String, |
79 | pub name: String, | 79 | pub name: String, |
80 | pub manifest: PathBuf, | 80 | pub manifest: PathBuf, |
81 | pub targets: Vec<Target>, | 81 | pub targets: Vec<Target>, |
@@ -174,14 +174,15 @@ impl CargoWorkspace { | |||
174 | let ws_members = &meta.workspace_members; | 174 | let ws_members = &meta.workspace_members; |
175 | 175 | ||
176 | for meta_pkg in meta.packages { | 176 | for meta_pkg in meta.packages { |
177 | let cargo_metadata::Package { id, edition, name, manifest_path, .. } = meta_pkg; | 177 | let cargo_metadata::Package { id, edition, name, manifest_path, version, .. } = |
178 | meta_pkg; | ||
178 | let is_member = ws_members.contains(&id); | 179 | let is_member = ws_members.contains(&id); |
179 | let edition = edition | 180 | let edition = edition |
180 | .parse::<Edition>() | 181 | .parse::<Edition>() |
181 | .with_context(|| format!("Failed to parse edition {}", edition))?; | 182 | .with_context(|| format!("Failed to parse edition {}", edition))?; |
182 | let pkg = packages.alloc(PackageData { | 183 | let pkg = packages.alloc(PackageData { |
183 | name, | 184 | name, |
184 | id: id.to_string(), | 185 | version: version.to_string(), |
185 | manifest: manifest_path, | 186 | manifest: manifest_path, |
186 | targets: Vec::new(), | 187 | targets: Vec::new(), |
187 | is_member, | 188 | is_member, |
@@ -256,7 +257,7 @@ impl CargoWorkspace { | |||
256 | if self.is_unique(&*package.name) { | 257 | if self.is_unique(&*package.name) { |
257 | package.name.clone() | 258 | package.name.clone() |
258 | } else { | 259 | } else { |
259 | package.id.clone() | 260 | format!("{}:{}", package.name, package.version) |
260 | } | 261 | } |
261 | } | 262 | } |
262 | 263 | ||
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3c8f55f1e..04f5bb473 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -16,21 +16,33 @@ use serde::Deserialize; | |||
16 | #[derive(Debug, Clone)] | 16 | #[derive(Debug, Clone)] |
17 | pub struct Config { | 17 | pub struct Config { |
18 | pub client_caps: ClientCapsConfig, | 18 | pub client_caps: ClientCapsConfig, |
19 | pub publish_decorations: bool, | 19 | |
20 | pub with_sysroot: bool, | ||
20 | pub publish_diagnostics: bool, | 21 | pub publish_diagnostics: bool, |
22 | pub lru_capacity: Option<usize>, | ||
23 | pub proc_macro_srv: Option<String>, | ||
24 | pub files: FilesConfig, | ||
21 | pub notifications: NotificationsConfig, | 25 | pub notifications: NotificationsConfig, |
26 | |||
27 | pub cargo: CargoConfig, | ||
28 | pub rustfmt: RustfmtConfig, | ||
29 | pub check: Option<FlycheckConfig>, | ||
30 | |||
22 | pub inlay_hints: InlayHintsConfig, | 31 | pub inlay_hints: InlayHintsConfig, |
23 | pub completion: CompletionConfig, | 32 | pub completion: CompletionConfig, |
24 | pub call_info_full: bool, | 33 | pub call_info_full: bool, |
25 | pub rustfmt: RustfmtConfig, | 34 | } |
26 | pub check: Option<FlycheckConfig>, | 35 | |
27 | pub vscode_lldb: bool, | 36 | #[derive(Debug, Clone)] |
28 | pub proc_macro_srv: Option<String>, | 37 | pub struct FilesConfig { |
29 | pub lru_capacity: Option<usize>, | 38 | pub watcher: FilesWatcher, |
30 | pub use_client_watching: bool, | 39 | pub exclude: Vec<String>, |
31 | pub exclude_globs: Vec<String>, | 40 | } |
32 | pub cargo: CargoConfig, | 41 | |
33 | pub with_sysroot: bool, | 42 | #[derive(Debug, Clone)] |
43 | pub enum FilesWatcher { | ||
44 | Client, | ||
45 | Notify, | ||
34 | } | 46 | } |
35 | 47 | ||
36 | #[derive(Debug, Clone)] | 48 | #[derive(Debug, Clone)] |
@@ -60,13 +72,26 @@ pub struct ClientCapsConfig { | |||
60 | impl Default for Config { | 72 | impl Default for Config { |
61 | fn default() -> Self { | 73 | fn default() -> Self { |
62 | Config { | 74 | Config { |
63 | publish_decorations: false, | 75 | client_caps: ClientCapsConfig::default(), |
76 | |||
77 | with_sysroot: true, | ||
64 | publish_diagnostics: true, | 78 | publish_diagnostics: true, |
79 | lru_capacity: None, | ||
80 | proc_macro_srv: None, | ||
81 | files: FilesConfig { watcher: FilesWatcher::Notify, exclude: Vec::new() }, | ||
65 | notifications: NotificationsConfig { | 82 | notifications: NotificationsConfig { |
66 | workspace_loaded: true, | 83 | workspace_loaded: true, |
67 | cargo_toml_not_found: true, | 84 | cargo_toml_not_found: true, |
68 | }, | 85 | }, |
69 | client_caps: ClientCapsConfig::default(), | 86 | |
87 | cargo: CargoConfig::default(), | ||
88 | rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() }, | ||
89 | check: Some(FlycheckConfig::CargoCommand { | ||
90 | command: "check".to_string(), | ||
91 | all_targets: true, | ||
92 | extra_args: Vec::new(), | ||
93 | }), | ||
94 | |||
70 | inlay_hints: InlayHintsConfig { | 95 | inlay_hints: InlayHintsConfig { |
71 | type_hints: true, | 96 | type_hints: true, |
72 | parameter_hints: true, | 97 | parameter_hints: true, |
@@ -79,19 +104,6 @@ impl Default for Config { | |||
79 | add_call_argument_snippets: true, | 104 | add_call_argument_snippets: true, |
80 | }, | 105 | }, |
81 | call_info_full: true, | 106 | call_info_full: true, |
82 | rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() }, | ||
83 | check: Some(FlycheckConfig::CargoCommand { | ||
84 | command: "check".to_string(), | ||
85 | all_targets: true, | ||
86 | extra_args: Vec::new(), | ||
87 | }), | ||
88 | vscode_lldb: false, | ||
89 | proc_macro_srv: None, | ||
90 | lru_capacity: None, | ||
91 | use_client_watching: false, | ||
92 | exclude_globs: Vec::new(), | ||
93 | cargo: CargoConfig::default(), | ||
94 | with_sysroot: true, | ||
95 | } | 107 | } |
96 | } | 108 | } |
97 | } | 109 | } |
@@ -105,46 +117,61 @@ impl Config { | |||
105 | *self = Default::default(); | 117 | *self = Default::default(); |
106 | self.client_caps = client_caps; | 118 | self.client_caps = client_caps; |
107 | 119 | ||
108 | set(value, "/publishDecorations", &mut self.publish_decorations); | 120 | set(value, "/withSysroot", &mut self.with_sysroot); |
109 | set(value, "/excludeGlobs", &mut self.exclude_globs); | 121 | set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); |
110 | set(value, "/useClientWatching", &mut self.use_client_watching); | ||
111 | set(value, "/lruCapacity", &mut self.lru_capacity); | 122 | set(value, "/lruCapacity", &mut self.lru_capacity); |
112 | 123 | if let Some(watcher) = get::<String>(value, "/files/watcher") { | |
113 | set(value, "/inlayHintsType", &mut self.inlay_hints.type_hints); | 124 | self.files.watcher = match watcher.as_str() { |
114 | set(value, "/inlayHintsParameter", &mut self.inlay_hints.parameter_hints); | 125 | "client" => FilesWatcher::Client, |
115 | set(value, "/inlayHintsChaining", &mut self.inlay_hints.chaining_hints); | 126 | "notify"| _ => FilesWatcher::Notify, |
116 | set(value, "/inlayHintsMaxLength", &mut self.inlay_hints.max_length); | 127 | } |
117 | 128 | } | |
118 | if let Some(false) = get(value, "cargo_watch_enable") { | 129 | set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded); |
130 | set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found); | ||
131 | |||
132 | set(value, "/cargo/noDefaultFeatures", &mut self.cargo.no_default_features); | ||
133 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); | ||
134 | set(value, "/cargo/features", &mut self.cargo.features); | ||
135 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | ||
136 | if let Some(mut args) = get::<Vec<String>>(value, "/rustfmt/overrideCommand") { | ||
137 | if !args.is_empty() { | ||
138 | let command = args.remove(0); | ||
139 | self.rustfmt = RustfmtConfig::CustomCommand { | ||
140 | command, | ||
141 | args, | ||
142 | } | ||
143 | } | ||
144 | } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { | ||
145 | set(value, "/rustfmt/extraArgs", extra_args); | ||
146 | } | ||
147 | if let Some(false) = get(value, "/checkOnSave/enable") { | ||
119 | self.check = None | 148 | self.check = None |
120 | } else { | 149 | } else { |
121 | if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check | 150 | if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") { |
151 | if !args.is_empty() { | ||
152 | let command = args.remove(0); | ||
153 | self.check = Some(FlycheckConfig::CustomCommand { | ||
154 | command, | ||
155 | args, | ||
156 | }) | ||
157 | } | ||
158 | |||
159 | } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check | ||
122 | { | 160 | { |
123 | set(value, "/cargoWatchArgs", extra_args); | 161 | set(value, "/checkOnSave/extraArgs", extra_args); |
124 | set(value, "/cargoWatchCommand", command); | 162 | set(value, "/checkOnSave/command", command); |
125 | set(value, "/cargoWatchAllTargets", all_targets); | 163 | set(value, "/checkOnSave/allTargets", all_targets); |
126 | } | 164 | } |
127 | }; | 165 | }; |
128 | 166 | ||
129 | set(value, "/withSysroot", &mut self.with_sysroot); | 167 | set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); |
130 | if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { | 168 | set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); |
131 | set(value, "/rustfmtArgs", extra_args); | 169 | set(value, "/inlayHints/chainingHints", &mut self.inlay_hints.chaining_hints); |
132 | } | 170 | set(value, "/inlayHints/maxLength", &mut self.inlay_hints.max_length); |
133 | 171 | set(value, "/completion/postfix/enable", &mut self.completion.enable_postfix_completions); | |
134 | set(value, "/cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features); | 172 | set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis); |
135 | set(value, "/cargoFeatures/allFeatures", &mut self.cargo.all_features); | 173 | set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets); |
136 | set(value, "/cargoFeatures/features", &mut self.cargo.features); | 174 | set(value, "/callInfo/full", &mut self.call_info_full); |
137 | set(value, "/cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | ||
138 | |||
139 | set(value, "/vscodeLldb", &mut self.vscode_lldb); | ||
140 | |||
141 | set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); | ||
142 | set(value, "/featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded); | ||
143 | set(value, "/featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found); | ||
144 | set(value, "/featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions); | ||
145 | set(value, "/featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis); | ||
146 | set(value, "/featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets); | ||
147 | set(value, "/featureFlags/call-info.full", &mut self.call_info_full); | ||
148 | 175 | ||
149 | log::info!("Config::update() = {:#?}", self); | 176 | log::info!("Config::update() = {:#?}", self); |
150 | 177 | ||
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 45ae0ad9d..95e676e0f 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -30,7 +30,7 @@ use serde::{de::DeserializeOwned, Serialize}; | |||
30 | use threadpool::ThreadPool; | 30 | use threadpool::ThreadPool; |
31 | 31 | ||
32 | use crate::{ | 32 | use crate::{ |
33 | config::Config, | 33 | config::{Config, FilesWatcher}, |
34 | diagnostics::DiagnosticTask, | 34 | diagnostics::DiagnosticTask, |
35 | main_loop::{ | 35 | main_loop::{ |
36 | pending_requests::{PendingRequest, PendingRequests}, | 36 | pending_requests::{PendingRequest, PendingRequests}, |
@@ -40,7 +40,6 @@ use crate::{ | |||
40 | world::{WorldSnapshot, WorldState}, | 40 | world::{WorldSnapshot, WorldState}, |
41 | Result, | 41 | Result, |
42 | }; | 42 | }; |
43 | use req::ConfigurationParams; | ||
44 | 43 | ||
45 | #[derive(Debug)] | 44 | #[derive(Debug)] |
46 | pub struct LspError { | 45 | pub struct LspError { |
@@ -122,12 +121,13 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection) | |||
122 | }; | 121 | }; |
123 | 122 | ||
124 | let globs = config | 123 | let globs = config |
125 | .exclude_globs | 124 | .files |
125 | .exclude | ||
126 | .iter() | 126 | .iter() |
127 | .map(|glob| crate::vfs_glob::Glob::new(glob)) | 127 | .map(|glob| crate::vfs_glob::Glob::new(glob)) |
128 | .collect::<std::result::Result<Vec<_>, _>>()?; | 128 | .collect::<std::result::Result<Vec<_>, _>>()?; |
129 | 129 | ||
130 | if config.use_client_watching { | 130 | if let FilesWatcher::Client = config.files.watcher { |
131 | let registration_options = req::DidChangeWatchedFilesRegistrationOptions { | 131 | let registration_options = req::DidChangeWatchedFilesRegistrationOptions { |
132 | watchers: workspaces | 132 | watchers: workspaces |
133 | .iter() | 133 | .iter() |
@@ -153,7 +153,7 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection) | |||
153 | workspaces, | 153 | workspaces, |
154 | config.lru_capacity, | 154 | config.lru_capacity, |
155 | &globs, | 155 | &globs, |
156 | Watch(!config.use_client_watching), | 156 | Watch(matches!(config.files.watcher, FilesWatcher::Notify)), |
157 | config, | 157 | config, |
158 | ) | 158 | ) |
159 | }; | 159 | }; |
@@ -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)? |
@@ -611,7 +607,12 @@ fn on_notification( | |||
611 | let request_id = loop_state.next_request_id(); | 607 | let request_id = loop_state.next_request_id(); |
612 | let request = request_new::<req::WorkspaceConfiguration>( | 608 | let request = request_new::<req::WorkspaceConfiguration>( |
613 | request_id.clone(), | 609 | request_id.clone(), |
614 | ConfigurationParams::default(), | 610 | req::ConfigurationParams { |
611 | items: vec![req::ConfigurationItem { | ||
612 | scope_uri: None, | ||
613 | section: Some("rust-analyzer".to_string()), | ||
614 | }], | ||
615 | }, | ||
615 | ); | 616 | ); |
616 | msg_sender.send(request.into())?; | 617 | msg_sender.send(request.into())?; |
617 | loop_state.configuration_request_id = Some(request_id); | 618 | loop_state.configuration_request_id = Some(request_id); |
@@ -884,15 +885,13 @@ where | |||
884 | fn update_file_notifications_on_threadpool( | 885 | fn update_file_notifications_on_threadpool( |
885 | pool: &ThreadPool, | 886 | pool: &ThreadPool, |
886 | world: WorldSnapshot, | 887 | world: WorldSnapshot, |
887 | publish_decorations: bool, | ||
888 | task_sender: Sender<Task>, | 888 | task_sender: Sender<Task>, |
889 | subscriptions: Vec<FileId>, | 889 | subscriptions: Vec<FileId>, |
890 | ) { | 890 | ) { |
891 | log::trace!("updating notifications for {:?}", subscriptions); | 891 | log::trace!("updating notifications for {:?}", subscriptions); |
892 | let publish_diagnostics = world.config.publish_diagnostics; | 892 | if world.config.publish_diagnostics { |
893 | pool.execute(move || { | 893 | pool.execute(move || { |
894 | for file_id in subscriptions { | 894 | for file_id in subscriptions { |
895 | if publish_diagnostics { | ||
896 | match handlers::publish_diagnostics(&world, file_id) { | 895 | match handlers::publish_diagnostics(&world, file_id) { |
897 | Err(e) => { | 896 | Err(e) => { |
898 | if !is_canceled(&e) { | 897 | if !is_canceled(&e) { |
@@ -904,21 +903,8 @@ fn update_file_notifications_on_threadpool( | |||
904 | } | 903 | } |
905 | } | 904 | } |
906 | } | 905 | } |
907 | if publish_decorations { | 906 | }) |
908 | match handlers::publish_decorations(&world, file_id) { | 907 | } |
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 | } | ||
921 | }); | ||
922 | } | 908 | } |
923 | 909 | ||
924 | pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) { | 910 | pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) { |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 23e48c089..b207f0764 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 | ||
392 | pub 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 | |||
401 | pub fn handle_completion( | 392 | pub fn handle_completion( |
402 | world: WorldSnapshot, | 393 | world: WorldSnapshot, |
403 | params: req::CompletionParams, | 394 | params: req::CompletionParams, |
@@ -819,23 +810,21 @@ pub fn handle_code_lens( | |||
819 | }; | 810 | }; |
820 | lenses.push(lens); | 811 | lenses.push(lens); |
821 | 812 | ||
822 | if world.config.vscode_lldb { | 813 | if r.args[0] == "run" { |
823 | if r.args[0] == "run" { | 814 | r.args[0] = "build".into(); |
824 | r.args[0] = "build".into(); | 815 | } else { |
825 | } else { | 816 | r.args.push("--no-run".into()); |
826 | r.args.push("--no-run".into()); | ||
827 | } | ||
828 | let debug_lens = CodeLens { | ||
829 | range: r.range, | ||
830 | command: Some(Command { | ||
831 | title: "Debug".into(), | ||
832 | command: "rust-analyzer.debugSingle".into(), | ||
833 | arguments: Some(vec![to_value(r).unwrap()]), | ||
834 | }), | ||
835 | data: None, | ||
836 | }; | ||
837 | lenses.push(debug_lens); | ||
838 | } | 817 | } |
818 | let debug_lens = CodeLens { | ||
819 | range: r.range, | ||
820 | command: Some(Command { | ||
821 | title: "Debug".into(), | ||
822 | command: "rust-analyzer.debugSingle".into(), | ||
823 | arguments: Some(vec![to_value(r).unwrap()]), | ||
824 | }), | ||
825 | data: None, | ||
826 | }; | ||
827 | lenses.push(debug_lens); | ||
839 | } | 828 | } |
840 | 829 | ||
841 | // Handle impls | 830 | // Handle impls |
@@ -970,15 +959,6 @@ pub fn publish_diagnostics(world: &WorldSnapshot, file_id: FileId) -> Result<Dia | |||
970 | Ok(DiagnosticTask::SetNative(file_id, diagnostics)) | 959 | Ok(DiagnosticTask::SetNative(file_id, diagnostics)) |
971 | } | 960 | } |
972 | 961 | ||
973 | pub 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 | |||
982 | fn to_lsp_runnable( | 962 | fn to_lsp_runnable( |
983 | world: &WorldSnapshot, | 963 | world: &WorldSnapshot, |
984 | file_id: FileId, | 964 | file_id: FileId, |
@@ -1008,21 +988,6 @@ fn to_lsp_runnable( | |||
1008 | }) | 988 | }) |
1009 | } | 989 | } |
1010 | 990 | ||
1011 | fn 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 | |||
1026 | pub fn handle_inlay_hints( | 991 | pub fn handle_inlay_hints( |
1027 | world: WorldSnapshot, | 992 | world: WorldSnapshot, |
1028 | params: InlayHintsParams, | 993 | params: InlayHintsParams, |
diff --git a/crates/rust-analyzer/src/req.rs b/crates/rust-analyzer/src/req.rs index 994f0ed61..b8b627e28 100644 --- a/crates/rust-analyzer/src/req.rs +++ b/crates/rust-analyzer/src/req.rs | |||
@@ -1,13 +1,13 @@ | |||
1 | //! Defines `rust-analyzer` specific custom messages. | 1 | //! Defines `rust-analyzer` specific custom messages. |
2 | 2 | ||
3 | use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url}; | 3 | use lsp_types::{Location, Position, Range, TextDocumentIdentifier}; |
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
6 | 6 | ||
7 | pub use lsp_types::{ | 7 | pub use lsp_types::{ |
8 | notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, | 8 | notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, |
9 | CodeLensParams, CompletionParams, CompletionResponse, ConfigurationParams, DiagnosticTag, | 9 | CodeLensParams, CompletionParams, CompletionResponse, ConfigurationItem, ConfigurationParams, |
10 | DidChangeConfigurationParams, DidChangeWatchedFilesParams, | 10 | DiagnosticTag, DidChangeConfigurationParams, DidChangeWatchedFilesParams, |
11 | DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams, | 11 | DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams, |
12 | DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType, | 12 | DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType, |
13 | PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken, | 13 | PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken, |
@@ -86,36 +86,6 @@ pub struct FindMatchingBraceParams { | |||
86 | pub offsets: Vec<Position>, | 86 | pub offsets: Vec<Position>, |
87 | } | 87 | } |
88 | 88 | ||
89 | pub enum DecorationsRequest {} | ||
90 | |||
91 | impl Request for DecorationsRequest { | ||
92 | type Params = TextDocumentIdentifier; | ||
93 | type Result = Vec<Decoration>; | ||
94 | const METHOD: &'static str = "rust-analyzer/decorationsRequest"; | ||
95 | } | ||
96 | |||
97 | pub enum PublishDecorations {} | ||
98 | |||
99 | impl 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")] | ||
106 | pub struct PublishDecorationsParams { | ||
107 | pub uri: Url, | ||
108 | pub decorations: Vec<Decoration>, | ||
109 | } | ||
110 | |||
111 | #[derive(Deserialize, Serialize, Debug)] | ||
112 | #[serde(rename_all = "camelCase")] | ||
113 | pub struct Decoration { | ||
114 | pub range: Range, | ||
115 | pub tag: String, | ||
116 | pub binding_hash: Option<String>, | ||
117 | } | ||
118 | |||
119 | pub enum ParentModule {} | 89 | pub enum ParentModule {} |
120 | 90 | ||
121 | impl Request for ParentModule { | 91 | impl Request for ParentModule { |