aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-12 17:11:25 +0000
committerGitHub <[email protected]>2020-03-12 17:11:25 +0000
commitfab40db8bdfdac5cde5789f74d1ec28e60a8bb7e (patch)
tree5ec90c43aa979d20a21aabd54c801d4bc39b69fd /crates/ra_ide/src
parentd98a5fab46c5850a484349c50dda7cb823cc179a (diff)
parentddfac09363fa778e3830cdb7a9ce6de3d779072e (diff)
Merge #3566
3566: Fix docs r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/completion.rs4
-rw-r--r--crates/ra_ide/src/inlay_hints.rs52
-rw-r--r--crates/ra_ide/src/lib.rs4
3 files changed, 30 insertions, 30 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 {
75pub(crate) fn completions( 75pub(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::{
11use crate::{FileId, FunctionSignature}; 11use crate::{FileId, FunctionSignature};
12 12
13#[derive(Clone, Debug, PartialEq, Eq)] 13#[derive(Clone, Debug, PartialEq, Eq)]
14pub struct InlayConfig { 14pub 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
20impl Default for InlayConfig { 20impl 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 {
39pub(crate) fn inlay_hints( 39pub(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(
62fn get_param_name_hints( 62fn 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(
102fn get_bind_pat_hints( 102fn 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)]
226mod tests { 226mod 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 }