span: add span_extend_to_line
helper
Adds a simple helper function to the `SourceMap` for extending a `Span` to encompass the entire line it is on - useful for suggestions where removing a line is the suggested action. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
224aec213d
commit
97edb9f336
1 changed files with 5 additions and 0 deletions
|
@ -718,6 +718,11 @@ impl SourceMap {
|
||||||
sp
|
sp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extends the given `Span` to contain the entire line it is on.
|
||||||
|
pub fn span_extend_to_line(&self, sp: Span) -> Span {
|
||||||
|
self.span_extend_to_prev_char(self.span_extend_to_next_char(sp, '\n', true), '\n', true)
|
||||||
|
}
|
||||||
|
|
||||||
/// Given a `Span`, tries to get a shorter span ending before the first occurrence of `char`
|
/// Given a `Span`, tries to get a shorter span ending before the first occurrence of `char`
|
||||||
/// `c`.
|
/// `c`.
|
||||||
pub fn span_until_char(&self, sp: Span, c: char) -> Span {
|
pub fn span_until_char(&self, sp: Span, c: char) -> Span {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue