mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Auto merge of #13134 - Veykril:proc-highlight, r=Veykril
Highlight namerefs by syntax until proc-macros have been loaded Usually when loading up a project, once loading is done we start answering highlight requests while proc-macros haven't always been loaded yet, so we start out with showing a lot of unresolved name-refs. After this PR, we'll use syntax based highlighting for those unresolved namerefs until the proc-macros have been loaded.
This commit is contained in:
commit
643c3a54de
@ -116,6 +116,7 @@ pub(crate) struct GlobalStateSnapshot {
|
|||||||
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
||||||
vfs: Arc<RwLock<(vfs::Vfs, NoHashHashMap<FileId, LineEndings>)>>,
|
vfs: Arc<RwLock<(vfs::Vfs, NoHashHashMap<FileId, LineEndings>)>>,
|
||||||
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||||
|
pub(crate) proc_macros_loaded: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::panic::UnwindSafe for GlobalStateSnapshot {}
|
impl std::panic::UnwindSafe for GlobalStateSnapshot {}
|
||||||
@ -256,6 +257,7 @@ impl GlobalState {
|
|||||||
check_fixes: Arc::clone(&self.diagnostics.check_fixes),
|
check_fixes: Arc::clone(&self.diagnostics.check_fixes),
|
||||||
mem_docs: self.mem_docs.clone(),
|
mem_docs: self.mem_docs.clone(),
|
||||||
semantic_tokens_cache: Arc::clone(&self.semantic_tokens_cache),
|
semantic_tokens_cache: Arc::clone(&self.semantic_tokens_cache),
|
||||||
|
proc_macros_loaded: !self.fetch_build_data_queue.last_op_result().0.is_empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1504,7 +1504,11 @@ pub(crate) fn handle_semantic_tokens_full(
|
|||||||
let text = snap.analysis.file_text(file_id)?;
|
let text = snap.analysis.file_text(file_id)?;
|
||||||
let line_index = snap.file_line_index(file_id)?;
|
let line_index = snap.file_line_index(file_id)?;
|
||||||
|
|
||||||
let highlights = snap.analysis.highlight(snap.config.highlighting_config(), file_id)?;
|
let mut highlight_config = snap.config.highlighting_config();
|
||||||
|
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
||||||
|
highlight_config.syntactic_name_ref_highlighting = !snap.proc_macros_loaded;
|
||||||
|
|
||||||
|
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
||||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||||
|
|
||||||
// Unconditionally cache the tokens
|
// Unconditionally cache the tokens
|
||||||
@ -1523,7 +1527,11 @@ pub(crate) fn handle_semantic_tokens_full_delta(
|
|||||||
let text = snap.analysis.file_text(file_id)?;
|
let text = snap.analysis.file_text(file_id)?;
|
||||||
let line_index = snap.file_line_index(file_id)?;
|
let line_index = snap.file_line_index(file_id)?;
|
||||||
|
|
||||||
let highlights = snap.analysis.highlight(snap.config.highlighting_config(), file_id)?;
|
let mut highlight_config = snap.config.highlighting_config();
|
||||||
|
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
||||||
|
highlight_config.syntactic_name_ref_highlighting = !snap.proc_macros_loaded;
|
||||||
|
|
||||||
|
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
||||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||||
|
|
||||||
let mut cache = snap.semantic_tokens_cache.lock();
|
let mut cache = snap.semantic_tokens_cache.lock();
|
||||||
|
@ -347,8 +347,8 @@ impl GlobalState {
|
|||||||
error
|
error
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect()
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let watch = match files_config.watcher {
|
let watch = match files_config.watcher {
|
||||||
|
Loading…
Reference in New Issue
Block a user