Skip to content

Commit 1643d94

Browse files
committed
switch to TextRange::subrange
1 parent 950e8b8 commit 1643d94

File tree

4 files changed

+4
-10
lines changed

4 files changed

+4
-10
lines changed

crates/ra_analysis/src/descriptors/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub(crate) mod module;
22

33
use ra_syntax::{
44
ast::{self, AstNode, NameOwner},
5-
text_utils::is_subrange,
65
};
76

87
#[derive(Debug, Clone)]
@@ -23,7 +22,7 @@ impl FnDescriptor {
2322
let label: String = node
2423
.syntax()
2524
.children()
26-
.filter(|child| !is_subrange(body_range, child.range()))
25+
.filter(|child| !child.range().is_subrange(&body_range))
2726
.map(|node| node.text().to_string())
2827
.collect();
2928
label

crates/ra_editor/src/completion.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use rustc_hash::{FxHashMap, FxHashSet};
33
use ra_syntax::{
44
algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx},
55
ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner},
6-
text_utils::is_subrange,
76
AstNode, File,
87
SyntaxKind::*,
98
SyntaxNodeRef, TextUnit,
@@ -191,7 +190,7 @@ fn is_in_loop_body(name_ref: ast::NameRef) -> bool {
191190
.visit::<ast::LoopExpr, _>(LoopBodyOwner::loop_body)
192191
.accept(node);
193192
if let Some(Some(body)) = loop_body {
194-
if is_subrange(body.syntax().range(), name_ref.syntax().range()) {
193+
if name_ref.syntax().range().is_subrange(&body.syntax().range()) {
195194
return true;
196195
}
197196
}

crates/ra_syntax/src/algo/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub mod visit;
22
// pub mod walk;
33

44
use crate::{
5-
text_utils::{contains_offset_nonstrict, is_subrange},
5+
text_utils::{contains_offset_nonstrict},
66
SyntaxNodeRef, TextRange, TextUnit,
77
};
88

@@ -91,7 +91,7 @@ impl<'f> Iterator for LeafAtOffset<'f> {
9191

9292
pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef {
9393
assert!(
94-
is_subrange(root.range(), range),
94+
range.is_subrange(&root.range()),
9595
"node range: {:?}, target range: {:?}",
9696
root.range(),
9797
range,

crates/ra_syntax/src/text_utils.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool {
44
range.start() <= offset && offset <= range.end()
55
}
66

7-
pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool {
8-
range.start() <= subrange.start() && subrange.end() <= range.end()
9-
}
10-
117
pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> {
128
let start = r1.start().max(r2.start());
139
let end = r1.end().min(r2.end());

0 commit comments

Comments
 (0)