From d4c317320d58fa5d31eab6f3533c14ad2c12d78d Mon Sep 17 00:00:00 2001 From: kjeremy Date: Mon, 30 Mar 2020 12:07:27 -0400 Subject: Simplify SemanticTokensBuilder build method This matches the next stable vscode api --- crates/rust-analyzer/src/main_loop/handlers.rs | 6 +++--- crates/rust-analyzer/src/semantic_tokens.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/rust-analyzer') diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 12f8ca297..f60a3f0a0 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -14,7 +14,7 @@ use lsp_types::{ 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())) } diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index d9ba77050..2a66bbfd8 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -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 @@ impl SemanticTokensBuilder { self.prev_char = range.start.character as u32; } - pub fn build(self) -> Vec { - self.data + pub fn build(self) -> SemanticTokens { + SemanticTokens { result_id: None, data: self.data } } } -- cgit v1.2.3