mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Introduce SyntaxErrorKind and TextRange in SyntaxError
This commit is contained in:
parent
576b9a0727
commit
3b42ddae60
10 changed files with 159 additions and 68 deletions
|
@ -165,19 +165,19 @@ fn merge_errors(
|
|||
) -> Vec<SyntaxError> {
|
||||
let mut res = Vec::new();
|
||||
for e in old_errors {
|
||||
if e.offset <= old_node.range().start() {
|
||||
if e.range.start() <= old_node.range().start() {
|
||||
res.push(e)
|
||||
} else if e.offset >= old_node.range().end() {
|
||||
} else if e.range.start() >= old_node.range().end() {
|
||||
res.push(SyntaxError {
|
||||
msg: e.msg,
|
||||
offset: e.offset + TextUnit::of_str(&edit.insert) - edit.delete.len(),
|
||||
kind: e.kind,
|
||||
range: e.range + TextUnit::of_str(&edit.insert) - edit.delete.len(),
|
||||
})
|
||||
}
|
||||
}
|
||||
for e in new_errors {
|
||||
res.push(SyntaxError {
|
||||
msg: e.msg,
|
||||
offset: e.offset + old_node.range().start(),
|
||||
kind: e.kind,
|
||||
range: e.range + old_node.range().start(),
|
||||
})
|
||||
}
|
||||
res
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue