port SyntaxTree.errors
commit992b9e8785a3d7ff14c40ee9eeb834dae9c59dc0
authorSteve Cao <shiqicao@fb.com>
Thu, 14 Nov 2019 04:08:13 +0000 (13 20:08 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 14 Nov 2019 04:10:44 +0000 (13 20:10 -0800)
treee5f3ea2446c9b81b40403ed91b32f3dd4893b306
parent12f9a59c576b18b08c5934678d6a11fffd84bbf6
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
hphp/hack/src/parser/aast_parser.rs
hphp/hack/src/parser/syntax.rs
hphp/hack/src/parser/syntax_error.rs
hphp/hack/src/parser/syntax_tree.rs