Uast: Ability to get the default class type from UClass

This commit is contained in:
Yan Zhulanow
2016-03-15 20:33:44 +03:00
parent 5c07e6de9d
commit 78ce025ca3
7 changed files with 32 additions and 19 deletions
@@ -18,9 +18,13 @@ package org.jetbrains.uast
import org.jetbrains.uast.kinds.UastClassKind
interface UClass : UDeclaration, UFqNamed, UModifierOwner, UAnnotated {
/* The simple class name is only for the debug purposes. Do not check against it in the production code */
override val name: String
val isAnonymous: Boolean
val visibility: UastVisibility
val kind: UastClassKind
val defaultType: UType
val companions: List<UClass>
@@ -78,7 +82,7 @@ object UClassNotResolved : UClass {
override val declarations = emptyList<UDeclaration>()
override fun isSubclassOf(name: String) = false
override val companions = emptyList<UClass>()
override val defaultType = UastErrorType
override val nameElement = null
override val parent = null
override val name = "<class not resolved>"
@@ -34,4 +34,13 @@ interface UTypeReference : UDeclaration, UResolvable, NoTraverse {
override fun resolve(context: UastContext): UClass?
override fun resolveOrEmpty(context: UastContext) = resolve(context) ?: UClassNotResolved
}
object UastErrorType : UType, NoAnnotations {
override val isInt = false
override val parent = null
override val name = "<error>"
override val fqName = null
override val isBoolean = false
override fun resolve(context: UastContext) = null
}