From 5bf3e949e8470a138a61c806769e1a329761cab6 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Thu, 23 May 2019 19:42:42 +0200 Subject: Semantic highlighting spike Very simple approach: For each identifier, set the hash of the range where it's defined as its 'id' and use it in the VSCode extension to generate unique colors. Thus, the generated colors are per-file. They are also quite fragile, and I'm not entirely sure why. Looks like we need to make sure the same ranges aren't overwritten by a later request? --- crates/ra_lsp_server/src/main_loop/handlers.rs | 6 +++++- crates/ra_lsp_server/src/req.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index a82ae696b..5dfd64ed4 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -872,7 +872,11 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { .analysis() .highlight(file_id)? .into_iter() - .map(|h| Decoration { range: h.range.conv_with(&line_index), tag: h.tag }) + .map(|h| Decoration { + range: h.range.conv_with(&line_index), + tag: h.tag, + id: h.id.map(|x| x.to_string()), + }) .collect(); Ok(res) } diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 6090eb7b9..cea0e6ce7 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -129,6 +129,7 @@ pub struct PublishDecorationsParams { pub struct Decoration { pub range: Range, pub tag: &'static str, + pub id: Option, } pub enum ParentModule {} -- cgit v1.2.3