mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
spans always come from real file
This commit is contained in:
parent
394d11b0fa
commit
30093a6d81
57 changed files with 1369 additions and 1224 deletions
|
@ -209,24 +209,26 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
use cfg::CfgExpr;
|
||||
use hir::HirFileId;
|
||||
use ide_db::base_db::span::{SpanAnchor, SyntaxContextId, ROOT_ERASED_FILE_AST_ID};
|
||||
use mbe::syntax_node_to_token_tree;
|
||||
use hir_def::tt::{self, Span};
|
||||
use mbe::{syntax_node_to_token_tree, SpanMapper};
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
SmolStr, TextSize,
|
||||
SmolStr,
|
||||
};
|
||||
|
||||
struct NoOpMap;
|
||||
|
||||
impl SpanMapper<tt::SpanData> for NoOpMap {
|
||||
fn span_for(&self, _: syntax::TextRange) -> tt::SpanData {
|
||||
tt::SpanData::DUMMY
|
||||
}
|
||||
}
|
||||
|
||||
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::<_, SyntaxContextId>(
|
||||
tt.syntax(),
|
||||
SpanAnchor { file_id: HirFileId::from(0), ast_id: ROOT_ERASED_FILE_AST_ID },
|
||||
TextSize::new(0),
|
||||
&Default::default(),
|
||||
);
|
||||
let tt = syntax_node_to_token_tree(tt.syntax(), &NoOpMap);
|
||||
CfgExpr::parse(&tt)
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue