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
This commit is contained in:
Mikhail Zarechenskiy
2019-11-20 15:18:44 +03:00
parent db24d4ac9a
commit 63e62dcf42
@@ -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<FqName>,
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