mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Incremental reparsing for single tokens (WHITESPACE, COMMENT, DOC_COMMENT, IDENT, STRING, RAW_STRING)
This commit is contained in:
parent
b6f8037a6f
commit
4356240fa4
2 changed files with 122 additions and 14 deletions
|
@ -33,7 +33,7 @@ fn reparse_test() {
|
|||
let incrementally_reparsed = {
|
||||
let f = File::parse(&before);
|
||||
let edit = AtomEdit { delete: range, insert: replace_with.to_string() };
|
||||
f.incremental_reparse(&edit).unwrap()
|
||||
f.incremental_reparse(&edit).expect("cannot incrementally reparse")
|
||||
};
|
||||
assert_eq_text!(
|
||||
&dump_tree(fully_reparsed.syntax()),
|
||||
|
@ -45,6 +45,11 @@ fn reparse_test() {
|
|||
fn foo() {
|
||||
let x = foo + <|>bar<|>
|
||||
}
|
||||
", "baz");
|
||||
do_check(r"
|
||||
fn foo() {
|
||||
let x = foo<|> + bar<|>
|
||||
}
|
||||
", "baz");
|
||||
do_check(r"
|
||||
struct Foo {
|
||||
|
@ -67,6 +72,11 @@ mod foo {
|
|||
trait Foo {
|
||||
type <|>Foo<|>;
|
||||
}
|
||||
", "Output");
|
||||
do_check(r"
|
||||
trait Foo {
|
||||
type<|> Foo<|>;
|
||||
}
|
||||
", "Output");
|
||||
do_check(r"
|
||||
impl IntoIterator<Item=i32> for Foo {
|
||||
|
@ -94,6 +104,50 @@ extern {
|
|||
fn<|>;<|>
|
||||
}
|
||||
", " exit(code: c_int)");
|
||||
do_check(r"<|><|>
|
||||
fn foo() -> i32 {
|
||||
1
|
||||
}
|
||||
", "\n\n\n \n");
|
||||
do_check(r"
|
||||
fn foo() -> <|><|> {}
|
||||
", " \n");
|
||||
do_check(r"
|
||||
fn <|>foo<|>() -> i32 {
|
||||
1
|
||||
}
|
||||
", "bar");
|
||||
do_check(r"
|
||||
fn aa<|><|>bb() {
|
||||
|
||||
}
|
||||
", "foofoo");
|
||||
do_check(r"
|
||||
fn aabb /* <|><|> */ () {
|
||||
|
||||
}
|
||||
", "some comment");
|
||||
do_check(r"
|
||||
fn aabb <|><|> () {
|
||||
|
||||
}
|
||||
", " \t\t\n\n");
|
||||
do_check(r"
|
||||
trait foo {
|
||||
// comment <|><|>
|
||||
}
|
||||
", "\n");
|
||||
do_check(r"
|
||||
/// good <|><|>omment
|
||||
mod {
|
||||
}
|
||||
", "c");
|
||||
do_check(r#"
|
||||
fn -> &str { "Hello<|><|>" }
|
||||
"#, ", world");
|
||||
do_check(r#"
|
||||
fn -> &str { // "Hello<|><|>"
|
||||
"#, ", world");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue