Do not force loading all kt-files inside LazyPackageDescriptor constructor
Effectively it leads to all stubs being built for any once used package The idea is that they only were used for FILE_TO_PACKAGE_FRAGMENT that is mostly read in backend and rarely in the IDE, so we can replace its usages with searching through related package-fragments
This commit is contained in:
+4
@@ -109,6 +109,10 @@ class StubBasedPackageMemberDeclarationProvider(
|
||||
return PackageIndexUtil.findFilesWithExactPackage(fqName, searchScope, project)
|
||||
}
|
||||
|
||||
override fun containsFile(file: KtFile): Boolean {
|
||||
return searchScope.contains(file.virtualFile ?: return false)
|
||||
}
|
||||
|
||||
override fun getTypeAliasDeclarations(name: Name): Collection<KtTypeAlias> {
|
||||
return KotlinTopLevelTypeAliasFqNameIndex.getInstance().get(childName(name), project, searchScope)
|
||||
}
|
||||
|
||||
@@ -23,23 +23,19 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities.*
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
object MakeVisibleFactory : KotlinIntentionActionsFactory() {
|
||||
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
||||
val element = diagnostic.psiElement as? KtElement ?: return emptyList()
|
||||
val context = element.analyze(BodyResolveMode.PARTIAL)
|
||||
val usageModule = context.get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, element.containingKtFile)?.module
|
||||
val usageModule = element.findModuleDescriptor()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val factory = diagnostic.factory as DiagnosticFactory3<*, DeclarationDescriptor, *, DeclarationDescriptor>
|
||||
@@ -58,4 +54,4 @@ object MakeVisibleFactory : KotlinIntentionActionsFactory() {
|
||||
|
||||
return targetVisibilities.mapNotNull { ChangeVisibilityFix.create(declaration, descriptor, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isSubclassOf
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.findPackageFragmentForFile
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.utils.SmartSet
|
||||
@@ -103,7 +104,11 @@ class MoveConflictChecker(
|
||||
is KtNamedDeclaration -> resolutionFacade.resolveToDescriptor(targetElement)
|
||||
|
||||
is KtFile -> {
|
||||
val packageFragment = resolutionFacade.analyze(targetElement)[BindingContext.FILE_TO_PACKAGE_FRAGMENT, targetElement]
|
||||
val packageFragment =
|
||||
targetElement
|
||||
.findModuleDescriptor()
|
||||
.findPackageFragmentForFile(targetElement)
|
||||
|
||||
packageFragment?.withSource(targetElement)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user