Avoid growing type parameters in Visitor
Summary:
`Visitor`, `Node` carries a list of type parameters, currently there are six, `Context`, `Error` and four aast annotations.
The long list of type parameters has lots of disadvantage,
1. Adding a new type parameters requires `O(n)` updates, `n` is number of all visitors,
2. Each visitor contains a lots boilerplate code,
3. Readability is compromised.
This diff reduces `n` type parameters to 1.
```
pub trait Params {
type Context;
type Error;
type Ex;
type Fb;
type En;
type Hi;
}
```
```
pub trait Node<P: Params> {
fn accept(&self, ctx: &mut P::Context, v: &mut dyn Visitor<P = P>) -> Result<(), P::Error> {
self.recurse(ctx, v)
}
fn recurse(&self, ctx: &mut P::Context, v: &mut dyn Visitor<P = P>) -> Result<(), P::Error> {
Ok(())
}
}
```
```
pub trait Visitor {
type P: Params;
......
fn visit_fun(
&mut self,
c: &mut <Self::P as Params>::Context,
p: &Fun<<Self::P as Params>::Fb>,
) -> Result<(), <Self::P as Params>::Error> {
p.recurse(c, self.object())
}
}
```
Reviewed By: dabek
Differential Revision:
D20333342
fbshipit-source-id:
7d8db5144a00a5113dfd5c8967dec753f646571d