mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-04 23:50:47 +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
|
@ -1,7 +1,5 @@
|
|||
use ide_db::{
|
||||
base_db::{FileId, SourceDatabase},
|
||||
RootDatabase,
|
||||
};
|
||||
use hir::Semantics;
|
||||
use ide_db::{FileId, RootDatabase};
|
||||
use syntax::{
|
||||
AstNode, NodeOrToken, SourceFile, SyntaxKind::STRING, SyntaxToken, TextRange, TextSize,
|
||||
};
|
||||
|
@ -22,9 +20,10 @@ pub(crate) fn syntax_tree(
|
|||
file_id: FileId,
|
||||
text_range: Option<TextRange>,
|
||||
) -> String {
|
||||
let parse = db.parse(file_id);
|
||||
let sema = Semantics::new(db);
|
||||
let parse = sema.parse_guess_edition(file_id);
|
||||
if let Some(text_range) = text_range {
|
||||
let node = match parse.tree().syntax().covering_element(text_range) {
|
||||
let node = match parse.syntax().covering_element(text_range) {
|
||||
NodeOrToken::Node(node) => node,
|
||||
NodeOrToken::Token(token) => {
|
||||
if let Some(tree) = syntax_tree_for_string(&token, text_range) {
|
||||
|
@ -36,7 +35,7 @@ pub(crate) fn syntax_tree(
|
|||
|
||||
format!("{node:#?}")
|
||||
} else {
|
||||
format!("{:#?}", parse.tree().syntax())
|
||||
format!("{:#?}", parse.syntax())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<St
|
|||
// Remove custom markers
|
||||
.replace("$0", "");
|
||||
|
||||
let parsed = SourceFile::parse(&text, span::Edition::CURRENT);
|
||||
let parsed = SourceFile::parse(&text, span::Edition::CURRENT_FIXME);
|
||||
|
||||
// If the "file" parsed without errors,
|
||||
// return its syntax
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue