Proper span representation with syntax context

This commit is contained in:
Lukas Wirth 2023-10-06 14:47:11 +02:00
parent 890eb17b4e
commit e36b3f7b8c
16 changed files with 414 additions and 470 deletions

View file

@ -4,20 +4,26 @@ use syntax::{ast, AstNode};
use test_utils::extract_annotations;
use tt::{
buffer::{TokenBuffer, TokenTreeRef},
Leaf, Punct, Spacing, Span,
Leaf, Punct, Spacing, SpanAnchor, SyntaxContext,
};
use crate::syntax_bridge::SpanData;
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)]
struct DummyFile;
impl Span for DummyFile {
impl SpanAnchor for DummyFile {
const DUMMY: Self = DummyFile;
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
struct DummyCtx;
impl SyntaxContext for DummyCtx {
const DUMMY: Self = 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());