Skip to content

Commit d4c3173

Browse files
committed
Simplify SemanticTokensBuilder build method
This matches the next stable vscode api
1 parent 671926a commit d4c3173

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use lsp_types::{
1414
CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
1515
DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams,
1616
Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse,
17-
Range, RenameParams, SemanticTokens, SemanticTokensParams, SemanticTokensRangeParams,
17+
Range, RenameParams, SemanticTokensParams, SemanticTokensRangeParams,
1818
SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, TextDocumentIdentifier,
1919
TextEdit, WorkspaceEdit,
2020
};
@@ -1145,7 +1145,7 @@ pub fn handle_semantic_tokens(
11451145
}
11461146
}
11471147

1148-
let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
1148+
let tokens = builder.build();
11491149

11501150
Ok(Some(tokens.into()))
11511151
}
@@ -1166,7 +1166,7 @@ pub fn handle_semantic_tokens_range(
11661166
builder.push(highlight_range.range.conv_with(&line_index), token_type, token_modifiers);
11671167
}
11681168

1169-
let tokens = SemanticTokens { data: builder.build(), ..Default::default() };
1169+
let tokens = builder.build();
11701170

11711171
Ok(Some(tokens.into()))
11721172
}

crates/rust-analyzer/src/semantic_tokens.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::ops;
44

5-
use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType};
5+
use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens};
66

77
pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute");
88
pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType");
@@ -109,8 +109,8 @@ impl SemanticTokensBuilder {
109109
self.prev_char = range.start.character as u32;
110110
}
111111

112-
pub fn build(self) -> Vec<SemanticToken> {
113-
self.data
112+
pub fn build(self) -> SemanticTokens {
113+
SemanticTokens { result_id: None, data: self.data }
114114
}
115115
}
116116

0 commit comments

Comments
 (0)