aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/algo/mod.rs4
-rw-r--r--crates/ra_syntax/src/text_utils.rs4
2 files changed, 2 insertions, 6 deletions
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());