mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Runnig tests somehow
This commit is contained in:
parent
89e56c364f
commit
6cade3f6d8
10 changed files with 149 additions and 32 deletions
19
crates/libsyntax2/src/text_utils.rs
Normal file
19
crates/libsyntax2/src/text_utils.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use {TextRange, TextUnit};
|
||||
|
||||
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());
|
||||
if start <= end {
|
||||
Some(TextRange::from_to(start, end))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue