[kotlin-dfa] Merge util.kt into KtDfaHelpers.kt

Preparatory step for KTIJ-28908 Convert "Constant conditions" inspection to K2

GitOrigin-RevId: 3199cae9b73d29269d4a998c588cc5ad91d69a3c
This commit is contained in:
Tagir Valeev
2024-02-23 14:37:52 +01:00
committed by intellij-monorepo-bot
parent 82adcad423
commit d7501472cd
2 changed files with 9 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.StandardNames.FqNames
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.caches.resolve.safeAnalyzeNonSourceRootCode
import org.jetbrains.kotlin.idea.codeInsight.hints.RangeKtExpressionType
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.bindingContextUtil.getAbbreviatedTypeOrType
@@ -263,4 +264,11 @@ internal fun getInlineableLambda(expr: KtCallExpression): LambdaAndParameter? {
return LambdaAndParameter(lambdaExpression, parameterDescriptor)
}
internal data class LambdaAndParameter(val lambda: KtLambdaExpression, val descriptor: ValueParameterDescriptor)
internal data class LambdaAndParameter(val lambda: KtLambdaExpression, val descriptor: ValueParameterDescriptor)
internal fun RangeKtExpressionType.getRelationType() =
when (this) {
RangeKtExpressionType.RANGE_TO -> RelationType.GE to RelationType.LE
RangeKtExpressionType.RANGE_UNTIL, RangeKtExpressionType.UNTIL -> RelationType.GE to RelationType.LT
RangeKtExpressionType.DOWN_TO -> RelationType.LE to RelationType.GE
}

View File

@@ -1,13 +0,0 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.inspections.dfa
import com.intellij.codeInspection.dataFlow.value.RelationType
import org.jetbrains.kotlin.idea.codeInsight.hints.RangeKtExpressionType
import org.jetbrains.kotlin.idea.codeInsight.hints.RangeKtExpressionType.*
fun RangeKtExpressionType.getRelationType() =
when (this) {
RANGE_TO -> RelationType.GE to RelationType.LE
RANGE_UNTIL, UNTIL -> RelationType.GE to RelationType.LT
DOWN_TO -> RelationType.LE to RelationType.GE
}