aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src/lib.rs
diff options
context:
space:
mode:
authorSteffen Lyngbaek <[email protected]>2020-03-10 07:55:46 +0000
committerSteffen Lyngbaek <[email protected]>2020-03-10 21:33:45 +0000
commite98aff109a1c4bda6a05f16981898425c302aa0c (patch)
treebad52598c5638a81af9066592913bdfcdcb639fa /crates/ra_project_model/src/lib.rs
parent0714a065d578e8b22b0451bfc64378c875fe858f (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/src/lib.rs')
-rw-r--r--crates/ra_project_model/src/lib.rs29
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};
16use ra_cfg::CfgOptions; 16use ra_cfg::CfgOptions;
17use ra_db::{CrateGraph, CrateName, Edition, Env, FileId}; 17use ra_db::{CrateGraph, CrateName, Edition, Env, FileId};
18use rustc_hash::FxHashMap; 18use rustc_hash::FxHashMap;
19use serde::Deserialize;
19use serde_json::from_reader; 20use serde_json::from_reader;
20 21
21pub use crate::{ 22pub 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")]
30pub 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)]
39pub struct InlayHintOptions {
40 pub display_type: InlayHintDisplayType,
41 pub max_length: Option<usize>,
42}
43
44impl InlayHintOptions {
45 pub fn new(max_length: Option<usize>) -> Self {
46 Self { display_type: InlayHintDisplayType::Full, max_length }
47 }
48}
49
50impl 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)]
28pub struct CargoTomlNotFoundError { 57pub struct CargoTomlNotFoundError {
29 pub searched_at: PathBuf, 58 pub searched_at: PathBuf,