aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock67
-rw-r--r--crates/ra_text_edit/Cargo.toml1
-rw-r--r--crates/ra_text_edit/src/lib.rs2
-rw-r--r--crates/ra_text_edit/src/test_utils.rs114
4 files changed, 184 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 51cf1825d..3a3793581 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -74,6 +74,19 @@ dependencies = [
74] 74]
75 75
76[[package]] 76[[package]]
77name = "bit-set"
78version = "0.5.0"
79source = "registry+https://github.com/rust-lang/crates.io-index"
80dependencies = [
81 "bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
82]
83
84[[package]]
85name = "bit-vec"
86version = "0.5.0"
87source = "registry+https://github.com/rust-lang/crates.io-index"
88
89[[package]]
77name = "bitflags" 90name = "bitflags"
78version = "1.0.4" 91version = "1.0.4"
79source = "registry+https://github.com/rust-lang/crates.io-index" 92source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -303,6 +316,11 @@ dependencies = [
303] 316]
304 317
305[[package]] 318[[package]]
319name = "fnv"
320version = "1.0.6"
321source = "registry+https://github.com/rust-lang/crates.io-index"
322
323[[package]]
306name = "fst" 324name = "fst"
307version = "0.3.3" 325version = "0.3.3"
308source = "registry+https://github.com/rust-lang/crates.io-index" 326source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -626,6 +644,28 @@ dependencies = [
626] 644]
627 645
628[[package]] 646[[package]]
647name = "proptest"
648version = "0.8.7"
649source = "registry+https://github.com/rust-lang/crates.io-index"
650dependencies = [
651 "bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
652 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
653 "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
654 "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
655 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
656 "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
657 "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
658 "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
659 "rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
660 "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
661]
662
663[[package]]
664name = "quick-error"
665version = "1.2.2"
666source = "registry+https://github.com/rust-lang/crates.io-index"
667
668[[package]]
629name = "quote" 669name = "quote"
630version = "0.6.10" 670version = "0.6.10"
631source = "registry+https://github.com/rust-lang/crates.io-index" 671source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -763,6 +803,7 @@ dependencies = [
763name = "ra_text_edit" 803name = "ra_text_edit"
764version = "0.1.0" 804version = "0.1.0"
765dependencies = [ 805dependencies = [
806 "proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
766 "test_utils 0.1.0", 807 "test_utils 0.1.0",
767 "text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 808 "text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
768] 809]
@@ -984,6 +1025,17 @@ dependencies = [
984] 1025]
985 1026
986[[package]] 1027[[package]]
1028name = "rusty-fork"
1029version = "0.2.1"
1030source = "registry+https://github.com/rust-lang/crates.io-index"
1031dependencies = [
1032 "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
1033 "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
1034 "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
1035 "wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1036]
1037
1038[[package]]
987name = "ryu" 1039name = "ryu"
988version = "0.2.7" 1040version = "0.2.7"
989source = "registry+https://github.com/rust-lang/crates.io-index" 1041source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1413,6 +1465,14 @@ version = "1.0.2"
1413source = "registry+https://github.com/rust-lang/crates.io-index" 1465source = "registry+https://github.com/rust-lang/crates.io-index"
1414 1466
1415[[package]] 1467[[package]]
1468name = "wait-timeout"
1469version = "0.1.5"
1470source = "registry+https://github.com/rust-lang/crates.io-index"
1471dependencies = [
1472 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
1473]
1474
1475[[package]]
1416name = "walkdir" 1476name = "walkdir"
1417version = "2.2.7" 1477version = "2.2.7"
1418source = "registry+https://github.com/rust-lang/crates.io-index" 1478source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1459,6 +1519,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1459"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" 1519"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5"
1460"checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" 1520"checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279"
1461"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" 1521"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
1522"checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a"
1523"checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf"
1462"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" 1524"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
1463"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" 1525"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
1464"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" 1526"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
@@ -1487,6 +1549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1487"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" 1549"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
1488"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" 1550"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
1489"checksum flexi_logger 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dda06444ccc8b0a6da19d939989b4a4e83f328710ada449eedaed48c8b903cd" 1551"checksum flexi_logger 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dda06444ccc8b0a6da19d939989b4a4e83f328710ada449eedaed48c8b903cd"
1552"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
1490"checksum fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db72126ca7dff566cdbbdd54af44668c544897d9d3862b198141f176f1238bdf" 1553"checksum fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db72126ca7dff566cdbbdd54af44668c544897d9d3862b198141f176f1238bdf"
1491"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 1554"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
1492"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 1555"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
@@ -1527,6 +1590,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1527"checksum pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebee4e9680be4fd162e6f3394ae4192a6b60b1e4d17d845e631f0c68d1a3386" 1590"checksum pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebee4e9680be4fd162e6f3394ae4192a6b60b1e4d17d845e631f0c68d1a3386"
1528"checksum pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f6d5f6f0e6082578c86af197d780dc38328e3f768cec06aac9bc46d714e8221" 1591"checksum pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f6d5f6f0e6082578c86af197d780dc38328e3f768cec06aac9bc46d714e8221"
1529"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" 1592"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09"
1593"checksum proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "926d0604475349f463fe44130aae73f2294b5309ab2ca0310b998bd334ef191f"
1594"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
1530"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" 1595"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
1531"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" 1596"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
1532"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" 1597"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
@@ -1551,6 +1616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1551"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7" 1616"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7"
1552"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" 1617"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
1553"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1618"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1619"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
1554"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" 1620"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
1555"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" 1621"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
1556"checksum salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)" = "<none>" 1622"checksum salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)" = "<none>"
@@ -1602,6 +1668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1602"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" 1668"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
1603"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" 1669"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
1604"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 1670"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
1671"checksum wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9f3bf741a801531993db6478b95682117471f76916f5e690dd8d45395b09349"
1605"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" 1672"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
1606"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" 1673"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
1607"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1674"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
diff --git a/crates/ra_text_edit/Cargo.toml b/crates/ra_text_edit/Cargo.toml
index 3c4157a4e..67dfd0924 100644
--- a/crates/ra_text_edit/Cargo.toml
+++ b/crates/ra_text_edit/Cargo.toml
@@ -10,3 +10,4 @@ text_unit = "0.1.5"
10 10
11[dev-dependencies] 11[dev-dependencies]
12test_utils = { path = "../test_utils" } 12test_utils = { path = "../test_utils" }
13proptest = "0.8.7"
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs
index 13e20f6fb..0a407795e 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/ra_text_edit/src/lib.rs
@@ -1,5 +1,7 @@
1mod text_edit; 1mod text_edit;
2pub mod text_utils; 2pub mod text_utils;
3#[cfg(test)]
4pub mod test_utils;
3 5
4pub use crate::text_edit::{TextEdit, TextEditBuilder}; 6pub use crate::text_edit::{TextEdit, TextEditBuilder};
5 7
diff --git a/crates/ra_text_edit/src/test_utils.rs b/crates/ra_text_edit/src/test_utils.rs
new file mode 100644
index 000000000..92b79ab59
--- /dev/null
+++ b/crates/ra_text_edit/src/test_utils.rs
@@ -0,0 +1,114 @@
1use proptest::{prelude::*, proptest, proptest_helper};
2use text_unit::{TextUnit, TextRange};
3use crate::AtomTextEdit;
4
5pub fn arb_text() -> proptest::string::RegexGeneratorStrategy<String> {
6 // generate multiple newlines
7 proptest::string::string_regex("(.*\n?)*").unwrap()
8}
9
10fn text_offsets(text: &str) -> Vec<TextUnit> {
11 text.char_indices()
12 .map(|(i, _)| TextUnit::from_usize(i))
13 .collect()
14}
15
16pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> {
17 let offsets = text_offsets(text);
18 // this is necessary to avoid "Uniform::new called with `low >= high`" panic
19 if offsets.is_empty() {
20 Just(TextUnit::from(0)).boxed()
21 } else {
22 prop::sample::select(offsets).boxed()
23 }
24}
25
26pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> {
27 let offsets = text_offsets(text);
28 let offsets_len = offsets.len();
29
30 if offsets_len == 0 {
31 return proptest::bool::ANY
32 .prop_flat_map(|b| {
33 // only valid edits
34 if b {
35 arb_text()
36 .prop_map(|text| vec![AtomTextEdit::insert(TextUnit::from(0), text)])
37 .boxed()
38 } else {
39 Just(vec![]).boxed()
40 }
41 })
42 .boxed();
43 }
44
45 proptest::sample::subsequence(offsets, 0..offsets_len)
46 .prop_flat_map(|xs| {
47 let strategies: Vec<_> = xs
48 .chunks(2)
49 .map(|chunk| match chunk {
50 &[from, to] => {
51 let range = TextRange::from_to(from, to);
52 (proptest::bool::ANY)
53 .prop_flat_map(move |b| {
54 if b {
55 Just(AtomTextEdit::delete(range)).boxed()
56 } else {
57 arb_text()
58 .prop_map(move |text| AtomTextEdit::replace(range, text))
59 .boxed()
60 }
61 })
62 .boxed()
63 }
64 &[x] => arb_text()
65 .prop_map(move |text| AtomTextEdit::insert(x, text))
66 .boxed(),
67 _ => unreachable!(),
68 })
69 .collect();
70 strategies
71 })
72 .boxed()
73}
74
75fn arb_text_with_edits() -> BoxedStrategy<(String, Vec<AtomTextEdit>)> {
76 let text = arb_text();
77 text.prop_flat_map(|s| {
78 let edits = arb_edits(&s);
79 (Just(s), edits)
80 })
81 .boxed()
82}
83
84fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> {
85 let start = r1.start().max(r2.start());
86 let end = r1.end().min(r2.end());
87 if start <= end {
88 Some(TextRange::from_to(start, end))
89 } else {
90 None
91 }
92}
93
94proptest! {
95#[test]
96 fn atom_text_edits_are_valid((text, edits) in arb_text_with_edits()) {
97 proptest_atom_text_edits_are_valid(text, edits)
98 }
99}
100
101fn proptest_atom_text_edits_are_valid(text: String, edits: Vec<AtomTextEdit>) {
102 // slicing doesn't panic
103 for e in &edits {
104 let _ = &text[e.delete];
105 }
106 // ranges do not overlap
107 for (i1, e1) in edits.iter().skip(1).enumerate() {
108 for e2 in &edits[0..i1] {
109 if intersect(e1.delete, e2.delete).is_some() {
110 assert!(false, "Overlapping ranges {} {}", e1.delete, e2.delete);
111 }
112 }
113 }
114}