Add extra information for EA-76201
This commit is contained in:
+18
-5
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||
import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager;
|
||||
@@ -92,12 +93,24 @@ public class LazyDeclarationResolver {
|
||||
DeclarationDescriptor descriptor = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classObjectOrScript);
|
||||
|
||||
if (descriptor == null) {
|
||||
String providerInfoString = null;
|
||||
if (scope instanceof AbstractLazyMemberScope) {
|
||||
AbstractLazyMemberScope lazyMemberScope = (AbstractLazyMemberScope) scope;
|
||||
providerInfoString = lazyMemberScope.toProviderString();
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Could not find a classifier for %s.\n" +
|
||||
"Found descriptor: %s (%s).\n",
|
||||
PsiUtilsKt.getElementTextWithContext(classObjectOrScript),
|
||||
scopeDescriptor != null ? DescriptorRenderer.DEBUG_TEXT.render(scopeDescriptor) : "null",
|
||||
scopeDescriptor != null ? (scopeDescriptor.getContainingDeclaration().getClass()) : null));
|
||||
String.format(
|
||||
"Could not find a classifier for %s.\n" +
|
||||
"Found descriptor: %s (%s).\n" +
|
||||
"Scope: %s.\n" +
|
||||
"Provider: %s.",
|
||||
PsiUtilsKt.getElementTextWithContext(classObjectOrScript),
|
||||
scopeDescriptor != null ? DescriptorRenderer.DEBUG_TEXT.render(scopeDescriptor) : "null",
|
||||
scopeDescriptor != null ? (scopeDescriptor.getContainingDeclaration().getClass()) : null,
|
||||
scope,
|
||||
providerInfoString != null ? providerInfoString : "null"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return (ClassDescriptor) descriptor;
|
||||
|
||||
+9
-6
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.lazy.declarations
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils.safeNameForLazyResolve
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassInfoUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtClassLikeInfo
|
||||
@@ -67,6 +66,8 @@ abstract class AbstractPsiBasedDeclarationProvider(storageManager: StorageManage
|
||||
else -> throw IllegalArgumentException("Unknown declaration: " + declaration)
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString() = "allDeclarations: " + allDeclarations.mapNotNull { it.name }
|
||||
}
|
||||
|
||||
private val index = storageManager.createLazyValue<Index> {
|
||||
@@ -77,21 +78,23 @@ abstract class AbstractPsiBasedDeclarationProvider(storageManager: StorageManage
|
||||
|
||||
protected abstract fun doCreateIndex(index: Index)
|
||||
|
||||
internal fun toInfoString() = toString() + ": " + index().toString()
|
||||
|
||||
override fun getDeclarations(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<KtDeclaration>
|
||||
= index().allDeclarations
|
||||
|
||||
override fun getFunctionDeclarations(name: Name): List<KtNamedFunction>
|
||||
= index().functions[ResolveSessionUtils.safeNameForLazyResolve(name)].toList()
|
||||
= index().functions[safeNameForLazyResolve(name)].toList()
|
||||
|
||||
override fun getPropertyDeclarations(name: Name): List<KtProperty>
|
||||
= index().properties[ResolveSessionUtils.safeNameForLazyResolve(name)].toList()
|
||||
= index().properties[safeNameForLazyResolve(name)].toList()
|
||||
|
||||
override fun getDestructuringDeclarationsEntries(name: Name): Collection<KtDestructuringDeclarationEntry>
|
||||
= index().destructuringDeclarationsEntries[ResolveSessionUtils.safeNameForLazyResolve(name)].toList()
|
||||
= index().destructuringDeclarationsEntries[safeNameForLazyResolve(name)].toList()
|
||||
|
||||
override fun getClassOrObjectDeclarations(name: Name): Collection<KtClassLikeInfo>
|
||||
= index().classesAndObjects[ResolveSessionUtils.safeNameForLazyResolve(name)]
|
||||
= index().classesAndObjects[safeNameForLazyResolve(name)]
|
||||
|
||||
override fun getTypeAliasDeclarations(name: Name): Collection<KtTypeAlias>
|
||||
= index().typeAliases[ResolveSessionUtils.safeNameForLazyResolve(name)]
|
||||
= index().typeAliases[safeNameForLazyResolve(name)]
|
||||
}
|
||||
|
||||
+2
-1
@@ -45,5 +45,6 @@ class FileBasedPackageMemberDeclarationProvider(
|
||||
|
||||
override fun getPackageFiles() = packageFiles
|
||||
|
||||
override fun toString() = "Declarations for package $fqName"
|
||||
override fun toString() = "Declarations for package $fqName with files ${packageFiles.map { it.name }} " +
|
||||
"with declarations inside ${packageFiles.flatMap { it.declarations }.map { it.name ?: "???"}}"
|
||||
}
|
||||
|
||||
+4
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.KtScriptInfo
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.AbstractPsiBasedDeclarationProvider
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
@@ -219,6 +220,9 @@ protected constructor(
|
||||
// a generic implementation can't do this properly
|
||||
abstract override fun toString(): String
|
||||
|
||||
fun toProviderString() = (declarationProvider as? AbstractPsiBasedDeclarationProvider)?.toInfoString()
|
||||
?: declarationProvider.toString()
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(this::class.java.simpleName, " {")
|
||||
p.pushIndent()
|
||||
|
||||
Reference in New Issue
Block a user