mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Proper span representation with syntax context
This commit is contained in:
parent
890eb17b4e
commit
e36b3f7b8c
16 changed files with 414 additions and 470 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue