aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-12-19 14:18:09 +0000
committerKirill Bulatov <[email protected]>2019-12-19 14:18:09 +0000
commit4fb25ef43bd96da94467ffa4de8fbf0af82b28d1 (patch)
treebccdcbad14a78bf670f77f1f98208009ea80b8dd /crates
parent3969c7c85373554fcd80aee359cd0def14f7a528 (diff)
Do not add any new configuration parameters
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs44
-rw-r--r--crates/ra_ide/src/lib.rs7
-rw-r--r--crates/ra_lsp_server/src/config.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs1
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs6
-rw-r--r--crates/ra_lsp_server/src/world.rs1
6 files changed, 12 insertions, 49 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 319ac0048..4c5004f67 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -160,7 +160,7 @@ mod tests {
160 use crate::mock_analysis::single_file; 160 use crate::mock_analysis::single_file;
161 161
162 #[test] 162 #[test]
163 fn default_generic_types_disabled() { 163 fn default_generic_types_should_not_be_displayed() {
164 let (analysis, file_id) = single_file( 164 let (analysis, file_id) = single_file(
165 r#" 165 r#"
166struct Test<K, T = u8> { 166struct Test<K, T = u8> {
@@ -173,7 +173,7 @@ fn main() {
173}"#, 173}"#,
174 ); 174 );
175 175
176 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, false).unwrap(), @r###" 176 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
177 [ 177 [
178 InlayHint { 178 InlayHint {
179 range: [69; 71), 179 range: [69; 71),
@@ -186,32 +186,6 @@ fn main() {
186 } 186 }
187 187
188 #[test] 188 #[test]
189 fn default_generic_types_enabled() {
190 let (analysis, file_id) = single_file(
191 r#"
192struct Test<K, T = u8> {
193 k: K,
194 t: T,
195}
196
197fn main() {
198 let zz = Test { t: 23, k: 33 };
199}"#,
200 );
201
202 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
203 [
204 InlayHint {
205 range: [69; 71),
206 kind: TypeHint,
207 label: "Test<i32, u8>",
208 },
209 ]
210 "###
211 );
212 }
213
214 #[test]
215 fn let_statement() { 189 fn let_statement() {
216 let (analysis, file_id) = single_file( 190 let (analysis, file_id) = single_file(
217 r#" 191 r#"
@@ -251,7 +225,7 @@ fn main() {
251}"#, 225}"#,
252 ); 226 );
253 227
254 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 228 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
255 [ 229 [
256 InlayHint { 230 InlayHint {
257 range: [193; 197), 231 range: [193; 197),
@@ -325,7 +299,7 @@ fn main() {
325}"#, 299}"#,
326 ); 300 );
327 301
328 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 302 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
329 [ 303 [
330 InlayHint { 304 InlayHint {
331 range: [21; 30), 305 range: [21; 30),
@@ -354,7 +328,7 @@ fn main() {
354}"#, 328}"#,
355 ); 329 );
356 330
357 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 331 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
358 [ 332 [
359 InlayHint { 333 InlayHint {
360 range: [21; 30), 334 range: [21; 30),
@@ -402,7 +376,7 @@ fn main() {
402}"#, 376}"#,
403 ); 377 );
404 378
405 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 379 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
406 [ 380 [
407 InlayHint { 381 InlayHint {
408 range: [166; 170), 382 range: [166; 170),
@@ -465,7 +439,7 @@ fn main() {
465}"#, 439}"#,
466 ); 440 );
467 441
468 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 442 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
469 [ 443 [
470 InlayHint { 444 InlayHint {
471 range: [166; 170), 445 range: [166; 170),
@@ -528,7 +502,7 @@ fn main() {
528}"#, 502}"#,
529 ); 503 );
530 504
531 assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###" 505 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
532 [ 506 [
533 InlayHint { 507 InlayHint {
534 range: [311; 315), 508 range: [311; 315),
@@ -570,7 +544,7 @@ fn main() {
570}"#, 544}"#,
571 ); 545 );
572 546
573 assert_debug_snapshot!(analysis.inlay_hints(file_id, Some(8), true).unwrap(), @r###" 547 assert_debug_snapshot!(analysis.inlay_hints(file_id, Some(8)).unwrap(), @r###"
574 [ 548 [
575 InlayHint { 549 InlayHint {
576 range: [74; 75), 550 range: [74; 75),
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index c3244a8dd..875919e60 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -348,12 +348,9 @@ impl Analysis {
348 &self, 348 &self,
349 file_id: FileId, 349 file_id: FileId,
350 max_inlay_hint_length: Option<usize>, 350 max_inlay_hint_length: Option<usize>,
351 show_default_types_in_inlay_hints: bool,
352 ) -> Cancelable<Vec<InlayHint>> { 351 ) -> Cancelable<Vec<InlayHint>> {
353 let truncate_options = hir::TruncateOptions { 352 let truncate_options =
354 max_length: max_inlay_hint_length, 353 hir::TruncateOptions { max_length: max_inlay_hint_length, show_default_types: false };
355 show_default_types: show_default_types_in_inlay_hints,
356 };
357 self.with_db(|db| { 354 self.with_db(|db| {
358 inlay_hints::inlay_hints(db, file_id, &db.parse(file_id).tree(), &truncate_options) 355 inlay_hints::inlay_hints(db, file_id, &db.parse(file_id).tree(), &truncate_options)
359 }) 356 })
diff --git a/crates/ra_lsp_server/src/config.rs b/crates/ra_lsp_server/src/config.rs
index a916c5fd6..67942aa41 100644
--- a/crates/ra_lsp_server/src/config.rs
+++ b/crates/ra_lsp_server/src/config.rs
@@ -31,7 +31,6 @@ pub struct ServerConfig {
31 pub lru_capacity: Option<usize>, 31 pub lru_capacity: Option<usize>,
32 32
33 pub max_inlay_hint_length: Option<usize>, 33 pub max_inlay_hint_length: Option<usize>,
34 pub show_default_types_in_inlay_hints: bool,
35 34
36 /// For internal usage to make integrated tests faster. 35 /// For internal usage to make integrated tests faster.
37 #[serde(deserialize_with = "nullable_bool_true")] 36 #[serde(deserialize_with = "nullable_bool_true")]
@@ -52,7 +51,6 @@ impl Default for ServerConfig {
52 use_client_watching: false, 51 use_client_watching: false,
53 lru_capacity: None, 52 lru_capacity: None,
54 max_inlay_hint_length: None, 53 max_inlay_hint_length: None,
55 show_default_types_in_inlay_hints: false,
56 with_sysroot: true, 54 with_sysroot: true,
57 feature_flags: FxHashMap::default(), 55 feature_flags: FxHashMap::default(),
58 cargo_features: Default::default(), 56 cargo_features: Default::default(),
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 01fde3b2d..965e7c53c 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -125,7 +125,6 @@ pub fn main_loop(
125 .and_then(|it| it.line_folding_only) 125 .and_then(|it| it.line_folding_only)
126 .unwrap_or(false), 126 .unwrap_or(false),
127 max_inlay_hint_length: config.max_inlay_hint_length, 127 max_inlay_hint_length: config.max_inlay_hint_length,
128 show_default_types_in_inlay_hints: config.show_default_types_in_inlay_hints,
129 } 128 }
130 }; 129 };
131 130
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 9069d1f1d..5b64b27cd 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -895,11 +895,7 @@ pub fn handle_inlay_hints(
895 let analysis = world.analysis(); 895 let analysis = world.analysis();
896 let line_index = analysis.file_line_index(file_id)?; 896 let line_index = analysis.file_line_index(file_id)?;
897 Ok(analysis 897 Ok(analysis
898 .inlay_hints( 898 .inlay_hints(file_id, world.options.max_inlay_hint_length)?
899 file_id,
900 world.options.max_inlay_hint_length,
901 world.options.show_default_types_in_inlay_hints,
902 )?
903 .into_iter() 899 .into_iter()
904 .map(|api_type| InlayHint { 900 .map(|api_type| InlayHint {
905 label: api_type.label.to_string(), 901 label: api_type.label.to_string(),
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index 0b6eefcbc..16cc11e8c 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -31,7 +31,6 @@ pub struct Options {
31 pub supports_location_link: bool, 31 pub supports_location_link: bool,
32 pub line_folding_only: bool, 32 pub line_folding_only: bool,
33 pub max_inlay_hint_length: Option<usize>, 33 pub max_inlay_hint_length: Option<usize>,
34 pub show_default_types_in_inlay_hints: bool,
35} 34}
36 35
37/// `WorldState` is the primary mutable state of the language server 36/// `WorldState` is the primary mutable state of the language server