-
Notifications
You must be signed in to change notification settings - Fork 456
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
Jsx ast #7286
Draft
nojaf
wants to merge
19
commits into
rescript-lang:master
Choose a base branch
from
nojaf:jsx-ast
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Jsx ast #7286
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a65d7ed
Intial exploration of JSX ast
nojaf d3c4f6e
Map child expressions
nojaf 3b0018d
Initial mapping of Pexp_jsx_fragment to 0
nojaf 019c31d
Correct location in mapping
nojaf e0caf83
Update analysis for jsx_fragment
nojaf a68fbed
Remove unused code
nojaf a528c1d
Print something for ml print
nojaf 58ea87c
Commit invalid test results for reference
nojaf bd5d4f1
Try improve printing
nojaf 26cee66
Correct fragment range, try and print comments
nojaf 239f653
Merge branch 'master' into jsx-ast
nojaf fc6f950
Indent jsx
nojaf c9102e1
Process comments from children inside fragment
nojaf 7550b73
Attach comments to fragment tags
nojaf 90bfe45
Fix comment
shulhi 5b9b2ff
Merge pull request #1 from shulhi/fix-comment
nojaf 9a99fc3
Improve comment formatting
nojaf 392d4dd
Print single element on same line
nojaf ff113ce
Update comment
nojaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1508,7 +1508,19 @@ and walk_expression expr t comments = | |
attach t.leading return_expr.pexp_loc leading; | ||
walk_expression return_expr t inside; | ||
attach t.trailing return_expr.pexp_loc trailing) | ||
| _ -> () | ||
| Pexp_jsx_fragment (opening_greater_than, exprs, closing_lesser_than) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shulhi comments are now printed too many times. I basically want to attach them to either |
||
let opening_token = {expr.pexp_loc with loc_end = opening_greater_than} in | ||
(* leading comments should be attached to the entire node *) | ||
let _leading, trailing = | ||
partition_leading_trailing comments opening_token | ||
in | ||
attach t.trailing opening_token trailing; | ||
walk_list (exprs |> List.map (fun e -> Expression e)) t comments; | ||
let closing_token = {expr.pexp_loc with loc_start = closing_lesser_than} in | ||
let leading, trailing = partition_leading_trailing comments closing_token in | ||
attach t.leading closing_token leading; | ||
attach t.trailing closing_token trailing | ||
| Pexp_send _ -> () | ||
|
||
and walk_expr_parameter (_attrs, _argLbl, expr_opt, pattern) t comments = | ||
let leading, inside, trailing = partition_by_loc comments pattern.ppat_loc in | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The reason the store the
>
and</
token is this edge case:https://rescript-lang.org/try?version=v12.0.0-alpha.8&module=esmodule&code=DYUwLgBA+hC8ECgCQAeCB6AVBAzmATgIYB2A5iBJuhAHzJIDeASiIQMZgB0e+AlmQAoARAFsQACyEBKAL7IU1LBEIiIASQh9S4yFVpA
If we ever want to restore comments I suppose we need the proper anchors.