port SyntaxTree.errors
Summary:
`SyntaxTree.error()` doesn't simply return all errors,
Ocaml's version
```
let errors tree =
let e =
if is_decl tree then
errors_no_bodies tree
else
all_errors tree
in
remove_cascading e
```
- Fix the TODO: in aast_parser by correctly using `tree.errors()` instead of `tree.all_errors()`, which was a placeholder,
- Revisit syntax_tree.rs
- rename `dedup_errors` to `remove_duplicates` to match Ocaml's version and moved it into `SyntaxTree`,
- moved `process_errors` into `SyntaxTree`,
- avoided some clones,
- `fn errors()` depends on `parentage`, which requires `Syntax<T, V>` for `is_*`, it also requries `full_width` from `SyntaxTrait`. Ocaml puts `parentage` in `SyntaxTrait`, then it duplicates similar implementation four times({
D18359772}). Moving `parentage` to `SyntaxTrait` needs to move all "is_*" functions to `SyntaxType`, make this task as TODO for now. #fileatask
```
pub trait SyntaxTrait {
fn parentage<'src, C>()
where
Self: SyntaxType<'src, C> {
}
}
```
Reviewed By: losvald
Differential Revision:
D18359931
fbshipit-source-id:
43e51c5af9b27d1359493601ff0d17593c7a747e