Allow semantic tokens for strings to be disabled

This commit is contained in:
John Renner
2021-05-10 13:09:38 -07:00
parent ba86203987
commit c3ba1f14fa
4 changed files with 58 additions and 9 deletions

View File

@@ -1376,7 +1376,8 @@ 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());
@@ -1395,8 +1396,8 @@ 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();
@@ -1425,7 +1426,8 @@ 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()))
}