From e98aff109a1c4bda6a05f16981898425c302aa0c Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Tue, 10 Mar 2020 00:55:46 -0700 Subject: 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 --- crates/ra_project_model/src/lib.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/ra_project_model/src') 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}; use ra_cfg::CfgOptions; use ra_db::{CrateGraph, CrateName, Edition, Env, FileId}; use rustc_hash::FxHashMap; +use serde::Deserialize; use serde_json::from_reader; pub use crate::{ @@ -24,6 +25,34 @@ pub use crate::{ sysroot::Sysroot, }; +#[derive(Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "lowercase")] +pub enum InlayHintDisplayType { + Off, + TypeHints, + ParameterHints, + Full, +} + +#[derive(Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "camelCase", default)] +pub struct InlayHintOptions { + pub display_type: InlayHintDisplayType, + pub max_length: Option, +} + +impl InlayHintOptions { + pub fn new(max_length: Option) -> Self { + Self { display_type: InlayHintDisplayType::Full, max_length } + } +} + +impl Default for InlayHintOptions { + fn default() -> Self { + Self { display_type: InlayHintDisplayType::Full, max_length: None } + } +} + #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct CargoTomlNotFoundError { pub searched_at: PathBuf, -- cgit v1.2.3