Merge #8795
8795: Allow semantic tokens for strings to be disabled r=matklad a=djrenren Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7111 Pretty straightforward change, but open to any suggestions if there's a more recommended testing strategy than what I went with. Co-authored-by: John Renner <john@jrenner.net>
This commit is contained in:
@@ -1394,7 +1394,9 @@ pub(crate) fn handle_semantic_tokens_full(
|
||||
let line_index = snap.file_line_index(file_id)?;
|
||||
|
||||
let highlights = snap.analysis.highlight(file_id)?;
|
||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||
let semantic_strings = snap.config.semantic_strings();
|
||||
let semantic_tokens =
|
||||
to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings);
|
||||
|
||||
// Unconditionally cache the tokens
|
||||
snap.semantic_tokens_cache.lock().insert(params.text_document.uri, semantic_tokens.clone());
|
||||
@@ -1413,8 +1415,9 @@ pub(crate) fn handle_semantic_tokens_full_delta(
|
||||
let line_index = snap.file_line_index(file_id)?;
|
||||
|
||||
let highlights = snap.analysis.highlight(file_id)?;
|
||||
|
||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||
let semantic_strings = snap.config.semantic_strings();
|
||||
let semantic_tokens =
|
||||
to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings);
|
||||
|
||||
let mut cache = snap.semantic_tokens_cache.lock();
|
||||
let cached_tokens = cache.entry(params.text_document.uri).or_default();
|
||||
@@ -1443,7 +1446,9 @@ pub(crate) fn handle_semantic_tokens_range(
|
||||
let line_index = snap.file_line_index(frange.file_id)?;
|
||||
|
||||
let highlights = snap.analysis.highlight_range(frange)?;
|
||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||
let semantic_strings = snap.config.semantic_strings();
|
||||
let semantic_tokens =
|
||||
to_proto::semantic_tokens(&text, &line_index, highlights, semantic_strings);
|
||||
Ok(Some(semantic_tokens.into()))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user