-
Notifications
You must be signed in to change notification settings - Fork 38
fix: Avoid tail comments inside tag from being eaten #664
fix: Avoid tail comments inside tag from being eaten #664
Conversation
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.
Some questions in the code.
label = Asttypes.Labelled "children") | ||
in | ||
match maybeChildren with | ||
| None -> () |
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.
Is this not walking the props at all?
What happens if you have props with comments and no children?
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.
Would you give me a hint under what circumstances this would happen? I tested some cases and found children were always there
If there are no children elements inside, there will be Pexp_construct "[]"
in the AST
Labelled "children"
expression (test.res[2,1+2]..[2,1+3])
Pexp_construct "[]" (test.res[2,1+2]..[2,1+3]) ghost
None
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.
How about adding a comment saying just that.
| Some (_, children) -> | ||
let leading, inside, _ = partitionByLoc after children.pexp_loc in | ||
if props = [] then | ||
let afterExpr, _ = |
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.
What happen to the second argument, _
in this case?
Why can it be ignored?
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.
Because it is an empty list.
<A
// comment
// comment
>
</A>
If there are no props, all comments after A
are trailing comments of A
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.
How about adding a comment saying that.
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.
Looks great.
Just asking to add a couple of comments to it's clear the code paths not covered are intentional and not an oversight.
label = Asttypes.Labelled "children") | ||
in | ||
match maybeChildren with | ||
| None -> () |
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.
How about adding a comment saying just that.
| Some (_, children) -> | ||
let leading, inside, _ = partitionByLoc after children.pexp_loc in | ||
if props = [] then | ||
let afterExpr, _ = |
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.
How about adding a comment saying that.
@cristianoc Comments added. |
Closes #663
tweak the output of
jsx
tag