Add helpers for getting commonly used services without an opt-in
These services are LanguageVersionSettings, DataFlowValueFactory #KT-39643 Fixed
This commit is contained in:
+2
-6
@@ -9,10 +9,9 @@ import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
@@ -45,10 +44,7 @@ class ExtractableSubstringInfo(
|
||||
|
||||
val tempContext = expr.analyzeInContext(scope, template)
|
||||
val trace = DelegatingBindingTrace(tempContext, "Evaluate '$literal'")
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val languageVersionSettings = facade.getFrontendService(LanguageVersionSettings::class.java)
|
||||
|
||||
val languageVersionSettings = facade.getLanguageVersionSettings()
|
||||
val value = ConstantExpressionEvaluator(module, languageVersionSettings, facade.project).evaluateExpression(expr, trace)
|
||||
if (value == null || value.isError) return stringType
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
|
||||
/**
|
||||
* Helper methods for commonly used frontend components.
|
||||
* Use them to avoid explicit opt-ins.
|
||||
* Before adding a new helper method please make sure component doesn't have fragile invariants that can be violated by external use.
|
||||
*/
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
fun ResolutionFacade.getLanguageVersionSettings(): LanguageVersionSettings =
|
||||
frontendService<LanguageVersionSettings>()
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
fun ResolutionFacade.getDataFlowValueFactory(): DataFlowValueFactory =
|
||||
frontendService<DataFlowValueFactory>()
|
||||
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
|
||||
@@ -252,8 +254,7 @@ fun CallTypeAndReceiver<*, *>.receiverTypesWithIndex(
|
||||
stableSmartCastsOnly: Boolean,
|
||||
withImplicitReceiversWhenExplicitPresent: Boolean = false
|
||||
): List<ReceiverType>? {
|
||||
@OptIn(FrontendInternals::class)
|
||||
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
|
||||
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
|
||||
|
||||
val receiverExpression: KtExpression?
|
||||
when (this) {
|
||||
@@ -356,8 +357,8 @@ private fun receiverValueTypes(
|
||||
stableSmartCastsOnly: Boolean,
|
||||
resolutionFacade: ResolutionFacade
|
||||
): List<KotlinType> {
|
||||
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
|
||||
val dataFlowValueFactory = resolutionFacade.frontendService<DataFlowValueFactory>()
|
||||
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
|
||||
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
|
||||
val smartCastManager = resolutionFacade.frontendService<SmartCastManager>()
|
||||
val dataFlowValue = dataFlowValueFactory.createDataFlowValue(receiverValue, bindingContext, moduleDescriptor)
|
||||
return if (dataFlowValue.isStable || !stableSmartCastsOnly) { // we don't include smart cast receiver types for "unstable" receiver value to mark members grayed
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
||||
@@ -19,7 +21,6 @@ import org.jetbrains.kotlin.resolve.calls.CallResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.ExplicitImportsScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
@@ -97,7 +98,6 @@ class ShadowedDeclarationsFilter(
|
||||
|
||||
private fun packageName(descriptor: DeclarationDescriptor) = descriptor.importableFqName?.parent()
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
private fun <TDescriptor : DeclarationDescriptor> filterEqualSignatureGroup(
|
||||
descriptors: Collection<TDescriptor>,
|
||||
descriptorsToImport: Collection<TDescriptor> = emptyList()
|
||||
@@ -194,9 +194,11 @@ class ShadowedDeclarationsFilter(
|
||||
val context = BasicCallResolutionContext.create(
|
||||
bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo,
|
||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
false, /* languageVersionSettings */ resolutionFacade.frontendService(),
|
||||
resolutionFacade.frontendService<DataFlowValueFactory>()
|
||||
false, resolutionFacade.getLanguageVersionSettings(),
|
||||
resolutionFacade.getDataFlowValueFactory()
|
||||
)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||
val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context)
|
||||
val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor }
|
||||
|
||||
@@ -10,9 +10,8 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -35,8 +34,7 @@ class SmartCastCalculator(
|
||||
receiver: KtExpression?,
|
||||
resolutionFacade: ResolutionFacade
|
||||
) {
|
||||
@OptIn(FrontendInternals::class)
|
||||
private val dataFlowValueFactory = resolutionFacade.frontendService<DataFlowValueFactory>()
|
||||
private val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
|
||||
|
||||
// keys are VariableDescriptor's and ThisReceiver's
|
||||
private val entityToSmartCastInfo: Map<Any, SmartCastInfo> = processDataFlowInfo(
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.references.resolveToDescriptors
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstanceToExpression
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -101,7 +103,6 @@ fun KtImportDirective.targetDescriptors(resolutionFacade: ResolutionFacade = thi
|
||||
return nameExpression.mainReference.resolveToDescriptors(resolutionFacade.analyze(nameExpression))
|
||||
}
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
fun Call.resolveCandidates(
|
||||
bindingContext: BindingContext,
|
||||
resolutionFacade: ResolutionFacade,
|
||||
@@ -117,9 +118,11 @@ fun Call.resolveCandidates(
|
||||
val callResolutionContext = BasicCallResolutionContext.create(
|
||||
bindingTrace, resolutionScope, this, expectedType, dataFlowInfo,
|
||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
false, resolutionFacade.frontendService(),
|
||||
resolutionFacade.frontendService()
|
||||
false, resolutionFacade.getLanguageVersionSettings(),
|
||||
resolutionFacade.getDataFlowValueFactory()
|
||||
).replaceCollectAllCandidates(true)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val callResolver = resolutionFacade.frontendService<CallResolver>()
|
||||
|
||||
val results = callResolver.resolveFunctionCall(callResolutionContext)
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.idea.util.hasJvmFieldAnnotation
|
||||
import org.jetbrains.kotlin.idea.util.isExpectDeclaration
|
||||
@@ -127,7 +128,7 @@ fun KtCallExpression.canMoveLambdaOutsideParentheses(): Boolean {
|
||||
val resolutionFacade = getResolutionFacade()
|
||||
val samConversionTransformer = resolutionFacade.frontendService<SamConversionResolver>()
|
||||
val samConversionOracle = resolutionFacade.frontendService<SamConversionOracle>()
|
||||
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
|
||||
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
|
||||
|
||||
val bindingContext = analyze(resolutionFacade, BodyResolveMode.PARTIAL)
|
||||
val targets = bindingContext[BindingContext.REFERENCE_TARGET, callee]?.let { listOf(it) }
|
||||
|
||||
@@ -13,14 +13,13 @@ import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
@@ -35,7 +34,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getParameterForArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||
@@ -114,8 +112,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
|
||||
|
||||
val result = expressionType?.let { typeRenderer.renderType(it) } ?: return KotlinBundle.message("type.provider.unknown.type")
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = element.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = element.getResolutionFacade().getDataFlowValueFactory()
|
||||
val dataFlowValue =
|
||||
dataFlowValueFactory.createDataFlowValue(element, expressionType, bindingContext, element.findModuleDescriptor())
|
||||
val types = expressionTypeInfo.dataFlowInfo.getStableTypes(dataFlowValue, element.languageVersionSettings)
|
||||
|
||||
+2
-5
@@ -16,18 +16,17 @@ import com.intellij.ui.EditorTextField
|
||||
import org.intellij.lang.regexp.RegExpFileType
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.KtVisitorVoid
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.isNullabilityFlexible
|
||||
import org.jetbrains.kotlin.types.isNullable
|
||||
@@ -74,9 +73,7 @@ class PlatformExtensionReceiverOfInlineInspection : AbstractKotlinInspection() {
|
||||
if (!descriptor.isInline || descriptor.extensionReceiverParameter?.type?.isNullable() == true) return
|
||||
|
||||
val receiverExpression = expression.receiverExpression
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = resolutionFacade.getFrontendService(DataFlowValueFactory::class.java)
|
||||
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
|
||||
val dataFlow = dataFlowValueFactory.createDataFlowValue(receiverExpression, extensionReceiverType, context, descriptor)
|
||||
val stableNullability = context.getDataFlowInfoBefore(receiverExpression).getStableNullability(dataFlow)
|
||||
if (!stableNullability.canBeNull()) return
|
||||
|
||||
+2
-4
@@ -11,13 +11,13 @@ import com.intellij.codeInspection.ProblemHighlightType
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isNullable
|
||||
@@ -57,7 +56,6 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
|
||||
)
|
||||
})
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
private fun KtReferenceExpression.isNullable(
|
||||
descriptor: CallableDescriptor,
|
||||
type: KotlinType,
|
||||
@@ -65,7 +63,7 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
|
||||
resolutionFacade: ResolutionFacade,
|
||||
): Boolean {
|
||||
if (!type.isNullable()) return false
|
||||
val dataFlowValueFactory = resolutionFacade.getFrontendService(DataFlowValueFactory::class.java)
|
||||
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
|
||||
val dataFlow = dataFlowValueFactory.createDataFlowValue(this, type, context, descriptor)
|
||||
val stableTypes = context.getDataFlowInfoBefore(this).getStableTypes(dataFlow, this.languageVersionSettings)
|
||||
return stableTypes.none { !it.isNullable() }
|
||||
|
||||
+2
-4
@@ -23,7 +23,6 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.containingDeclarationForPseudocode
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.analysis.analyzeAsReplacement
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -38,6 +37,7 @@ import org.jetbrains.kotlin.idea.intentions.isOperatorOrCompatible
|
||||
import org.jetbrains.kotlin.idea.intentions.isReceiverExpressionWithValue
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.project.platform
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.util.calleeTextRangeInThis
|
||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -50,7 +50,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getKotlinTypeWithPossibleSmartCastToFP
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -202,13 +201,12 @@ class ReplaceCallWithBinaryOperatorInspection : AbstractApplicabilityBasedInspec
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
private fun KtDotQualifiedExpression.isFloatingPointNumberEquals(): Boolean {
|
||||
val resolvedCall = resolveToCall() ?: return false
|
||||
val resolutionFacade = getResolutionFacade()
|
||||
val context = analyze(resolutionFacade, BodyResolveMode.PARTIAL)
|
||||
val declarationDescriptor = containingDeclarationForPseudocode?.resolveToDescriptorIfAny()
|
||||
val dataFlowValueFactory = resolutionFacade.getFrontendService(DataFlowValueFactory::class.java)
|
||||
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
|
||||
val defaultType: (KotlinType, Set<KotlinType>) -> KotlinType = { givenType, stableTypes -> stableTypes.firstOrNull() ?: givenType }
|
||||
val receiverType = resolvedCall.getReceiverExpression()?.getKotlinTypeWithPossibleSmartCastToFP(
|
||||
context, declarationDescriptor, languageVersionSettings, dataFlowValueFactory, defaultType
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.idea.util.shouldNotConvertToProperty
|
||||
@@ -224,7 +226,6 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
||||
return property.name
|
||||
}
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
private fun checkWillResolveToProperty(
|
||||
resolvedCall: ResolvedCall<out CallableDescriptor>,
|
||||
property: SyntheticJavaPropertyDescriptor,
|
||||
@@ -248,10 +249,11 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
||||
val context = BasicCallResolutionContext.create(
|
||||
bindingTrace, resolutionScope, newCall, expectedType, dataFlowInfo,
|
||||
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
|
||||
false, facade.frontendService<LanguageVersionSettings>(),
|
||||
facade.frontendService<DataFlowValueFactory>()
|
||||
false, facade.getLanguageVersionSettings(),
|
||||
facade.getDataFlowValueFactory()
|
||||
)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val callResolver = facade.frontendService<CallResolver>()
|
||||
val result = callResolver.resolveSimpleProperty(context)
|
||||
return result.isSuccess && result.resultingDescriptor.original == property
|
||||
|
||||
+2
-6
@@ -8,12 +8,10 @@ package org.jetbrains.kotlin.idea.intentions.branchedTransformations
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.TransactionGuard
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.search.LocalSearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
@@ -25,7 +23,7 @@ import org.jetbrains.kotlin.idea.intentions.replaceFirstReceiver
|
||||
import org.jetbrains.kotlin.idea.refactoring.inline.KotlinInlineValHandler
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.idea.util.textRangeIn
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
@@ -41,7 +39,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.findVariable
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -194,10 +191,9 @@ fun KtExpression.isStableVal(context: BindingContext = this.analyze()): Boolean
|
||||
|
||||
fun elvisPattern(newLine: Boolean): String = if (newLine) "$0\n?: $1" else "$0 ?: $1"
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
private fun KtExpression.toDataFlowValue(context: BindingContext): DataFlowValue? {
|
||||
val expressionType = this.getType(context) ?: return null
|
||||
val dataFlowValueFactory = this.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = this.getResolutionFacade().getDataFlowValueFactory()
|
||||
return dataFlowValueFactory.createDataFlowValue(this, expressionType, context, findModuleDescriptor())
|
||||
}
|
||||
|
||||
|
||||
@@ -30,20 +30,18 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.UNSAFE_CALL
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isNullExpression
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -139,8 +137,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo
|
||||
context[BindingContext.EXPRESSION_TYPE_INFO, psiElement]?.let {
|
||||
val type = it.type
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = psiElement.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = psiElement.getResolutionFacade().getDataFlowValueFactory()
|
||||
|
||||
if (type != null) {
|
||||
val nullability = it.dataFlowInfo.getStableNullability(
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
@@ -130,7 +131,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
): LexicalScope? {
|
||||
val module = resolutionFacade.moduleDescriptor
|
||||
val explicitImportsScope = buildExplicitImportsScope(annotation, resolutionFacade, module)
|
||||
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
|
||||
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
|
||||
val defaultImportsScopes = buildDefaultImportsScopes(resolutionFacade, module, languageVersionSettings)
|
||||
|
||||
return getResolutionScope(
|
||||
|
||||
+2
-5
@@ -24,7 +24,6 @@ import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
@@ -33,7 +32,7 @@ import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.ExtractableSubstringInfo
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractableSubstringInfo
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.substringContextOrThis
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiRange
|
||||
@@ -48,7 +47,6 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.hasBothReceivers
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isSynthesizedInvoke
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
@@ -184,8 +182,7 @@ data class ExtractionData(
|
||||
}
|
||||
|
||||
private fun getPossibleTypes(expression: KtExpression, resolvedCall: ResolvedCall<*>?, context: BindingContext): Set<KotlinType> {
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = expression.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = expression.getResolutionFacade().getDataFlowValueFactory()
|
||||
val dataFlowInfo = context.getDataFlowInfoAfter(expression)
|
||||
|
||||
resolvedCall?.getImplicitReceiverValue()?.let {
|
||||
|
||||
+2
-5
@@ -27,13 +27,12 @@ import org.jetbrains.kotlin.cfg.pseudocode.getExpectedTypePredicate
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithReceivers
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.lexer.KtToken
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -387,9 +386,7 @@ private fun suggestParameterType(
|
||||
val typeByDataFlowInfo = if (useSmartCastsIfPossible) {
|
||||
val callElement = resolvedCall!!.call.callElement
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfoAfter(callElement)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = callElement.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = callElement.getResolutionFacade().getDataFlowValueFactory()
|
||||
val possibleTypes = dataFlowInfo.getCollectedTypes(
|
||||
dataFlowValueFactory.createDataFlowValueForStableReceiver(receiverToExtract),
|
||||
callElement.languageVersionSettings
|
||||
|
||||
@@ -7,9 +7,7 @@ package org.jetbrains.kotlin.idea.util
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
@@ -18,7 +16,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.idea.project.TargetPlatformDetector
|
||||
import org.jetbrains.kotlin.idea.project.findAnalyzerServices
|
||||
import org.jetbrains.kotlin.idea.refactoring.fqName.isImported
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -47,9 +45,8 @@ class ImportInsertHelperImpl(private val project: Project) : ImportInsertHelper(
|
||||
override val importSortComparator: Comparator<ImportPath>
|
||||
get() = ImportPathComparator(codeStyleSettings.PACKAGES_IMPORT_LAYOUT)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
override fun isImportedWithDefault(importPath: ImportPath, contextFile: KtFile): Boolean {
|
||||
val languageVersionSettings = contextFile.getResolutionFacade().frontendService<LanguageVersionSettings>()
|
||||
val languageVersionSettings = contextFile.getResolutionFacade().getLanguageVersionSettings()
|
||||
val platform = TargetPlatformDetector.getPlatform(contextFile)
|
||||
val analyzerServices = platform.findAnalyzerServices(contextFile.project)
|
||||
val allDefaultImports = analyzerServices.getDefaultImports(languageVersionSettings, includeLowPriorityImports = true)
|
||||
|
||||
@@ -19,20 +19,19 @@ package org.jetbrains.kotlin.idea.util
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
@@ -60,8 +59,7 @@ fun getDataFlowAwareTypes(
|
||||
if (originalType == null) return emptyList()
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfoAfter(expression)
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValueFactory = expression.getResolutionFacade().frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValueFactory = expression.getResolutionFacade().getDataFlowValueFactory()
|
||||
val expressionType = bindingContext.getType(expression) ?: return listOf(originalType)
|
||||
val dataFlowValue = dataFlowValueFactory.createDataFlowValue(
|
||||
expression, expressionType, bindingContext, expression.getResolutionFacade().moduleDescriptor
|
||||
|
||||
+4
-5
@@ -14,10 +14,10 @@ import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
|
||||
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
|
||||
import org.jetbrains.kotlin.checkers.utils.DiagnosticsRenderingConfiguration
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromTextFile
|
||||
import org.jetbrains.kotlin.idea.project.KotlinMultiplatformAnalysisModeComponent
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.test.allKotlinFiles
|
||||
@@ -71,7 +71,6 @@ abstract class AbstractMultiModuleIdeResolveTest : AbstractMultiModuleTest() {
|
||||
return testSourcePath.toFile()
|
||||
}
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
protected open fun checkFile(file: KtFile, expectedFile: File) {
|
||||
val resolutionFacade = file.getResolutionFacade()
|
||||
val (bindingContext, moduleDescriptor) = resolutionFacade.analyzeWithAllCompilerChecks(listOf(file))
|
||||
@@ -87,9 +86,9 @@ abstract class AbstractMultiModuleIdeResolveTest : AbstractMultiModuleTest() {
|
||||
configuration = DiagnosticsRenderingConfiguration(
|
||||
platform = null, // we don't need to attach platform-description string to diagnostic here
|
||||
withNewInference = false,
|
||||
languageVersionSettings = resolutionFacade.frontendService(),
|
||||
languageVersionSettings = resolutionFacade.getLanguageVersionSettings(),
|
||||
),
|
||||
dataFlowValueFactory = resolutionFacade.frontendService(),
|
||||
dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory(),
|
||||
moduleDescriptor = moduleDescriptor as ModuleDescriptorImpl
|
||||
).filter { diagnosticsFilter.value(it.diagnostic) }
|
||||
|
||||
|
||||
+2
-5
@@ -6,20 +6,18 @@
|
||||
package org.jetbrains.kotlin.nj2k.inference.nullability
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isNullExpression
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.resolve.frontendService
|
||||
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
|
||||
import org.jetbrains.kotlin.nj2k.inference.common.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.mustNotBeNull
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -96,8 +94,7 @@ class NullabilityBoundTypeEnhancer(private val resolutionFacade: ResolutionFacad
|
||||
val bindingContext = analyze(resolutionFacade)
|
||||
val type = getType(bindingContext) ?: return null
|
||||
|
||||
@OptIn(FrontendInternals::class)
|
||||
val dataFlowValue = resolutionFacade.frontendService<DataFlowValueFactory>()
|
||||
val dataFlowValue = resolutionFacade.getDataFlowValueFactory()
|
||||
.createDataFlowValue(this, type, bindingContext, resolutionFacade.moduleDescriptor)
|
||||
val dataFlowInfo = bindingContext[BindingContext.EXPRESSION_TYPE_INFO, this]?.dataFlowInfo ?: return null
|
||||
return analyzer(dataFlowValue, dataFlowInfo, type)
|
||||
|
||||
Reference in New Issue
Block a user