ClassClsStubBuilder: do not report errors for nested stubs

We log differently case with obfuscated library (KT-29427)
and regular case (KT-9618 and others)

#KT-29427 Fixed
#KT-9618 Fixed
This commit is contained in:
Mikhail Glukhikh
2019-01-22 12:54:42 +03:00
parent ae9cd4aa55
commit f782f26c4f
@@ -249,19 +249,29 @@ private class ClassClsStubBuilder(
private fun createNestedClassStub(classBody: StubElement<out PsiElement>, nestedClassId: ClassId) { private fun createNestedClassStub(classBody: StubElement<out PsiElement>, nestedClassId: ClassId) {
val (nameResolver, classProto, _, sourceElement) = val (nameResolver, classProto, _, sourceElement) =
c.components.classDataFinder.findClassData(nestedClassId) c.components.classDataFinder.findClassData(nestedClassId)
?: c.components.virtualFileForDebug.let { rootFile -> ?: c.components.virtualFileForDebug.let { rootFile ->
LOG.error( val outerClassId = nestedClassId.outerClassId
"Could not find class data for nested class $nestedClassId of class ${nestedClassId.outerClassId}\n" + val sortedChildren = rootFile.parent.children.sortedBy { it.name }
"Root file: ${rootFile.canonicalPath}\n" + val msgPrefix = "Could not find data for nested class $nestedClassId of class $outerClassId\n"
"Dir: ${rootFile.parent.canonicalPath}\n" + val explanation = when {
"Children:\n" + outerClassId != null && sortedChildren.none { it.name.startsWith("${outerClassId.relativeClassName}\$a") } ->
rootFile.parent.children.sortedBy { it.name }.joinToString(separator = "\n") { // KT-29427: case with obfuscation
"${it.name} (valid: ${it.isValid})" "Reason: obfuscation suspected (single-letter name)\n"
} else ->
) // General case
return ""
} }
val msg = msgPrefix + explanation +
"Root file: ${rootFile.canonicalPath}\n" +
"Dir: ${rootFile.parent.canonicalPath}\n" +
"Children:\n" +
sortedChildren.joinToString(separator = "\n") {
"${it.name} (valid: ${it.isValid})"
}
LOG.info(msg)
return
}
createClassStub(classBody, classProto, nameResolver, nestedClassId, sourceElement, c) createClassStub(classBody, classProto, nameResolver, nestedClassId, sourceElement, c)
} }