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/to_proto.rs | |
parent | ba8620398713d6f116dd1cce1a7e1cd6e3f97461 (diff) |
Allow semantic tokens for strings to be disabled
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index ecf6fd12f..01ffe8db1 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -381,6 +381,7 @@ pub(crate) fn semantic_tokens( | |||
381 | text: &str, | 381 | text: &str, |
382 | line_index: &LineIndex, | 382 | line_index: &LineIndex, |
383 | highlights: Vec<HlRange>, | 383 | highlights: Vec<HlRange>, |
384 | include_strings: bool | ||
384 | ) -> lsp_types::SemanticTokens { | 385 | ) -> lsp_types::SemanticTokens { |
385 | let id = TOKEN_RESULT_COUNTER.fetch_add(1, Ordering::SeqCst).to_string(); | 386 | let id = TOKEN_RESULT_COUNTER.fetch_add(1, Ordering::SeqCst).to_string(); |
386 | let mut builder = semantic_tokens::SemanticTokensBuilder::new(id); | 387 | let mut builder = semantic_tokens::SemanticTokensBuilder::new(id); |
@@ -389,8 +390,11 @@ pub(crate) fn semantic_tokens( | |||
389 | if highlight_range.highlight.is_empty() { | 390 | if highlight_range.highlight.is_empty() { |
390 | continue; | 391 | continue; |
391 | } | 392 | } |
392 | let (type_, mods) = semantic_token_type_and_modifiers(highlight_range.highlight); | 393 | let (typ, mods) = semantic_token_type_and_modifiers(highlight_range.highlight); |
393 | let token_index = semantic_tokens::type_index(type_); | 394 | if !include_strings && typ == lsp_types::SemanticTokenType::STRING { |
395 | continue; | ||
396 | } | ||
397 | let token_index = semantic_tokens::type_index(typ); | ||
394 | let modifier_bitset = mods.0; | 398 | let modifier_bitset = mods.0; |
395 | 399 | ||
396 | for mut text_range in line_index.index.lines(highlight_range.range) { | 400 | for mut text_range in line_index.index.lines(highlight_range.range) { |