From 9863b9161d8d702848516be70c5c8161b7f382e8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Aug 2018 00:55:32 +0300 Subject: decorations --- crates/server/src/handlers.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/server/src/handlers.rs') diff --git a/crates/server/src/handlers.rs b/crates/server/src/handlers.rs index de1fd557d..8b7e00c92 100644 --- a/crates/server/src/handlers.rs +++ b/crates/server/src/handlers.rs @@ -4,7 +4,7 @@ use libanalysis::World; use libeditor::{self, LineIndex, LineCol, TextRange, TextUnit}; use ::{ - req, Result, + req::{self, Decoration}, Result, util::FilePath, }; @@ -51,6 +51,18 @@ pub fn publish_diagnostics(world: World, uri: Url) -> Result Result { + let path = uri.file_path()?; + let file = world.file_syntax(&path)?; + let line_index = world.file_line_index(&path)?; + let decorations = libeditor::highlight(&file) + .into_iter() + .map(|h| Decoration { + range: to_vs_range(&line_index, h.range), + tag: h.tag, + }).collect(); + Ok(req::PublishDecorationsParams { uri, decorations }) +} fn to_text_range(line_index: &LineIndex, range: Range) -> TextRange { TextRange::from_to( -- cgit v1.2.3