From 1643d94a65a66f32b9278829dd3af00883f3852b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 30 Oct 2018 21:26:55 +0300 Subject: switch to TextRange::subrange --- crates/ra_syntax/src/algo/mod.rs | 4 ++-- crates/ra_syntax/src/text_utils.rs | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'crates/ra_syntax/src') 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; // pub mod walk; use crate::{ - text_utils::{contains_offset_nonstrict, is_subrange}, + text_utils::{contains_offset_nonstrict}, SyntaxNodeRef, TextRange, TextUnit, }; @@ -91,7 +91,7 @@ impl<'f> Iterator for LeafAtOffset<'f> { pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { assert!( - is_subrange(root.range(), range), + range.is_subrange(&root.range()), "node range: {:?}, target range: {:?}", root.range(), 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 { range.start() <= offset && offset <= range.end() } -pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool { - range.start() <= subrange.start() && subrange.end() <= range.end() -} - pub fn intersect(r1: TextRange, r2: TextRange) -> Option { let start = r1.start().max(r2.start()); let end = r1.end().min(r2.end()); -- cgit v1.2.3