aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-30 18:32:24 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-30 18:32:24 +0000
commit46cce4f8f1b71458029ebfd391c37e27cc6c5c9c (patch)
tree95344947f1957d03edcbcd6ef8a2786cc1b9142d /crates/ra_syntax
parentbc4de7128f474f75a9eff6591923657025099b74 (diff)
parent1643d94a65a66f32b9278829dd3af00883f3852b (diff)
Merge #169
169: Syntax ptr r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/Cargo.toml1
-rw-r--r--crates/ra_syntax/src/algo/mod.rs4
-rw-r--r--crates/ra_syntax/src/text_utils.rs4
3 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 7efebab8b..043c9bacd 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -11,6 +11,7 @@ itertools = "0.7.8"
11drop_bomb = "0.1.4" 11drop_bomb = "0.1.4"
12parking_lot = "0.6.0" 12parking_lot = "0.6.0"
13rowan = "0.1.1" 13rowan = "0.1.1"
14text_unit = "0.1.5"
14 15
15[dev-dependencies] 16[dev-dependencies]
16test_utils = { path = "../test_utils" } 17test_utils = { path = "../test_utils" }
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs
index d82c42b3e..f92529d3e 100644
--- a/crates/ra_syntax/src/algo/mod.rs
+++ b/crates/ra_syntax/src/algo/mod.rs
@@ -2,7 +2,7 @@ pub mod visit;
2// pub mod walk; 2// pub mod walk;
3 3
4use crate::{ 4use crate::{
5 text_utils::{contains_offset_nonstrict, is_subrange}, 5 text_utils::{contains_offset_nonstrict},
6 SyntaxNodeRef, TextRange, TextUnit, 6 SyntaxNodeRef, TextRange, TextUnit,
7}; 7};
8 8
@@ -91,7 +91,7 @@ impl<'f> Iterator for LeafAtOffset<'f> {
91 91
92pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { 92pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef {
93 assert!( 93 assert!(
94 is_subrange(root.range(), range), 94 range.is_subrange(&root.range()),
95 "node range: {:?}, target range: {:?}", 95 "node range: {:?}, target range: {:?}",
96 root.range(), 96 root.range(),
97 range, 97 range,
diff --git a/crates/ra_syntax/src/text_utils.rs b/crates/ra_syntax/src/text_utils.rs
index abda5ec39..a90f8a083 100644
--- a/crates/ra_syntax/src/text_utils.rs
+++ b/crates/ra_syntax/src/text_utils.rs
@@ -4,10 +4,6 @@ pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool {
4 range.start() <= offset && offset <= range.end() 4 range.start() <= offset && offset <= range.end()
5} 5}
6 6
7pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool {
8 range.start() <= subrange.start() && subrange.end() <= range.end()
9}
10
11pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> { 7pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> {
12 let start = r1.start().max(r2.start()); 8 let start = r1.start().max(r2.start());
13 let end = r1.end().min(r2.end()); 9 let end = r1.end().min(r2.end());