diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt index a40e0493df9..9f3bb3206e6 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt @@ -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 diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt index 67da98879a1..865bc68983b 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/caches/resolve/resolutionApi.kt @@ -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: diff --git a/idea/jvm-debugger/jvm-debugger-util/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerCaches.kt b/idea/jvm-debugger/jvm-debugger-util/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerCaches.kt index 8db0899822f..a65241acf89 100644 --- a/idea/jvm-debugger/jvm-debugger-util/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerCaches.kt +++ b/idea/jvm-debugger/jvm-debugger-util/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinDebuggerCaches.kt @@ -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 =