diff options
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( |