-
Notifications
You must be signed in to change notification settings - Fork 464
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
70
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.
+1,695
−1,251
Draft
Jsx ast #7286
Changes from 7 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
db7eee6
Intial exploration of JSX ast
nojaf 28aa287
Initial mapping from0
nojaf b57f2df
Format code
nojaf 32161a3
Merge branch 'master' into jsx-ast
nojaf d714829
Fix jsx fragment mapping
nojaf e27b339
Remove fragment
nojaf 92657ee
Update test output
nojaf 441de6e
Introducing Pexp_jsx_unary_element & Pexp_jsx_container_element
nojaf bf1b411
Refactor fragment transformation.
nojaf 5fe5f12
Initial transform of Pexp_jsx_unary_element in automatic mode
nojaf 9251609
Make props for unary element in automatic mode.
nojaf 1aaa686
Initial custom component unary tag
nojaf b374212
lowercase container element with children.
nojaf c91aeda
Uppercase container elements
nojaf 85ccab4
Streamline automatic element calls
nojaf 86c9f5f
lowercase container element in classic mode
nojaf 0dfd5b6
Deal with uppercase tags in classic mode.
nojaf 203ff25
Remove old code
nojaf a273f2e
Improve recovery of incomplete jsx tags.
nojaf 998edbe
Correct range of incomplete jsx elements
nojaf fcf2d90
Update semantic tokens
nojaf 162b7a2
Make the closing tag optional for jsx_container_element.
nojaf 9b815a0
Add tighter pattern match for edge case in jsx props completion.
nojaf 9408d06
Update analysis tests for jsx elements ast.
nojaf cc5beb4
print_jsx_unary_tag
nojaf 02e9fc9
Merge branch 'master' into jsx-ast
nojaf 5e060ea
Rough print_jsx_container_tag
nojaf e57ab30
Add ml printing
nojaf b6407d0
Wing the sexp thing
nojaf e565ca7
First step towards ast mapping
nojaf 84e9cbe
prop punning conversion
nojaf bbfe816
Map prop value
nojaf 63fc87b
Map prop spreading
nojaf d6c9fa8
Initial container element mapping.
nojaf e446ae1
Try support children spreading
nojaf 5fef337
Only print space when there are props
nojaf 251244b
Add space after children.
nojaf aec0d8e
Restore braces in props and children
nojaf 6a3f4c9
Inline is_jsx_expression and remove old code
nojaf 506dda3
Better indentation of children
nojaf 96839f4
Handle unary tag
shulhi ff1bb65
Refactor
shulhi 91c283e
WIP: Fix unary tag comments handling
shulhi 2b9b5ce
Fix comments inside prop expression
shulhi 0133f91
Formats
shulhi aaef8ac
Fix closing tag indentation
shulhi b863888
Fix closing tag indentation for cases with break vs inline
shulhi 7f8bf01
Handle some edge cases
shulhi 4e0951c
Refactor
shulhi 7843795
Merge pull request #3 from shulhi/shulhi-jsx-ast
nojaf 9e68c1a
WIP: Handle punning
shulhi 53616a7
Fix optional printing with braces
shulhi 25e20b8
WIP: Handle comments attachment in a different way
shulhi ad72bf2
Handle empty props
shulhi 7ba4996
Handle props spread
shulhi f09cd70
Fix optional with punning
shulhi aa1d978
Merge pull request #4 from shulhi/shulhi-jsx-ast-2
nojaf 0ee7601
Indent props if they don't fit on one line.
nojaf bd45146
Fix indentation of children when props are multiline.
nojaf 2d50ff8
Refactor to Pexp_jsx_element
nojaf fcabcff
Merge branch 'master' into jsx-ast
nojaf ddcdaa2
Don't always append make when uppercase component
nojaf 52ecf03
Use Doc.line for child spreading
nojaf cd9059f
Exotic prop name
nojaf 2e9fb66
Don't create record if only spreading prop, use that expression instead.
nojaf 37755ae
Key prop can be optional
nojaf 3a434c9
Keep comment after opening greater than
nojaf 6cf1e71
Print prop value with comments
nojaf ae9b428
Update generic jsx completion tests
nojaf f3b96df
Revert isJsxComponent
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
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.
@shulhi I struggle a bit to grasp this part.
What should happen in the follow scenario:
Is
// comment
linked to"hey"
or the entirebar="hey"
expression?The loc created here is combining the prop name and value but is further processed with only the value expression?
This feel off, is this by design? If so, I assume you then compensate for this in
res_printer
?Would it not make more sense to either introduce a new node type or create a helper function and process the three parts (entire prop, prop name & prop value)?
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.
Initially I had it attached to just the property (i.e.
bar
) instead of the whole expression but it doesn't work well especially for multiline expression. Attaching it to the whole thing seems to work better.This is compensated in the printer. Technically, we can still attach it to just the property, but we still have to compensate for the comment printing or add additional logic to cater for multiline expression or other edge cases. This approach seems like a better trade off at that point.
I think a helper function should work. A new node type would work in the future to improve the comment printing.