diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-28 22:21:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-28 22:21:37 +0100 |
commit | 7869b01b702d1f12acb03ac131b6eb90ad82e9bb (patch) | |
tree | e6d76df5212db7589ef8dc6583b32d6c64871a33 /crates/test_utils/src | |
parent | d5f7b2e52a41a7d3b841f4d0e2225eb703f6a50a (diff) | |
parent | e42c448077ca2b7675320da3c5294bf4bebaedeb (diff) |
Merge #9041
9041: internal: Implement prev sibling determination for `CompletionContext ` r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r-- | crates/test_utils/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index fce4fd6bf..bd017567c 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -96,6 +96,21 @@ pub enum RangeOrOffset { | |||
96 | Offset(TextSize), | 96 | Offset(TextSize), |
97 | } | 97 | } |
98 | 98 | ||
99 | impl RangeOrOffset { | ||
100 | pub fn expect_offset(self) -> TextSize { | ||
101 | match self { | ||
102 | RangeOrOffset::Offset(it) => it, | ||
103 | RangeOrOffset::Range(_) => panic!("expected an offset but got a range instead"), | ||
104 | } | ||
105 | } | ||
106 | pub fn expect_range(self) -> TextRange { | ||
107 | match self { | ||
108 | RangeOrOffset::Range(it) => it, | ||
109 | RangeOrOffset::Offset(_) => panic!("expected a range but got an offset"), | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
99 | impl From<RangeOrOffset> for TextRange { | 114 | impl From<RangeOrOffset> for TextRange { |
100 | fn from(selection: RangeOrOffset) -> Self { | 115 | fn from(selection: RangeOrOffset) -> Self { |
101 | match selection { | 116 | match selection { |