summaryrefslogtreecommitdiff
path: root/plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt')
-rw-r--r--plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt b/plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt
index 5207043b7663..7239d67cc1b0 100644
--- a/plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt
+++ b/plugins/kotlin/common/src/org/jetbrains/kotlin/idea/caches/resolve/extendedResolutionApi.kt
@@ -7,6 +7,8 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
+import org.jetbrains.kotlin.idea.util.actionUnderSafeAnalyzeBlock
+import org.jetbrains.kotlin.idea.util.returnIfNoDescriptorForDeclarationException
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -126,3 +128,23 @@ fun KtDeclaration.analyzeWithContent(resolutionFacade: ResolutionFacade): Bindin
inline fun <reified T> T.analyzeWithContent(resolutionFacade: ResolutionFacade): BindingContext where T : KtDeclarationContainer, T : KtElement =
resolutionFacade.analyzeWithAllCompilerChecks(this).bindingContext
+
+@JvmOverloads
+fun KtElement.safeAnalyzeNonSourceRootCode(
+ bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL
+): BindingContext = safeAnalyzeNonSourceRootCode(getResolutionFacade(), bodyResolveMode)
+
+fun KtElement.safeAnalyzeNonSourceRootCode(
+ resolutionFacade: ResolutionFacade,
+ bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL
+): BindingContext =
+ actionUnderSafeAnalyzeBlock({ analyze(resolutionFacade, bodyResolveMode) }, { BindingContext.EMPTY })
+
+@JvmOverloads
+fun KtDeclaration.safeAnalyzeWithContentNonSourceRootCode(): BindingContext =
+ safeAnalyzeWithContentNonSourceRootCode(getResolutionFacade())
+
+fun KtDeclaration.safeAnalyzeWithContentNonSourceRootCode(
+ resolutionFacade: ResolutionFacade,
+): BindingContext =
+ actionUnderSafeAnalyzeBlock({ analyzeWithContent(resolutionFacade) }, { BindingContext.EMPTY }) \ No newline at end of file