diff options
author | Kirill Bulatov <[email protected]> | 2019-12-07 22:54:18 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2019-12-19 10:27:33 +0000 |
commit | 14c167a9f6da07024a5101ffa04bc2f79ce64353 (patch) | |
tree | a5fc10aaa8ed0cad0c08a9ff478acb23795aa322 /crates/ra_hir_ty/src/display.rs | |
parent | 8dd0e0086fc07422c9b1044b1db021cff6563214 (diff) |
Omit default parameter types
Diffstat (limited to 'crates/ra_hir_ty/src/display.rs')
-rw-r--r-- | crates/ra_hir_ty/src/display.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 9bb3ece6c..9176c0629 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs | |||
@@ -9,7 +9,7 @@ pub struct HirFormatter<'a, 'b, DB> { | |||
9 | fmt: &'a mut fmt::Formatter<'b>, | 9 | fmt: &'a mut fmt::Formatter<'b>, |
10 | buf: String, | 10 | buf: String, |
11 | curr_size: usize, | 11 | curr_size: usize, |
12 | max_size: Option<usize>, | 12 | truncate_options: Option<&'a TruncateOptions>, |
13 | } | 13 | } |
14 | 14 | ||
15 | pub trait HirDisplay { | 15 | pub trait HirDisplay { |
@@ -25,12 +25,12 @@ pub trait HirDisplay { | |||
25 | fn display_truncated<'a, DB>( | 25 | fn display_truncated<'a, DB>( |
26 | &'a self, | 26 | &'a self, |
27 | db: &'a DB, | 27 | db: &'a DB, |
28 | max_size: Option<usize>, | 28 | truncate_options: &'a TruncateOptions, |
29 | ) -> HirDisplayWrapper<'a, DB, Self> | 29 | ) -> HirDisplayWrapper<'a, DB, Self> |
30 | where | 30 | where |
31 | Self: Sized, | 31 | Self: Sized, |
32 | { | 32 | { |
33 | HirDisplayWrapper(db, self, max_size) | 33 | HirDisplayWrapper(db, self, Some(truncate_options)) |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
@@ -66,15 +66,24 @@ where | |||
66 | } | 66 | } |
67 | 67 | ||
68 | pub fn should_truncate(&self) -> bool { | 68 | pub fn should_truncate(&self) -> bool { |
69 | if let Some(max_size) = self.max_size { | 69 | if let Some(max_size) = self.truncate_options.and_then(|options| options.max_length) { |
70 | self.curr_size >= max_size | 70 | self.curr_size >= max_size |
71 | } else { | 71 | } else { |
72 | false | 72 | false |
73 | } | 73 | } |
74 | } | 74 | } |
75 | |||
76 | pub fn should_display_default_types(&self) -> bool { | ||
77 | self.truncate_options.map(|options| options.show_default_types).unwrap_or(true) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | pub struct TruncateOptions { | ||
82 | pub max_length: Option<usize>, | ||
83 | pub show_default_types: bool, | ||
75 | } | 84 | } |
76 | 85 | ||
77 | pub struct HirDisplayWrapper<'a, DB, T>(&'a DB, &'a T, Option<usize>); | 86 | pub struct HirDisplayWrapper<'a, DB, T>(&'a DB, &'a T, Option<&'a TruncateOptions>); |
78 | 87 | ||
79 | impl<'a, DB, T> fmt::Display for HirDisplayWrapper<'a, DB, T> | 88 | impl<'a, DB, T> fmt::Display for HirDisplayWrapper<'a, DB, T> |
80 | where | 89 | where |
@@ -87,7 +96,7 @@ where | |||
87 | fmt: f, | 96 | fmt: f, |
88 | buf: String::with_capacity(20), | 97 | buf: String::with_capacity(20), |
89 | curr_size: 0, | 98 | curr_size: 0, |
90 | max_size: self.2, | 99 | truncate_options: self.2, |
91 | }) | 100 | }) |
92 | } | 101 | } |
93 | } | 102 | } |