mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Report errors only once
This commit is contained in:
parent
26d34cc443
commit
edd162bda8
1 changed files with 3 additions and 14 deletions
|
@ -107,21 +107,10 @@ pub fn highlight(file: &File) -> Vec<HighlightedRange> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostics(file: &File) -> Vec<Diagnostic> {
|
pub fn diagnostics(file: &File) -> Vec<Diagnostic> {
|
||||||
let mut res = Vec::new();
|
file.errors().into_iter().map(|err| Diagnostic {
|
||||||
|
|
||||||
for node in file.syntax().descendants() {
|
|
||||||
if node.kind() == ERROR {
|
|
||||||
res.push(Diagnostic {
|
|
||||||
range: node.range(),
|
|
||||||
msg: "Syntax Error".to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.extend(file.errors().into_iter().map(|err| Diagnostic {
|
|
||||||
range: TextRange::offset_len(err.offset, 1.into()),
|
range: TextRange::offset_len(err.offset, 1.into()),
|
||||||
msg: err.msg,
|
msg: "Syntax Error: ".to_string() + &err.msg,
|
||||||
}));
|
}).collect()
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn syntax_tree(file: &File) -> String {
|
pub fn syntax_tree(file: &File) -> String {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue