diff options
author | Aleksey Kladov <[email protected]> | 2018-08-10 22:55:32 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-10 22:55:32 +0100 |
commit | 9863b9161d8d702848516be70c5c8161b7f382e8 (patch) | |
tree | 3aa95abbacf0897e4e738e1fc8ccf10492b7c60c /crates/server/src/handlers.rs | |
parent | 836e0c1863eaea5dffdf76a658c2ee9d7bc22e6f (diff) |
decorations
Diffstat (limited to 'crates/server/src/handlers.rs')
-rw-r--r-- | crates/server/src/handlers.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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; | |||
4 | use libeditor::{self, LineIndex, LineCol, TextRange, TextUnit}; | 4 | use libeditor::{self, LineIndex, LineCol, TextRange, TextUnit}; |
5 | 5 | ||
6 | use ::{ | 6 | use ::{ |
7 | req, Result, | 7 | req::{self, Decoration}, Result, |
8 | util::FilePath, | 8 | util::FilePath, |
9 | }; | 9 | }; |
10 | 10 | ||
@@ -51,6 +51,18 @@ pub fn publish_diagnostics(world: World, uri: Url) -> Result<req::PublishDiagnos | |||
51 | Ok(req::PublishDiagnosticsParams { uri, diagnostics }) | 51 | Ok(req::PublishDiagnosticsParams { uri, diagnostics }) |
52 | } | 52 | } |
53 | 53 | ||
54 | pub fn publish_decorations(world: World, uri: Url) -> Result<req::PublishDecorationsParams> { | ||
55 | let path = uri.file_path()?; | ||
56 | let file = world.file_syntax(&path)?; | ||
57 | let line_index = world.file_line_index(&path)?; | ||
58 | let decorations = libeditor::highlight(&file) | ||
59 | .into_iter() | ||
60 | .map(|h| Decoration { | ||
61 | range: to_vs_range(&line_index, h.range), | ||
62 | tag: h.tag, | ||
63 | }).collect(); | ||
64 | Ok(req::PublishDecorationsParams { uri, decorations }) | ||
65 | } | ||
54 | 66 | ||
55 | fn to_text_range(line_index: &LineIndex, range: Range) -> TextRange { | 67 | fn to_text_range(line_index: &LineIndex, range: Range) -> TextRange { |
56 | TextRange::from_to( | 68 | TextRange::from_to( |