]> git.lizzy.rs Git - rust.git/commitdiff
Simplify SemanticTokensBuilder build method
authorkjeremy <kjeremy@gmail.com>
Mon, 30 Mar 2020 16:07:27 +0000 (12:07 -0400)
committerkjeremy <kjeremy@gmail.com>
Mon, 30 Mar 2020 16:07:27 +0000 (12:07 -0400)
This matches the next stable vscode api

crates/rust-analyzer/src/main_loop/handlers.rs
crates/rust-analyzer/src/semantic_tokens.rs

index 12f8ca2976d82eec0a43480ce24da87f745debef..f60a3f0a0bde96c80d8f2087e27b75f4321f7d9f 100644 (file)
@@ -14,7 +14,7 @@
     CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
     DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams,
     Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse,
-    Range, RenameParams, SemanticTokens, SemanticTokensParams, SemanticTokensRangeParams,
+    Range, RenameParams, SemanticTokensParams, SemanticTokensRangeParams,
     SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, TextDocumentIdentifier,
     TextEdit, WorkspaceEdit,
 };
@@ -1145,7 +1145,7 @@ pub fn handle_semantic_tokens(
         }
     }
 
-    let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
+    let tokens = builder.build();
 
     Ok(Some(tokens.into()))
 }
@@ -1166,7 +1166,7 @@ pub fn handle_semantic_tokens_range(
         builder.push(highlight_range.range.conv_with(&line_index), token_type, token_modifiers);
     }
 
-    let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
+    let tokens = builder.build();
 
     Ok(Some(tokens.into()))
 }
index d9ba770509e06d0d5a2a9f894b4d68ff18348f03..2a66bbfd85e5183209c9ac23f88d1db34a08a36e 100644 (file)
@@ -2,7 +2,7 @@
 
 use std::ops;
 
-use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType};
+use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens};
 
 pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute");
 pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType");
@@ -109,8 +109,8 @@ pub fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
         self.prev_char = range.start.character as u32;
     }
 
-    pub fn build(self) -> Vec<SemanticToken> {
-        self.data
+    pub fn build(self) -> SemanticTokens {
+        SemanticTokens { result_id: None, data: self.data }
     }
 }