Skip to content

Commit

Permalink
Simplify breakIntoParts a bit
Browse files Browse the repository at this point in the history
Summary: Applying hick209's recommendation to this function

Reviewed By: hick209

Differential Revision: D35439998

fbshipit-source-id: d976c4933a88a96b3094b429a2477e081cad3c5d
  • Loading branch information
strulovich authored and facebook-github-bot committed Apr 7, 2022
1 parent 7b1d548 commit 46129b6
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,20 +558,17 @@ class KotlinInputAstVisitor(

// use an ArrayDeque and add elements to the beginning so the innermost expression comes first
// foo.bar.yay -> [yay, bar.yay, foo.bar.yay]
parts.addFirst(expression)

var node: KtExpression? = expression
while (node != null) {
parts.addFirst(node)
node =
when (node) {
is KtQualifiedExpression -> node.receiverExpression
is KtArrayAccessExpression -> node.arrayExpression
is KtPostfixExpression -> node.baseExpression
else -> null
}
if (node != null) {
parts.addFirst(node)
}
}

return parts.toList()
Expand Down

0 comments on commit 46129b6

Please # to comment.