Skip to content

Commit

Permalink
remove psi from BlankLineBeforeDeclarationRule
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroth0 committed Dec 10, 2024
1 parent c8d1a54 commit efd32be
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pinterest.ktlint.ruleset.standard.rules

import com.pinterest.ktlint.rule.engine.core.api.AutocorrectDecision
import com.pinterest.ktlint.rule.engine.core.api.ElementType
import com.pinterest.ktlint.rule.engine.core.api.ElementType.BLOCK
import com.pinterest.ktlint.rule.engine.core.api.ElementType.CLASS
import com.pinterest.ktlint.rule.engine.core.api.ElementType.CLASS_BODY
Expand Down Expand Up @@ -30,10 +31,8 @@ import com.pinterest.ktlint.rule.engine.core.api.nextCodeSibling
import com.pinterest.ktlint.rule.engine.core.api.prevCodeSibling
import com.pinterest.ktlint.rule.engine.core.api.prevLeaf
import com.pinterest.ktlint.rule.engine.core.api.upsertWhitespaceBeforeMe
import com.pinterest.ktlint.rule.engine.core.util.safeAs
import com.pinterest.ktlint.ruleset.standard.StandardRule
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.psi.KtFunctionLiteral
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets

/**
Expand Down Expand Up @@ -181,10 +180,8 @@ public class BlankLineBeforeDeclarationRule :
treeParent
.takeIf { it.elementType == BLOCK && it.treeParent.elementType == FUNCTION_LITERAL }
?.treeParent
?.psi
?.safeAs<KtFunctionLiteral>()
?.bodyExpression
?.node
?.takeIf { it.elementType == ElementType.FUNCTION_LITERAL }
?.findChildByType(ElementType.BLOCK)
?.children()
?.firstOrNull { !it.isWhiteSpace() && !it.isPartOfComment() }

Expand Down

0 comments on commit efd32be

Please sign in to comment.