Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/span/src/lib.rs')
-rw-r--r--crates/span/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs
index 057fab89c7..b4e21d64f8 100644
--- a/crates/span/src/lib.rs
+++ b/crates/span/src/lib.rs
@@ -33,6 +33,16 @@ pub const FIXUP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId =
pub type Span = SpanData<SyntaxContextId>;
+impl Span {
+ pub fn cover(self, other: Span) -> Span {
+ if self.anchor != other.anchor {
+ return self;
+ }
+ let range = self.range.cover(other.range);
+ Span { range, ..self }
+ }
+}
+
/// Spans represent a region of code, used by the IDE to be able link macro inputs and outputs
/// together. Positions in spans are relative to some [`SpanAnchor`] to make them more incremental
/// friendly.