Body elements resolution in KotlinDebuggerCache added / analyzeWithContentAndGetResult

While we trying to find an inlined SourcePosition, the body should be
resolved KotlinPositionManager.getLambdaOrFunIfInside / InlineUtil.isInlinedArgument
to make shure the lambda is an argument for a call.

 #KT-39309 fixed
 #KT-39435 fixed
This commit is contained in:
Vladimir Ilmov
2020-06-30 18:13:31 +02:00
parent a0f8ada285
commit a2040f01bf
3 changed files with 15 additions and 5 deletions
@@ -96,9 +96,13 @@ fun KtElement.analyze(
): BindingContext =
resolutionFacade.analyze(this, bodyResolveMode)
fun KtElement.analyzeAndGetResult(resolutionFacade: ResolutionFacade): AnalysisResult {
return AnalysisResult.success(resolutionFacade.analyze(this), resolutionFacade.moduleDescriptor)
}
fun KtElement.analyzeAndGetResult(resolutionFacade: ResolutionFacade): AnalysisResult =
AnalysisResult.success(resolutionFacade.analyze(this), resolutionFacade.moduleDescriptor)
// 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 KtElement.analyzeWithContentAndGetResult(resolutionFacade: ResolutionFacade): AnalysisResult =
resolutionFacade.analyzeWithAllCompilerChecks(listOf(this))
// 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
@@ -132,6 +132,12 @@ fun KtElement.analyzeAndGetResult(): AnalysisResult {
return analyzeAndGetResult(getResolutionFacade())
}
/**
* **Please, use overload with providing resolutionFacade for stable results of subsequent calls**
*/
fun KtElement.analyzeWithContentAndGetResult(): AnalysisResult =
analyzeWithContentAndGetResult(getResolutionFacade())
fun KtElement.findModuleDescriptor(): ModuleDescriptor = getResolutionFacade().moduleDescriptor
// This function is used on declarations to make analysis not only declaration itself but also it content:
@@ -36,8 +36,8 @@ import org.jetbrains.kotlin.codegen.ClassBuilderFactories
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContentAndGetResult
import org.jetbrains.kotlin.idea.core.util.runInReadActionWithWriteActionPriorityWithPCE
import org.jetbrains.kotlin.idea.debugger.BinaryCacheKey
import org.jetbrains.kotlin.idea.debugger.BytecodeDebugInfo
@@ -199,7 +199,7 @@ class KotlinDebuggerCaches(project: Project) {
private fun createTypeMapperForLibraryFile(element: KtElement, file: KtFile): KotlinTypeMapper =
runInReadActionWithWriteActionPriorityWithPCE {
createTypeMapper(file, element.analyzeAndGetResult())
createTypeMapper(file, element.analyzeWithContentAndGetResult())
}
private fun createTypeMapperForSourceFile(file: KtFile): KotlinTypeMapper =