New J2K: do not ignore long expressions in LiftReturnOrAssignmentInspection in post-processing
This commit is contained in:
@@ -28,12 +28,13 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
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) =
|
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) =
|
||||||
object : KtVisitorVoid() {
|
object : KtVisitorVoid() {
|
||||||
private fun visitIfOrWhenOrTry(expression: KtExpression, keyword: PsiElement) {
|
private fun visitIfOrWhenOrTry(expression: KtExpression, keyword: PsiElement) {
|
||||||
if (expression.lineCount() > LINES_LIMIT) return
|
if (skipLongExpressions && expression.lineCount() > LINES_LIMIT) return
|
||||||
if (expression.isElseIf()) return
|
if (expression.isElseIf()) return
|
||||||
|
|
||||||
val foldableReturns = BranchedFoldingUtils.getFoldableReturns(expression)
|
val foldableReturns = BranchedFoldingUtils.getFoldableReturns(expression)
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ private val processings: List<GeneralPostProcessing> = listOf(
|
|||||||
intentionBasedProcessing(
|
intentionBasedProcessing(
|
||||||
RemoveRedundantCallsOfConversionMethodsIntention()
|
RemoveRedundantCallsOfConversionMethodsIntention()
|
||||||
),
|
),
|
||||||
generalInspectionBasedProcessing(LiftReturnOrAssignmentInspection()),
|
generalInspectionBasedProcessing(LiftReturnOrAssignmentInspection(skipLongExpressions = false)),
|
||||||
generalInspectionBasedProcessing(MayBeConstantInspection()),
|
generalInspectionBasedProcessing(MayBeConstantInspection()),
|
||||||
intentionBasedProcessing(RemoveEmptyPrimaryConstructorIntention()),
|
intentionBasedProcessing(RemoveEmptyPrimaryConstructorIntention()),
|
||||||
diagnosticBasedProcessing(Errors.PLATFORM_CLASS_MAPPED_TO_KOTLIN) { element: KtDotQualifiedExpression, _ ->
|
diagnosticBasedProcessing(Errors.PLATFORM_CLASS_MAPPED_TO_KOTLIN) { element: KtDotQualifiedExpression, _ ->
|
||||||
|
|||||||
Reference in New Issue
Block a user