New J2K: do not ignore long expressions in LiftReturnOrAssignmentInspection in post-processing

This commit is contained in:
Ilya Kirillov
2019-05-29 13:44:33 +03:00
parent 8fa9b9923f
commit 39dfa631bf
2 changed files with 4 additions and 3 deletions
@@ -28,12 +28,13 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
import org.jetbrains.kotlin.psi.psiUtil.startOffset
class LiftReturnOrAssignmentInspection : AbstractKotlinInspection() {
class LiftReturnOrAssignmentInspection @JvmOverloads constructor(private val skipLongExpressions: Boolean = true) :
AbstractKotlinInspection() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) =
object : KtVisitorVoid() {
private fun visitIfOrWhenOrTry(expression: KtExpression, keyword: PsiElement) {
if (expression.lineCount() > LINES_LIMIT) return
if (skipLongExpressions && expression.lineCount() > LINES_LIMIT) return
if (expression.isElseIf()) return
val foldableReturns = BranchedFoldingUtils.getFoldableReturns(expression)
@@ -133,7 +133,7 @@ private val processings: List<GeneralPostProcessing> = listOf(
intentionBasedProcessing(
RemoveRedundantCallsOfConversionMethodsIntention()
),
generalInspectionBasedProcessing(LiftReturnOrAssignmentInspection()),
generalInspectionBasedProcessing(LiftReturnOrAssignmentInspection(skipLongExpressions = false)),
generalInspectionBasedProcessing(MayBeConstantInspection()),
intentionBasedProcessing(RemoveEmptyPrimaryConstructorIntention()),
diagnosticBasedProcessing(Errors.PLATFORM_CLASS_MAPPED_TO_KOTLIN) { element: KtDotQualifiedExpression, _ ->