Skip to content

Commit f414d9e

Browse files
committed
Support full semantic tokens request
1 parent 48581bb commit f414d9e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/server.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use log::{error, info};
1313
use lsp_server::{Connection, ErrorCode, Message, RequestId};
1414
use lsp_types::{notification::*, request::*, *};
1515
use once_cell::sync::Lazy;
16-
use rowan::{ast::AstNode, TextSize};
16+
use rowan::{ast::AstNode, TextLen, TextRange, TextSize};
1717
use rustc_hash::FxHashSet;
1818
use serde::{Deserialize, Serialize};
1919
use serde_repr::{Deserialize_repr, Serialize_repr};
@@ -184,7 +184,7 @@ impl Server {
184184
work_done_progress_options: Default::default(),
185185
legend: semantic_tokens::legend(),
186186
range: Some(true),
187-
full: Some(SemanticTokensFullOptions::Bool(false)),
187+
full: Some(SemanticTokensFullOptions::Bool(true)),
188188
}),
189189
),
190190
..ServerCapabilities::default()
@@ -814,6 +814,16 @@ impl Server {
814814
Ok(())
815815
}
816816

817+
fn semantic_tokens_full(&mut self, id: RequestId, params: SemanticTokensParams) -> Result<()> {
818+
self.run_with_db(id, move |db| {
819+
let Some(document) = Workspace::get(db).lookup_uri(db, &params.text_document.uri) else { return None };
820+
let range = document.line_index(db).line_col_lsp_range(TextRange::new(0.into(), document.text(db).text_len()));
821+
semantic_tokens::find_all(db, &params.text_document.uri, range)
822+
});
823+
824+
Ok(())
825+
}
826+
817827
fn semantic_tokens_range(
818828
&mut self,
819829
id: RequestId,
@@ -917,6 +927,9 @@ impl Server {
917927
.on::<SemanticTokensRangeRequest, _>(|id, params| {
918928
self.semantic_tokens_range(id, params)
919929
})?
930+
.on::<SemanticTokensFullRequest, _>(|id, params| {
931+
self.semantic_tokens_full(id, params)
932+
})?
920933
.on::<InlayHintRequest, _>(|id,params| {
921934
self.inlay_hints(id, params)
922935
})?

0 commit comments

Comments
 (0)