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
|
@ -7,12 +7,14 @@ use tt::{
|
|||
Leaf, Punct, Spacing, SpanAnchor, SyntaxContext,
|
||||
};
|
||||
|
||||
use crate::SpanMapper;
|
||||
|
||||
use super::syntax_node_to_token_tree;
|
||||
|
||||
fn check_punct_spacing(fixture: &str) {
|
||||
type SpanData = tt::SpanData<DummyFile, DummyCtx>;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
|
||||
struct DummyFile;
|
||||
impl SpanAnchor for DummyFile {
|
||||
const DUMMY: Self = DummyFile;
|
||||
|
@ -24,9 +26,16 @@ fn check_punct_spacing(fixture: &str) {
|
|||
const DUMMY: Self = DummyCtx;
|
||||
}
|
||||
|
||||
struct NoOpMap;
|
||||
|
||||
impl SpanMapper<SpanData> for NoOpMap {
|
||||
fn span_for(&self, range: syntax::TextRange) -> SpanData {
|
||||
SpanData { range, anchor: DummyFile, ctx: DummyCtx }
|
||||
}
|
||||
}
|
||||
|
||||
let source_file = ast::SourceFile::parse(fixture).ok().unwrap();
|
||||
let subtree =
|
||||
syntax_node_to_token_tree(source_file.syntax(), DummyFile, 0.into(), &Default::default());
|
||||
let subtree = syntax_node_to_token_tree(source_file.syntax(), NoOpMap);
|
||||
let mut annotations: HashMap<_, _> = extract_annotations(fixture)
|
||||
.into_iter()
|
||||
.map(|(range, annotation)| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue