Revert "Introduce @FrontendInternals annotation"

Revert due to Mobile IDE Trunk IJ TC configuration
This reverts commits:
ffc3d8bdfc
c0e713980b

^KT-39643 In Progress
This commit is contained in:
Pavel Kirpichenkov
2020-08-06 18:35:48 +03:00
parent 7f2efabe6a
commit 9ca4717d11
52 changed files with 57 additions and 214 deletions
@@ -1,16 +0,0 @@
/*
* 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
/**
* Indicates sensitive frontend API, which should be used with caution to avoid invariant violation.
* Use sites of this annotation include all methods for direct access to frontend components.
* Please make sure that components don't receive resolution results (descriptors etc.) from different resolution facade for processing.
* The simplest way to do so is to explicitly provide the same resolution facade to all related computations.
* Not following this rule may lead to obscure memory leaks and other potential problems.
*/
@RequiresOptIn
annotation class FrontendInternals
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.idea.analysis
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.resolve.frontendService
@@ -28,7 +27,6 @@ import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
@JvmOverloads
@OptIn(FrontendInternals::class)
fun KtExpression.computeTypeInfoInContext(
scope: LexicalScope,
contextExpression: KtExpression = this,
@@ -46,7 +44,6 @@ fun KtExpression.computeTypeInfoInContext(
}
@JvmOverloads
@OptIn(FrontendInternals::class)
fun KtExpression.analyzeInContext(
scope: LexicalScope,
contextExpression: KtExpression = this,
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
@@ -189,7 +188,6 @@ fun KtFile.analyzeWithAllCompilerChecks(vararg extraFiles: KtFile): AnalysisResu
fun KtElement.analyzeWithAllCompilerChecks(): AnalysisResult = getResolutionFacade().analyzeWithAllCompilerChecks(listOf(this))
// this method don't check visibility and collect all descriptors with given fqName
@OptIn(FrontendInternals::class)
fun ResolutionFacade.resolveImportReference(
moduleDescriptor: ModuleDescriptor,
fqName: FqName
@@ -9,7 +9,6 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
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.util.*
@@ -41,7 +40,6 @@ import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
import org.jetbrains.kotlin.types.typeUtil.isUnit
import java.util.*
@OptIn(FrontendInternals::class)
class ReferenceVariantsHelper(
private val bindingContext: BindingContext,
private val resolutionFacade: ResolutionFacade,
@@ -465,7 +463,6 @@ private fun MemberScope.collectStaticMembers(
)
}
@OptIn(FrontendInternals::class)
fun ResolutionScope.collectSyntheticStaticMembersAndConstructors(
resolutionFacade: ResolutionFacade,
kindFilter: DescriptorKindFilter,
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.analysis.analyzeAsReplacement
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
@@ -289,7 +288,6 @@ class OptimizedImportsBuilder(
return fileWithImports.getFileResolutionScope()
}
@OptIn(FrontendInternals::class)
private fun KtFile.getFileResolutionScope() =
getResolutionFacade().frontendService<FileScopeProvider>().getFileScopes(this).importingScope
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.kdoc
import com.intellij.openapi.components.ServiceManager
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.util.CallType
import org.jetbrains.kotlin.idea.util.getFileResolutionScope
@@ -120,8 +119,6 @@ private fun resolveDefaultKDocLink(
}
val moduleDescriptor = fromDescriptor.module
@OptIn(FrontendInternals::class)
val qualifiedExpressionResolver = resolutionFacade.getFrontendService(moduleDescriptor, QualifiedExpressionResolver::class.java)
val contextElement = DescriptorToSourceUtils.descriptorToDeclaration(fromDescriptor)
@@ -9,9 +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.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
@@ -44,7 +44,7 @@ class ExtractableSubstringInfo(
val tempContext = expr.analyzeInContext(scope, template)
val trace = DelegatingBindingTrace(tempContext, "Evaluate '$literal'")
val languageVersionSettings = facade.getLanguageVersionSettings()
val languageVersionSettings = facade.getFrontendService(LanguageVersionSettings::class.java)
val value = ConstantExpressionEvaluator(module, languageVersionSettings, facade.project).evaluateExpression(expr, trace)
if (value == null || value.isError) return stringType
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.analyzer.ResolverForProject
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.BindingContext
@@ -31,25 +30,19 @@ interface ResolutionFacade {
val moduleDescriptor: ModuleDescriptor
// get service for the module this resolution was created for
@FrontendInternals
fun <T : Any> getFrontendService(serviceClass: Class<T>): T
fun <T : Any> getIdeService(serviceClass: Class<T>): T
// get service for the module defined by PsiElement/ModuleDescriptor passed as parameter
@FrontendInternals
fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T
@FrontendInternals
fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T?
@FrontendInternals
fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T
fun getResolverForProject(): ResolverForProject<out ModuleInfo>
}
@FrontendInternals
inline fun <reified T : Any> ResolutionFacade.frontendService(): T = this.getFrontendService(T::class.java)
inline fun <reified T : Any> ResolutionFacade.ideService(): T = this.getIdeService(T::class.java)
@@ -1,24 +0,0 @@
/*
* 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>()
@@ -9,11 +9,8 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
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
@@ -254,7 +251,7 @@ fun CallTypeAndReceiver<*, *>.receiverTypesWithIndex(
stableSmartCastsOnly: Boolean,
withImplicitReceiversWhenExplicitPresent: Boolean = false
): List<ReceiverType>? {
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
val receiverExpression: KtExpression?
when (this) {
@@ -348,7 +345,6 @@ fun CallTypeAndReceiver<*, *>.receiverTypesWithIndex(
return result
}
@OptIn(FrontendInternals::class)
private fun receiverValueTypes(
receiverValue: ReceiverValue,
dataFlowInfo: DataFlowInfo,
@@ -357,8 +353,8 @@ private fun receiverValueTypes(
stableSmartCastsOnly: Boolean,
resolutionFacade: ResolutionFacade
): List<KotlinType> {
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
val dataFlowValueFactory = resolutionFacade.frontendService<DataFlowValueFactory>()
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
@@ -7,12 +7,9 @@ package org.jetbrains.kotlin.idea.util
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.*
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
@@ -21,6 +18,7 @@ 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
@@ -194,11 +192,9 @@ class ShadowedDeclarationsFilter(
val context = BasicCallResolutionContext.create(
bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo,
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
false, resolutionFacade.getLanguageVersionSettings(),
resolutionFacade.getDataFlowValueFactory()
false, /* languageVersionSettings */ resolutionFacade.frontendService(),
resolutionFacade.frontendService<DataFlowValueFactory>()
)
@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 }
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.builtins.replaceReturnType
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
@@ -205,7 +204,6 @@ fun KotlinType.isAbstract(): Boolean {
* NOTE: this is a very shaky implementation of [PsiType] to [KotlinType] conversion,
* produced types are fakes and are usable only for code generation. Please be careful using this method.
*/
@OptIn(FrontendInternals::class)
fun PsiType.resolveToKotlinType(resolutionFacade: ResolutionFacade): KotlinType {
if (this == PsiType.NULL) {
return resolutionFacade.moduleDescriptor.builtIns.nullableAnyType
@@ -11,7 +11,6 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ClassDescriptorWithResolutionScopes
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.resolve.frontendService
@@ -86,7 +85,6 @@ fun KtElement.getResolutionScope(): LexicalScope {
return getResolutionScope(context, resolutionFacade)
}
@OptIn(FrontendInternals::class)
fun ResolutionFacade.getFileResolutionScope(file: KtFile): LexicalScope {
return frontendService<FileScopeProvider>().getFileResolutionScope(file)
}
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.frontend.di.configureModule
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.lightClasses.IDELightClassConstructionContext.Mode.EXACT
import org.jetbrains.kotlin.idea.caches.lightClasses.IDELightClassConstructionContext.Mode.LIGHT
import org.jetbrains.kotlin.idea.caches.lightClasses.annotations.KOTLINX_SERIALIZABLE_FQ_NAME
@@ -92,7 +91,6 @@ internal object IDELightClassContexts {
val bindingContext = if (classOrObject is KtClass && classOrObject.isAnnotation()) {
// need to make sure default values for parameters are resolved
// because java resolve depends on whether there is a default value for an annotation attribute
@OptIn(FrontendInternals::class)
resolutionFacade.getFrontendService(ResolveElementCache::class.java)
.resolvePrimaryConstructorParametersDefaultValues(classOrObject)
} else {
@@ -138,7 +136,6 @@ internal object IDELightClassContexts {
fun contextForFacade(files: List<KtFile>): LightClassConstructionContext {
@OptIn(FrontendInternals::class)
val resolveSession = files.first().getResolutionFacade().getFrontendService(ResolveSession::class.java)
forceResolvePackageDeclarations(files, resolveSession)
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.lightClasses.IDELightClassContexts
import org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder
import org.jetbrains.kotlin.idea.project.languageVersionSettings
@@ -91,9 +90,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
return null
}
@OptIn(FrontendInternals::class)
override val deprecationResolver: DeprecationResolver
get() = resolutionFacade.getFrontendService(DeprecationResolver::class.java)
override val deprecationResolver: DeprecationResolver get() = resolutionFacade.getFrontendService(DeprecationResolver::class.java)
override val typeMapper: KotlinTypeMapper by lazyPub {
@@ -208,7 +205,6 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
)
}
@OptIn(FrontendInternals::class)
private fun KtElement.getDiagnosticsHolder() =
getResolutionFacade().frontendService<LazyLightClassDataHolder.DiagnosticsHolder>()
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.container.getService
import org.jetbrains.kotlin.container.tryGetService
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo
import org.jetbrains.kotlin.idea.project.ResolveElementCache
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
@@ -68,7 +67,6 @@ internal class ModuleResolutionFacadeImpl(
}
}
@OptIn(FrontendInternals::class)
val resolveElementCache = getFrontendService(elements.first(), ResolveElementCache::class.java)
return runWithCancellationCheck {
resolveElementCache.resolveToElements(elements, bodyResolveMode)
@@ -97,19 +95,16 @@ internal class ModuleResolutionFacadeImpl(
}
}
@FrontendInternals
override fun <T : Any> getFrontendService(serviceClass: Class<T>): T = getFrontendService(moduleInfo, serviceClass)
override fun <T : Any> getIdeService(serviceClass: Class<T>): T {
return projectFacade.resolverForModuleInfo(moduleInfo).componentProvider.create(serviceClass)
}
@FrontendInternals
override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {
return projectFacade.resolverForElement(element).componentProvider.getService(serviceClass)
}
@FrontendInternals
override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {
return projectFacade.resolverForElement(element).componentProvider.tryGetService(serviceClass)
}
@@ -118,7 +113,6 @@ internal class ModuleResolutionFacadeImpl(
return projectFacade.resolverForModuleInfo(ideaModuleInfo).componentProvider.getService(serviceClass)
}
@FrontendInternals
override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {
return projectFacade.resolverForDescriptor(moduleDescriptor).componentProvider.getService(serviceClass)
}
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.analyzer.ResolverForProject
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo
import org.jetbrains.kotlin.idea.caches.project.getNullableModuleInfo
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
@@ -67,7 +66,6 @@ private class ResolutionFacadeWithDebugInfo(
override val moduleDescriptor: ModuleDescriptor
get() = delegate.moduleDescriptor
@FrontendInternals
override fun <T : Any> getFrontendService(serviceClass: Class<T>): T {
return wrapExceptions({ ResolvingWhat(serviceClass = serviceClass) }) {
delegate.getFrontendService(serviceClass)
@@ -80,14 +78,12 @@ private class ResolutionFacadeWithDebugInfo(
}
}
@FrontendInternals
override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {
return wrapExceptions({ ResolvingWhat(listOf(element), serviceClass = serviceClass) }) {
delegate.getFrontendService(element, serviceClass)
}
}
@FrontendInternals
override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {
return wrapExceptions({ ResolvingWhat(listOf(element), serviceClass = serviceClass) }) {
delegate.tryGetFrontendService(element, serviceClass)
@@ -98,7 +94,6 @@ private class ResolutionFacadeWithDebugInfo(
return delegate.getResolverForProject()
}
@FrontendInternals
override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {
return wrapExceptions({ ResolvingWhat(serviceClass = serviceClass, moduleDescriptor = moduleDescriptor) }) {
delegate.getFrontendService(moduleDescriptor, serviceClass)
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.lightClasses.KtLightClassForDecompiledDeclaration
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.util.application.runReadAction
@@ -112,7 +111,6 @@ fun PsiClass.resolveToDescriptor(
} as? ClassDescriptor
}
@OptIn(FrontendInternals::class)
private fun PsiElement.getJavaDescriptorResolver(resolutionFacade: ResolutionFacade): JavaDescriptorResolver? {
return resolutionFacade.tryGetFrontendService(this, JavaDescriptorResolver::class.java)
}
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
import org.jetbrains.kotlin.idea.completion.smart.ExpectedInfoMatch
import org.jetbrains.kotlin.idea.completion.smart.SmartCompletionItemPriority
@@ -87,8 +86,6 @@ object KeywordValues {
if (callTypeAndReceiver is CallTypeAndReceiver.CALLABLE_REFERENCE && callTypeAndReceiver.receiver != null) {
val qualifierType = bindingContext.get(BindingContext.DOUBLE_COLON_LHS, callTypeAndReceiver.receiver!!)?.type
if (qualifierType != null) {
@OptIn(FrontendInternals::class)
val kClassDescriptor = resolutionFacade.getFrontendService(ReflectionTypes::class.java).kClass
val classLiteralType =
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kClassDescriptor, listOf(TypeProjectionImpl(qualifierType)))
@@ -14,7 +14,6 @@ import com.intellij.openapi.util.Key
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.completion.handlers.WithExpressionPrefixInsertHandler
import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler
import org.jetbrains.kotlin.idea.completion.shortenReferences
@@ -246,7 +245,6 @@ private fun MutableCollection<LookupElement>.addLookupElementsForNullable(
}
}
@OptIn(FrontendInternals::class)
fun CallableDescriptor.callableReferenceType(resolutionFacade: ResolutionFacade, lhs: DoubleColonLHS?): FuzzyType? {
if (!CallType.CALLABLE_REFERENCE.descriptorKindFilter.accepts(this)) return null // not supported by callable references
@@ -25,7 +25,6 @@ import com.intellij.psi.stubs.StringStubIndexExtension
import com.intellij.util.indexing.IdFilter
import org.jetbrains.kotlin.asJava.elements.KtLightElement
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache
import org.jetbrains.kotlin.idea.caches.resolve.*
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor
@@ -73,7 +72,6 @@ class KotlinIndicesHelper(
private val project = resolutionFacade.project
private val scopeWithoutKotlin = scope.excludeKotlinSources() as GlobalSearchScope
@OptIn(FrontendInternals::class)
private val descriptorFilter: (DeclarationDescriptor) -> Boolean = filter@{
if (resolutionFacade.frontendService<DeprecationResolver>().isHiddenInResolution(it)) return@filter false
if (!visibilityFilter(it)) return@filter false
@@ -473,7 +471,6 @@ class KotlinIndicesHelper(
processor(descriptor)
// SAM-adapter
@OptIn(FrontendInternals::class)
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java).forceEnableSamAdapters()
val contributedFunctions = container.staticScope.getContributedFunctions(descriptor.name, NoLookupLocation.FROM_IDE)
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.psi.KtExpression
@@ -34,7 +34,7 @@ class SmartCastCalculator(
receiver: KtExpression?,
resolutionFacade: ResolutionFacade
) {
private val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
private val dataFlowValueFactory = resolutionFacade.frontendService<DataFlowValueFactory>()
// keys are VariableDescriptor's and ThisReceiver's
private val entityToSmartCastInfo: Map<Any, SmartCastInfo> = processDataFlowInfo(
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.idea.core
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.analysis.computeTypeInContext
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
@@ -16,8 +15,6 @@ 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
@@ -118,11 +115,9 @@ fun Call.resolveCandidates(
val callResolutionContext = BasicCallResolutionContext.create(
bindingTrace, resolutionScope, this, expectedType, dataFlowInfo,
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
false, resolutionFacade.getLanguageVersionSettings(),
resolutionFacade.getDataFlowValueFactory()
false, resolutionFacade.frontendService(),
resolutionFacade.frontendService()
).replaceCollectAllCandidates(true)
@OptIn(FrontendInternals::class)
val callResolver = resolutionFacade.frontendService<CallResolver>()
val results = callResolver.resolveFunctionCall(callResolutionContext)
@@ -15,13 +15,11 @@ import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
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.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
@@ -115,7 +113,6 @@ fun KtCallExpression.getLastLambdaExpression(): KtLambdaExpression? {
return valueArguments.lastOrNull()?.getArgumentExpression()?.unpackFunctionLiteral()
}
@OptIn(FrontendInternals::class)
fun KtCallExpression.canMoveLambdaOutsideParentheses(): Boolean {
if (getStrictParentOfType<KtDelegatedSuperTypeEntry>() != null) return false
if (getLastLambdaExpression() == null) return false
@@ -128,7 +125,7 @@ fun KtCallExpression.canMoveLambdaOutsideParentheses(): Boolean {
val resolutionFacade = getResolutionFacade()
val samConversionTransformer = resolutionFacade.frontendService<SamConversionResolver>()
val samConversionOracle = resolutionFacade.frontendService<SamConversionOracle>()
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
val bindingContext = analyze(resolutionFacade, BodyResolveMode.PARTIAL)
val targets = bindingContext[BindingContext.REFERENCE_TARGET, callee]?.let { listOf(it) }
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.debugger.evaluate.EvaluationStatus
import org.jetbrains.kotlin.idea.debugger.evaluate.ExecutionContext
import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.ClassToLoad
@@ -70,8 +69,6 @@ class CodeFragmentCompiler(private val executionContext: ExecutionContext, priva
val project = codeFragment.project
val resolutionFacade = getResolutionFacadeForCodeFragment(codeFragment)
@OptIn(FrontendInternals::class)
val resolveSession = resolutionFacade.getFrontendService(ResolveSession::class.java)
val moduleDescriptorWrapper = EvaluatorModuleDescriptor(codeFragment, moduleDescriptor, resolveSession)
@@ -373,7 +373,6 @@ open class KotlinDocumentationProviderCompatBase : AbstractDocumentationProvider
}
}
@OptIn(FrontendInternals::class)
val deprecationProvider = resolutionFacade.frontendService<DeprecationResolver>()
return KDocTemplate().apply {
@@ -19,7 +19,7 @@ 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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
import org.jetbrains.kotlin.psi.psiUtil.parents
@@ -34,6 +34,7 @@ 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
@@ -112,7 +113,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
val result = expressionType?.let { typeRenderer.renderType(it) } ?: return KotlinBundle.message("type.provider.unknown.type")
val dataFlowValueFactory = element.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = element.getResolutionFacade().frontendService<DataFlowValueFactory>()
val dataFlowValue =
dataFlowValueFactory.createDataFlowValue(element, expressionType, bindingContext, element.findModuleDescriptor())
val types = expressionTypeInfo.dataFlowInfo.getStableTypes(dataFlowValue, element.languageVersionSettings)
@@ -24,7 +24,6 @@ import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.ui.GuiUtils
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
@@ -52,7 +51,6 @@ import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() {
@OptIn(FrontendInternals::class)
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
val file = session.file as? KtFile ?: return PsiElementVisitor.EMPTY_VISITOR
val resolutionFacade = file.getResolutionFacade()
@@ -10,7 +10,6 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.resolve.frontendService
@@ -39,7 +38,6 @@ class OverridingDeprecatedMemberInspection : AbstractKotlinInspection() {
val resolutionFacade = declaration.getResolutionFacade()
val accessorDescriptor = declaration.resolveToDescriptorIfAny(resolutionFacade) as? CallableMemberDescriptor ?: return
@OptIn(FrontendInternals::class)
val deprecationProvider = resolutionFacade.frontendService<DeprecationResolver>()
val message = deprecationProvider.getDeprecations(accessorDescriptor)
@@ -21,12 +21,12 @@ 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
@@ -64,8 +64,7 @@ class PlatformExtensionReceiverOfInlineInspection : AbstractKotlinInspection() {
return
}
val resolutionFacade = expression.getResolutionFacade()
val context = expression.analyze(resolutionFacade, BodyResolveMode.PARTIAL)
val context = expression.analyze(BodyResolveMode.PARTIAL)
val resolvedCall = expression.getResolvedCall(context) ?: return
val extensionReceiverType = resolvedCall.extensionReceiver?.type ?: return
if (!extensionReceiverType.isNullabilityFlexible()) return
@@ -73,7 +72,7 @@ class PlatformExtensionReceiverOfInlineInspection : AbstractKotlinInspection() {
if (!descriptor.isInline || descriptor.extensionReceiverParameter?.type?.isNullable() == true) return
val receiverExpression = expression.receiverExpression
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
val dataFlowValueFactory = receiverExpression.getResolutionFacade().getFrontendService(DataFlowValueFactory::class.java)
val dataFlow = dataFlowValueFactory.createDataFlowValue(receiverExpression, extensionReceiverType, context, descriptor)
val stableNullability = context.getDataFlowInfoBefore(receiverExpression).getStableNullability(dataFlow)
if (!stableNullability.canBeNull()) return
@@ -16,8 +16,6 @@ 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,6 +27,7 @@ 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
@@ -36,8 +35,7 @@ import org.jetbrains.kotlin.types.isNullable
class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = callExpressionVisitor(fun(callExpression) {
val callee = callExpression.calleeExpression ?: return
val resolutionFacade = callExpression.getResolutionFacade()
val context = callExpression.analyze(resolutionFacade, BodyResolveMode.PARTIAL)
val context = callExpression.analyze(BodyResolveMode.PARTIAL)
if (!callExpression.isCalling(FqName("kotlin.requireNotNull"), context)
&& !callExpression.isCalling(FqName("kotlin.checkNotNull"), context)
) return
@@ -45,7 +43,7 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
val argument = callExpression.valueArguments.firstOrNull()?.getArgumentExpression()?.referenceExpression() ?: return
val descriptor = argument.getResolvedCall(context)?.resultingDescriptor ?: return
val type = descriptor.returnType ?: return
if (argument.isNullable(descriptor, type, context, resolutionFacade)) return
if (argument.isNullable(descriptor, type, context)) return
val functionName = callee.text
holder.registerProblem(
@@ -56,14 +54,9 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
)
})
private fun KtReferenceExpression.isNullable(
descriptor: CallableDescriptor,
type: KotlinType,
context: BindingContext,
resolutionFacade: ResolutionFacade,
): Boolean {
private fun KtReferenceExpression.isNullable(descriptor: CallableDescriptor, type: KotlinType, context: BindingContext): Boolean {
if (!type.isNullable()) return false
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
val dataFlowValueFactory = this.getResolutionFacade().getFrontendService(DataFlowValueFactory::class.java)
val dataFlow = dataFlowValueFactory.createDataFlowValue(this, type, context, descriptor)
val stableTypes = context.getDataFlowInfoBefore(this).getStableTypes(dataFlow, this.languageVersionSettings)
return stableTypes.none { !it.isNullable() }
@@ -11,7 +11,6 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.codegen.SamCodegenUtil
import org.jetbrains.kotlin.config.LanguageFeature
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
@@ -120,8 +119,6 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
val originalCall = parentCall.getResolvedCall(context) ?: return false
val dataFlow = context.getDataFlowInfoBefore(parentCall)
@OptIn(FrontendInternals::class)
val callResolver = parentCall.getResolutionFacade().frontendService<CallResolver>()
val newCall = CallWithConvertedArguments(originalCall.call, samConstructorCallArgumentMap)
@@ -164,7 +161,6 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
override fun getValueArguments() = newArguments
}
@OptIn(FrontendInternals::class)
fun samConstructorCallsToBeConverted(functionCall: KtCallExpression): Collection<KtCallExpression> {
val valueArguments = functionCall.valueArguments
if (valueArguments.none { canBeSamConstructorCall(it) }) return emptyList()
@@ -37,7 +37,6 @@ 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,6 +49,7 @@ 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
@@ -203,10 +203,9 @@ class ReplaceCallWithBinaryOperatorInspection : AbstractApplicabilityBasedInspec
private fun KtDotQualifiedExpression.isFloatingPointNumberEquals(): Boolean {
val resolvedCall = resolveToCall() ?: return false
val resolutionFacade = getResolutionFacade()
val context = analyze(resolutionFacade, BodyResolveMode.PARTIAL)
val context = analyze(BodyResolveMode.PARTIAL)
val declarationDescriptor = containingDeclarationForPseudocode?.resolveToDescriptorIfAny()
val dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory()
val dataFlowValueFactory = getResolutionFacade().getFrontendService(DataFlowValueFactory::class.java)
val defaultType: (KotlinType, Set<KotlinType>) -> KotlinType = { givenType, stableTypes -> stableTypes.firstOrNull() ?: givenType }
val receiverType = resolvedCall.getReceiverExpression()?.getKotlinTypeWithPossibleSmartCastToFP(
context, declarationDescriptor, languageVersionSettings, dataFlowValueFactory, defaultType
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
@@ -27,8 +26,6 @@ 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
@@ -167,8 +164,6 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
if (function.shouldNotConvertToProperty(notProperties)) return null
val resolutionScope = callExpression.getResolutionScope(bindingContext, resolutionFacade)
@OptIn(FrontendInternals::class)
val property = findSyntheticProperty(function, resolutionFacade.getFrontendService(SyntheticScopes::class.java)) ?: return null
if (KtTokens.KEYWORDS.types.any { it.toString() == property.name.asString() }) return null
@@ -249,11 +244,10 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
val context = BasicCallResolutionContext.create(
bindingTrace, resolutionScope, newCall, expectedType, dataFlowInfo,
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
false, facade.getLanguageVersionSettings(),
facade.getDataFlowValueFactory()
false, facade.frontendService<LanguageVersionSettings>(),
facade.frontendService<DataFlowValueFactory>()
)
@OptIn(FrontendInternals::class)
val callResolver = facade.frontendService<CallResolver>()
val result = callResolver.resolveSimpleProperty(context)
return result.isSuccess && result.resultingDescriptor.original == property
@@ -8,6 +8,7 @@ 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
@@ -23,7 +24,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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.idea.util.textRangeIn
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
@@ -39,6 +40,7 @@ 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
@@ -193,7 +195,7 @@ fun elvisPattern(newLine: Boolean): String = if (newLine) "$0\n?: $1" else "$0 ?
private fun KtExpression.toDataFlowValue(context: BindingContext): DataFlowValue? {
val expressionType = this.getType(context) ?: return null
val dataFlowValueFactory = this.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = this.getResolutionFacade().frontendService<DataFlowValueFactory>()
return dataFlowValueFactory.createDataFlowValue(this, expressionType, context, findModuleDescriptor())
}
@@ -28,7 +28,6 @@ import com.intellij.ui.JBColor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
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.core.OptionalParametersHelper
@@ -186,9 +185,9 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
context.setCurrentParameter(parameterIndex)
runReadAction {
val resolutionFacade = argumentList.getResolutionFacade()
val bindingContext = argumentList.analyze(resolutionFacade, BodyResolveMode.PARTIAL)
val bindingContext = argumentList.analyze(BodyResolveMode.PARTIAL)
val call = findCall(argumentList, bindingContext) ?: return@runReadAction
val resolutionFacade = argumentList.getResolutionFacade()
context.objectsToView.forEach { resolveCallInfo(it as CallInfo, call, bindingContext, resolutionFacade) }
}
@@ -419,7 +418,6 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
!argument.hasError(bindingContext) /* ignore arguments that have error type */
}
@OptIn(FrontendInternals::class)
val isDeprecated = resolutionFacade.frontendService<DeprecationResolver>().getDeprecations(resultingDescriptor).isNotEmpty()
with(info) {
@@ -35,13 +35,14 @@ 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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
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
@@ -137,7 +138,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo
context[BindingContext.EXPRESSION_TYPE_INFO, psiElement]?.let {
val type = it.type
val dataFlowValueFactory = psiElement.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = psiElement.getResolutionFacade().frontendService<DataFlowValueFactory>()
if (type != null) {
val nullability = it.dataFlowInfo.getStableNullability(
@@ -10,7 +10,6 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
@@ -86,7 +85,6 @@ open class RemovePartsFromPropertyFix(
//
// But calling another type refinement also helps because it makes KotlinType instance using new module descriptor
@OptIn(TypeRefinement::class)
@OptIn(FrontendInternals::class)
typeToAdd = replaceElement.getResolutionFacade().frontendService<KotlinTypeRefiner>().refineType(typeToAdd)
SpecifyTypeExplicitlyIntention.addTypeAnnotation(editor, replaceElement, typeToAdd)
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
@@ -64,7 +63,6 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.types.TypeUtils
@@ -393,7 +391,6 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
}
}
@OptIn(FrontendInternals::class)
private fun createFakeFunctionDescriptor(scope: HierarchicalScope, typeParameterCount: Int): FunctionDescriptor {
val fakeFunction = SimpleFunctionDescriptorImpl.create(
MutablePackageFragmentDescriptor(currentFileModule, FqName("fake")),
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.quickfix.KotlinIntentionActionFactoryWithDelegate
@@ -63,7 +62,6 @@ object CreateTypeParameterByUnresolvedRefActionFactory : KotlinIntentionActionFa
return ktUserType
}
@OptIn(FrontendInternals::class)
fun extractFixData(element: KtTypeElement, newName: String): CreateTypeParameterData? {
val declaration = element.parents.firstOrNull {
it is KtProperty || it is KtNamedFunction || it is KtClass
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createTypeParameter
import com.intellij.psi.SmartPsiElementPointer
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.codeInsight.DescriptorToSourceUtilsIde
@@ -43,7 +42,6 @@ object CreateTypeParameterUnmatchedTypeArgumentActionFactory :
KotlinIntentionActionFactoryWithDelegate<KtTypeArgumentList, CreateTypeParameterData>() {
override fun getElementOfInterest(diagnostic: Diagnostic) = diagnostic.psiElement as? KtTypeArgumentList
@OptIn(FrontendInternals::class)
override fun extractFixData(element: KtTypeArgumentList, diagnostic: Diagnostic): CreateTypeParameterData? {
val project = element.project
val typeArguments = element.arguments
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.quickfix.replaceWith
import com.intellij.openapi.diagnostic.ControlFlowException
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
import org.jetbrains.kotlin.idea.codeInliner.CodeToInline
@@ -19,7 +18,6 @@ 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
@@ -40,7 +38,6 @@ import java.util.*
data class ReplaceWith(val pattern: String, val imports: List<String>, val replaceInWholeProject: Boolean)
@OptIn(FrontendInternals::class)
object ReplaceWithAnnotationAnalyzer {
fun analyzeCallableReplacement(
annotation: ReplaceWith,
@@ -131,7 +128,7 @@ object ReplaceWithAnnotationAnalyzer {
): LexicalScope? {
val module = resolutionFacade.moduleDescriptor
val explicitImportsScope = buildExplicitImportsScope(annotation, resolutionFacade, module)
val languageVersionSettings = resolutionFacade.getLanguageVersionSettings()
val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()
val defaultImportsScopes = buildDefaultImportsScopes(resolutionFacade, module, languageVersionSettings)
return getResolutionScope(
@@ -32,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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiRange
@@ -47,6 +47,7 @@ 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
@@ -182,7 +183,7 @@ data class ExtractionData(
}
private fun getPossibleTypes(expression: KtExpression, resolvedCall: ResolvedCall<*>?, context: BindingContext): Set<KotlinType> {
val dataFlowValueFactory = expression.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = expression.getResolutionFacade().frontendService<DataFlowValueFactory>()
val dataFlowInfo = context.getDataFlowInfoAfter(expression)
resolvedCall?.getImplicitReceiverValue()?.let {
@@ -32,7 +32,7 @@ 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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.lexer.KtToken
import org.jetbrains.kotlin.psi.*
@@ -386,7 +386,8 @@ private fun suggestParameterType(
val typeByDataFlowInfo = if (useSmartCastsIfPossible) {
val callElement = resolvedCall!!.call.callElement
val dataFlowInfo = bindingContext.getDataFlowInfoAfter(callElement)
val dataFlowValueFactory = callElement.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = callElement.getResolutionFacade().frontendService<DataFlowValueFactory>()
val possibleTypes = dataFlowInfo.getCollectedTypes(
dataFlowValueFactory.createDataFlowValueForStableReceiver(receiverToExtract),
callElement.languageVersionSettings
@@ -22,7 +22,6 @@ import com.intellij.refactoring.classMembers.AbstractMemberInfoStorage
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
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.refactoring.isInterfaceClass
@@ -40,8 +39,6 @@ class KotlinMemberInfoStorage(
classOrObject: KtClassOrObject,
filter: (KtNamedDeclaration) -> Boolean = { true }
) : AbstractMemberInfoStorage<KtNamedDeclaration, PsiNamedElement, KotlinMemberInfo>(classOrObject, filter) {
@OptIn(FrontendInternals::class)
override fun memberConflict(member1: KtNamedDeclaration, member: KtNamedDeclaration): Boolean {
val descriptor1 = member1.resolveToDescriptorWrapperAware()
val descriptor = member.resolveToDescriptorWrapperAware()
@@ -11,7 +11,6 @@ import com.intellij.refactoring.util.MoveRenameUsageInfo
import com.intellij.usageView.UsageInfo
import com.intellij.usageView.UsageViewUtil
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
import org.jetbrains.kotlin.idea.caches.resolve.analyze
@@ -154,8 +153,6 @@ internal fun checkRedeclarations(
is PropertyDescriptor,
is FunctionDescriptor,
is ClassifierDescriptor -> {
@OptIn(FrontendInternals::class)
val typeSpecificityComparator = resolutionFacade.getFrontendService(descriptor.module, TypeSpecificityComparator::class.java)
OverloadChecker(typeSpecificityComparator)
}
@@ -7,6 +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.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
@@ -16,7 +17,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.getLanguageVersionSettings
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -46,7 +47,7 @@ class ImportInsertHelperImpl(private val project: Project) : ImportInsertHelper(
get() = ImportPathComparator(codeStyleSettings.PACKAGES_IMPORT_LAYOUT)
override fun isImportedWithDefault(importPath: ImportPath, contextFile: KtFile): Boolean {
val languageVersionSettings = contextFile.getResolutionFacade().getLanguageVersionSettings()
val languageVersionSettings = contextFile.getResolutionFacade().frontendService<LanguageVersionSettings>()
val platform = TargetPlatformDetector.getPlatform(contextFile)
val analyzerServices = platform.findAnalyzerServices(contextFile.project)
val allDefaultImports = analyzerServices.getDefaultImports(languageVersionSettings, includeLowPriorityImports = true)
@@ -25,13 +25,13 @@ 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
@@ -58,8 +58,7 @@ fun getDataFlowAwareTypes(
): Collection<KotlinType> {
if (originalType == null) return emptyList()
val dataFlowInfo = bindingContext.getDataFlowInfoAfter(expression)
val dataFlowValueFactory = expression.getResolutionFacade().getDataFlowValueFactory()
val dataFlowValueFactory = expression.getResolutionFacade().frontendService<DataFlowValueFactory>()
val expressionType = bindingContext.getType(expression) ?: return listOf(originalType)
val dataFlowValue = dataFlowValueFactory.createDataFlowValue(
expression, expressionType, bindingContext, expression.getResolutionFacade().moduleDescriptor
@@ -16,8 +16,7 @@ import org.jetbrains.kotlin.checkers.utils.DiagnosticsRenderingConfiguration
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromTextFile
import org.jetbrains.kotlin.idea.project.KotlinMultiplatformAnalysisModeComponent
import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.idea.test.allKotlinFiles
@@ -86,9 +85,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.getLanguageVersionSettings(),
languageVersionSettings = resolutionFacade.frontendService(),
),
dataFlowValueFactory = resolutionFacade.getDataFlowValueFactory(),
dataFlowValueFactory = resolutionFacade.frontendService(),
moduleDescriptor = moduleDescriptor as ModuleDescriptorImpl
).filter { diagnosticsFilter.value(it.diagnostic) }
@@ -13,7 +13,6 @@ import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.PsiModificationTrackerImpl
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.trackers.outOfBlockModificationCount
@@ -89,8 +88,6 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur
val ktDeclaration: KtDeclaration? = PsiTreeUtil.getParentOfType(updateElement, KtDeclaration::class.java, false)
val ktElement = ktExpression ?: ktDeclaration ?: return
val facade = ktElement.containingKtFile.getResolutionFacade()
@OptIn(FrontendInternals::class)
val session = facade.getFrontendService(ResolveSession::class.java)
session.forceResolveAll()
@@ -11,13 +11,14 @@ 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.getDataFlowValueFactory
import org.jetbrains.kotlin.idea.resolve.frontendService
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
@@ -94,7 +95,7 @@ class NullabilityBoundTypeEnhancer(private val resolutionFacade: ResolutionFacad
val bindingContext = analyze(resolutionFacade)
val type = getType(bindingContext) ?: return null
val dataFlowValue = resolutionFacade.getDataFlowValueFactory()
val dataFlowValue = resolutionFacade.frontendService<DataFlowValueFactory>()
.createDataFlowValue(this, type, bindingContext, resolutionFacade.moduleDescriptor)
val dataFlowInfo = bindingContext[BindingContext.EXPRESSION_TYPE_INFO, this]?.dataFlowInfo ?: return null
return analyzer(dataFlowValue, dataFlowInfo, type)
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.container.ComponentProvider
import org.jetbrains.kotlin.container.getService
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.FrontendInternals
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtElement
@@ -39,7 +38,6 @@ class KotlinResolutionFacadeForRepl(
override val moduleDescriptor: ModuleDescriptor = provider.getService(ModuleDescriptor::class.java)
@FrontendInternals
override fun <T : Any> getFrontendService(serviceClass: Class<T>): T {
return provider.resolve(serviceClass)!!.getValue() as T
}
@@ -48,7 +46,6 @@ class KotlinResolutionFacadeForRepl(
throw UnsupportedOperationException()
}
@FrontendInternals
override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {
throw UnsupportedOperationException()
}
@@ -57,12 +54,10 @@ class KotlinResolutionFacadeForRepl(
throw UnsupportedOperationException()
}
@FrontendInternals
override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {
throw UnsupportedOperationException()
}
@FrontendInternals
override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {
throw UnsupportedOperationException()
}