Deprecate KtElement.analyzeFullyAndGetResult(), use analyzeAndGetResult
This commit is contained in:
@@ -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:
|
// 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
|
// 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.
|
// This function is used to make full analysis of declaration container.
|
||||||
// All its declarations, including their content (see above), are analyzed.
|
// All its declarations, including their content (see above), are analyzed.
|
||||||
inline fun <reified T> T.analyzeWithDeclarations(): BindingContext where T : KtDeclarationContainer, T : KtElement =
|
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(),
|
// NB: for statements / expressions, usually should be replaced with analyze(),
|
||||||
// for declarations, analyzeWithContent() will do what you want.
|
// 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()",
|
"Use either analyzeWithContent() or analyzeWithDeclarations() instead, or use just analyze()",
|
||||||
ReplaceWith("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
|
// 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.)
|
// 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 =
|
fun KtFile.analyzeFullyAndGetResult(vararg extraFiles: KtFile): AnalysisResult =
|
||||||
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeFullyAndGetResult(listOf(this))
|
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeFullyAndGetResult(listOf(this))
|
||||||
|
|
||||||
fun KtElement.analyzeFullyAndGetResult(): AnalysisResult =
|
@Deprecated(
|
||||||
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this)).analyzeFullyAndGetResult(listOf(this))
|
"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
|
// this method don't check visibility and collect all descriptors with given fqName
|
||||||
fun ResolutionFacade.resolveImportReference(
|
fun ResolutionFacade.resolveImportReference(
|
||||||
|
|||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass
|
package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass
|
||||||
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
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.ParameterInfo
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getTypeInfoForTypeArguments
|
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> {
|
override fun getPossibleClassKinds(element: KtCallExpression, diagnostic: Diagnostic): List<ClassKind> {
|
||||||
val inAnnotationEntry = diagnostic.psiElement.getNonStrictParentOfType<KtAnnotationEntry>() != null
|
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 call = element.getCall(context) ?: return emptyList()
|
||||||
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return emptyList() }
|
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return emptyList() }
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ object CreateClassFromConstructorCallActionFactory: CreateClassFromUsageFactory<
|
|||||||
val fullCallExpr =
|
val fullCallExpr =
|
||||||
if (callParent is KtQualifiedExpression && callParent.selectorExpression == callExpr) callParent else callExpr
|
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 call = callExpr.getCall(context) ?: return null
|
||||||
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return null }
|
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return null }
|
||||||
|
|||||||
+3
-3
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass
|
|||||||
import com.intellij.psi.PsiClass
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
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.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
@@ -59,7 +59,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac
|
|||||||
|
|
||||||
val name = element.getReferencedName()
|
val name = element.getReferencedName()
|
||||||
|
|
||||||
val (context, moduleDescriptor) = element.analyzeFullyAndGetResult()
|
val (context, moduleDescriptor) = element.analyzeAndGetResult()
|
||||||
|
|
||||||
val fullCallExpr = getFullCallExpression(element) ?: return Collections.emptyList()
|
val fullCallExpr = getFullCallExpression(element) ?: return Collections.emptyList()
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac
|
|||||||
override fun extractFixData(element: KtSimpleNameExpression, diagnostic: Diagnostic): ClassInfo? {
|
override fun extractFixData(element: KtSimpleNameExpression, diagnostic: Diagnostic): ClassInfo? {
|
||||||
val name = element.getReferencedName()
|
val name = element.getReferencedName()
|
||||||
|
|
||||||
val (context, moduleDescriptor) = element.analyzeFullyAndGetResult()
|
val (context, moduleDescriptor) = element.analyzeAndGetResult()
|
||||||
|
|
||||||
val fullCallExpr = getFullCallExpression(element) ?: return null
|
val fullCallExpr = getFullCallExpression(element) ?: return null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user