diff options
author | Omer Strulovich <ostrulovich@fb.com> | 2022-04-06 10:54:24 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-04-06 10:54:24 -0700 |
commit | f19bd22a97f5922168c1c32399c4efaac9ebdc7a (patch) | |
tree | 46a2b03a2a4d558708f2cd6c18ca34a4d8e91f6f /core/src/main/java/com/facebook | |
parent | c7fffbeac65e15a897d6fae09a4ce82bf7cd01be (diff) | |
download | ktfmt-f19bd22a97f5922168c1c32399c4efaac9ebdc7a.tar.gz |
Allow breaking in KtCallableReferenceExpression after ::
Summary: The correct solution should also account for it being in a qualified expression, but for now, let's fix this case.
Reviewed By: hick209
Differential Revision: D35293688
fbshipit-source-id: 823c65fb439c9b1946e82d0e055ebc1949f4b8ed
Diffstat (limited to 'core/src/main/java/com/facebook')
-rw-r--r-- | core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt index da6cc95..324a6f7 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt @@ -2015,20 +2015,24 @@ class KotlinInputAstVisitor( } } + /** Example `String::isNullOrEmpty` */ override fun visitCallableReferenceExpression(expression: KtCallableReferenceExpression) { builder.sync(expression) visit(expression.receiverExpression) - // For some reason, expression.receiverExpression doesn't contain the question-mark - // token in case of a nullable type, e.g., in String?::isNullOrEmpty. - // Instead, KtCallableReferenceExpression exposes a method that looks for the QUEST token in its - // children. + // For some reason, expression.receiverExpression doesn't contain the question-mark token in + // case of a nullable type, e.g., in String?::isNullOrEmpty. + // Instead, KtCallableReferenceExpression exposes a method that looks for the QUEST token in + // its children. if (expression.hasQuestionMarks) { builder.token("?") } - builder.token("::") - visit(expression.callableReference) + builder.block(expressionBreakIndent) { + builder.token("::") + builder.breakOp(Doc.FillMode.INDEPENDENT, "", ZERO) + visit(expression.callableReference) + } } override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) { |