Kotlin Uast: support class literal expressions.
Ability to get type of class of class literal expressions.
This commit is contained in:
@@ -18,4 +18,6 @@ package org.jetbrains.uast
|
|||||||
interface UClassLiteralExpression : UExpression, NoTraverse {
|
interface UClassLiteralExpression : UExpression, NoTraverse {
|
||||||
override fun logString() = "UClassLiteralExpression"
|
override fun logString() = "UClassLiteralExpression"
|
||||||
override fun renderString() = getExpressionType()?.name ?: "::class"
|
override fun renderString() = getExpressionType()?.name ?: "::class"
|
||||||
|
|
||||||
|
val type: UType
|
||||||
}
|
}
|
||||||
+4
-1
@@ -19,9 +19,12 @@ import com.intellij.psi.PsiClassObjectAccessExpression
|
|||||||
import org.jetbrains.uast.NoEvaluate
|
import org.jetbrains.uast.NoEvaluate
|
||||||
import org.jetbrains.uast.UClassLiteralExpression
|
import org.jetbrains.uast.UClassLiteralExpression
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UType
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
class JavaUClassLiteralExpression(
|
class JavaUClassLiteralExpression(
|
||||||
override val psi: PsiClassObjectAccessExpression,
|
override val psi: PsiClassObjectAccessExpression,
|
||||||
override val parent: UElement
|
override val parent: UElement
|
||||||
) : JavaAbstractUElement(), UClassLiteralExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
) : JavaAbstractUElement(), UClassLiteralExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||||
|
override val type: UType by lz { JavaConverter.convert(psi.type, this) }
|
||||||
|
}
|
||||||
@@ -128,6 +128,7 @@ internal object KotlinConverter : UastConverter {
|
|||||||
}
|
}
|
||||||
declarations = listOf(tempAssignment) + destructuringAssignments
|
declarations = listOf(tempAssignment) + destructuringAssignments
|
||||||
}
|
}
|
||||||
|
is KtClassLiteralExpression -> KotlinUClassLiteralExpression(expression, parent)
|
||||||
is KtObjectLiteralExpression -> KotlinUObjectLiteralExpression(expression, parent)
|
is KtObjectLiteralExpression -> KotlinUObjectLiteralExpression(expression, parent)
|
||||||
is KtStringTemplateEntry -> convertOrEmpty(expression.expression, parent)
|
is KtStringTemplateEntry -> convertOrEmpty(expression.expression, parent)
|
||||||
is KtDotQualifiedExpression -> KotlinUQualifiedExpression(expression, parent)
|
is KtDotQualifiedExpression -> KotlinUQualifiedExpression(expression, parent)
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.uast
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
|
||||||
|
import org.jetbrains.uast.NoEvaluate
|
||||||
|
import org.jetbrains.uast.UClassLiteralExpression
|
||||||
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
|
class KotlinUClassLiteralExpression(
|
||||||
|
override val psi: KtClassLiteralExpression,
|
||||||
|
override val parent: UElement
|
||||||
|
) : KotlinAbstractUElement(), UClassLiteralExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||||
|
override val type by lz { KotlinConverter.convert(psi.typeReference, this) }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user