Add toString for KotlinStubBaseImpl
Try to simplify "Stub and PSI element type mismatch" exception analyze. (cherry picked from commit 11aa71e)
This commit is contained in:
committed by
Nikolay Krasko
parent
1e04945609
commit
355dca2a97
@@ -28,15 +28,18 @@ import org.jetbrains.kotlin.psi.stubs.KotlinStubWithFqName
|
||||
import java.lang.reflect.Method
|
||||
import java.util.ArrayList
|
||||
|
||||
val STUB_TO_STRING_PREFIX = "KotlinStub$"
|
||||
|
||||
open class KotlinStubBaseImpl<T : KtElementImplStub<*>>(parent: StubElement<*>?, elementType: IStubElementType<*, *>) : StubBase<T>(parent, elementType) {
|
||||
|
||||
override fun toString(): String {
|
||||
val stubInterface = this.javaClass.interfaces.filter { it.name.contains("Stub") }.single()
|
||||
val propertiesValues = renderPropertyValues(stubInterface)
|
||||
if (propertiesValues.isEmpty()) {
|
||||
return ""
|
||||
return "$STUB_TO_STRING_PREFIX$stubType"
|
||||
}
|
||||
return propertiesValues.joinToString(separator = ", ", prefix = "[", postfix = "]")
|
||||
val properties = propertiesValues.joinToString(separator = ", ", prefix = "[", postfix = "]")
|
||||
return "$STUB_TO_STRING_PREFIX$stubType$properties"
|
||||
}
|
||||
|
||||
private fun renderPropertyValues(stubInterface: Class<out Any?>): List<String> {
|
||||
|
||||
Reference in New Issue
Block a user