-
Notifications
You must be signed in to change notification settings - Fork 14
Add layout annotations #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add layout annotations #42
Conversation
8bee6d5
to
302a440
Compare
This PR is ready for review. It consists of the following changes:
Review suggestion: @goldfirere? |
ec7fac8
to
7f5f434
Compare
Rebased this PR over all the new changes |
21fd82a
to
4bb9282
Compare
Tip of |
7f5f434
to
f82adb5
Compare
lib/Fmt_ast.ml
Outdated
Cmts.relocate c.cmts ~src:pexp_loc ~before ~after:e.pexp_loc ; | ||
Cmts.relocate c.cmts ~src:pexp_loc ~before:before_name | ||
~after:e.pexp_loc ; | ||
Option.iter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new Cmts.relocate
supersedes the previous one, right? Then I think it would be cleaner to just have a match before_layout_opt with ...
that either does one relocate
call or the other. As it is, I've stared at this for 5 minutes and I'm still not sure exactly what's going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I over-complicated the logic here and there's no need for the call to Cmts.relocate
inside the Option.iter
. Relocating the comments to before the tyvar name should be enough.
lib/Fmt_ast.ml
Outdated
@@ -3525,17 +3563,17 @@ and fmt_tydcl_param c ctx ty = | |||
here. *) | |||
match ty.ptyp_attributes with | |||
| [] | _ :: _ :: _ -> noop | |||
| [attr] -> fmt_if_k (is_layout attr) (fmt "@ :@ " $ str attr.attr_name.txt) | |||
| [attr] -> fmt_if_k (is_layout attr) (fmt_layout_attr c attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (?) this shouldn't be necessary any more. It rewrites something like
type 'a [@immediate] t
to
type ('a : immediate) t
But we've stopped accepting the previous syntax for a little while. So I think this extra logic can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this extra logic together with the bit in fmt_core_type
. It doesn't seem to break any of the tests and a quick grep search doesn't show any occurrences of the old syntax in jane.
Signed-off-by: alanechang <alanechang@janestreet.com> other diffs Signed-off-by: alanechang <alanechang@janestreet.com> jane syntax diff Signed-off-by: alanechang <alanechang@janestreet.com> ast helper diff Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> copy paste Signed-off-by: alanechang <alanechang@janestreet.com> add match_jane_syntax_piece Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> parser standard updated Signed-off-by: alanechang <alanechang@janestreet.com> fix parser Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> wip Signed-off-by: alanechang <alanechang@janestreet.com> building now Signed-off-by: alanechang <alanechang@janestreet.com> fix format Signed-off-by: alanechang <alanechang@janestreet.com> fix format Signed-off-by: alanechang <alanechang@janestreet.com> fix up paren Signed-off-by: alanechang <alanechang@janestreet.com> new layout annot for type decl Signed-off-by: alanechang <alanechang@janestreet.com> add new test Signed-off-by: alanechang <alanechang@janestreet.com> new layout annot on type decl Signed-off-by: alanechang <alanechang@janestreet.com> fix paren Signed-off-by: alanechang <alanechang@janestreet.com> remove extra paren Signed-off-by: alanechang <alanechang@janestreet.com> test changes Signed-off-by: alanechang <alanechang@janestreet.com> handle layout annot and attr differently Signed-off-by: alanechang <alanechang@janestreet.com> test changes Signed-off-by: alanechang <alanechang@janestreet.com> diff changes Signed-off-by: alanechang <alanechang@janestreet.com> parenize in more ctx Signed-off-by: alanechang <alanechang@janestreet.com> remove cr Signed-off-by: alanechang <alanechang@janestreet.com> clean up newtype Signed-off-by: alanechang <alanechang@janestreet.com> test and diff Signed-off-by: alanechang <alanechang@janestreet.com> fix comment bug Signed-off-by: alanechang <alanechang@janestreet.com> add missing map Signed-off-by: alanechang <alanechang@janestreet.com> refactor Signed-off-by: alanechang <alanechang@janestreet.com> more clean up Signed-off-by: alanechang <alanechang@janestreet.com> test change Signed-off-by: alanechang <alanechang@janestreet.com> reduce diff Signed-off-by: alanechang <alanechang@janestreet.com> less diff Signed-off-by: alanechang <alanechang@janestreet.com> new patch Signed-off-by: alanechang <alanechang@janestreet.com> add new line Signed-off-by: alanechang <alanechang@janestreet.com> patch diff Signed-off-by: alanechang <alanechang@janestreet.com> more tests Signed-off-by: alanechang <alanechang@janestreet.com>
Signed-off-by: alanechang <alanechang@janestreet.com>
Signed-off-by: alanechang <alanechang@janestreet.com>
Signed-off-by: alanechang <alanechang@janestreet.com>
Signed-off-by: alanechang <alanechang@janestreet.com>
Signed-off-by: alanechang <alanechang@janestreet.com>
4387993
to
c9ccbb2
Compare
Had to rebase to fix the CI. I added two new commits:
|
No description provided.