From 8f3377d9f93a256f8e68ae183808fd767b529d18 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 22 Jul 2019 21:52:47 +0300 Subject: Code review fixes --- crates/ra_lsp_server/src/main_loop/handlers.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 68865b755..5bf950a53 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -21,7 +21,7 @@ use url_serde::Ser; use crate::{ cargo_target_spec::{runnable_args, CargoTargetSpec}, conv::{to_location, Conv, ConvWith, MapConvWith, TryConvWith, TryConvWithToVec}, - req::{self, Decoration}, + req::{self, Decoration, InlayHint, InlayHintsParams, InlayKind}, world::WorldSnapshot, LspError, Result, }; @@ -874,3 +874,24 @@ fn to_diagnostic_severity(severity: Severity) -> DiagnosticSeverity { WeakWarning => DiagnosticSeverity::Hint, } } + +pub fn handle_inlay_hints( + world: WorldSnapshot, + params: InlayHintsParams, +) -> Result> { + let file_id = params.text_document.try_conv_with(&world)?; + let analysis = world.analysis(); + let line_index = analysis.file_line_index(file_id); + Ok(analysis + .inlay_hints(file_id)? + .into_iter() + .map(|api_type| InlayHint { + label: api_type.label.to_string(), + range: api_type.range.conv_with(&line_index), + kind: match api_type.kind { + ra_ide_api::InlayKind::LetBindingType => InlayKind::LetBindingType, + ra_ide_api::InlayKind::ClosureParameterType => InlayKind::ClosureParameterType, + }, + }) + .collect()) +} -- cgit v1.2.3