Skip to content

Commit

Permalink
Use inExpression in a nullsafe way
Browse files Browse the repository at this point in the history
  • Loading branch information
nreid260 committed Sep 13, 2023
1 parent 2c36ddb commit be69526
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ class KotlinInputAstVisitor(
* @throws FormattingError
*/
override fun visitElement(element: PsiElement) {
inExpression.addLast(element is KtExpression || inExpression.peekLast())
inExpression.addLast(element is KtExpression || inExpression.last())
val previous = builder.depth()
try {
super.visitElement(element)
Expand Down Expand Up @@ -2430,10 +2430,6 @@ class KotlinInputAstVisitor(
markForPartialFormat()
}

private fun inExpression(): Boolean {
return inExpression.peekLast()
}

/**
* markForPartialFormat is used to delineate the smallest areas of code that must be formatted
* together.
Expand All @@ -2442,7 +2438,7 @@ class KotlinInputAstVisitor(
* covered by an area marked by this method.
*/
private fun markForPartialFormat() {
if (!inExpression()) {
if (!inExpression.last()) {
builder.markForPartialFormat()
}
}
Expand Down

0 comments on commit be69526

Please sign in to comment.