mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Encode edition within FileId in the hir layer
This commit is contained in:
parent
92268627a8
commit
5264f86242
160 changed files with 1117 additions and 824 deletions
|
@ -15,6 +15,7 @@ mod tests;
|
|||
|
||||
use hir::{DescendPreference, Name, Semantics};
|
||||
use ide_db::{FxHashMap, RootDatabase, SymbolKind};
|
||||
use span::EditionedFileId;
|
||||
use syntax::{
|
||||
ast::{self, IsString},
|
||||
AstNode, AstToken, NodeOrToken,
|
||||
|
@ -188,11 +189,14 @@ pub(crate) fn highlight(
|
|||
) -> Vec<HlRange> {
|
||||
let _p = tracing::info_span!("highlight").entered();
|
||||
let sema = Semantics::new(db);
|
||||
let file_id = sema
|
||||
.attach_first_edition(file_id)
|
||||
.unwrap_or_else(|| EditionedFileId::current_edition(file_id));
|
||||
|
||||
// Determine the root based on the given range.
|
||||
let (root, range_to_highlight) = {
|
||||
let source_file = sema.parse(file_id);
|
||||
let source_file = source_file.syntax();
|
||||
let file = sema.parse(file_id);
|
||||
let source_file = file.syntax();
|
||||
match range_to_highlight {
|
||||
Some(range) => {
|
||||
let node = match source_file.covering_element(range) {
|
||||
|
@ -218,7 +222,7 @@ fn traverse(
|
|||
hl: &mut Highlights,
|
||||
sema: &Semantics<'_, RootDatabase>,
|
||||
config: HighlightConfig,
|
||||
file_id: FileId,
|
||||
file_id: EditionedFileId,
|
||||
root: &SyntaxNode,
|
||||
krate: hir::Crate,
|
||||
range_to_highlight: TextRange,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue