More diagnostics for EA-85926 and EA-77163
This commit is contained in:
@@ -86,7 +86,11 @@ class FileScopeFactory(
|
||||
|
||||
val packageView = moduleDescriptor.getPackage(file.packageFqName)
|
||||
val packageFragment = topLevelDescriptorProvider.getPackageFragment(file.packageFqName)
|
||||
?: error("Could not find fragment ${file.packageFqName} for file ${file.name}")
|
||||
if (packageFragment == null) {
|
||||
// TODO J2K and change return type of diagnoseMissingPackageFragment() to Nothing
|
||||
(topLevelDescriptorProvider as? LazyClassContext)?.declarationProviderFactory?.diagnoseMissingPackageFragment(file)
|
||||
error("Could not find fragment ${file.packageFqName} for file ${file.name}")
|
||||
}
|
||||
|
||||
fun createImportResolver(indexedImports: IndexedImports, trace: BindingTrace, excludedImports: List<FqName>? = null) =
|
||||
LazyImportResolver(
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.stubindex
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
@@ -42,6 +43,7 @@ class SubpackagesIndexService(private val project: Project) {
|
||||
// a map from any existing package (in kotlin) to a set of subpackages (not necessarily direct) containing files
|
||||
private val allPackageFqNames = hashSetOf<FqName>()
|
||||
private val fqNameByPrefix = MultiMap.createSet<FqName, FqName>()
|
||||
private val oocbCount = PsiManager.getInstance(project).modificationTracker.outOfCodeBlockModificationCount
|
||||
|
||||
init {
|
||||
for (fqNameAsString in allPackageFqNames) {
|
||||
@@ -80,6 +82,8 @@ class SubpackagesIndexService(private val project: Project) {
|
||||
|
||||
return existingSubPackagesShortNames.map { fqName.child(it) }
|
||||
}
|
||||
|
||||
override fun toString() = "SubpackagesIndex: OOCB on creation $oocbCount, all packages size ${allPackageFqNames.size}"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+5
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.stubindex.resolve
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||
import org.jetbrains.kotlin.idea.stubindex.SubpackagesIndexService
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo
|
||||
@@ -56,9 +57,12 @@ class PluginDeclarationProviderFactory(
|
||||
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile) {
|
||||
val packageFqName = file.packageFqName
|
||||
val subpackagesIndex = SubpackagesIndexService.getInstance(project)
|
||||
throw IllegalStateException("Cannot find package fragment for file ${file.name} with package $packageFqName, " +
|
||||
"vFile ${file.virtualFile}, nonIndexed ${file in nonIndexedFiles} " +
|
||||
"packageExists=${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)}")
|
||||
"packageExists=${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)} in $indexedFilesScope," +
|
||||
"SPI.packageExists=${subpackagesIndex.packageExists(packageFqName)} SPI=$subpackagesIndex " +
|
||||
"OOCB count ${file.manager.modificationTracker.outOfCodeBlockModificationCount}}")
|
||||
}
|
||||
|
||||
// trying to diagnose org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException in completion
|
||||
|
||||
Reference in New Issue
Block a user