diff options
author | John Renner <[email protected]> | 2021-05-10 21:09:38 +0100 |
---|---|---|
committer | John Renner <[email protected]> | 2021-05-10 21:09:38 +0100 |
commit | c3ba1f14faaf132de7c216123878a681d7f3ca61 (patch) | |
tree | e9364d8209ec7ef0f7ca7440fb391576227c9388 /crates/rust-analyzer/src/handlers.rs | |
parent | ba8620398713d6f116dd1cce1a7e1cd6e3f97461 (diff) |
Allow semantic tokens for strings to be disabled
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index f6e40f872..85dd73fca 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -1376,7 +1376,8 @@ pub(crate) fn handle_semantic_tokens_full( | |||
1376 | let line_index = snap.file_line_index(file_id)?; | 1376 | let line_index = snap.file_line_index(file_id)?; |
1377 | 1377 | ||
1378 | let highlights = snap.analysis.highlight(file_id)?; | 1378 | let highlights = snap.analysis.highlight(file_id)?; |
1379 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights); | 1379 | let semantic_strings = snap.config.semantic_strings(); |
1380 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings); | ||
1380 | 1381 | ||
1381 | // Unconditionally cache the tokens | 1382 | // Unconditionally cache the tokens |
1382 | snap.semantic_tokens_cache.lock().insert(params.text_document.uri, semantic_tokens.clone()); | 1383 | snap.semantic_tokens_cache.lock().insert(params.text_document.uri, semantic_tokens.clone()); |
@@ -1395,8 +1396,8 @@ pub(crate) fn handle_semantic_tokens_full_delta( | |||
1395 | let line_index = snap.file_line_index(file_id)?; | 1396 | let line_index = snap.file_line_index(file_id)?; |
1396 | 1397 | ||
1397 | let highlights = snap.analysis.highlight(file_id)?; | 1398 | let highlights = snap.analysis.highlight(file_id)?; |
1398 | 1399 | let semantic_strings = snap.config.semantic_strings(); | |
1399 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights); | 1400 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings); |
1400 | 1401 | ||
1401 | let mut cache = snap.semantic_tokens_cache.lock(); | 1402 | let mut cache = snap.semantic_tokens_cache.lock(); |
1402 | let cached_tokens = cache.entry(params.text_document.uri).or_default(); | 1403 | let cached_tokens = cache.entry(params.text_document.uri).or_default(); |
@@ -1425,7 +1426,8 @@ pub(crate) fn handle_semantic_tokens_range( | |||
1425 | let line_index = snap.file_line_index(frange.file_id)?; | 1426 | let line_index = snap.file_line_index(frange.file_id)?; |
1426 | 1427 | ||
1427 | let highlights = snap.analysis.highlight_range(frange)?; | 1428 | let highlights = snap.analysis.highlight_range(frange)?; |
1428 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights); | 1429 | let semantic_strings = snap.config.semantic_strings(); |
1430 | let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings); | ||
1429 | Ok(Some(semantic_tokens.into())) | 1431 | Ok(Some(semantic_tokens.into())) |
1430 | } | 1432 | } |
1431 | 1433 | ||