mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
update tests
This commit is contained in:
parent
afeaea7051
commit
bc2550b196
4 changed files with 36 additions and 47 deletions
|
@ -31,7 +31,7 @@ pub mod ast;
|
|||
#[doc(hidden)]
|
||||
pub mod fuzz;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::{sync::Arc, fmt::Write};
|
||||
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
|
||||
|
@ -68,6 +68,14 @@ impl Parse {
|
|||
Err(self.errors)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug_dump(&self) -> String {
|
||||
let mut buf = self.tree.syntax().debug_dump();
|
||||
for err in self.errors.iter() {
|
||||
writeln!(buf, "err: `{}`", err).unwrap();
|
||||
}
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
/// `SourceFile` represents a parse tree for a single Rust file.
|
||||
|
@ -83,6 +91,12 @@ impl SourceFile {
|
|||
TreeArc::cast(root)
|
||||
}
|
||||
|
||||
pub fn parse2(text: &str) -> Parse {
|
||||
let (green, errors) = parsing::parse_text(text);
|
||||
let tree = SourceFile::new(green);
|
||||
Parse { tree, errors: Arc::new(errors) }
|
||||
}
|
||||
|
||||
pub fn parse(text: &str) -> TreeArc<SourceFile> {
|
||||
let (green, _errors) = parsing::parse_text(text);
|
||||
SourceFile::new(green)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue