Syntactic highlighting of NAME_REF for injections

This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.
This commit is contained in:
Leander Tentrup
2020-06-14 14:43:43 +02:00
parent f4f51171ca
commit c4b3db0c2f
12 changed files with 102 additions and 16 deletions

View File

@@ -137,7 +137,7 @@ pub(super) fn highlight_doc_comment(
let (analysis, tmp_file_id) = Analysis::from_single_file(text);
stack.push();
for mut h in analysis.highlight(tmp_file_id).unwrap() {
for mut h in analysis.with_db(|db| super::highlight(db, tmp_file_id, None, true)).unwrap() {
// Determine start offset and end offset in case of multi-line ranges
let mut start_offset = None;
let mut end_offset = None;