UAST: Log error when failed to create light class for UObjectLiteralExpression
This commit is contained in:
+22
-2
@@ -16,8 +16,12 @@
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.psi.impl.light.LightPsiClassBuilder
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
|
||||
@@ -27,7 +31,19 @@ class KotlinUObjectLiteralExpression(
|
||||
override val psi: KtObjectLiteralExpression,
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UObjectLiteralExpression, KotlinUElementWithType {
|
||||
override val declaration by lz { getLanguagePlugin().convert<UClass>(psi.objectDeclaration.toLightClass()!!, this) }
|
||||
override val declaration: UClass by lz {
|
||||
val lightClass: KtLightClass? = psi.objectDeclaration.toLightClass()
|
||||
if (lightClass != null) {
|
||||
getLanguagePlugin().convert<UClass>(lightClass, this)
|
||||
}
|
||||
else {
|
||||
logger.error(
|
||||
"Failed to create light class for object declaration",
|
||||
Attachment(psi.containingFile.virtualFile?.path ?: "<no path>", psi.containingFile.text))
|
||||
|
||||
getLanguagePlugin().convert(LightPsiClassBuilder(psi, "<unnamed>"), this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getExpressionType() = psi.objectDeclaration.toPsiType()
|
||||
|
||||
@@ -69,5 +85,9 @@ class KotlinUObjectLiteralExpression(
|
||||
|
||||
override val identifier: String
|
||||
get() = psi.name ?: "<error>"
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val logger by lz { Logger.getInstance(KotlinUObjectLiteralExpression::class.java) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user