switch to TextRange::subrange
This commit is contained in:
parent
950e8b8182
commit
1643d94a65
@ -2,7 +2,6 @@
|
||||
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, NameOwner},
|
||||
text_utils::is_subrange,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -23,7 +22,7 @@ pub fn new(node: ast::FnDef) -> Option<Self> {
|
||||
let label: String = node
|
||||
.syntax()
|
||||
.children()
|
||||
.filter(|child| !is_subrange(body_range, child.range()))
|
||||
.filter(|child| !child.range().is_subrange(&body_range))
|
||||
.map(|node| node.text().to_string())
|
||||
.collect();
|
||||
label
|
||||
|
@ -3,7 +3,6 @@
|
||||
use ra_syntax::{
|
||||
algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx},
|
||||
ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner},
|
||||
text_utils::is_subrange,
|
||||
AstNode, File,
|
||||
SyntaxKind::*,
|
||||
SyntaxNodeRef, TextUnit,
|
||||
@ -191,7 +190,7 @@ fn is_in_loop_body(name_ref: ast::NameRef) -> bool {
|
||||
.visit::<ast::LoopExpr, _>(LoopBodyOwner::loop_body)
|
||||
.accept(node);
|
||||
if let Some(Some(body)) = loop_body {
|
||||
if is_subrange(body.syntax().range(), name_ref.syntax().range()) {
|
||||
if name_ref.syntax().range().is_subrange(&body.syntax().range()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// pub mod walk;
|
||||
|
||||
use crate::{
|
||||
text_utils::{contains_offset_nonstrict, is_subrange},
|
||||
text_utils::{contains_offset_nonstrict},
|
||||
SyntaxNodeRef, TextRange, TextUnit,
|
||||
};
|
||||
|
||||
@ -91,7 +91,7 @@ fn next(&mut self) -> Option<SyntaxNodeRef<'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,
|
||||
|
@ -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<TextRange> {
|
||||
let start = r1.start().max(r2.start());
|
||||
let end = r1.end().min(r2.end());
|
||||
|
Loading…
Reference in New Issue
Block a user