Implement legacy formatting for unknown shape fields
commit8c1b1103b47105ff27c9c0b39a45b25e65422579
authorMichael Tingley <tingley@fb.com>
Wed, 5 Apr 2017 11:43:16 +0000 (5 04:43 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 5 Apr 2017 12:00:07 +0000 (5 05:00 -0700)
treee58d617f018eb84eb0692b84ae237a9a71603e9e
parentc66763fa97eb0896c80b256163cd010b210fc114
Implement legacy formatting for unknown shape fields

Summary:
Supports formatting for unknown shape fields within shapes. In order to support this feature, I had to generalize `list_comma_multi_nl` slightly. I've introduced the new `list_comma_multi_nl_maybe_trail`, to follow the naming convention used with `list_comma_multi_maybe_trail`. The newly-introduced method takes a reduction function of `bool -> env -> bool` in addition to the base case `~trailing`. It uses `list_comma_multi_maybe_trail` (which itself takes a reduction function as an argument), passing in the reduction function, which is used to determine whether or not a formatted list should have a trailing comma.

For cleanliness, I've rewritten the existing `list_comma_multi_nl`, which is expressible in terms of the new `list_comma_multi_nl_maybe_trail`.

Reviewed By: eshrews

Differential Revision: D4645959

fbshipit-source-id: ed25fe2cba16ed3cabe8bedebfcb79eac11ac241
hphp/hack/src/format/format_hack.ml
hphp/hack/test/typecheck/shape/shape_typedef_with_known_and_unknown_fields.php