Add better diagnostic for "could not create stub for nested class" failures
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ public class KotlinBuiltInStubBuilder : ClsStubBuilder() {
|
||||
private fun createStubBuilderComponents(file: VirtualFile, packageFqName: FqName, nameResolver: NameResolver): ClsStubBuilderComponents {
|
||||
val finder = DirectoryBasedClassDataFinder(file.parent!!, packageFqName, nameResolver, BuiltInsSerializedResourcePaths)
|
||||
val annotationLoader = AnnotationLoaderForStubBuilderImpl(BuiltInSerializerProtocol)
|
||||
return ClsStubBuilderComponents(finder, annotationLoader)
|
||||
return ClsStubBuilderComponents(finder, annotationLoader, file)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
val classFinder = DirectoryBasedClassFinder(file.getParent()!!, packageFqName)
|
||||
val classDataFinder = DirectoryBasedDataFinder(classFinder, LOG)
|
||||
val annotationLoader = AnnotationLoaderForClassFileStubBuilder(classFinder, LoggingErrorReporter(LOG))
|
||||
return ClsStubBuilderComponents(classDataFinder, annotationLoader)
|
||||
return ClsStubBuilderComponents(classDataFinder, annotationLoader, file)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -82,6 +82,6 @@ public class KotlinJavaScriptStubBuilder : ClsStubBuilder() {
|
||||
file.parent!!, packageFqName, nameResolver, KotlinJavascriptSerializedResourcePaths
|
||||
)
|
||||
val annotationLoader = AnnotationLoaderForStubBuilderImpl(JsSerializerProtocol)
|
||||
return ClsStubBuilderComponents(classDataFinder, annotationLoader)
|
||||
return ClsStubBuilderComponents(classDataFinder, annotationLoader, file)
|
||||
}
|
||||
}
|
||||
|
||||
+17
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
@@ -233,10 +234,24 @@ private class ClassClsStubBuilder(
|
||||
}
|
||||
|
||||
private fun createNestedClassStub(classBody: StubElement<out PsiElement>, nestedClassId: ClassId) {
|
||||
val classDataWithSource = c.components.classDataFinder.findClassData(nestedClassId).sure {
|
||||
"Could not find class data for nested class ${nestedClassId.shortClassName} of class ${nestedClassId.outerClassId}"
|
||||
val classDataWithSource = c.components.classDataFinder.findClassData(nestedClassId)
|
||||
if (classDataWithSource == null) {
|
||||
val rootFile = c.components.virtualFileForDebug
|
||||
LOG.error(
|
||||
"Could not find class data for nested class $nestedClassId of class ${nestedClassId.outerClassId}\n" +
|
||||
"Root file: ${rootFile.canonicalPath}\n" +
|
||||
"Dir: ${rootFile.parent.canonicalPath}\n" +
|
||||
"Children:\n" +
|
||||
"${rootFile.parent.children.sortedBy { it.name }.joinToString(separator = "\n") {
|
||||
it.name + " (valid: ${it.isValid})"
|
||||
} }")
|
||||
return
|
||||
}
|
||||
val (nameResolver, classProto) = classDataWithSource.classData
|
||||
createClassStub(classBody, classProto, nestedClassId, c.child(nameResolver, TypeTable(classProto.typeTable)))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(ClassClsStubBuilder::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -30,7 +31,8 @@ data class ClassIdWithTarget(val classId: ClassId, val target: AnnotationUseSite
|
||||
|
||||
class ClsStubBuilderComponents(
|
||||
val classDataFinder: ClassDataFinder,
|
||||
val annotationLoader: AnnotationAndConstantLoader<ClassId, Unit, ClassIdWithTarget>
|
||||
val annotationLoader: AnnotationAndConstantLoader<ClassId, Unit, ClassIdWithTarget>,
|
||||
val virtualFileForDebug: VirtualFile
|
||||
) {
|
||||
fun createContext(
|
||||
nameResolver: NameResolver,
|
||||
|
||||
Reference in New Issue
Block a user