Deprecate KtElement.analyzeFullyAndGetResult(), use analyzeAndGetResult

This commit is contained in:
Mikhail Glukhikh
2018-02-14 14:43:49 +03:00
parent cd1745d354
commit 8c97f8cbb5
3 changed files with 15 additions and 11 deletions
@@ -102,12 +102,13 @@ fun KtElement.findModuleDescriptor(): ModuleDescriptor = getResolutionFacade().m
// This function is used on declarations to make analysis not only declaration itself but also it content:
// body for declaration with body, initializer & accessors for properties
fun KtDeclaration.analyzeWithContent(): BindingContext = analyzeFullyAndGetResult().bindingContext
fun KtDeclaration.analyzeWithContent(): BindingContext =
getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
// This function is used to make full analysis of declaration container.
// All its declarations, including their content (see above), are analyzed.
inline fun <reified T> T.analyzeWithDeclarations(): BindingContext where T : KtDeclarationContainer, T : KtElement =
analyzeFullyAndGetResult().bindingContext
getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
// NB: for statements / expressions, usually should be replaced with analyze(),
// for declarations, analyzeWithContent() will do what you want.
@@ -115,7 +116,7 @@ inline fun <reified T> T.analyzeWithDeclarations(): BindingContext where T : KtD
"Use either analyzeWithContent() or analyzeWithDeclarations() instead, or use just analyze()",
ReplaceWith("analyze()")
)
fun KtElement.analyzeFully(): BindingContext = analyzeFullyAndGetResult().bindingContext
fun KtElement.analyzeFully(): BindingContext = getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
// This and next function are expected to produce the same result as compiler
// for the given element and its children (including diagnostics, trace slices, descriptors, etc.)
@@ -124,8 +125,11 @@ fun KtElement.analyzeFully(): BindingContext = analyzeFullyAndGetResult().bindin
fun KtFile.analyzeFullyAndGetResult(vararg extraFiles: KtFile): AnalysisResult =
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeFullyAndGetResult(listOf(this))
fun KtElement.analyzeFullyAndGetResult(): AnalysisResult =
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this)).analyzeFullyAndGetResult(listOf(this))
@Deprecated(
"Use either KtFile.analyzeFullyAndGetResult() or KtElement.analyzeAndGetResult()",
ReplaceWith("analyzeAndGetResult()")
)
fun KtElement.analyzeFullyAndGetResult(): AnalysisResult = getResolutionFacade().analyzeFullyAndGetResult(listOf(this))
// this method don't check visibility and collect all descriptors with given fqName
fun ResolutionFacade.resolveImportReference(
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.ParameterInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getTypeInfoForTypeArguments
@@ -41,7 +41,7 @@ object CreateClassFromConstructorCallActionFactory: CreateClassFromUsageFactory<
override fun getPossibleClassKinds(element: KtCallExpression, diagnostic: Diagnostic): List<ClassKind> {
val inAnnotationEntry = diagnostic.psiElement.getNonStrictParentOfType<KtAnnotationEntry>() != null
val (context, moduleDescriptor) = element.analyzeFullyAndGetResult()
val (context, moduleDescriptor) = element.analyzeAndGetResult()
val call = element.getCall(context) ?: return emptyList()
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return emptyList() }
@@ -71,7 +71,7 @@ object CreateClassFromConstructorCallActionFactory: CreateClassFromUsageFactory<
val fullCallExpr =
if (callParent is KtQualifiedExpression && callParent.selectorExpression == callExpr) callParent else callExpr
val (context, moduleDescriptor) = callExpr.analyzeFullyAndGetResult()
val (context, moduleDescriptor) = callExpr.analyzeAndGetResult()
val call = callExpr.getCall(context) ?: return null
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return null }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.*
@@ -59,7 +59,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac
val name = element.getReferencedName()
val (context, moduleDescriptor) = element.analyzeFullyAndGetResult()
val (context, moduleDescriptor) = element.analyzeAndGetResult()
val fullCallExpr = getFullCallExpression(element) ?: return Collections.emptyList()
@@ -116,7 +116,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac
override fun extractFixData(element: KtSimpleNameExpression, diagnostic: Diagnostic): ClassInfo? {
val name = element.getReferencedName()
val (context, moduleDescriptor) = element.analyzeFullyAndGetResult()
val (context, moduleDescriptor) = element.analyzeAndGetResult()
val fullCallExpr = getFullCallExpression(element) ?: return null