From 950e8b8182897da60bcece70d84e9f0b6dc88632 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 30 Oct 2018 21:23:23 +0300 Subject: introduce syntax-ptr --- crates/ra_syntax/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_syntax') 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" drop_bomb = "0.1.4" parking_lot = "0.6.0" rowan = "0.1.1" +text_unit = "0.1.5" [dev-dependencies] test_utils = { path = "../test_utils" } -- cgit v1.2.3 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') 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