FIR UAST: implement constructors/delegations
But, the logic is identical to the counterpart in FE1.0 UAST Many declaration abstractions, such as (primary|secondary) constructor methods and class, are very similar, and thus can be commonized soon once the remaining parts (in particular, annotations) are done.
This commit is contained in:
committed by
Ilya Kirillov
parent
8b3c6489da
commit
31d1c002c5
@@ -5,11 +5,18 @@
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.uast.*
|
||||
|
||||
interface BaseKotlinConverter {
|
||||
|
||||
fun convertDeclaration(
|
||||
element: PsiElement,
|
||||
givenParent: UElement?,
|
||||
requiredTypes: Array<out Class<out UElement>>
|
||||
): UElement?
|
||||
|
||||
fun convertReceiverParameter(receiver: KtTypeReference): UParameter? {
|
||||
val call = (receiver.parent as? KtCallableDeclaration) ?: return null
|
||||
if (call.receiverTypeReference != receiver) return null
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
||||
|
||||
class KotlinSupertypeDelegationUExpression(
|
||||
override val sourcePsi: KtDelegatedSuperTypeEntry,
|
||||
givenParent: UElement?
|
||||
) : KotlinAbstractUExpression(givenParent), UExpressionList {
|
||||
|
||||
override val psi: PsiElement
|
||||
get() = sourcePsi
|
||||
|
||||
val typeReference: UTypeReferenceExpression? by lz {
|
||||
sourcePsi.typeReference?.let {
|
||||
KotlinUTypeReferenceExpression(it, this) {
|
||||
baseResolveProviderService.resolveToType(it, this) ?: UastErrorType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val delegateExpression: UExpression? by lz {
|
||||
sourcePsi.delegateExpression?.let { languagePlugin?.convertElement(it, this, UExpression::class.java) as? UExpression }
|
||||
}
|
||||
|
||||
override val expressions: List<UExpression>
|
||||
get() = listOfNotNull(typeReference, delegateExpression)
|
||||
|
||||
override val kind: UastSpecialExpressionKind
|
||||
get() = KotlinSpecialExpressionKinds.SUPER_DELEGATION
|
||||
}
|
||||
+5
@@ -5,8 +5,10 @@
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.elements.FakeFileForLightClass
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightMember
|
||||
@@ -52,3 +54,6 @@ fun KtElement.canAnalyze(): Boolean {
|
||||
if (containingFile.doNotAnalyze != null) return false // To prevent exceptions during analysis
|
||||
return true
|
||||
}
|
||||
|
||||
val PsiClass.isEnumEntryLightClass: Boolean
|
||||
get() = (this as? KtLightClass)?.kotlinOrigin is KtEnumEntry
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtBlockExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.kotlin.internal.KotlinFakeUElement
|
||||
|
||||
@@ -66,3 +68,19 @@ fun wrapExpressionBody(function: UElement, bodyExpression: KtExpression): UExpre
|
||||
}
|
||||
else -> function.getLanguagePlugin().convertElement(bodyExpression, function) as? UExpression
|
||||
}
|
||||
|
||||
fun reportConvertFailure(psiMethod: PsiMethod): Nothing {
|
||||
val isValid = psiMethod.isValid
|
||||
val report = KotlinExceptionWithAttachments(
|
||||
"cant convert $psiMethod of ${psiMethod.javaClass} to UMethod" + if (!isValid) " (method is not valid)" else ""
|
||||
)
|
||||
|
||||
if (isValid) {
|
||||
report.withAttachment("method", psiMethod.text)
|
||||
psiMethod.containingFile?.let {
|
||||
report.withAttachment("file", it.text)
|
||||
}
|
||||
}
|
||||
|
||||
throw report
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ internal object FirKotlinConverter : BaseKotlinConverter {
|
||||
?: convertPsiElement(element, givenParent, requiredTypes)
|
||||
}
|
||||
|
||||
internal fun convertDeclaration(
|
||||
override fun convertDeclaration(
|
||||
element: PsiElement,
|
||||
givenParent: UElement?,
|
||||
requiredTypes: Array<out Class<out UElement>>
|
||||
@@ -104,6 +104,10 @@ internal object FirKotlinConverter : BaseKotlinConverter {
|
||||
// TODO: KtAnnotationEntry
|
||||
// TODO: KtCallExpression (for nested annotation)
|
||||
|
||||
is KtDelegatedSuperTypeEntry -> el<KotlinSupertypeDelegationUExpression> {
|
||||
KotlinSupertypeDelegationUExpression(original, givenParent)
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
+65
-11
@@ -5,17 +5,21 @@
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiIdentifier
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
|
||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.internal.acceptList
|
||||
import org.jetbrains.uast.visitor.UastVisitor
|
||||
|
||||
// TODO: can be commonized once annotation is handled
|
||||
sealed class AbstractFirKotlinUClass(
|
||||
givenParent: UElement?
|
||||
) : KotlinAbstractUElement(givenParent), UClass, UAnchorOwner {
|
||||
@@ -41,11 +45,14 @@ sealed class AbstractFirKotlinUClass(
|
||||
KotlinUTypeReferenceExpression(it, this)
|
||||
}
|
||||
|
||||
// TODO: delegateExpressions
|
||||
val delegateExpressions: List<UExpression>
|
||||
get() = ktClass?.superTypeListEntries.orEmpty()
|
||||
.filterIsInstance<KtDelegatedSuperTypeEntry>()
|
||||
.map { KotlinSupertypeDelegationUExpression(it, this) }
|
||||
|
||||
override fun accept(visitor: UastVisitor) {
|
||||
if (visitor.visitClass(this)) return
|
||||
// TODO: delegate expressions
|
||||
delegateExpressions.acceptList(visitor)
|
||||
uAnnotations.acceptList(visitor)
|
||||
uastDeclarations.acceptList(visitor)
|
||||
visitor.afterVisitClass(this)
|
||||
@@ -63,6 +70,7 @@ sealed class AbstractFirKotlinUClass(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: can be commonized once *KotlinUClass is commonized
|
||||
class FirKotlinUClass(
|
||||
override val javaPsi: KtLightClass,
|
||||
givenParent: UElement?,
|
||||
@@ -92,8 +100,13 @@ class FirKotlinUClass(
|
||||
}
|
||||
|
||||
override fun getInnerClasses(): Array<UClass> {
|
||||
// TODO: Not yet implemented
|
||||
return super.getInnerClasses()
|
||||
// filter DefaultImpls to avoid processing same methods from original interface multiple times
|
||||
// filter Enum entry classes to avoid duplication with PsiEnumConstant initializer class
|
||||
return psi.innerClasses.filter {
|
||||
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass
|
||||
}.mapNotNull {
|
||||
languagePlugin?.convertOpt<UClass>(it, this)
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
||||
override fun getSuperClass(): UClass? {
|
||||
@@ -101,7 +114,6 @@ class FirKotlinUClass(
|
||||
}
|
||||
|
||||
override fun getFields(): Array<UField> {
|
||||
// TODO: Not yet implemented
|
||||
return super.getFields()
|
||||
}
|
||||
|
||||
@@ -111,8 +123,50 @@ class FirKotlinUClass(
|
||||
}
|
||||
|
||||
override fun getMethods(): Array<UMethod> {
|
||||
// TODO: Not yet implemented
|
||||
return super.getMethods()
|
||||
val hasPrimaryConstructor = ktClass?.hasPrimaryConstructor() ?: false
|
||||
var secondaryConstructorsCount = 0
|
||||
|
||||
fun createUMethod(psiMethod: PsiMethod): UMethod {
|
||||
return if (psiMethod is KtLightMethod && psiMethod.isConstructor) {
|
||||
if (!hasPrimaryConstructor && secondaryConstructorsCount++ == 0)
|
||||
FirKotlinSecondaryConstructorWithInitializersUMethod(ktClass, psiMethod, this)
|
||||
else
|
||||
FirKotlinConstructorUMethod(ktClass, psiMethod, this)
|
||||
} else {
|
||||
languagePlugin?.convertOpt(psiMethod, this) ?: reportConvertFailure(psiMethod)
|
||||
}
|
||||
}
|
||||
|
||||
fun isDelegatedMethod(psiMethod: PsiMethod) = psiMethod is KtLightMethod && psiMethod.isDelegated
|
||||
|
||||
val result = ArrayList<UMethod>(javaPsi.methods.size)
|
||||
val handledKtDeclarations = mutableSetOf<PsiElement>()
|
||||
|
||||
for (lightMethod in javaPsi.methods) {
|
||||
if (isDelegatedMethod(lightMethod)) continue
|
||||
val uMethod = createUMethod(lightMethod)
|
||||
result.add(uMethod)
|
||||
|
||||
// Ensure we pick the main Kotlin origin, not the auxiliary one
|
||||
val kotlinOrigin = (lightMethod as? KtLightMethod)?.kotlinOrigin ?: uMethod.sourcePsi
|
||||
handledKtDeclarations.addIfNotNull(kotlinOrigin)
|
||||
}
|
||||
|
||||
val ktDeclarations: List<KtDeclaration> = run ktDeclarations@{
|
||||
ktClass?.let { return@ktDeclarations it.declarations }
|
||||
(javaPsi as? KtLightClassForFacade)?.let { facade ->
|
||||
return@ktDeclarations facade.files.flatMap { file -> file.declarations }
|
||||
}
|
||||
emptyList()
|
||||
}
|
||||
|
||||
ktDeclarations.asSequence()
|
||||
.filterNot { handledKtDeclarations.contains(it) }
|
||||
.mapNotNullTo(result) {
|
||||
baseResolveProviderService.baseKotlinConverter.convertDeclaration(it, this, arrayOf(UElement::class.java)) as? UMethod
|
||||
}
|
||||
|
||||
return result.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+49
-1
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.asJava.elements.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.uast.*
|
||||
|
||||
open class FirKotlinUMethod(
|
||||
@@ -124,7 +125,8 @@ open class FirKotlinUMethod(
|
||||
}
|
||||
}
|
||||
|
||||
class FirKotlinConstructorUMethod(
|
||||
// TODO: can be commonized if *KotlinUMethod is commonized
|
||||
open class FirKotlinConstructorUMethod(
|
||||
private val ktClass: KtClassOrObject?,
|
||||
override val psi: PsiMethod,
|
||||
kotlinOrigin: KtDeclaration?,
|
||||
@@ -141,6 +143,29 @@ class FirKotlinConstructorUMethod(
|
||||
val isPrimary: Boolean
|
||||
get() = sourcePsi is KtPrimaryConstructor || sourcePsi is KtClassOrObject
|
||||
|
||||
override val uastBody: UExpression? by lz {
|
||||
val delegationCall: KtCallElement? = sourcePsi.let {
|
||||
when {
|
||||
isPrimary -> ktClass?.superTypeListEntries?.firstIsInstanceOrNull<KtSuperTypeCallEntry>()
|
||||
it is KtSecondaryConstructor -> it.getDelegationCall()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
val bodyExpressions = getBodyExpressions()
|
||||
if (delegationCall == null && bodyExpressions.isEmpty()) return@lz null
|
||||
KotlinLazyUBlockExpression(this) { uastParent ->
|
||||
SmartList<UExpression>().apply {
|
||||
delegationCall?.let {
|
||||
// TODO: function call for delegationCall
|
||||
add(UastEmptyExpression(uastParent))
|
||||
}
|
||||
bodyExpressions.forEach {
|
||||
add(baseResolveProviderService.baseKotlinConverter.convertOrEmpty(it, uastParent))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val uastAnchor: UIdentifier? by lz {
|
||||
KotlinUIdentifier(
|
||||
javaPsi.nameIdentifier,
|
||||
@@ -148,4 +173,27 @@ class FirKotlinConstructorUMethod(
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
protected open fun getBodyExpressions(): List<KtExpression> {
|
||||
if (isPrimary) return getInitializers()
|
||||
val bodyExpression = (sourcePsi as? KtFunction)?.bodyExpression ?: return emptyList()
|
||||
if (bodyExpression is KtBlockExpression) return bodyExpression.statements
|
||||
return listOf(bodyExpression)
|
||||
}
|
||||
|
||||
protected fun getInitializers(): List<KtExpression> {
|
||||
return ktClass?.getAnonymousInitializers()?.mapNotNull { it.body } ?: emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: can be commonized if *KotlinUMethod is commonized
|
||||
// also reuse the comments there (about KT-21617)
|
||||
class FirKotlinSecondaryConstructorWithInitializersUMethod(
|
||||
ktClass: KtClassOrObject?,
|
||||
psi: KtLightMethod,
|
||||
givenParent: UElement?
|
||||
) : FirKotlinConstructorUMethod(ktClass, psi, givenParent) {
|
||||
override fun getBodyExpressions(): List<KtExpression> {
|
||||
return getInitializers() + super.getBodyExpressions()
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -16,5 +16,11 @@ UFile (package = )
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UClass (name = Derived)
|
||||
UExpressionList (super_delegation)
|
||||
UTypeReferenceExpression (name = Base)
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UExpressionList (super_delegation)
|
||||
UTypeReferenceExpression (name = java.lang.CharSequence)
|
||||
ULiteralExpression (value = "abc")
|
||||
UMethod (name = Derived)
|
||||
UParameter (name = b)
|
||||
|
||||
@@ -5,20 +5,34 @@ UFile (package = )
|
||||
UParameter (name = str)
|
||||
UMethod (name = A)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UMethod (name = getStr)
|
||||
UClass (name = AWithInit)
|
||||
UField (name = str)
|
||||
UMethod (name = AWithInit)
|
||||
UParameter (name = str)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UMethod (name = AWithInit)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UMethod (name = getStr)
|
||||
UClass (name = AWith2Init)
|
||||
UField (name = str)
|
||||
UMethod (name = AWith2Init)
|
||||
UParameter (name = str)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UMethod (name = AWith2Init)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UMethod (name = getStr)
|
||||
UClass (name = AOnlyInit)
|
||||
UMethod (name = AOnlyInit)
|
||||
@@ -27,10 +41,12 @@ UFile (package = )
|
||||
UMethod (name = AWithSecondary)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
UMethod (name = AWithSecondary)
|
||||
UParameter (name = s)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
UMethod (name = getA)
|
||||
UMethod (name = setA)
|
||||
@@ -40,10 +56,14 @@ UFile (package = )
|
||||
UMethod (name = AWithSecondaryInit)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
UMethod (name = AWithSecondaryInit)
|
||||
UParameter (name = s)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
[!] UnknownKotlinExpression (PROPERTY)
|
||||
[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION)
|
||||
@@ -54,4 +74,7 @@ UFile (package = )
|
||||
UField (name = a)
|
||||
UMethod (name = AWithFieldInit)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
UMethod (name = getA)
|
||||
|
||||
+34
-6
@@ -1,21 +1,38 @@
|
||||
public final class A {
|
||||
private final var str: java.lang.String
|
||||
public fun A(str: java.lang.String) = UastEmptyExpression
|
||||
public fun A(i: int) = UastEmptyExpression
|
||||
public fun A(i: int) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
public final fun getStr() : java.lang.String = UastEmptyExpression
|
||||
}
|
||||
|
||||
public final class AWithInit {
|
||||
private final var str: java.lang.String
|
||||
public fun AWithInit(str: java.lang.String) = UastEmptyExpression
|
||||
public fun AWithInit(i: int) = UastEmptyExpression
|
||||
public fun AWithInit(str: java.lang.String) {
|
||||
{
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
}
|
||||
}
|
||||
public fun AWithInit(i: int) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
public final fun getStr() : java.lang.String = UastEmptyExpression
|
||||
}
|
||||
|
||||
public final class AWith2Init {
|
||||
private final var str: java.lang.String
|
||||
public fun AWith2Init(str: java.lang.String) = UastEmptyExpression
|
||||
public fun AWith2Init(i: int) = UastEmptyExpression
|
||||
public fun AWith2Init(str: java.lang.String) {
|
||||
{
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
}
|
||||
{
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
}
|
||||
}
|
||||
public fun AWith2Init(i: int) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
public final fun getStr() : java.lang.String = UastEmptyExpression
|
||||
}
|
||||
|
||||
@@ -26,9 +43,11 @@ public final class AOnlyInit {
|
||||
public final class AWithSecondary {
|
||||
private var a: java.lang.String
|
||||
public fun AWithSecondary(i: int) {
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
}
|
||||
public fun AWithSecondary(s: java.lang.String) {
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
}
|
||||
public final fun getA() : java.lang.String = UastEmptyExpression
|
||||
@@ -38,9 +57,14 @@ public final class AWithSecondary {
|
||||
public final class AWithSecondaryInit {
|
||||
private var a: java.lang.String
|
||||
public fun AWithSecondaryInit(i: int) {
|
||||
UastEmptyExpression
|
||||
{
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
}
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
}
|
||||
public fun AWithSecondaryInit(s: java.lang.String) {
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
[!] UnknownKotlinExpression (PROPERTY)
|
||||
[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION)
|
||||
@@ -51,6 +75,10 @@ public final class AWithSecondaryInit {
|
||||
|
||||
public final class AWithFieldInit {
|
||||
private final var a: java.lang.String
|
||||
public fun AWithFieldInit(i: int) = UastEmptyExpression
|
||||
public fun AWithFieldInit(i: int) {
|
||||
{
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
}
|
||||
}
|
||||
public final fun getA() : java.lang.String = UastEmptyExpression
|
||||
}
|
||||
|
||||
+3
@@ -22,6 +22,9 @@ UFile (package = )
|
||||
UField (name = mutableProp)
|
||||
UMethod (name = A)
|
||||
UParameter (name = init)
|
||||
UBlockExpression
|
||||
UBlockExpression
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
UMethod (name = getMutableProp)
|
||||
UMethod (name = setMutableProp)
|
||||
UParameter (name = value)
|
||||
|
||||
+5
-1
@@ -19,7 +19,11 @@ public final class PropertyReferencesKt {
|
||||
public final class A {
|
||||
private var privateProp: int = "not-yet-compile-time-constant"
|
||||
private var mutableProp: int
|
||||
public fun A(init: int) = UastEmptyExpression
|
||||
public fun A(init: int) {
|
||||
{
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION)
|
||||
}
|
||||
}
|
||||
public final fun getMutableProp() : int = UastEmptyExpression
|
||||
public final fun setMutableProp(value: int) : void = UastEmptyExpression
|
||||
public final fun add(x: int) : int {
|
||||
|
||||
@@ -12,6 +12,8 @@ UFile (package = )
|
||||
UParameter (name = str)
|
||||
UMethod (name = A)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UMethod (name = getStr)
|
||||
UMethod (name = foo)
|
||||
UParameter (name = a)
|
||||
@@ -19,12 +21,17 @@ UFile (package = )
|
||||
UClass (name = B)
|
||||
UMethod (name = B)
|
||||
UParameter (name = param)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UClass (name = C)
|
||||
UMethod (name = C)
|
||||
UParameter (name = p)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
UMethod (name = C)
|
||||
UParameter (name = i)
|
||||
UBlockExpression
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
UMethod (name = foo)
|
||||
UParameter (name = a)
|
||||
|
||||
+10
-3
@@ -8,19 +8,26 @@ public final class SuperCallsKt {
|
||||
public class A {
|
||||
private final var str: java.lang.String
|
||||
public fun A(str: java.lang.String) = UastEmptyExpression
|
||||
public fun A(i: int) = UastEmptyExpression
|
||||
public fun A(i: int) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
public final fun getStr() : java.lang.String = UastEmptyExpression
|
||||
public fun foo(a: long) : void {
|
||||
}
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public fun B(param: java.lang.String) = UastEmptyExpression
|
||||
public fun B(param: java.lang.String) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
}
|
||||
|
||||
public final class C : A {
|
||||
public fun C(p: java.lang.String) = UastEmptyExpression
|
||||
public fun C(p: java.lang.String) {
|
||||
UastEmptyExpression
|
||||
}
|
||||
public fun C(i: int) {
|
||||
UastEmptyExpression
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION)
|
||||
}
|
||||
public fun foo(a: long) : void {
|
||||
|
||||
+6
@@ -16,5 +16,11 @@ UFile (package = ) [public final class ConstructorDelegateKt {...]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UClass (name = Derived) [public final class Derived : Base, java.lang.CharSequence {...}]
|
||||
UExpressionList (super_delegation) [super_delegation Base : [!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UTypeReferenceExpression (name = Base) [Base]
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UExpressionList (super_delegation) [super_delegation java.lang.CharSequence : "abc"]
|
||||
UTypeReferenceExpression (name = java.lang.CharSequence) [java.lang.CharSequence]
|
||||
ULiteralExpression (value = "abc") ["abc"] : PsiType:String
|
||||
UMethod (name = Derived) [public fun Derived(b: Base) = UastEmptyExpression]
|
||||
UParameter (name = b) [var b: Base]
|
||||
|
||||
@@ -3,22 +3,36 @@ UFile (package = ) [public final class A {...]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(str: java.lang.String) = UastEmptyExpression]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(i: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AWithInit) [public final class AWithInit {...}]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(str: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(str: java.lang.String) {...}]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(i: int) = UastEmptyExpression]
|
||||
UBlockExpression [{...}]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AWith2Init) [public final class AWith2Init {...}]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(str: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(str: java.lang.String) {...}]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(i: int) = UastEmptyExpression]
|
||||
UBlockExpression [{...}]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AOnlyInit) [public final class AOnlyInit {...}]
|
||||
UMethod (name = AOnlyInit) [public fun AOnlyInit() = UastEmptyExpression]
|
||||
@@ -26,11 +40,13 @@ UFile (package = ) [public final class A {...]
|
||||
UField (name = a) [private var a: java.lang.String]
|
||||
UMethod (name = AWithSecondary) [public fun AWithSecondary(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
UMethod (name = AWithSecondary) [public fun AWithSecondary(s: java.lang.String) {...}]
|
||||
UParameter (name = s) [var s: java.lang.String]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
UMethod (name = getA) [public final fun getA() : java.lang.String = UastEmptyExpression]
|
||||
UMethod (name = setA) [public final fun setA(value: java.lang.String) : void = UastEmptyExpression]
|
||||
@@ -39,11 +55,15 @@ UFile (package = ) [public final class A {...]
|
||||
UField (name = a) [private var a: java.lang.String]
|
||||
UMethod (name = AWithSecondaryInit) [public fun AWithSecondaryInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
UMethod (name = AWithSecondaryInit) [public fun AWithSecondaryInit(s: java.lang.String) {...}]
|
||||
UParameter (name = s) [var s: java.lang.String]
|
||||
UBlockExpression [{...}] : PsiType:String
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
[!] UnknownKotlinExpression (PROPERTY) [[!] UnknownKotlinExpression (PROPERTY)]
|
||||
[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION) [[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION)]
|
||||
@@ -52,6 +72,9 @@ UFile (package = ) [public final class A {...]
|
||||
UParameter (name = value) [var value: java.lang.String]
|
||||
UClass (name = AWithFieldInit) [public final class AWithFieldInit {...}]
|
||||
UField (name = a) [private final var a: java.lang.String]
|
||||
UMethod (name = AWithFieldInit) [public fun AWithFieldInit(i: int) = UastEmptyExpression]
|
||||
UMethod (name = AWithFieldInit) [public fun AWithFieldInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
UMethod (name = getA) [public final fun getA() : java.lang.String = UastEmptyExpression]
|
||||
|
||||
+4
-1
@@ -20,8 +20,11 @@ UFile (package = ) [public final class PropertyReferencesKt {...]
|
||||
UField (name = privateProp) [private var privateProp: int = "not-yet-compile-time-constant"]
|
||||
ULiteralExpression (value = "not-yet-compile-time-constant") ["not-yet-compile-time-constant"] : PsiType:int
|
||||
UField (name = mutableProp) [private var mutableProp: int]
|
||||
UMethod (name = A) [public fun A(init: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(init: int) {...}]
|
||||
UParameter (name = init) [var init: int]
|
||||
UBlockExpression [{...}]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)]
|
||||
UMethod (name = getMutableProp) [public final fun getMutableProp() : int = UastEmptyExpression]
|
||||
UMethod (name = setMutableProp) [public final fun setMutableProp(value: int) : void = UastEmptyExpression]
|
||||
UParameter (name = value) [var value: int]
|
||||
|
||||
@@ -10,21 +10,28 @@ UFile (package = ) [public final class SuperCallsKt {...]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(str: java.lang.String) = UastEmptyExpression]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(i: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UMethod (name = foo) [public fun foo(a: long) : void {...}]
|
||||
UParameter (name = a) [var a: long]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UClass (name = B) [public final class B : A {...}]
|
||||
UMethod (name = B) [public fun B(param: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = B) [public fun B(param: java.lang.String) {...}]
|
||||
UParameter (name = param) [var param: java.lang.String]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UClass (name = C) [public final class C : A {...}]
|
||||
UMethod (name = C) [public fun C(p: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = C) [public fun C(p: java.lang.String) {...}]
|
||||
UParameter (name = p) [var p: java.lang.String]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = C) [public fun C(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
|
||||
UMethod (name = foo) [public fun foo(a: long) : void {...}]
|
||||
UParameter (name = a) [var a: long]
|
||||
|
||||
+6
@@ -16,5 +16,11 @@ UFile (package = ) [public final class ConstructorDelegateKt {...]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UClass (name = Derived) [public final class Derived : Base, java.lang.CharSequence {...}]
|
||||
UExpressionList (super_delegation) [super_delegation Base : [!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UTypeReferenceExpression (name = Base) [Base] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UExpressionList (super_delegation) [super_delegation java.lang.CharSequence : "abc"] = Undetermined
|
||||
UTypeReferenceExpression (name = java.lang.CharSequence) [java.lang.CharSequence] = Undetermined
|
||||
ULiteralExpression (value = "abc") ["abc"] = Undetermined
|
||||
UMethod (name = Derived) [public fun Derived(b: Base) = UastEmptyExpression]
|
||||
UParameter (name = b) [var b: Base]
|
||||
|
||||
@@ -3,22 +3,36 @@ UFile (package = ) [public final class A {...]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(str: java.lang.String) = UastEmptyExpression]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(i: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AWithInit) [public final class AWithInit {...}]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(str: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(str: java.lang.String) {...}]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = AWithInit) [public fun AWithInit(i: int) = UastEmptyExpression]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UMethod (name = AWithInit) [public fun AWithInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AWith2Init) [public final class AWith2Init {...}]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(str: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(str: java.lang.String) {...}]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(i: int) = UastEmptyExpression]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UMethod (name = AWith2Init) [public fun AWith2Init(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UClass (name = AOnlyInit) [public final class AOnlyInit {...}]
|
||||
UMethod (name = AOnlyInit) [public fun AOnlyInit() = UastEmptyExpression]
|
||||
@@ -27,10 +41,12 @@ UFile (package = ) [public final class A {...]
|
||||
UMethod (name = AWithSecondary) [public fun AWithSecondary(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
UMethod (name = AWithSecondary) [public fun AWithSecondary(s: java.lang.String) {...}]
|
||||
UParameter (name = s) [var s: java.lang.String]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
UMethod (name = getA) [public final fun getA() : java.lang.String = UastEmptyExpression]
|
||||
UMethod (name = setA) [public final fun setA(value: java.lang.String) : void = UastEmptyExpression]
|
||||
@@ -40,10 +56,14 @@ UFile (package = ) [public final class A {...]
|
||||
UMethod (name = AWithSecondaryInit) [public fun AWithSecondaryInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
UMethod (name = AWithSecondaryInit) [public fun AWithSecondaryInit(s: java.lang.String) {...}]
|
||||
UParameter (name = s) [var s: java.lang.String]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
[!] UnknownKotlinExpression (PROPERTY) [[!] UnknownKotlinExpression (PROPERTY)] = Undetermined
|
||||
[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION) [[!] UnknownKotlinExpression (DOT_QUALIFIED_EXPRESSION)] = Undetermined
|
||||
@@ -52,6 +72,9 @@ UFile (package = ) [public final class A {...]
|
||||
UParameter (name = value) [var value: java.lang.String]
|
||||
UClass (name = AWithFieldInit) [public final class AWithFieldInit {...}]
|
||||
UField (name = a) [private final var a: java.lang.String]
|
||||
UMethod (name = AWithFieldInit) [public fun AWithFieldInit(i: int) = UastEmptyExpression]
|
||||
UMethod (name = AWithFieldInit) [public fun AWithFieldInit(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
UMethod (name = getA) [public final fun getA() : java.lang.String = UastEmptyExpression]
|
||||
|
||||
+4
-1
@@ -20,8 +20,11 @@ UFile (package = ) [public final class PropertyReferencesKt {...]
|
||||
UField (name = privateProp) [private var privateProp: int = "not-yet-compile-time-constant"]
|
||||
ULiteralExpression (value = "not-yet-compile-time-constant") ["not-yet-compile-time-constant"] = "not-yet-compile-time-constant"
|
||||
UField (name = mutableProp) [private var mutableProp: int]
|
||||
UMethod (name = A) [public fun A(init: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(init: int) {...}]
|
||||
UParameter (name = init) [var init: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
[!] UnknownKotlinExpression (BINARY_EXPRESSION) [[!] UnknownKotlinExpression (BINARY_EXPRESSION)] = Undetermined
|
||||
UMethod (name = getMutableProp) [public final fun getMutableProp() : int = UastEmptyExpression]
|
||||
UMethod (name = setMutableProp) [public final fun setMutableProp(value: int) : void = UastEmptyExpression]
|
||||
UParameter (name = value) [var value: int]
|
||||
|
||||
@@ -10,21 +10,28 @@ UFile (package = ) [public final class SuperCallsKt {...]
|
||||
UField (name = str) [private final var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(str: java.lang.String) = UastEmptyExpression]
|
||||
UParameter (name = str) [var str: java.lang.String]
|
||||
UMethod (name = A) [public fun A(i: int) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UMethod (name = getStr) [public final fun getStr() : java.lang.String = UastEmptyExpression]
|
||||
UMethod (name = foo) [public fun foo(a: long) : void {...}]
|
||||
UParameter (name = a) [var a: long]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UClass (name = B) [public final class B : A {...}]
|
||||
UMethod (name = B) [public fun B(param: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = B) [public fun B(param: java.lang.String) {...}]
|
||||
UParameter (name = param) [var param: java.lang.String]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UClass (name = C) [public final class C : A {...}]
|
||||
UMethod (name = C) [public fun C(p: java.lang.String) = UastEmptyExpression]
|
||||
UMethod (name = C) [public fun C(p: java.lang.String) {...}]
|
||||
UParameter (name = p) [var p: java.lang.String]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
UMethod (name = C) [public fun C(i: int) {...}]
|
||||
UParameter (name = i) [var i: int]
|
||||
UBlockExpression [{...}] = Undetermined
|
||||
UastEmptyExpression [UastEmptyExpression] = Undetermined
|
||||
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
|
||||
UMethod (name = foo) [public fun foo(a: long) : void {...}]
|
||||
UParameter (name = a) [var a: long]
|
||||
|
||||
@@ -5,8 +5,10 @@ UFile (package = ) [public final class UnresolvedKt {...]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
UClass (name = A) [public final class A : error.NonExistentClass {...}]
|
||||
UField (name = prop) [private final var prop: error.NonExistentClass]
|
||||
UMethod (name = A) [public fun A(prop: error.NonExistentClass) = UastEmptyExpression]
|
||||
UMethod (name = A) [public fun A(prop: error.NonExistentClass) {...}]
|
||||
UParameter (name = prop) [var prop: error.NonExistentClass]
|
||||
UBlockExpression [{...}]
|
||||
UastEmptyExpression [UastEmptyExpression]
|
||||
UMethod (name = getProp) [public final fun getProp() : error.NonExistentClass = UastEmptyExpression]
|
||||
UMethod (name = bar) [public fun bar() : error.NonExistentClass {...}]
|
||||
UBlockExpression [{...}] : PsiType:Unit
|
||||
|
||||
@@ -306,10 +306,10 @@ internal object KotlinConverter : BaseKotlinConverter {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun convertDeclaration(
|
||||
override fun convertDeclaration(
|
||||
element: PsiElement,
|
||||
givenParent: UElement?,
|
||||
expectedTypes: Array<out Class<out UElement>>
|
||||
requiredTypes: Array<out Class<out UElement>>
|
||||
): UElement? {
|
||||
val original = element.originalElement
|
||||
|
||||
@@ -328,18 +328,18 @@ internal object KotlinConverter : BaseKotlinConverter {
|
||||
ctor(original as P, ktElement, givenParent)
|
||||
}
|
||||
|
||||
return with(expectedTypes) {
|
||||
return with(requiredTypes) {
|
||||
when (original) {
|
||||
is KtLightMethod -> el<UMethod>(build(KotlinUMethod.Companion::create)) // .Companion is needed because of KT-13934
|
||||
is UastFakeLightMethod -> el<UMethod> {
|
||||
val ktFunction = original.original
|
||||
if (ktFunction.isLocal)
|
||||
convertDeclaration(ktFunction, givenParent, expectedTypes)
|
||||
convertDeclaration(ktFunction, givenParent, requiredTypes)
|
||||
else
|
||||
KotlinUMethodWithFakeLightDelegate(ktFunction, original, givenParent)
|
||||
}
|
||||
is UastFakeLightPrimaryConstructor ->
|
||||
convertFakeLightConstructorAlternatives(original, givenParent, expectedTypes).firstOrNull()
|
||||
convertFakeLightConstructorAlternatives(original, givenParent, requiredTypes).firstOrNull()
|
||||
is KtLightClass -> when (original.kotlinOrigin) {
|
||||
is KtEnumEntry -> el<UEnumConstant> {
|
||||
convertEnumEntry(original.kotlinOrigin as KtEnumEntry, givenParent)
|
||||
@@ -380,7 +380,7 @@ internal object KotlinConverter : BaseKotlinConverter {
|
||||
el<UMethod> {
|
||||
val lightMethod = LightClassUtil.getLightClassMethod(original)
|
||||
if (lightMethod != null)
|
||||
convertDeclaration(lightMethod, givenParent, expectedTypes)
|
||||
convertDeclaration(lightMethod, givenParent, requiredTypes)
|
||||
else {
|
||||
val ktLightClass = getLightClassForFakeMethod(original) ?: return null
|
||||
KotlinUMethodWithFakeLightDelegate(original, ktLightClass, givenParent)
|
||||
@@ -390,14 +390,14 @@ internal object KotlinConverter : BaseKotlinConverter {
|
||||
|
||||
is KtPropertyAccessor -> el<UMethod> {
|
||||
val lightMethod = LightClassUtil.getLightClassAccessorMethod(original) ?: return null
|
||||
convertDeclaration(lightMethod, givenParent, expectedTypes)
|
||||
convertDeclaration(lightMethod, givenParent, requiredTypes)
|
||||
}
|
||||
|
||||
is KtProperty ->
|
||||
if (original.isLocal) {
|
||||
convertPsiElement(original, givenParent, expectedTypes)
|
||||
convertPsiElement(original, givenParent, requiredTypes)
|
||||
} else {
|
||||
convertNonLocalProperty(original, givenParent, expectedTypes).firstOrNull()
|
||||
convertNonLocalProperty(original, givenParent, requiredTypes).firstOrNull()
|
||||
}
|
||||
|
||||
is KtParameter -> convertParameter(original, givenParent, this).firstOrNull()
|
||||
@@ -406,12 +406,12 @@ internal object KotlinConverter : BaseKotlinConverter {
|
||||
is FakeFileForLightClass -> el<UFile> { KotlinUFile(original.navigationElement, kotlinUastPlugin) }
|
||||
is KtAnnotationEntry -> el<UAnnotation>(build(::KotlinUAnnotation))
|
||||
is KtCallExpression ->
|
||||
if (expectedTypes.isAssignableFrom(KotlinUNestedAnnotation::class.java) &&
|
||||
!expectedTypes.isAssignableFrom(UCallExpression::class.java)
|
||||
if (requiredTypes.isAssignableFrom(KotlinUNestedAnnotation::class.java) &&
|
||||
!requiredTypes.isAssignableFrom(UCallExpression::class.java)
|
||||
) {
|
||||
el<UAnnotation> { KotlinUNestedAnnotation.tryCreate(original, givenParent) }
|
||||
} else null
|
||||
is KtLightAnnotationForSourceEntry -> convertDeclarationOrElement(original.kotlinOrigin, givenParent, expectedTypes)
|
||||
is KtLightAnnotationForSourceEntry -> convertDeclarationOrElement(original.kotlinOrigin, givenParent, requiredTypes)
|
||||
is KtDelegatedSuperTypeEntry -> el<KotlinSupertypeDelegationUExpression> {
|
||||
KotlinSupertypeDelegationUExpression(original, givenParent)
|
||||
}
|
||||
|
||||
@@ -24,14 +24,12 @@ import org.jetbrains.kotlin.asJava.classes.KtLightClassForScript
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.internal.acceptList
|
||||
import org.jetbrains.uast.kotlin.declarations.KotlinUMethod
|
||||
import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
||||
import org.jetbrains.uast.visitor.UastVisitor
|
||||
|
||||
abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUElement(givenParent), UClassTypeSpecific, UAnchorOwner {
|
||||
@@ -74,26 +72,6 @@ abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUEle
|
||||
|
||||
}
|
||||
|
||||
class KotlinSupertypeDelegationUExpression(override val sourcePsi: KtDelegatedSuperTypeEntry, givenParent: UElement?) :
|
||||
KotlinAbstractUExpression(givenParent), UExpressionList {
|
||||
|
||||
override val psi: PsiElement? get() = sourcePsi
|
||||
|
||||
val typeReference: UTypeReferenceExpression? by lazy {
|
||||
sourcePsi.typeReference?.let { KotlinUTypeReferenceExpression(it, this) { it.toPsiType(this) } }
|
||||
}
|
||||
|
||||
val delegateExpression: UExpression? by lazy {
|
||||
sourcePsi.delegateExpression?.let { kotlinUastPlugin.convertElement(it, this, UExpression::class.java) as? UExpression }
|
||||
}
|
||||
|
||||
override val expressions: List<UExpression>
|
||||
get() = listOfNotNull(typeReference, delegateExpression)
|
||||
|
||||
override val kind: UastSpecialExpressionKind get() = KotlinSpecialExpressionKinds.SUPER_DELEGATION
|
||||
|
||||
}
|
||||
|
||||
open class KotlinUClass private constructor(
|
||||
psi: KtLightClass,
|
||||
givenParent: UElement?
|
||||
@@ -127,9 +105,9 @@ open class KotlinUClass private constructor(
|
||||
// filter DefaultImpls to avoid processing same methods from original interface multiple times
|
||||
// filter Enum entry classes to avoid duplication with PsiEnumConstant initializer class
|
||||
return psi.innerClasses.filter {
|
||||
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass()
|
||||
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass
|
||||
}.mapNotNull {
|
||||
getLanguagePlugin().convertOpt<UClass>(it, this)
|
||||
languagePlugin?.convertOpt<UClass>(it, this)
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
||||
@@ -149,7 +127,7 @@ open class KotlinUClass private constructor(
|
||||
else
|
||||
KotlinConstructorUMethod(ktClass, psiMethod, this)
|
||||
} else {
|
||||
getLanguagePlugin().convertOpt(psiMethod, this) ?: reportConvertFailure(psiMethod)
|
||||
languagePlugin?.convertOpt(psiMethod, this) ?: reportConvertFailure(psiMethod)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,13 +156,13 @@ open class KotlinUClass private constructor(
|
||||
|
||||
ktDeclarations.asSequence()
|
||||
.filterNot { handledKtDeclarations.contains(it) }
|
||||
.mapNotNullTo(result) { KotlinConverter.convertDeclaration(it, this, arrayOf(UElement::class.java)) as? UMethod }
|
||||
.mapNotNullTo(result) {
|
||||
baseResolveProviderService.baseKotlinConverter.convertDeclaration(it, this, arrayOf(UElement::class.java)) as? UMethod
|
||||
}
|
||||
|
||||
return result.toTypedArray()
|
||||
}
|
||||
|
||||
private fun PsiClass.isEnumEntryLightClass() = (this as? KtLightClass)?.kotlinOrigin is KtEnumEntry
|
||||
|
||||
companion object {
|
||||
fun create(psi: KtLightClass, containingElement: UElement?): UClass = when (psi) {
|
||||
is PsiAnonymousClass -> KotlinUAnonymousClass(psi, containingElement)
|
||||
@@ -374,20 +352,3 @@ class KotlinInvalidUClass(
|
||||
|
||||
override fun getOriginalElement(): PsiElement? = null
|
||||
}
|
||||
|
||||
private fun reportConvertFailure(psiMethod: PsiMethod): Nothing {
|
||||
val isValid = psiMethod.isValid
|
||||
val report = KotlinExceptionWithAttachments(
|
||||
"cant convert $psiMethod of ${psiMethod.javaClass} to UMethod"
|
||||
+ if (!isValid) " (method is not valid)" else ""
|
||||
)
|
||||
|
||||
if (isValid) {
|
||||
report.withAttachment("method", psiMethod.text)
|
||||
psiMethod.containingFile?.let {
|
||||
report.withAttachment("file", it.text)
|
||||
}
|
||||
}
|
||||
|
||||
throw report
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user