aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/syntax_error.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:48:55 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:48:55 +0000
commit2a6544f906818263e2791bc4cdf4fcbdf7260ab9 (patch)
tree12cc178506343e5dbbea0285e1dcd0bd0035398c /crates/ra_syntax/src/syntax_error.rs
parented823cb38d6c6852b2645f6bcd4c3b699b4b7539 (diff)
parentbf8e7930daa3fb168106534b1cc418f5bc44e8c0 (diff)
Merge #1013
1013: Fuzz reparsing and fix found bugs r=matklad a=pcpthm Add fuzz test for reparsing which: - Checks reparsing doesn't panic and validate result syntax tree. - Checks that incremental reparsing produces the same syntax tree as full reparse. - Check for that errors are the same as full reparsing is disabled because errors are less important than syntax tree and produce failures which I couldn't figure out how to fix immediately (FIXME comment). I guess the current input generation is inefficient but still found several bugs: - Arithmetic overflow (negative result on an unsigned type). I changed the signature of `SyntaxError::add_offset` to solve this problem. - When reparsing a leaf, the token of the leaf can be joined to the next characters. Such case was not considered. - UNDERSCORE token was not produced when text length is exactly 1 (not a reparsing bug). - When reparsing a block, *inner* curly braces should be balanced. i.e. `{}{}` is invalid. - Effects of deleting newlines were not considered. Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/syntax_error.rs')
-rw-r--r--crates/ra_syntax/src/syntax_error.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs
index bdd431742..4b8c22a57 100644
--- a/crates/ra_syntax/src/syntax_error.rs
+++ b/crates/ra_syntax/src/syntax_error.rs
@@ -48,10 +48,10 @@ impl SyntaxError {
48 } 48 }
49 } 49 }
50 50
51 pub fn add_offset(mut self, plus_offset: TextUnit) -> SyntaxError { 51 pub fn add_offset(mut self, plus_offset: TextUnit, minus_offset: TextUnit) -> SyntaxError {
52 self.location = match self.location { 52 self.location = match self.location {
53 Location::Range(range) => Location::Range(range + plus_offset), 53 Location::Range(range) => Location::Range(range + plus_offset - minus_offset),
54 Location::Offset(offset) => Location::Offset(offset + plus_offset), 54 Location::Offset(offset) => Location::Offset(offset + plus_offset - minus_offset),
55 }; 55 };
56 56
57 self 57 self