refactor(tvix/eval): implement ToSpan directly for rnix::TextRange
This logic was duplicated between the two rnix types before, but more crucially - it is also needed for correctly displaying the text ranges contained in syntax errors. Change-Id: Ifc6a521de1594d6ced9cba6274f1931df99b6634 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6870 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
50baf0bcfc
commit
70113407d2
1 changed files with 9 additions and 10 deletions
|
@ -16,23 +16,22 @@ impl ToSpan for Span {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToSpan for rnix::TextRange {
|
||||
fn span_for(&self, file: &File) -> Span {
|
||||
file.span
|
||||
.subspan(u32::from(self.start()) as u64, u32::from(self.end()) as u64)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSpan for rnix::SyntaxToken {
|
||||
fn span_for(&self, file: &File) -> Span {
|
||||
let rowan_span = self.text_range();
|
||||
file.span.subspan(
|
||||
u32::from(rowan_span.start()) as u64,
|
||||
u32::from(rowan_span.end()) as u64,
|
||||
)
|
||||
self.text_range().span_for(file)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSpan for rnix::SyntaxNode {
|
||||
fn span_for(&self, file: &File) -> Span {
|
||||
let rowan_span = self.text_range();
|
||||
file.span.subspan(
|
||||
u32::from(rowan_span.start()) as u64,
|
||||
u32::from(rowan_span.end()) as u64,
|
||||
)
|
||||
self.text_range().span_for(file)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue