From 63e62dcf429f1fbcc69ec56b0a8f67fbd2b348ce Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 20 Nov 2019 15:18:44 +0300 Subject: [PATCH] Add `checkCanceled` check on resolving imports path Imports resolution is a rather time consuming task and doesn't have `checkCanceled` on its computation path. So, if a thread is resolving imports it will do it until the end of computation, which can lead to unnecessary work and some IDE freezes. #KT-34990 Fixed --- .../jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt index 80a284c3639..a576b2727da 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector @@ -220,6 +221,8 @@ class QualifiedExpressionResolver(val languageVersionSettings: LanguageVersionSe excludedImportNames: Collection, packageFragmentForVisibilityCheck: PackageFragmentDescriptor? ): ImportingScope? { // null if some error happened + ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() + val importedReference = importDirective.importContent ?: return null val path = importedReference.asQualifierPartList() val lastPart = path.lastOrNull() ?: return null