mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Replace ID based TokenMap with proper relative text-ranges / spans
This commit is contained in:
parent
f79439caed
commit
890eb17b4e
80 changed files with 1816 additions and 2046 deletions
|
@ -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)
|
||||
};
|
||||
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue