Rename: analyzeFullyAndGetResult -> analyzeWithAllCompilerChecks in ResolutionFacade

This commit is contained in:
Nikolay Krasko
2018-03-22 13:25:30 +03:00
parent f2b478f304
commit 059013a8d3
9 changed files with 15 additions and 15 deletions
@@ -121,12 +121,12 @@ 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 =
getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
getResolutionFacade().analyzeWithAllCompilerChecks(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.analyzeWithContent(): BindingContext where T : KtDeclarationContainer, T : KtElement =
getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
getResolutionFacade().analyzeWithAllCompilerChecks(listOf(this)).bindingContext
// NB: for statements / expressions, usually should be replaced with analyze(),
// for declarations, analyzeWithContent() will do what you want.
@@ -134,20 +134,20 @@ inline fun <reified T> T.analyzeWithContent(): BindingContext where T : KtDeclar
"Use analyzeWithContent() instead, or use just analyze()",
ReplaceWith("analyze()")
)
fun KtElement.analyzeFully(): BindingContext = getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
fun KtElement.analyzeFully(): BindingContext = getResolutionFacade().analyzeWithAllCompilerChecks(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.)
// Not recommended to call both of them without real need
// See also KotlinResolveCache, KotlinResolveDataProvider
fun KtFile.analyzeWithAllCompilerChecks(vararg extraFiles: KtFile): AnalysisResult =
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeFullyAndGetResult(listOf(this))
KotlinCacheService.getInstance(project).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeWithAllCompilerChecks(listOf(this))
@Deprecated(
"Use either KtFile.analyzeWithAllCompilerChecks() or KtElement.analyzeAndGetResult()",
ReplaceWith("analyzeAndGetResult()")
)
fun KtElement.analyzeWithAllCompilerChecks(): AnalysisResult = getResolutionFacade().analyzeFullyAndGetResult(listOf(this))
fun KtElement.analyzeWithAllCompilerChecks(): AnalysisResult = getResolutionFacade().analyzeWithAllCompilerChecks(listOf(this))
// this method don't check visibility and collect all descriptors with given fqName
fun ResolutionFacade.resolveImportReference(
@@ -32,7 +32,7 @@ interface ResolutionFacade {
fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext
fun analyze(elements: Collection<KtElement>, bodyResolveMode: BodyResolveMode): BindingContext
fun analyzeFullyAndGetResult(elements: Collection<KtElement>): AnalysisResult
fun analyzeWithAllCompilerChecks(elements: Collection<KtElement>): AnalysisResult
fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): DeclarationDescriptor
@@ -59,7 +59,7 @@ internal class ResolutionFacadeImpl(
return resolveElementCache.resolveToElements(elements, bodyResolveMode)
}
override fun analyzeFullyAndGetResult(elements: Collection<KtElement>): AnalysisResult =
override fun analyzeWithAllCompilerChecks(elements: Collection<KtElement>): AnalysisResult =
projectFacade.getAnalysisResultsForElements(elements)
override fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode): DeclarationDescriptor {
@@ -529,7 +529,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour
val filesToAnalyze = if (contextFile == null) listOf(this) else listOf(this, contextFile)
val resolutionFacade = KotlinCacheService.getInstance(project).getResolutionFacade(filesToAnalyze)
val analysisResult = resolutionFacade.analyzeFullyAndGetResult(filesToAnalyze)
val analysisResult = resolutionFacade.analyzeWithAllCompilerChecks(filesToAnalyze)
if (analysisResult.isError()) {
exception(analysisResult.error)
@@ -275,7 +275,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
): GenerationState {
val resolutionFacade = ktFile.getResolutionFacade()
val bindingContextForFile = resolutionFacade.analyzeFullyAndGetResult(listOf(ktFile)).bindingContext
val bindingContextForFile = resolutionFacade.analyzeWithAllCompilerChecks(listOf(ktFile)).bindingContext
val (bindingContext, toProcess) = DebuggerUtils.analyzeInlinedFunctions(
resolutionFacade, ktFile, configuration.getBoolean(CommonConfigurationKeys.DISABLE_INLINE),
@@ -40,7 +40,7 @@ class IntroduceBackingPropertyIntention : SelfTargetingIntention<KtProperty>(KtP
fun canIntroduceBackingProperty(property: KtProperty): Boolean {
val name = property.name ?: return false
val bindingContext = property.getResolutionFacade().analyzeFullyAndGetResult(listOf(property)).bindingContext
val bindingContext = property.getResolutionFacade().analyzeWithAllCompilerChecks(listOf(property)).bindingContext
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property) as? PropertyDescriptor ?: return false
if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor) == false) return false
@@ -145,7 +145,7 @@ class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
file.elementsInRange(rangeMarker.range!!).filterIsInstance<KtElement>()
return if (elements.isNotEmpty())
file.getResolutionFacade().analyzeFullyAndGetResult(elements).bindingContext.diagnostics
file.getResolutionFacade().analyzeWithAllCompilerChecks(elements).bindingContext.diagnostics
else
Diagnostics.EMPTY
}
@@ -20,8 +20,8 @@ import com.intellij.psi.PsiNamedElement
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
import org.jetbrains.kotlin.idea.refactoring.memberInfo.getClassDescriptorIfAny
import org.jetbrains.kotlin.idea.util.getResolutionScope
@@ -42,7 +42,7 @@ class KotlinPullUpData(val sourceClass: KtClassOrObject,
val membersToMove: Collection<KtNamedDeclaration>) {
val resolutionFacade = sourceClass.getResolutionFacade()
val sourceClassContext = resolutionFacade.analyzeFullyAndGetResult(listOf(sourceClass)).bindingContext
val sourceClassContext = resolutionFacade.analyzeWithAllCompilerChecks(listOf(sourceClass)).bindingContext
val sourceClassDescriptor = sourceClassContext[BindingContext.DECLARATION_TO_DESCRIPTOR, sourceClass] as ClassDescriptor
@@ -30,8 +30,8 @@ import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
@@ -54,7 +54,7 @@ class KotlinPushDownContext(
) {
val resolutionFacade = sourceClass.getResolutionFacade()
val sourceClassContext = resolutionFacade.analyzeFullyAndGetResult(listOf(sourceClass)).bindingContext
val sourceClassContext = resolutionFacade.analyzeWithAllCompilerChecks(listOf(sourceClass)).bindingContext
val sourceClassDescriptor = sourceClassContext[BindingContext.DECLARATION_TO_DESCRIPTOR, sourceClass] as ClassDescriptor