-
Notifications
You must be signed in to change notification settings - Fork 140
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
Pretty print statements #1280
Pretty print statements #1280
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1280 +/- ##
==========================================
+ Coverage 77.22% 77.35% +0.12%
==========================================
Files 278 278
Lines 35814 35932 +118
==========================================
+ Hits 27659 27796 +137
+ Misses 7069 7050 -19
Partials 1086 1086
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit 7091617 Results
|
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.
Nice!
const forStatementSpaceInKeywordSpaceDoc = prettier.Text(" in ") | ||
|
||
func (s *ForStatement) Doc() prettier.Doc { | ||
doc := prettier.Concat{ |
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.
need this concat?
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.
Yes, we always need the concatenation, as https://github.com/onflow/cadence/pull/1280/files#diff-cb6a372e592ff206bc8f5ad13e85ba6527d1e6914f281f0dd263479c7f3a278eR350 always appends more after the conditionally appended index (https://github.com/onflow/cadence/pull/1280/files#diff-cb6a372e592ff206bc8f5ad13e85ba6527d1e6914f281f0dd263479c7f3a278eR342)
} | ||
|
||
if s.Index != nil { | ||
doc = append( |
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 there a difference between using an array (append) vs prettier.Concat{}
?
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.
prettier.Concat
is a prettier document, but is also just a slice of documents, so we can use the Go append
to add to it
Work towards #209
Description
Implement pretty-printing functions for all statement AST nodes:
ReturnStatement
BreakStatement
ContinueStatement
IfStatement
WhileStatement
ForStatement
EmitStatement
AssignmentStatement
SwapStatement
ExpressionStatement
Also:
master
branchFiles changed
in the Github PR explorer