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
For --google_style, break between ( and long condition expressions #325
Conversation
3b526b9
to
4ce0ae6
Compare
Importing for easier review |
@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
private fun emitKeywordWithCondition(keyword: String, condition: KtExpression?) { | ||
if (condition == null) { | ||
builder.token(keyword) | ||
return | ||
} | ||
|
||
builder.block(ZERO) { | ||
builder.token(keyword) | ||
builder.space() | ||
builder.token("(") | ||
if (isGoogleStyle) { | ||
builder.block(expressionBreakIndent) { | ||
builder.breakOp(Doc.FillMode.UNIFIED, "", ZERO) | ||
visit(condition) | ||
builder.breakOp(Doc.FillMode.UNIFIED, "", expressionBreakNegativeIndent) | ||
} | ||
} else { | ||
builder.block(ZERO) { | ||
visit(condition) | ||
} | ||
} | ||
} | ||
builder.token(")") | ||
} | ||
|
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.
We organize methods by chronological order if possible, so caller before callee. Could you move these below all callers?
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.
Done
@@ -698,6 +698,31 @@ class KotlinInputAstVisitor( | |||
return extractCallExpression(this)?.lambdaArguments?.isNotEmpty() ?: false | |||
} | |||
|
|||
private fun emitKeywordWithCondition(keyword: String, condition: KtExpression?) { |
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.
Please add a KDoc.
We usually state example of the content this parses, so something alike:
/** Emits a key word followed by a condition, e.g. `if (b)` or `while (c <d )` */
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.
Done
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.
Thanks!
@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Fixes #319