Skip to content

Commit 17ffdf9

Browse files
committed
Add docs
1 parent 9f0cfb7 commit 17ffdf9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/rust-analyzer/src/semantic_tokens.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Semantic Tokens helpers
2+
13
use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType};
24

35
const SUPPORTED_TYPES: &[SemanticTokenType] = &[
@@ -36,14 +38,19 @@ const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
3638
SemanticTokenModifier::READONLY,
3739
];
3840

41+
/// Token types that the server supports
3942
pub(crate) fn supported_token_types() -> &'static [SemanticTokenType] {
4043
SUPPORTED_TYPES
4144
}
4245

46+
/// Token modifiers that the server supports
4347
pub(crate) fn supported_token_modifiers() -> &'static [SemanticTokenModifier] {
4448
SUPPORTED_MODIFIERS
4549
}
4650

51+
/// Tokens are encoded relative to each other.
52+
///
53+
/// This is a direct port of https://github.com/microsoft/vscode-languageserver-node/blob/f425af9de46a0187adb78ec8a46b9b2ce80c5412/server/src/sematicTokens.proposed.ts#L45
4754
#[derive(Default)]
4855
pub(crate) struct SemanticTokensBuilder {
4956
prev_line: u32,
@@ -52,6 +59,7 @@ pub(crate) struct SemanticTokensBuilder {
5259
}
5360

5461
impl SemanticTokensBuilder {
62+
/// Push a new token onto the builder
5563
pub fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
5664
let mut push_line = range.start.line as u32;
5765
let mut push_char = range.start.character as u32;

0 commit comments

Comments
 (0)