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

@@ -440,12 +440,14 @@ impl Analysis {
/// Computes syntax highlighting for the given file
pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
self.with_db(|db| syntax_highlighting::highlight(db, file_id, None))
self.with_db(|db| syntax_highlighting::highlight(db, file_id, None, false))
}
/// Computes syntax highlighting for the given file range.
pub fn highlight_range(&self, frange: FileRange) -> Cancelable<Vec<HighlightedRange>> {
self.with_db(|db| syntax_highlighting::highlight(db, frange.file_id, Some(frange.range)))
self.with_db(|db| {
syntax_highlighting::highlight(db, frange.file_id, Some(frange.range), false)
})
}
/// Computes syntax highlighting for the given file.