diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/descriptors/mod.rs | 3 | ||||
-rw-r--r-- | crates/ra_editor/src/completion.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/src/algo/mod.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/text_utils.rs | 4 |
4 files changed, 4 insertions, 10 deletions
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs index 873eb47e4..0220f7d5d 100644 --- a/crates/ra_analysis/src/descriptors/mod.rs +++ b/crates/ra_analysis/src/descriptors/mod.rs | |||
@@ -2,7 +2,6 @@ pub(crate) mod module; | |||
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, AstNode, NameOwner}, | 4 | ast::{self, AstNode, NameOwner}, |
5 | text_utils::is_subrange, | ||
6 | }; | 5 | }; |
7 | 6 | ||
8 | #[derive(Debug, Clone)] | 7 | #[derive(Debug, Clone)] |
@@ -23,7 +22,7 @@ impl FnDescriptor { | |||
23 | let label: String = node | 22 | let label: String = node |
24 | .syntax() | 23 | .syntax() |
25 | .children() | 24 | .children() |
26 | .filter(|child| !is_subrange(body_range, child.range())) | 25 | .filter(|child| !child.range().is_subrange(&body_range)) |
27 | .map(|node| node.text().to_string()) | 26 | .map(|node| node.text().to_string()) |
28 | .collect(); | 27 | .collect(); |
29 | label | 28 | label |
diff --git a/crates/ra_editor/src/completion.rs b/crates/ra_editor/src/completion.rs index 0a3675255..a0b168bc6 100644 --- a/crates/ra_editor/src/completion.rs +++ b/crates/ra_editor/src/completion.rs | |||
@@ -3,7 +3,6 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx}, | 4 | algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx}, |
5 | ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner}, | 5 | ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner}, |
6 | text_utils::is_subrange, | ||
7 | AstNode, File, | 6 | AstNode, File, |
8 | SyntaxKind::*, | 7 | SyntaxKind::*, |
9 | SyntaxNodeRef, TextUnit, | 8 | SyntaxNodeRef, TextUnit, |
@@ -191,7 +190,7 @@ fn is_in_loop_body(name_ref: ast::NameRef) -> bool { | |||
191 | .visit::<ast::LoopExpr, _>(LoopBodyOwner::loop_body) | 190 | .visit::<ast::LoopExpr, _>(LoopBodyOwner::loop_body) |
192 | .accept(node); | 191 | .accept(node); |
193 | if let Some(Some(body)) = loop_body { | 192 | 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()) { |
195 | return true; | 194 | return true; |
196 | } | 195 | } |
197 | } | 196 | } |
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 | ||
4 | use crate::{ | 4 | use 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 | ||
92 | pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { | 92 | pub 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 | ||
7 | pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool { | ||
8 | range.start() <= subrange.start() && subrange.end() <= range.end() | ||
9 | } | ||
10 | |||
11 | pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> { | 7 | pub 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()); |