add command to report all TAST `Holes` for a given fils
Summary:
As part of a codemod for the proposed `unsafe_cast` migration, we would like to access subtyping / coercion error information using `HackAst`. The initial approach to this was to provide a command (`--type-error-at-pos`) which operated in a similar manner to `--type-at-pos` which provided an API to call from `HackAst` for a given expression. The workflow was then:
i) Find all expressions with a covering fixmes
ii) Call `--type-error-at-pos` for each subexpression
iii) Modify expression if `Hole` was found
This diff adds a command `--tast-holes` which will be used to provide _all_ `Hole`s on the TAST and their positions at once, i.e.
i) Call `--tast-holes`
ii) Find largest expression exactly contained in each Hole
iii) Modify expression
This approach leads to fewer calls to `hh` and has the benefit of handling corner cases arising in `HackClient` due to using positional information to find `Hole`s. In particular, this approach will allow us to correctly handle `Hole`s on an expression and a constituent subexpression which have the same start position e.g.
```
function foo(bool $x): string {
/* HH_FIXME[4110] */
return $x + 1 ? '1' : 1;
}
```
```
Hole
( ( ([5:10-26], (int | string))
, Eif
( ( ([5:10-16], int)
, Binop
( Plus
, ( ([5:10-12], bool)
, Hole
( (([5:10-12], bool), (Lvar ([5:10-12], $x)))
, bool
, num
, Typing
)
)
, (([5:15-16], int), (Int "1"))
)
)
, (Some (([5:19-22], string), String "1"))
, ( ([5:25-26], int), Int "1")
)
)
, (int | string)
, string
, Typing
)
```
Reviewed By: madgen
Differential Revision:
D28091408
fbshipit-source-id:
868b115b9d0b3471e439a5e1d4e4dddb04cf1406