diff options
author | Aleksey Kladov <[email protected]> | 2020-03-12 16:38:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-03-12 16:38:48 +0000 |
commit | fd3ece2b739b2e8d97626d6c5a6cb91b70df1071 (patch) | |
tree | 0b133ad3347251ab2db0aeedca89ef9e14b1732d | |
parent | d98a5fab46c5850a484349c50dda7cb823cc179a (diff) |
Make naming more uniform
-rw-r--r-- | crates/ra_ide/src/completion.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 52 | ||||
-rw-r--r-- | crates/ra_ide/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/req.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 4 |
6 files changed, 35 insertions, 35 deletions
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 93e53c921..cd0757be5 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs | |||
@@ -75,9 +75,9 @@ impl Default for CompletionOptions { | |||
75 | pub(crate) fn completions( | 75 | pub(crate) fn completions( |
76 | db: &RootDatabase, | 76 | db: &RootDatabase, |
77 | position: FilePosition, | 77 | position: FilePosition, |
78 | opts: &CompletionOptions, | 78 | options: &CompletionOptions, |
79 | ) -> Option<Completions> { | 79 | ) -> Option<Completions> { |
80 | let ctx = CompletionContext::new(db, position, opts)?; | 80 | let ctx = CompletionContext::new(db, position, options)?; |
81 | 81 | ||
82 | let mut acc = Completions::default(); | 82 | let mut acc = Completions::default(); |
83 | 83 | ||
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 59922e14c..ecd615cf4 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -11,13 +11,13 @@ use ra_syntax::{ | |||
11 | use crate::{FileId, FunctionSignature}; | 11 | use crate::{FileId, FunctionSignature}; |
12 | 12 | ||
13 | #[derive(Clone, Debug, PartialEq, Eq)] | 13 | #[derive(Clone, Debug, PartialEq, Eq)] |
14 | pub struct InlayConfig { | 14 | pub struct InlayHintsOptions { |
15 | pub type_hints: bool, | 15 | pub type_hints: bool, |
16 | pub parameter_hints: bool, | 16 | pub parameter_hints: bool, |
17 | pub max_length: Option<usize>, | 17 | pub max_length: Option<usize>, |
18 | } | 18 | } |
19 | 19 | ||
20 | impl Default for InlayConfig { | 20 | impl Default for InlayHintsOptions { |
21 | fn default() -> Self { | 21 | fn default() -> Self { |
22 | Self { type_hints: true, parameter_hints: true, max_length: None } | 22 | Self { type_hints: true, parameter_hints: true, max_length: None } |
23 | } | 23 | } |
@@ -39,7 +39,7 @@ pub struct InlayHint { | |||
39 | pub(crate) fn inlay_hints( | 39 | pub(crate) fn inlay_hints( |
40 | db: &RootDatabase, | 40 | db: &RootDatabase, |
41 | file_id: FileId, | 41 | file_id: FileId, |
42 | inlay_hint_opts: &InlayConfig, | 42 | options: &InlayHintsOptions, |
43 | ) -> Vec<InlayHint> { | 43 | ) -> Vec<InlayHint> { |
44 | let _p = profile("inlay_hints"); | 44 | let _p = profile("inlay_hints"); |
45 | let sema = Semantics::new(db); | 45 | let sema = Semantics::new(db); |
@@ -49,9 +49,9 @@ pub(crate) fn inlay_hints( | |||
49 | for node in file.syntax().descendants() { | 49 | for node in file.syntax().descendants() { |
50 | match_ast! { | 50 | match_ast! { |
51 | match node { | 51 | match node { |
52 | ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); }, | 52 | ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, |
53 | ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); }, | 53 | ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, |
54 | ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, inlay_hint_opts, it); }, | 54 | ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, options, it); }, |
55 | _ => (), | 55 | _ => (), |
56 | } | 56 | } |
57 | } | 57 | } |
@@ -62,10 +62,10 @@ pub(crate) fn inlay_hints( | |||
62 | fn get_param_name_hints( | 62 | fn get_param_name_hints( |
63 | acc: &mut Vec<InlayHint>, | 63 | acc: &mut Vec<InlayHint>, |
64 | sema: &Semantics<RootDatabase>, | 64 | sema: &Semantics<RootDatabase>, |
65 | inlay_hint_opts: &InlayConfig, | 65 | options: &InlayHintsOptions, |
66 | expr: ast::Expr, | 66 | expr: ast::Expr, |
67 | ) -> Option<()> { | 67 | ) -> Option<()> { |
68 | if !inlay_hint_opts.parameter_hints { | 68 | if !options.parameter_hints { |
69 | return None; | 69 | return None; |
70 | } | 70 | } |
71 | 71 | ||
@@ -102,10 +102,10 @@ fn get_param_name_hints( | |||
102 | fn get_bind_pat_hints( | 102 | fn get_bind_pat_hints( |
103 | acc: &mut Vec<InlayHint>, | 103 | acc: &mut Vec<InlayHint>, |
104 | sema: &Semantics<RootDatabase>, | 104 | sema: &Semantics<RootDatabase>, |
105 | inlay_hint_opts: &InlayConfig, | 105 | options: &InlayHintsOptions, |
106 | pat: ast::BindPat, | 106 | pat: ast::BindPat, |
107 | ) -> Option<()> { | 107 | ) -> Option<()> { |
108 | if !inlay_hint_opts.type_hints { | 108 | if !options.type_hints { |
109 | return None; | 109 | return None; |
110 | } | 110 | } |
111 | 111 | ||
@@ -118,7 +118,7 @@ fn get_bind_pat_hints( | |||
118 | acc.push(InlayHint { | 118 | acc.push(InlayHint { |
119 | range: pat.syntax().text_range(), | 119 | range: pat.syntax().text_range(), |
120 | kind: InlayKind::TypeHint, | 120 | kind: InlayKind::TypeHint, |
121 | label: ty.display_truncated(sema.db, inlay_hint_opts.max_length).to_string().into(), | 121 | label: ty.display_truncated(sema.db, options.max_length).to_string().into(), |
122 | }); | 122 | }); |
123 | Some(()) | 123 | Some(()) |
124 | } | 124 | } |
@@ -224,7 +224,7 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option< | |||
224 | 224 | ||
225 | #[cfg(test)] | 225 | #[cfg(test)] |
226 | mod tests { | 226 | mod tests { |
227 | use crate::inlay_hints::InlayConfig; | 227 | use crate::inlay_hints::InlayHintsOptions; |
228 | use insta::assert_debug_snapshot; | 228 | use insta::assert_debug_snapshot; |
229 | 229 | ||
230 | use crate::mock_analysis::single_file; | 230 | use crate::mock_analysis::single_file; |
@@ -238,7 +238,7 @@ mod tests { | |||
238 | let _x = foo(4, 4); | 238 | let _x = foo(4, 4); |
239 | }"#, | 239 | }"#, |
240 | ); | 240 | ); |
241 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###" | 241 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###" |
242 | [ | 242 | [ |
243 | InlayHint { | 243 | InlayHint { |
244 | range: [106; 107), | 244 | range: [106; 107), |
@@ -262,7 +262,7 @@ mod tests { | |||
262 | let _x = foo(4, 4); | 262 | let _x = foo(4, 4); |
263 | }"#, | 263 | }"#, |
264 | ); | 264 | ); |
265 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###); | 265 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###); |
266 | } | 266 | } |
267 | 267 | ||
268 | #[test] | 268 | #[test] |
@@ -274,7 +274,7 @@ mod tests { | |||
274 | let _x = foo(4, 4); | 274 | let _x = foo(4, 4); |
275 | }"#, | 275 | }"#, |
276 | ); | 276 | ); |
277 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###" | 277 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###" |
278 | [ | 278 | [ |
279 | InlayHint { | 279 | InlayHint { |
280 | range: [97; 99), | 280 | range: [97; 99), |
@@ -298,7 +298,7 @@ fn main() { | |||
298 | }"#, | 298 | }"#, |
299 | ); | 299 | ); |
300 | 300 | ||
301 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 301 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
302 | [ | 302 | [ |
303 | InlayHint { | 303 | InlayHint { |
304 | range: [69; 71), | 304 | range: [69; 71), |
@@ -355,7 +355,7 @@ fn main() { | |||
355 | }"#, | 355 | }"#, |
356 | ); | 356 | ); |
357 | 357 | ||
358 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 358 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
359 | [ | 359 | [ |
360 | InlayHint { | 360 | InlayHint { |
361 | range: [193; 197), | 361 | range: [193; 197), |
@@ -435,7 +435,7 @@ fn main() { | |||
435 | }"#, | 435 | }"#, |
436 | ); | 436 | ); |
437 | 437 | ||
438 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 438 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
439 | [ | 439 | [ |
440 | InlayHint { | 440 | InlayHint { |
441 | range: [21; 30), | 441 | range: [21; 30), |
@@ -499,7 +499,7 @@ fn main() { | |||
499 | }"#, | 499 | }"#, |
500 | ); | 500 | ); |
501 | 501 | ||
502 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 502 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
503 | [ | 503 | [ |
504 | InlayHint { | 504 | InlayHint { |
505 | range: [21; 30), | 505 | range: [21; 30), |
@@ -549,7 +549,7 @@ fn main() { | |||
549 | }"#, | 549 | }"#, |
550 | ); | 550 | ); |
551 | 551 | ||
552 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 552 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
553 | [ | 553 | [ |
554 | InlayHint { | 554 | InlayHint { |
555 | range: [188; 192), | 555 | range: [188; 192), |
@@ -644,7 +644,7 @@ fn main() { | |||
644 | }"#, | 644 | }"#, |
645 | ); | 645 | ); |
646 | 646 | ||
647 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 647 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
648 | [ | 648 | [ |
649 | InlayHint { | 649 | InlayHint { |
650 | range: [188; 192), | 650 | range: [188; 192), |
@@ -739,7 +739,7 @@ fn main() { | |||
739 | }"#, | 739 | }"#, |
740 | ); | 740 | ); |
741 | 741 | ||
742 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 742 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
743 | [ | 743 | [ |
744 | InlayHint { | 744 | InlayHint { |
745 | range: [252; 256), | 745 | range: [252; 256), |
@@ -811,7 +811,7 @@ fn main() { | |||
811 | }"#, | 811 | }"#, |
812 | ); | 812 | ); |
813 | 813 | ||
814 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" | 814 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" |
815 | [ | 815 | [ |
816 | InlayHint { | 816 | InlayHint { |
817 | range: [74; 75), | 817 | range: [74; 75), |
@@ -899,7 +899,7 @@ fn main() { | |||
899 | }"#, | 899 | }"#, |
900 | ); | 900 | ); |
901 | 901 | ||
902 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###" | 902 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" |
903 | [ | 903 | [ |
904 | InlayHint { | 904 | InlayHint { |
905 | range: [798; 809), | 905 | range: [798; 809), |
@@ -1021,7 +1021,7 @@ fn main() { | |||
1021 | }"#, | 1021 | }"#, |
1022 | ); | 1022 | ); |
1023 | 1023 | ||
1024 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" | 1024 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" |
1025 | [] | 1025 | [] |
1026 | "### | 1026 | "### |
1027 | ); | 1027 | ); |
@@ -1047,7 +1047,7 @@ fn main() { | |||
1047 | }"#, | 1047 | }"#, |
1048 | ); | 1048 | ); |
1049 | 1049 | ||
1050 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" | 1050 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" |
1051 | [] | 1051 | [] |
1052 | "### | 1052 | "### |
1053 | ); | 1053 | ); |
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 922e4caa8..e9af80b6c 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -68,7 +68,7 @@ pub use crate::{ | |||
68 | expand_macro::ExpandedMacro, | 68 | expand_macro::ExpandedMacro, |
69 | folding_ranges::{Fold, FoldKind}, | 69 | folding_ranges::{Fold, FoldKind}, |
70 | hover::HoverResult, | 70 | hover::HoverResult, |
71 | inlay_hints::{InlayConfig, InlayHint, InlayKind}, | 71 | inlay_hints::{InlayHint, InlayHintsOptions, InlayKind}, |
72 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, | 72 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, |
73 | runnables::{Runnable, RunnableKind, TestId}, | 73 | runnables::{Runnable, RunnableKind, TestId}, |
74 | source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, | 74 | source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, |
@@ -319,7 +319,7 @@ impl Analysis { | |||
319 | pub fn inlay_hints( | 319 | pub fn inlay_hints( |
320 | &self, | 320 | &self, |
321 | file_id: FileId, | 321 | file_id: FileId, |
322 | inlay_hint_opts: &InlayConfig, | 322 | inlay_hint_opts: &InlayHintsOptions, |
323 | ) -> Cancelable<Vec<InlayHint>> { | 323 | ) -> Cancelable<Vec<InlayHint>> { |
324 | self.with_db(|db| inlay_hints::inlay_hints(db, file_id, inlay_hint_opts)) | 324 | self.with_db(|db| inlay_hints::inlay_hints(db, file_id, inlay_hint_opts)) |
325 | } | 325 | } |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index bd5904db0..a6f832ed7 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -8,7 +8,7 @@ | |||
8 | //! tweak things like automatic insertion of `()` in completions. | 8 | //! tweak things like automatic insertion of `()` in completions. |
9 | 9 | ||
10 | use crate::req::InlayConfigDef; | 10 | use crate::req::InlayConfigDef; |
11 | use ra_ide::InlayConfig; | 11 | use ra_ide::InlayHintsOptions; |
12 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::FxHashMap; |
13 | 13 | ||
14 | use ra_project_model::CargoFeatures; | 14 | use ra_project_model::CargoFeatures; |
@@ -33,7 +33,7 @@ pub struct ServerConfig { | |||
33 | pub lru_capacity: Option<usize>, | 33 | pub lru_capacity: Option<usize>, |
34 | 34 | ||
35 | #[serde(with = "InlayConfigDef")] | 35 | #[serde(with = "InlayConfigDef")] |
36 | pub inlay_hints: InlayConfig, | 36 | pub inlay_hints: InlayHintsOptions, |
37 | 37 | ||
38 | pub cargo_watch_enable: bool, | 38 | pub cargo_watch_enable: bool, |
39 | pub cargo_watch_args: Vec<String>, | 39 | pub cargo_watch_args: Vec<String>, |
diff --git a/crates/rust-analyzer/src/req.rs b/crates/rust-analyzer/src/req.rs index 1dcab2703..fa7a42099 100644 --- a/crates/rust-analyzer/src/req.rs +++ b/crates/rust-analyzer/src/req.rs | |||
@@ -4,7 +4,7 @@ use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url}; | |||
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
6 | 6 | ||
7 | use ra_ide::{InlayConfig, InlayKind}; | 7 | use ra_ide::{InlayHintsOptions, InlayKind}; |
8 | 8 | ||
9 | pub use lsp_types::{ | 9 | pub use lsp_types::{ |
10 | notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, | 10 | notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, |
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index d358f6b47..058ce2af8 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -13,7 +13,7 @@ use lsp_types::Url; | |||
13 | use parking_lot::RwLock; | 13 | use parking_lot::RwLock; |
14 | use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWatcher}; | 14 | use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWatcher}; |
15 | use ra_ide::{ | 15 | use ra_ide::{ |
16 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayConfig, LibraryData, | 16 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsOptions, LibraryData, |
17 | SourceRootId, | 17 | SourceRootId, |
18 | }; | 18 | }; |
19 | use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace}; | 19 | use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace}; |
@@ -35,7 +35,7 @@ pub struct Options { | |||
35 | pub publish_decorations: bool, | 35 | pub publish_decorations: bool, |
36 | pub supports_location_link: bool, | 36 | pub supports_location_link: bool, |
37 | pub line_folding_only: bool, | 37 | pub line_folding_only: bool, |
38 | pub inlay_hints: InlayConfig, | 38 | pub inlay_hints: InlayHintsOptions, |
39 | pub rustfmt_args: Vec<String>, | 39 | pub rustfmt_args: Vec<String>, |
40 | pub cargo_watch: CheckOptions, | 40 | pub cargo_watch: CheckOptions, |
41 | } | 41 | } |