Wrap index access in read actions (EA-96128)
This commit is contained in:
+16
-7
@@ -47,11 +47,10 @@ import org.jetbrains.kotlin.idea.decompiler.navigation.SourceNavigationHelper
|
||||
import org.jetbrains.kotlin.idea.stubindex.*
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope.Companion.sourceAndClassFiles
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
@@ -93,11 +92,15 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
}
|
||||
|
||||
override fun findClassOrObjectDeclarations(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtClassOrObject> {
|
||||
return KotlinFullClassNameIndex.getInstance().get(fqName.asString(), project, sourceAndClassFiles(searchScope, project))
|
||||
return runReadAction {
|
||||
KotlinFullClassNameIndex.getInstance().get(fqName.asString(), project, sourceAndClassFiles(searchScope, project))
|
||||
}
|
||||
}
|
||||
|
||||
override fun findFilesForPackage(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtFile> {
|
||||
return PackageIndexUtil.findFilesWithExactPackage(fqName, sourceAndClassFiles(searchScope, project), project)
|
||||
return runReadAction {
|
||||
PackageIndexUtil.findFilesWithExactPackage(fqName, sourceAndClassFiles(searchScope, project), project)
|
||||
}
|
||||
}
|
||||
|
||||
override fun findClassOrObjectDeclarationsInPackage(
|
||||
@@ -195,7 +198,9 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
}
|
||||
|
||||
override fun findFilesForFacade(facadeFqName: FqName, scope: GlobalSearchScope): Collection<KtFile> {
|
||||
return KotlinFileFacadeFqNameIndex.INSTANCE.get(facadeFqName.asString(), project, scope)
|
||||
return runReadAction {
|
||||
KotlinFileFacadeFqNameIndex.INSTANCE.get(facadeFqName.asString(), project, scope)
|
||||
}
|
||||
}
|
||||
|
||||
override fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor? {
|
||||
@@ -212,12 +217,16 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
override fun analyzeFully(element: KtElement) = element.analyzeFully()
|
||||
|
||||
override fun getFacadeNames(packageFqName: FqName, scope: GlobalSearchScope): Collection<String> {
|
||||
val facadeFilesInPackage = KotlinFileFacadeClassByPackageIndex.getInstance().get(packageFqName.asString(), project, scope)
|
||||
val facadeFilesInPackage = runReadAction {
|
||||
KotlinFileFacadeClassByPackageIndex.getInstance().get(packageFqName.asString(), project, scope)
|
||||
}
|
||||
return facadeFilesInPackage.map { it.javaFileFacadeFqName.shortName().asString() }
|
||||
}
|
||||
|
||||
override fun getFacadeClassesInPackage(packageFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
val facadeFilesInPackage = KotlinFileFacadeClassByPackageIndex.getInstance().get(packageFqName.asString(), project, scope)
|
||||
val facadeFilesInPackage = runReadAction {
|
||||
KotlinFileFacadeClassByPackageIndex.getInstance().get(packageFqName.asString(), project, scope)
|
||||
}
|
||||
val groupedByFqNameAndModuleInfo = facadeFilesInPackage.groupBy {
|
||||
Pair(it.javaFileFacadeFqName, it.getModuleInfo())
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.idea.stubindex
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
object StaticFacadeIndexUtil {
|
||||
@@ -30,14 +30,16 @@ object StaticFacadeIndexUtil {
|
||||
partFqName: FqName,
|
||||
searchScope: GlobalSearchScope,
|
||||
project: Project
|
||||
) : Collection<KtFile> =
|
||||
PackagePartClassUtils.getFilesWithCallables(
|
||||
KotlinFileFacadeFqNameIndex.INSTANCE.get(partFqName.asString(), project, searchScope))
|
||||
) : Collection<KtFile> = runReadAction {
|
||||
PackagePartClassUtils.getFilesWithCallables(
|
||||
KotlinFileFacadeFqNameIndex.INSTANCE.get(partFqName.asString(), project, searchScope))
|
||||
}
|
||||
|
||||
@JvmStatic fun getMultifileClassForPart(
|
||||
partFqName: FqName,
|
||||
searchScope: GlobalSearchScope,
|
||||
project: Project
|
||||
): Collection<KtFile> =
|
||||
KotlinMultifileClassPartIndex.INSTANCE.get(partFqName.asString(), project, searchScope)
|
||||
): Collection<KtFile> = runReadAction {
|
||||
KotlinMultifileClassPartIndex.INSTANCE.get(partFqName.asString(), project, searchScope)
|
||||
}
|
||||
}
|
||||
+22
-15
@@ -18,18 +18,19 @@ package org.jetbrains.kotlin.idea.stubindex.resolve
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.PackageMemberDeclarationProvider
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassInfoUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import com.intellij.psi.stubs.StringStubIndexExtension
|
||||
import org.jetbrains.kotlin.idea.stubindex.*
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassInfoUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtScriptInfo
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.PackageMemberDeclarationProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import java.util.*
|
||||
|
||||
class StubBasedPackageMemberDeclarationProvider(
|
||||
private val fqName: FqName,
|
||||
@@ -62,20 +63,26 @@ class StubBasedPackageMemberDeclarationProvider(
|
||||
|
||||
override fun getClassOrObjectDeclarations(name: Name): Collection<KtClassLikeInfo> {
|
||||
val result = ArrayList<KtClassLikeInfo>()
|
||||
KotlinFullClassNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
.mapTo(result) { KtClassInfoUtil.createClassLikeInfo(it) }
|
||||
runReadAction {
|
||||
KotlinFullClassNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
.mapTo(result) { KtClassInfoUtil.createClassLikeInfo(it) }
|
||||
|
||||
KotlinScriptFqnIndex.instance.get(childName(name), project, searchScope)
|
||||
.mapTo(result, ::KtScriptInfo)
|
||||
KotlinScriptFqnIndex.instance.get(childName(name), project, searchScope)
|
||||
.mapTo(result, ::KtScriptInfo)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getFunctionDeclarations(name: Name): Collection<KtNamedFunction> {
|
||||
return KotlinTopLevelFunctionFqnNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
return runReadAction {
|
||||
KotlinTopLevelFunctionFqnNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPropertyDeclarations(name: Name): Collection<KtProperty> {
|
||||
return KotlinTopLevelPropertyFqnNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
return runReadAction {
|
||||
KotlinTopLevelPropertyFqnNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection<FqName> {
|
||||
|
||||
Reference in New Issue
Block a user