diff options
author | Steffen Lyngbaek <[email protected]> | 2020-03-10 07:55:46 +0000 |
---|---|---|
committer | Steffen Lyngbaek <[email protected]> | 2020-03-10 21:33:45 +0000 |
commit | e98aff109a1c4bda6a05f16981898425c302aa0c (patch) | |
tree | bad52598c5638a81af9066592913bdfcdcb639fa /crates/ra_project_model | |
parent | 0714a065d578e8b22b0451bfc64378c875fe858f (diff) |
Parameter inlay hint separate from variable type inlay? #2876
Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.
- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 37845ca56..a5012c0ef 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -16,6 +16,7 @@ use anyhow::{bail, Context, Result}; | |||
16 | use ra_cfg::CfgOptions; | 16 | use ra_cfg::CfgOptions; |
17 | use ra_db::{CrateGraph, CrateName, Edition, Env, FileId}; | 17 | use ra_db::{CrateGraph, CrateName, Edition, Env, FileId}; |
18 | use rustc_hash::FxHashMap; | 18 | use rustc_hash::FxHashMap; |
19 | use serde::Deserialize; | ||
19 | use serde_json::from_reader; | 20 | use serde_json::from_reader; |
20 | 21 | ||
21 | pub use crate::{ | 22 | pub use crate::{ |
@@ -24,6 +25,34 @@ pub use crate::{ | |||
24 | sysroot::Sysroot, | 25 | sysroot::Sysroot, |
25 | }; | 26 | }; |
26 | 27 | ||
28 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] | ||
29 | #[serde(rename_all = "lowercase")] | ||
30 | pub enum InlayHintDisplayType { | ||
31 | Off, | ||
32 | TypeHints, | ||
33 | ParameterHints, | ||
34 | Full, | ||
35 | } | ||
36 | |||
37 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] | ||
38 | #[serde(rename_all = "camelCase", default)] | ||
39 | pub struct InlayHintOptions { | ||
40 | pub display_type: InlayHintDisplayType, | ||
41 | pub max_length: Option<usize>, | ||
42 | } | ||
43 | |||
44 | impl InlayHintOptions { | ||
45 | pub fn new(max_length: Option<usize>) -> Self { | ||
46 | Self { display_type: InlayHintDisplayType::Full, max_length } | ||
47 | } | ||
48 | } | ||
49 | |||
50 | impl Default for InlayHintOptions { | ||
51 | fn default() -> Self { | ||
52 | Self { display_type: InlayHintDisplayType::Full, max_length: None } | ||
53 | } | ||
54 | } | ||
55 | |||
27 | #[derive(Clone, PartialEq, Eq, Hash, Debug)] | 56 | #[derive(Clone, PartialEq, Eq, Hash, Debug)] |
28 | pub struct CargoTomlNotFoundError { | 57 | pub struct CargoTomlNotFoundError { |
29 | pub searched_at: PathBuf, | 58 | pub searched_at: PathBuf, |