Replace ID based TokenMap with proper relative text-ranges / spans

This commit is contained in:
Lukas Wirth 2023-09-29 12:37:57 +02:00
parent f79439caed
commit 890eb17b4e
80 changed files with 1816 additions and 2046 deletions

View file

@ -209,17 +209,24 @@ mod tests {
use super::*;
use cfg::CfgExpr;
use hir::HirFileId;
use ide_db::base_db::span::{SpanAnchor, ROOT_ERASED_FILE_AST_ID};
use mbe::syntax_node_to_token_tree;
use syntax::{
ast::{self, AstNode},
SmolStr,
SmolStr, TextSize,
};
fn check(cfg: &str, expected_features: &[&str]) {
let cfg_expr = {
let source_file = ast::SourceFile::parse(cfg).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
let (tt, _) = syntax_node_to_token_tree(tt.syntax());
let tt = syntax_node_to_token_tree(
tt.syntax(),
SpanAnchor { file_id: HirFileId::from(0), ast_id: ROOT_ERASED_FILE_AST_ID },
TextSize::new(0),
&Default::default(),
);
CfgExpr::parse(&tt)
};

View file

@ -8,7 +8,7 @@ use std::{
use hir::{
db::{DefDatabase, ExpandDatabase, HirDatabase},
Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, ModuleDef, Name,
Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, HirFileIdExt, ModuleDef, Name,
};
use hir_def::{
body::{BodySourceMap, SyntheticSyntax},

View file

@ -4,7 +4,7 @@
use project_model::{CargoConfig, RustLibSource};
use rustc_hash::FxHashSet;
use hir::{db::HirDatabase, Crate, Module};
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module};
use ide::{AssistResolveStrategy, DiagnosticsConfig, Severity};
use ide_db::base_db::SourceDatabaseExt;
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};