diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 29b47608e..4157ce8ea 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -235,8 +235,10 @@ pub(crate) fn semantic_tokens( | |||
235 | let mut builder = semantic_tokens::SemanticTokensBuilder::default(); | 235 | let mut builder = semantic_tokens::SemanticTokensBuilder::default(); |
236 | 236 | ||
237 | for highlight_range in highlights { | 237 | for highlight_range in highlights { |
238 | let (token_index, modifier_bitset) = | 238 | let (type_, mods) = semantic_token_type_and_modifiers(highlight_range.highlight); |
239 | token_type_index_modifiers_bitself(highlight_range.highlight); | 239 | let token_index = semantic_tokens::type_index(type_); |
240 | let modifier_bitset = mods.0; | ||
241 | |||
240 | for mut text_range in line_index.lines(highlight_range.range) { | 242 | for mut text_range in line_index.lines(highlight_range.range) { |
241 | if text[text_range].ends_with('\n') { | 243 | if text[text_range].ends_with('\n') { |
242 | text_range = | 244 | text_range = |
@@ -250,7 +252,9 @@ pub(crate) fn semantic_tokens( | |||
250 | builder.build() | 252 | builder.build() |
251 | } | 253 | } |
252 | 254 | ||
253 | fn token_type_index_modifiers_bitself(highlight: Highlight) -> (u32, u32) { | 255 | fn semantic_token_type_and_modifiers( |
256 | highlight: Highlight, | ||
257 | ) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) { | ||
254 | let mut mods = semantic_tokens::ModifierSet::default(); | 258 | let mut mods = semantic_tokens::ModifierSet::default(); |
255 | let type_ = match highlight.tag { | 259 | let type_ = match highlight.tag { |
256 | HighlightTag::Struct => lsp_types::SemanticTokenType::STRUCT, | 260 | HighlightTag::Struct => lsp_types::SemanticTokenType::STRUCT, |
@@ -300,7 +304,7 @@ fn token_type_index_modifiers_bitself(highlight: Highlight) -> (u32, u32) { | |||
300 | mods |= modifier; | 304 | mods |= modifier; |
301 | } | 305 | } |
302 | 306 | ||
303 | (semantic_tokens::type_index(type_), mods.0) | 307 | (type_, mods) |
304 | } | 308 | } |
305 | 309 | ||
306 | pub(crate) fn folding_range( | 310 | pub(crate) fn folding_range( |