Update to UAST 0.12
This commit is contained in:
@@ -9,7 +9,7 @@ import org.jetbrains.uast.*
|
||||
|
||||
class KotlinUAnnotation(
|
||||
override val psi: KtAnnotationEntry,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : UAnnotation {
|
||||
private val resolvedAnnotation by lz { psi.analyze()[BindingContext.ANNOTATION, psi] }
|
||||
|
||||
@@ -40,7 +40,7 @@ class KotlinUAnnotation(
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinUNamedExpression(override val name: String, override val containingElement: UElement?) : UNamedExpression {
|
||||
class KotlinUNamedExpression(override val name: String, override val uastParent: UElement?) : UNamedExpression {
|
||||
override lateinit var expression: UExpression
|
||||
|
||||
override val annotations: List<UAnnotation>
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUMethod
|
||||
|
||||
class KotlinUClass private constructor(
|
||||
psi: KtLightClass,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractJavaUClass(), PsiClass by psi {
|
||||
|
||||
val ktClass = psi.kotlinOrigin
|
||||
@@ -49,17 +49,21 @@ class KotlinUClass private constructor(
|
||||
override val uastAnchor: UElement
|
||||
get() = UIdentifier(psi.nameIdentifier, this)
|
||||
|
||||
override val uastNestedClasses: List<UClass> by lz {
|
||||
override fun getInnerClasses(): Array<UClass> {
|
||||
// filter DefaultImpls to avoid processing same methods from original interface multiple times
|
||||
// filter Enum entry classes to avoid duplication with PsiEnumConstant initializer class
|
||||
psi.innerClasses.filter {
|
||||
return psi.innerClasses.filter {
|
||||
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass()
|
||||
}.map {
|
||||
getLanguagePlugin().convert<UClass>(it, this)
|
||||
}
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
||||
override val uastMethods: List<UMethod> by lz {
|
||||
override fun getSuperClass(): UClass? = super.getSuperClass()
|
||||
override fun getFields(): Array<UField> = super.getFields()
|
||||
override fun getInitializers(): Array<UClassInitializer> = super.getInitializers()
|
||||
|
||||
override fun getMethods(): Array<UMethod> {
|
||||
val primaryConstructor = ktClass?.getPrimaryConstructor()?.toLightMethods()?.firstOrNull()
|
||||
val initBlocks = ktClass?.getAnonymousInitializers() ?: emptyList()
|
||||
|
||||
@@ -75,7 +79,7 @@ class KotlinUClass private constructor(
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
get() = containingMethod
|
||||
|
||||
override val annotations: List<UAnnotation>
|
||||
@@ -96,10 +100,11 @@ class KotlinUClass private constructor(
|
||||
|
||||
fun isDelegatedMethod(psiMethod: PsiMethod) = psiMethod is KtLightMethod && psiMethod.isDelegated
|
||||
|
||||
psi.methods.asSequence()
|
||||
return psi.methods.asSequence()
|
||||
.filterNot(::isDelegatedMethod)
|
||||
.map(::createUMethod)
|
||||
.toList()
|
||||
.toTypedArray()
|
||||
}
|
||||
|
||||
private fun PsiClass.isEnumEntryLightClass() = (this as? KtLightClass)?.kotlinOrigin is KtEnumEntry
|
||||
@@ -116,7 +121,7 @@ class KotlinUClass private constructor(
|
||||
|
||||
class KotlinUAnonymousClass(
|
||||
psi: PsiAnonymousClass,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractJavaUClass(), UAnonymousClass, PsiAnonymousClass by psi {
|
||||
|
||||
override val psi: PsiAnonymousClass = unwrap<UAnonymousClass, PsiAnonymousClass>(psi)
|
||||
@@ -125,6 +130,12 @@ class KotlinUAnonymousClass(
|
||||
return super<AbstractJavaUClass>.getOriginalElement()
|
||||
}
|
||||
|
||||
override fun getSuperClass(): UClass? = super<AbstractJavaUClass>.getSuperClass()
|
||||
override fun getFields(): Array<UField> = super<AbstractJavaUClass>.getFields()
|
||||
override fun getMethods(): Array<UMethod> = super<AbstractJavaUClass>.getMethods()
|
||||
override fun getInitializers(): Array<UClassInitializer> = super<AbstractJavaUClass>.getInitializers()
|
||||
override fun getInnerClasses(): Array<UClass> = super<AbstractJavaUClass>.getInnerClasses()
|
||||
|
||||
override val uastAnchor: UElement?
|
||||
get() {
|
||||
val ktClassOrObject = (psi.originalElement as? KtLightClass)?.kotlinOrigin as? KtObjectDeclaration ?: return null
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.USimpleNameReferenceExpression
|
||||
|
||||
class KotlinUImportStatement(
|
||||
override val psi: KtImportDirective,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : UImportStatement {
|
||||
override val isOnDemand: Boolean
|
||||
get() = psi.isAllUnder
|
||||
@@ -47,7 +47,7 @@ class KotlinUImportStatement(
|
||||
private class ImportReference(
|
||||
override val psi: KtExpression,
|
||||
override val identifier: String,
|
||||
override val containingElement: UElement?,
|
||||
override val uastParent: UElement?,
|
||||
private val importDirective: KtImportDirective
|
||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
||||
override val resolvedName: String?
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.uast.kotlin.*
|
||||
|
||||
open class KotlinUMethod(
|
||||
psi: KtLightMethod,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : UMethod, JavaUElementWithComments, PsiMethod by psi {
|
||||
override val psi: KtLightMethod = unwrap<UMethod, KtLightMethod>(psi)
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class AbstractKotlinUVariable : AbstractJavaUVariable() {
|
||||
|
||||
class KotlinUVariable(
|
||||
psi: PsiVariable,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractKotlinUVariable(), UVariable, PsiVariable by psi {
|
||||
override val psi = unwrap<UVariable, PsiVariable>(psi)
|
||||
|
||||
@@ -81,7 +81,7 @@ class KotlinUVariable(
|
||||
|
||||
open class KotlinUParameter(
|
||||
psi: PsiParameter,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractKotlinUVariable(), UParameter, PsiParameter by psi {
|
||||
|
||||
override val psi = unwrap<UParameter, PsiParameter>(psi)
|
||||
@@ -97,7 +97,7 @@ open class KotlinUParameter(
|
||||
|
||||
open class KotlinUField(
|
||||
psi: PsiField,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractKotlinUVariable(), UField, PsiField by psi {
|
||||
|
||||
override val psi = unwrap<UField, PsiField>(psi)
|
||||
@@ -113,7 +113,7 @@ open class KotlinUField(
|
||||
|
||||
open class KotlinULocalVariable(
|
||||
psi: PsiLocalVariable,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractKotlinUVariable(), ULocalVariable, PsiLocalVariable by psi {
|
||||
|
||||
override val psi = unwrap<ULocalVariable, PsiLocalVariable>(psi)
|
||||
@@ -130,7 +130,7 @@ open class KotlinULocalVariable(
|
||||
|
||||
open class KotlinUEnumConstant(
|
||||
psi: PsiEnumConstant,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : AbstractKotlinUVariable(), UEnumConstant, PsiEnumConstant by psi {
|
||||
override val initializingClass: UClass? by lz { getLanguagePlugin().convertOpt<UClass>(psi.initializingClass, this) }
|
||||
|
||||
@@ -177,7 +177,7 @@ open class KotlinUEnumConstant(
|
||||
|
||||
private class KotlinEnumConstantClassReference(
|
||||
override val psi: PsiEnumConstant,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : JavaAbstractUExpression(), USimpleNameReferenceExpression {
|
||||
override fun resolve() = psi.containingClass
|
||||
override val resolvedName: String?
|
||||
|
||||
@@ -14,7 +14,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
||||
object : USimpleNameReferenceExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override fun resolve(): PsiElement? = variable
|
||||
override val containingElement: UElement? = containingElement
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val resolvedName: String? = variable.name
|
||||
override val annotations: List<UAnnotation> = emptyList()
|
||||
override val identifier: String = variable.name.orAnonymous()
|
||||
@@ -23,7 +23,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
||||
private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||
object : ULiteralExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val containingElement: UElement? = containingElement
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val value: Any? = null
|
||||
override val annotations: List<UAnnotation> = emptyList()
|
||||
}
|
||||
@@ -31,7 +31,7 @@ private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
||||
object : UBinaryExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val containingElement: UElement? = containingElement
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val leftOperand: UExpression by lz { createVariableReferenceExpression(variable, this) }
|
||||
override val rightOperand: UExpression by lz { createNullLiteralExpression(this) }
|
||||
override val operator: UastBinaryOperator = UastBinaryOperator.NOT_EQUALS
|
||||
@@ -53,7 +53,7 @@ private fun createElvisExpressions(
|
||||
|
||||
val ifExpression = object : UIfExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val containingElement: UElement? = containingElement
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val condition: UExpression by lz { createNotEqWithNullExpression(tempVariable, this) }
|
||||
override val thenExpression: UExpression? by lz { createVariableReferenceExpression(tempVariable, this) }
|
||||
override val elseExpression: UExpression? by lz { KotlinConverter.convertExpression(right, this) }
|
||||
@@ -73,7 +73,7 @@ fun createElvisExpression(elvisExpression: KtBinaryExpression, containingElement
|
||||
return object : UExpressionList, KotlinEvaluatableUElement, KotlinUElementWithType {
|
||||
override val psi: PsiElement? = elvisExpression
|
||||
override val kind = KotlinSpecialExpressionKinds.ELVIS
|
||||
override val containingElement: UElement? = containingElement
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val annotations: List<UAnnotation> = emptyList()
|
||||
override val expressions: List<UExpression> by lz {
|
||||
createElvisExpressions(left, right, this, elvisExpression.parent)
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UastBinaryOperator
|
||||
|
||||
class KotlinStringTemplateUPolyadicExpression(
|
||||
override val psi: KtStringTemplateExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(),
|
||||
UPolyadicExpression,
|
||||
KotlinUElementWithType,
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UElement
|
||||
|
||||
class KotlinUArrayAccessExpression(
|
||||
override val psi: KtArrayAccessExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UArrayAccessExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) }
|
||||
override val indices by lz { psi.indexExpressions.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.*
|
||||
|
||||
class KotlinUBinaryExpression(
|
||||
override val psi: KtBinaryExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBinaryExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
private companion object {
|
||||
val BITWISE_OPERATORS = mapOf(
|
||||
@@ -88,7 +88,7 @@ class KotlinUBinaryExpression(
|
||||
|
||||
class KotlinCustomUBinaryExpression(
|
||||
override val psi: PsiElement,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBinaryExpression {
|
||||
lateinit override var leftOperand: UExpression
|
||||
internal set
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.uast.*
|
||||
|
||||
class KotlinUBinaryExpressionWithType(
|
||||
override val psi: KtBinaryExpressionWithTypeRHS,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType,
|
||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
|
||||
@@ -44,7 +44,7 @@ class KotlinUBinaryExpressionWithType(
|
||||
|
||||
class KotlinCustomUBinaryExpressionWithType(
|
||||
override val psi: PsiElement,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType {
|
||||
lateinit override var operand: UExpression
|
||||
internal set
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UElement
|
||||
|
||||
class KotlinUBlockExpression(
|
||||
override val psi: KtBlockExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBlockExpression, KotlinUElementWithType {
|
||||
override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
||||
|
||||
class KotlinUBreakExpression(
|
||||
override val psi: KtBreakExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBreakExpression {
|
||||
override val label: String?
|
||||
get() = psi.getLabelName()
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.UExpression
|
||||
|
||||
class KotlinUCallableReferenceExpression(
|
||||
override val psi: KtCallableReferenceExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UCallableReferenceExpression, KotlinUElementWithType {
|
||||
override val qualifierExpression: UExpression?
|
||||
get() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
||||
|
||||
class KotlinUCatchClause(
|
||||
override val psi: KtCatchClause,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUElement(), UCatchClause {
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.catchBody, this) }
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UExpression
|
||||
|
||||
class KotlinUClassLiteralExpression(
|
||||
override val psi: KtClassLiteralExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UClassLiteralExpression, KotlinUElementWithType {
|
||||
override val type by lz {
|
||||
val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
||||
|
||||
class KotlinUContinueExpression(
|
||||
override val psi: KtContinueExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UContinueExpression {
|
||||
override val label: String?
|
||||
get() = psi.getLabelName()
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
||||
|
||||
class KotlinUDeclarationsExpression(
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UDeclarationsExpression {
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UIdentifier
|
||||
|
||||
class KotlinUDoWhileExpression(
|
||||
override val psi: KtDoWhileExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UDoWhileExpression {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.uast.UastSpecialExpressionKind
|
||||
open class KotlinUExpressionList(
|
||||
override val psi: PsiElement?,
|
||||
override val kind: UastSpecialExpressionKind, // original element
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UExpressionList, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override lateinit var expressions: List<UExpression>
|
||||
internal set
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.UastPsiParameterNotResolved
|
||||
|
||||
class KotlinUForEachExpression(
|
||||
override val psi: KtForExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UForEachExpression {
|
||||
override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import org.jetbrains.uast.visitor.UastVisitor
|
||||
|
||||
class KotlinUFunctionCallExpression(
|
||||
override val psi: KtCallExpression,
|
||||
override val containingElement: UElement?,
|
||||
override val uastParent: UElement?,
|
||||
private val _resolvedCall: ResolvedCall<*>? = null
|
||||
) : KotlinAbstractUExpression(), UCallExpression, KotlinUElementWithType {
|
||||
companion object {
|
||||
@@ -96,8 +96,8 @@ class KotlinUFunctionCallExpression(
|
||||
|
||||
override val receiver: UExpression?
|
||||
get() {
|
||||
return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this)
|
||||
containingElement.receiver
|
||||
return if (uastParent is UQualifiedReferenceExpression && uastParent.selector == this)
|
||||
uastParent.receiver
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UIfExpression
|
||||
|
||||
class KotlinUIfExpression(
|
||||
override val psi: KtIfExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UIfExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val thenExpression by lz { KotlinConverter.convertOrNull(psi.then, this) }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.ULabeledExpression
|
||||
|
||||
class KotlinULabeledExpression(
|
||||
override val psi: KtLabeledExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), ULabeledExpression {
|
||||
override val label: String
|
||||
get() = psi.getLabelName().orAnonymous("label")
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.withMargin
|
||||
|
||||
class KotlinULambdaExpression(
|
||||
override val psi: KtLambdaExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), ULambdaExpression, KotlinUElementWithType {
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.ULiteralExpression
|
||||
|
||||
class KotlinULiteralExpression(
|
||||
override val psi: KtConstantExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val isNull: Boolean
|
||||
get() = psi.unwrapBlockOrParenthesis().node?.elementType == KtNodeTypes.NULL
|
||||
@@ -35,7 +35,7 @@ class KotlinULiteralExpression(
|
||||
|
||||
class KotlinStringULiteralExpression(
|
||||
override val psi: PsiElement,
|
||||
override val containingElement: UElement?,
|
||||
override val uastParent: UElement?,
|
||||
val text: String? = null
|
||||
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType{
|
||||
override val value: String
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.*
|
||||
|
||||
class KotlinUObjectLiteralExpression(
|
||||
override val psi: KtObjectLiteralExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UObjectLiteralExpression, KotlinUElementWithType {
|
||||
override val declaration by lz { getLanguagePlugin().convert<UClass>(psi.objectDeclaration.toLightClass()!!, this) }
|
||||
|
||||
@@ -57,7 +57,7 @@ class KotlinUObjectLiteralExpression(
|
||||
|
||||
private class ObjectLiteralClassReference(
|
||||
override val psi: KtSuperTypeCallEntry,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUElement(), USimpleNameReferenceExpression {
|
||||
override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UParenthesizedExpression
|
||||
|
||||
class KotlinUParenthesizedExpression(
|
||||
override val psi: KtParenthesizedExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UParenthesizedExpression, KotlinUElementWithType {
|
||||
override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.*
|
||||
|
||||
class KotlinUPostfixExpression(
|
||||
override val psi: KtPostfixExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UPostfixExpression, KotlinUElementWithType, KotlinEvaluatableUElement, UResolvable {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.UastPrefixOperator
|
||||
|
||||
class KotlinUPrefixExpression(
|
||||
override val psi: KtPrefixExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UPrefixExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.UastQualifiedExpressionAccessType
|
||||
|
||||
class KotlinUQualifiedReferenceExpression(
|
||||
override val psi: KtDotQualifiedExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
@@ -43,7 +43,7 @@ class KotlinUQualifiedReferenceExpression(
|
||||
|
||||
class KotlinUComponentQualifiedReferenceExpression(
|
||||
override val psi: KtDestructuringDeclarationEntry,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val accessType = UastQualifiedExpressionAccessType.SIMPLE
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UReturnExpression
|
||||
|
||||
class KotlinUReturnExpression(
|
||||
override val psi: KtReturnExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UReturnExpression, KotlinUElementWithType {
|
||||
override val returnExpression by lz { KotlinConverter.convertOrNull(psi.returnedExpression, this) }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UQualifiedReferenceExpression
|
||||
|
||||
class KotlinUSafeQualifiedExpression(
|
||||
override val psi: KtSafeQualifiedExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
|
||||
+6
-6
@@ -36,7 +36,7 @@ import org.jetbrains.uast.visitor.UastVisitor
|
||||
open class KotlinUSimpleReferenceExpression(
|
||||
override val psi: KtSimpleNameExpression,
|
||||
override val identifier: String,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
private val resolvedDeclaration by lz { psi.resolveCallToDeclaration(this) }
|
||||
|
||||
@@ -90,7 +90,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
|
||||
class KotlinAccessorCallExpression(
|
||||
override val psi: KtElement,
|
||||
override val containingElement: KotlinUSimpleReferenceExpression,
|
||||
override val uastParent: KotlinUSimpleReferenceExpression,
|
||||
private val resolvedCall: ResolvedCall<*>,
|
||||
private val accessorDescriptor: DeclarationDescriptor,
|
||||
val setterValue: KtExpression?
|
||||
@@ -100,7 +100,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
|
||||
override val receiver: UExpression?
|
||||
get() {
|
||||
val containingElement = containingElement.containingElement
|
||||
val containingElement = uastParent.uastParent
|
||||
return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this)
|
||||
containingElement.receiver
|
||||
else
|
||||
@@ -116,7 +116,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
}
|
||||
|
||||
override val methodIdentifier: UIdentifier?
|
||||
get() = UIdentifier(containingElement.psi, this)
|
||||
get() = UIdentifier(uastParent.psi, this)
|
||||
|
||||
override val classReference: UReferenceExpression?
|
||||
get() = null
|
||||
@@ -184,7 +184,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
override val psi: KtCallExpression,
|
||||
override val identifier: String,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType {
|
||||
override val resolvedName: String?
|
||||
get() = (psi.getResolvedCall(psi.analyze())?.resultingDescriptor as? ConstructorDescriptor)
|
||||
@@ -200,7 +200,7 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
|
||||
class KotlinStringUSimpleReferenceExpression(
|
||||
override val identifier: String,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.USuperExpression
|
||||
|
||||
class KotlinUSuperExpression(
|
||||
override val psi: KtSuperExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), USuperExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val label: String?
|
||||
get() = psi.getLabelName()
|
||||
|
||||
+3
-4
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
||||
|
||||
class KotlinUSwitchExpression(
|
||||
override val psi: KtWhenExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), USwitchExpression, KotlinUElementWithType {
|
||||
override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) }
|
||||
|
||||
@@ -48,7 +48,7 @@ class KotlinUSwitchExpression(
|
||||
|
||||
class KotlinUSwitchEntry(
|
||||
override val psi: KtWhenEntry,
|
||||
override val containingElement: UExpression
|
||||
override val uastParent: UExpression
|
||||
) : KotlinAbstractUExpression(), USwitchClauseExpressionWithBody {
|
||||
override val caseValues by lz {
|
||||
psi.conditions.map { when (it) {
|
||||
@@ -89,13 +89,12 @@ class KotlinUSwitchEntry(
|
||||
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
||||
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
||||
}
|
||||
containingElement
|
||||
expressions = userExpressions + object : UBreakExpression {
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
override val label: String?
|
||||
get() = null
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
get() = this@KotlinUSwitchEntry
|
||||
override val annotations: List<UAnnotation>
|
||||
get() = emptyList()
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UThisExpression
|
||||
|
||||
class KotlinUThisExpression(
|
||||
override val psi: KtThisExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UThisExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val label: String?
|
||||
get() = psi.getLabelName()
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UThrowExpression
|
||||
|
||||
class KotlinUThrowExpression(
|
||||
override val psi: KtThrowExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UThrowExpression, KotlinUElementWithType {
|
||||
override val thrownExpression by lz { KotlinConverter.convertOrEmpty(psi.thrownExpression, this) }
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UVariable
|
||||
|
||||
class KotlinUTryExpression(
|
||||
override val psi: KtTryExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UTryExpression, KotlinUElementWithType {
|
||||
override val tryClause by lz { KotlinConverter.convertOrEmpty(psi.tryBlock, this) }
|
||||
override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UastBinaryExpressionWithTypeKind
|
||||
|
||||
class KotlinUTypeCheckExpression(
|
||||
override val psi: KtIsExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.leftHandSide, this) }
|
||||
|
||||
|
||||
+2
-2
@@ -8,13 +8,13 @@ import org.jetbrains.uast.UTypeReferenceExpression
|
||||
open class KotlinUTypeReferenceExpression(
|
||||
override val type: PsiType,
|
||||
override val psi: PsiElement?,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UTypeReferenceExpression, KotlinUElementWithType
|
||||
|
||||
|
||||
class LazyKotlinUTypeReferenceExpression(
|
||||
override val psi: PsiElement,
|
||||
override val containingElement: UElement?,
|
||||
override val uastParent: UElement?,
|
||||
private val typeSupplier: () -> PsiType
|
||||
) : KotlinAbstractUExpression(), UTypeReferenceExpression {
|
||||
override val type: PsiType by lz { typeSupplier() }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UWhileExpression
|
||||
|
||||
class KotlinUWhileExpression(
|
||||
override val psi: KtWhileExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UWhileExpression {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
||||
private class KotlinLocalFunctionUVariable(
|
||||
val function: KtFunction,
|
||||
override val psi: PsiVariable,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : UVariable, PsiVariable by psi {
|
||||
override val uastInitializer: UExpression? by lz {
|
||||
createLocalFunctionLambdaExpression(function, this)
|
||||
@@ -27,7 +27,7 @@ private class KotlinLocalFunctionUVariable(
|
||||
|
||||
private class KotlinLocalFunctionULambdaExpression(
|
||||
override val psi: KtFunction,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
): KotlinAbstractUExpression(), ULambdaExpression {
|
||||
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UExpression
|
||||
|
||||
class UnknownKotlinExpression(
|
||||
override val psi: KtExpression,
|
||||
override val containingElement: UElement?
|
||||
override val uastParent: UElement?
|
||||
) : KotlinAbstractUExpression(), UExpression {
|
||||
override fun asLogString() = "[!] UnknownKotlinExpression ($psi)"
|
||||
}
|
||||
Reference in New Issue
Block a user