diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt index 7af3e07f69b..e32508533e7 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt @@ -40,7 +40,8 @@ abstract class KotlinAbstractUElement(private val givenParent: UElement?) : Kotl } protected open fun convertParent(): UElement? { - val psi = psi + @Suppress("DEPRECATION") + val psi = psi //TODO: `psi` is deprecated but it seems that it couldn't be simply replaced for this case var parent = psi?.parent ?: psi?.containingFile if (psi is KtLightClassForLocalDeclaration) { @@ -221,12 +222,12 @@ abstract class KotlinAbstractUExpression(givenParent: UElement?) : override val javaPsi: PsiElement? = null - override val sourcePsi - get() = psi + override val psi + get() = sourcePsi override val annotations: List get() { - val annotatedExpression = psi?.parent as? KtAnnotatedExpression ?: return emptyList() + val annotatedExpression = sourcePsi?.parent as? KtAnnotatedExpression ?: return emptyList() return annotatedExpression.annotationEntries.map { KotlinUAnnotation(it, this) } } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.183 index 392872e9ce3..8e32b0d66bf 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.183 @@ -40,7 +40,8 @@ abstract class KotlinAbstractUElement(private val givenParent: UElement?) : Kotl } protected open fun convertParent(): UElement? { - val psi = psi + @Suppress("DEPRECATION") + val psi = psi //TODO: `psi` is deprecated but it seems that it couldn't be simply replaced for this case var parent = psi?.parent ?: psi?.containingFile if (psi is KtLightClassForLocalDeclaration) { @@ -110,7 +111,7 @@ abstract class KotlinAbstractUElement(private val givenParent: UElement?) : Kotl val result = doConvertParent(this, parent) if (result == this) { - throw IllegalStateException("Loop in parent structure when converting a $psi of type ${psi?.javaClass} with parent $parent of type ${parent?.javaClass} text: [${parent?.text}]") + throw IllegalStateException("Loop in parent structure when converting a $psi of type ${psi?.javaClass} with parent $parent of type ${parent?.javaClass} text: [${parent?.text}], result = $result") } return result @@ -217,12 +218,12 @@ abstract class KotlinAbstractUExpression(givenParent: UElement?) : override val javaPsi: PsiElement? = null - override val sourcePsi - get() = psi + override val psi + get() = sourcePsi override val annotations: List get() { - val annotatedExpression = psi?.parent as? KtAnnotatedExpression ?: return emptyList() + val annotatedExpression = sourcePsi?.parent as? KtAnnotatedExpression ?: return emptyList() return annotatedExpression.annotationEntries.map { KotlinUAnnotation(it, this) } } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt index f474533049e..09ffb61f61b 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt @@ -134,7 +134,7 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin { return when (element) { is KotlinUSimpleReferenceExpression.KotlinAccessorCallExpression -> element.setterValue != null is KotlinAbstractUExpression -> { - val ktElement = element.psi as? KtElement ?: return false + val ktElement = element.sourcePsi as? KtElement ?: return false ktElement.analyze()[BindingContext.USED_AS_EXPRESSION, ktElement] ?: false } else -> false @@ -239,7 +239,7 @@ internal object KotlinConverter { } } is KtLiteralStringTemplateEntry, is KtEscapeStringTemplateEntry -> el(build(::KotlinStringULiteralExpression)) - is KtStringTemplateEntry -> element.expression?.let { convertExpression(it, givenParent, expectedTypes) } ?: expr { UastEmptyExpression(null) } + is KtStringTemplateEntry -> element.expression?.let { convertExpression(it, givenParent, expectedTypes) } ?: expr { UastEmptyExpression(givenParent) } is KtWhenEntry -> el(build(::KotlinUSwitchEntry)) is KtWhenCondition -> convertWhenCondition(element, givenParent, expectedTypes) is KtTypeReference -> el { LazyKotlinUTypeReferenceExpression(element, givenParent) } @@ -341,7 +341,7 @@ internal object KotlinConverter { val initializer = psiFactory.createAnalyzableExpression("${tempAssignment.name}.component${i + 1}()", expression.containingFile) initializer.destructuringDeclarationInitializer = true - KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.psi, declarationsExpression, initializer), entry, declarationsExpression) + KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.javaPsi, declarationsExpression, initializer), entry, declarationsExpression) } declarations = listOf(tempAssignment) + destructuringAssignments } @@ -387,7 +387,7 @@ internal object KotlinConverter { KotlinUDeclarationsExpression(givenParent).apply { declarations = listOf(KotlinUClass.create(lightClass, this)) } - } ?: UastEmptyExpression(null) + } ?: UastEmptyExpression(givenParent) } is KtFunction -> if (expression.name.isNullOrEmpty()) { expr(build(::createLocalFunctionLambdaExpression)) @@ -433,7 +433,7 @@ internal object KotlinConverter { is KtWhenConditionWithExpression -> condition.expression?.let { KotlinConverter.convertExpression(it, givenParent, requiredType) } - else -> expr { UastEmptyExpression(null) } + else -> expr { UastEmptyExpression(givenParent) } } } } @@ -627,7 +627,7 @@ internal object KotlinConverter { internal fun convertOrEmpty(expression: KtExpression?, parent: UElement?): UExpression { - return expression?.let { convertExpression(it, parent, DEFAULT_EXPRESSION_TYPES_LIST) } ?: UastEmptyExpression(null) + return expression?.let { convertExpression(it, parent, DEFAULT_EXPRESSION_TYPES_LIST) } ?: UastEmptyExpression(parent) } internal fun convertOrNull(expression: KtExpression?, parent: UElement?): UExpression? { @@ -656,7 +656,7 @@ private fun convertVariablesDeclaration( val declarationsExpression = parent as? KotlinUDeclarationsExpression ?: psi.parent.toUElementOfType() as? KotlinUDeclarationsExpression ?: KotlinUDeclarationsExpression(null, parent, psi) - val parentPsiElement = parent?.psi + val parentPsiElement = parent?.javaPsi //TODO: looks weird. mb look for the first non-null `javaPsi` in `parents` ? val variable = KotlinUAnnotatedLocalVariable( UastKotlinPsiVariable.create(psi, parentPsiElement, declarationsExpression), psi, declarationsExpression) { annotationParent -> psi.annotationEntries.map { KotlinUAnnotation(it, annotationParent) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.182 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.182 index 44dd123fdd9..0c9461ab2af 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.182 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.182 @@ -128,7 +128,7 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin { return when (element) { is KotlinUSimpleReferenceExpression.KotlinAccessorCallExpression -> element.setterValue != null is KotlinAbstractUExpression -> { - val ktElement = element.psi as? KtElement ?: return false + val ktElement = element.sourcePsi as? KtElement ?: return false ktElement.analyze()[BindingContext.USED_AS_EXPRESSION, ktElement] ?: false } else -> false @@ -166,7 +166,10 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class?): UElement? { fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? { - return { ctor(element as P, givenParent) } + return { + @Suppress("UNCHECKED_CAST") + ctor(element as P, givenParent) + } } return with (requiredType) { when (element) { @@ -266,7 +269,10 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class? = null): UExpression? { fun

build(ctor: (P, UElement?) -> UExpression): () -> UExpression? { - return { ctor(expression as P, givenParent) } + return { + @Suppress("UNCHECKED_CAST") + ctor(expression as P, givenParent) + } } return with (requiredType) { when (expression) { @@ -292,7 +298,7 @@ internal object KotlinConverter { val initializer = psiFactory.createAnalyzableExpression("${tempAssignment.name}.component${i + 1}()", expression.containingFile) initializer.destructuringDeclarationInitializer = true - KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.psi, declarationsExpression, initializer), entry, declarationsExpression) + KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.javaPsi, declarationsExpression, initializer), entry, declarationsExpression) } declarations = listOf(tempAssignment) + destructuringAssignments } @@ -338,7 +344,7 @@ internal object KotlinConverter { KotlinUDeclarationsExpression(givenParent).apply { declarations = listOf(KotlinUClass.create(lightClass, this)) } - } ?: UastEmptyExpression + } ?: UastEmptyExpression(givenParent) } is KtFunction -> if (expression.name.isNullOrEmpty()) { expr(build(::createLocalFunctionLambdaExpression)) @@ -384,7 +390,7 @@ internal object KotlinConverter { is KtWhenConditionWithExpression -> condition.expression?.let { KotlinConverter.convertExpression(it, givenParent, requiredType) } - else -> expr { UastEmptyExpression } + else -> expr { UastEmptyExpression(givenParent) } } } } @@ -405,13 +411,20 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class? ): UElement? { - fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? = { ctor(element as P, givenParent) } + fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, givenParent) + } - fun

buildKt(ktElement: K, ctor: (P, K, UElement?) -> UElement): () -> UElement? = - { ctor(element as P, ktElement, givenParent) } + fun

buildKt(ktElement: K, ctor: (P, K, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, ktElement, givenParent) + } - fun

buildKtOpt(ktElement: K?, ctor: (P, K?, UElement?) -> UElement): () -> UElement? = - { ctor(element as P, ktElement, givenParent) } + fun

buildKtOpt(ktElement: K?, ctor: (P, K?, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, ktElement, givenParent) + } val original = element.originalElement return with(requiredType) { @@ -552,6 +565,7 @@ internal object KotlinConverter { val file = createAnalyzableFile("dummy.kt", text, context) val declarations = file.declarations assert(declarations.size == 1) { "${declarations.size} declarations in $text" } + @Suppress("UNCHECKED_CAST") return declarations.first() as TDeclaration } } @@ -563,7 +577,7 @@ private fun convertVariablesDeclaration( val declarationsExpression = parent as? KotlinUDeclarationsExpression ?: psi.parent.toUElementOfType() as? KotlinUDeclarationsExpression ?: KotlinUDeclarationsExpression(null, parent, psi) - val parentPsiElement = parent?.psi + val parentPsiElement = parent?.javaPsi //TODO: looks weird. mb look for the first non-null `javaPsi` in `parents` ? val variable = KotlinUAnnotatedLocalVariable( UastKotlinPsiVariable.create(psi, parentPsiElement, declarationsExpression), psi, declarationsExpression) { annotationParent -> psi.annotationEntries.map { KotlinUAnnotation(it, annotationParent) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.183 index f81e66c6eff..70bbda4b3c3 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinUastLanguagePlugin.kt.183 @@ -130,7 +130,7 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin { return when (element) { is KotlinUSimpleReferenceExpression.KotlinAccessorCallExpression -> element.setterValue != null is KotlinAbstractUExpression -> { - val ktElement = element.psi as? KtElement ?: return false + val ktElement = element.sourcePsi as? KtElement ?: return false ktElement.analyze()[BindingContext.USED_AS_EXPRESSION, ktElement] ?: false } else -> false @@ -168,7 +168,10 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class?): UElement? { fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? { - return { ctor(element as P, givenParent) } + return { + @Suppress("UNCHECKED_CAST") + ctor(element as P, givenParent) + } } return with (requiredType) { when (element) { @@ -268,7 +271,10 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class? = null): UExpression? { fun

build(ctor: (P, UElement?) -> UExpression): () -> UExpression? { - return { ctor(expression as P, givenParent) } + return { + @Suppress("UNCHECKED_CAST") + ctor(expression as P, givenParent) + } } return with (requiredType) { when (expression) { @@ -294,7 +300,7 @@ internal object KotlinConverter { val initializer = psiFactory.createAnalyzableExpression("${tempAssignment.name}.component${i + 1}()", expression.containingFile) initializer.destructuringDeclarationInitializer = true - KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.psi, declarationsExpression, initializer), entry, declarationsExpression) + KotlinULocalVariable(UastKotlinPsiVariable.create(entry, tempAssignment.javaPsi, declarationsExpression, initializer), entry, declarationsExpression) } declarations = listOf(tempAssignment) + destructuringAssignments } @@ -340,7 +346,7 @@ internal object KotlinConverter { KotlinUDeclarationsExpression(givenParent).apply { declarations = listOf(KotlinUClass.create(lightClass, this)) } - } ?: UastEmptyExpression + } ?: UastEmptyExpression(givenParent) } is KtFunction -> if (expression.name.isNullOrEmpty()) { expr(build(::createLocalFunctionLambdaExpression)) @@ -386,7 +392,7 @@ internal object KotlinConverter { is KtWhenConditionWithExpression -> condition.expression?.let { KotlinConverter.convertExpression(it, givenParent, requiredType) } - else -> expr { UastEmptyExpression } + else -> expr { UastEmptyExpression(givenParent) } } } } @@ -407,13 +413,20 @@ internal object KotlinConverter { givenParent: UElement?, requiredType: Class? ): UElement? { - fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? = { ctor(element as P, givenParent) } + fun

build(ctor: (P, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, givenParent) + } - fun

buildKt(ktElement: K, ctor: (P, K, UElement?) -> UElement): () -> UElement? = - { ctor(element as P, ktElement, givenParent) } + fun

buildKt(ktElement: K, ctor: (P, K, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, ktElement, givenParent) + } - fun

buildKtOpt(ktElement: K?, ctor: (P, K?, UElement?) -> UElement): () -> UElement? = - { ctor(element as P, ktElement, givenParent) } + fun

buildKtOpt(ktElement: K?, ctor: (P, K?, UElement?) -> UElement): () -> UElement? = { + @Suppress("UNCHECKED_CAST") + ctor(element as P, ktElement, givenParent) + } val original = element.originalElement return with(requiredType) { @@ -554,6 +567,7 @@ internal object KotlinConverter { val file = createAnalyzableFile("dummy.kt", text, context) val declarations = file.declarations assert(declarations.size == 1) { "${declarations.size} declarations in $text" } + @Suppress("UNCHECKED_CAST") return declarations.first() as TDeclaration } } @@ -565,7 +579,7 @@ private fun convertVariablesDeclaration( val declarationsExpression = parent as? KotlinUDeclarationsExpression ?: psi.parent.toUElementOfType() as? KotlinUDeclarationsExpression ?: KotlinUDeclarationsExpression(null, parent, psi) - val parentPsiElement = parent?.psi + val parentPsiElement = parent?.javaPsi //TODO: looks weird. mb look for the first non-null `javaPsi` in `parents` ? val variable = KotlinUAnnotatedLocalVariable( UastKotlinPsiVariable.create(psi, parentPsiElement, declarationsExpression), psi, declarationsExpression) { annotationParent -> psi.annotationEntries.map { KotlinUAnnotation(it, annotationParent) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt index 177ccad2c1a..9e2f4bf193c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt @@ -78,8 +78,8 @@ private fun createElvisExpressions( } fun createElvisExpression(elvisExpression: KtBinaryExpression, givenParent: UElement?): UExpression { - val left = elvisExpression.left ?: return UastEmptyExpression(null) - val right = elvisExpression.right ?: return UastEmptyExpression(null) + val left = elvisExpression.left ?: return UastEmptyExpression(givenParent) + val right = elvisExpression.right ?: return UastEmptyExpression(givenParent) return KotlinUElvisExpression(elvisExpression, left, right, givenParent) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt.183 index 74e3b5f4ea6..8249ed1a84a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/ElvisExpression.kt.183 @@ -78,8 +78,8 @@ private fun createElvisExpressions( } fun createElvisExpression(elvisExpression: KtBinaryExpression, givenParent: UElement?): UExpression { - val left = elvisExpression.left ?: return UastEmptyExpression - val right = elvisExpression.right ?: return UastEmptyExpression + val left = elvisExpression.left ?: return UastEmptyExpression(givenParent) + val right = elvisExpression.right ?: return UastEmptyExpression(givenParent) return KotlinUElvisExpression(elvisExpression, left, right, givenParent) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt index 65c25c8a1ed..0c78d3489f6 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt @@ -22,7 +22,7 @@ import org.jetbrains.uast.* import org.jetbrains.uast.expressions.UInjectionHost class KotlinStringTemplateUPolyadicExpression( - override val psi: KtStringTemplateExpression, + override val sourcePsi: KtStringTemplateExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UPolyadicExpression, @@ -30,7 +30,7 @@ class KotlinStringTemplateUPolyadicExpression( KotlinEvaluatableUElement, UInjectionHost { override val operands: List by lz { - psi.entries.map { + sourcePsi.entries.map { KotlinConverter.convertEntry( it, this, @@ -40,7 +40,7 @@ class KotlinStringTemplateUPolyadicExpression( } override val operator = UastBinaryOperator.PLUS - override val psiLanguageInjectionHost: PsiLanguageInjectionHost get() = psi + override val psiLanguageInjectionHost: PsiLanguageInjectionHost get() = sourcePsi override val isString: Boolean get() = true override fun asRenderString(): String = if (operands.isEmpty()) "\"\"" else super.asRenderString() diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt.183 index 5db5fbc72a4..3f6d20a1891 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinStringTemplateUPolyadicExpression.kt.183 @@ -23,12 +23,12 @@ import org.jetbrains.uast.UPolyadicExpression import org.jetbrains.uast.UastBinaryOperator class KotlinStringTemplateUPolyadicExpression( - override val psi: KtStringTemplateExpression, + override val sourcePsi: KtStringTemplateExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UPolyadicExpression, KotlinUElementWithType, KotlinEvaluatableUElement { - override val operands: List by lz { psi.entries.map { KotlinConverter.convertEntry(it, this)!! } } + override val operands: List by lz { sourcePsi.entries.map { KotlinConverter.convertEntry(it, this)!! } } override val operator = UastBinaryOperator.PLUS } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUArrayAccessExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUArrayAccessExpression.kt index 49c8bd616bf..cb348622422 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUArrayAccessExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUArrayAccessExpression.kt @@ -21,9 +21,9 @@ import org.jetbrains.uast.UArrayAccessExpression import org.jetbrains.uast.UElement class KotlinUArrayAccessExpression( - override val psi: KtArrayAccessExpression, + override val sourcePsi: KtArrayAccessExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), 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) } } + override val receiver by lz { KotlinConverter.convertOrEmpty(sourcePsi.arrayExpression, this) } + override val indices by lz { sourcePsi.indexExpressions.map { KotlinConverter.convertOrEmpty(it, this) } } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpression.kt index 675dff520c6..b2bd9f84038 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpression.kt @@ -28,7 +28,7 @@ import org.jetbrains.uast.* import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUBinaryExpression( - override val psi: KtBinaryExpression, + override val sourcePsi: KtBinaryExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UBinaryExpression, KotlinUElementWithType, KotlinEvaluatableUElement { private companion object { @@ -39,15 +39,15 @@ class KotlinUBinaryExpression( ) } - override val leftOperand by lz { KotlinConverter.convertOrEmpty(psi.left, this) } - override val rightOperand by lz { KotlinConverter.convertOrEmpty(psi.right, this) } + override val leftOperand by lz { KotlinConverter.convertOrEmpty(sourcePsi.left, this) } + override val rightOperand by lz { KotlinConverter.convertOrEmpty(sourcePsi.right, this) } override val operatorIdentifier: UIdentifier? - get() = KotlinUIdentifier(psi.operationReference.getReferencedNameElement(), this) + get() = KotlinUIdentifier(sourcePsi.operationReference.getReferencedNameElement(), this) - override fun resolveOperator() = psi.operationReference.resolveCallToDeclaration() as? PsiMethod + override fun resolveOperator() = sourcePsi.operationReference.resolveCallToDeclaration() as? PsiMethod - override val operator = when (psi.operationToken) { + override val operator = when (sourcePsi.operationToken) { KtTokens.EQ -> UastBinaryOperator.ASSIGN KtTokens.PLUS -> UastBinaryOperator.PLUS KtTokens.MINUS -> UastBinaryOperator.MINUS @@ -74,8 +74,8 @@ class KotlinUBinaryExpression( KtTokens.RANGE -> KotlinBinaryOperators.RANGE_TO else -> run { // Handle bitwise operators val other = UastBinaryOperator.OTHER - val ref = psi.operationReference - val resolvedCall = psi.operationReference.getResolvedCall(ref.analyze()) ?: return@run other + val ref = sourcePsi.operationReference + val resolvedCall = sourcePsi.operationReference.getResolvedCall(ref.analyze()) ?: return@run other val resultingDescriptor = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return@run other val applicableOperator = BITWISE_OPERATORS[resultingDescriptor.name.asString()] ?: return@run other diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpressionWithType.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpressionWithType.kt index 85c8f522f5d..c30625bf547 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpressionWithType.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBinaryExpressionWithType.kt @@ -23,19 +23,19 @@ import org.jetbrains.kotlin.psi.KtBinaryExpressionWithTypeRHS import org.jetbrains.uast.* class KotlinUBinaryExpressionWithType( - override val psi: KtBinaryExpressionWithTypeRHS, + override val sourcePsi: KtBinaryExpressionWithTypeRHS, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UBinaryExpressionWithType, KotlinUElementWithType, KotlinEvaluatableUElement { - override val operand by lz { KotlinConverter.convertOrEmpty(psi.left, this) } - override val type by lz { psi.right.toPsiType(this) } + override val operand by lz { KotlinConverter.convertOrEmpty(sourcePsi.left, this) } + override val type by lz { sourcePsi.right.toPsiType(this) } - override val typeReference by lz { - psi.right?.let { LazyKotlinUTypeReferenceExpression(it, this) } + override val typeReference by lz { + sourcePsi.right?.let { LazyKotlinUTypeReferenceExpression(it, this) } } - override val operationKind = when (psi.operationReference.getReferencedNameElementType()) { + override val operationKind = when (sourcePsi.operationReference.getReferencedNameElementType()) { KtTokens.AS_KEYWORD -> UastBinaryExpressionWithTypeKind.TYPE_CAST KtTokens.AS_SAFE -> KotlinBinaryExpressionWithTypeKinds.SAFE_TYPE_CAST else -> UastBinaryExpressionWithTypeKind.UNKNOWN diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBlockExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBlockExpression.kt index 24f42e65a61..ab0f06f0819 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBlockExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBlockExpression.kt @@ -22,18 +22,18 @@ import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.uast.* class KotlinUBlockExpression( - override val psi: KtBlockExpression, - givenParent: UElement? + override val sourcePsi: KtBlockExpression, + givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UBlockExpression, KotlinUElementWithType { - override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } } + override val expressions by lz { sourcePsi.statements.map { KotlinConverter.convertOrEmpty(it, this) } } class KotlinLazyUBlockExpression( override val uastParent: UElement?, expressionProducer: (expressionParent: UElement) -> List ) : UBlockExpression, JvmDeclarationUElementPlaceholder { - override val psi: PsiElement? = null - override val javaPsi: PsiElement? = null - override val sourcePsi: PsiElement? = null + override val psi: PsiElement? get() = null + override val javaPsi: PsiElement? get() = null + override val sourcePsi: PsiElement? get() = null override val annotations: List = emptyList() override val expressions by lz { expressionProducer(this) } } @@ -42,14 +42,14 @@ class KotlinUBlockExpression( fun create(initializers: List, uastParent: UElement): UBlockExpression { val languagePlugin = uastParent.getLanguagePlugin() return KotlinLazyUBlockExpression(uastParent) { expressionParent -> - initializers.map { languagePlugin.convertOpt(it.body, expressionParent) ?: UastEmptyExpression(null) } + initializers.map { languagePlugin.convertOpt(it.body, expressionParent) ?: UastEmptyExpression(expressionParent) } } } } override fun convertParent(): UElement? { val directParent = super.convertParent() - if (directParent is UnknownKotlinExpression && directParent.psi is KtAnonymousInitializer) { + if (directParent is UnknownKotlinExpression && directParent.sourcePsi is KtAnonymousInitializer) { val containingUClass = directParent.getContainingUClass() ?: return directParent containingUClass.methods .find { it is KotlinConstructorUMethod && it.isPrimary || it is KotlinSecondaryConstructorWithInitializersUMethod }?.let { diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBreakExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBreakExpression.kt index cb90da55a39..ba025bc6612 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBreakExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUBreakExpression.kt @@ -22,9 +22,9 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.kotlin.KotlinAbstractUExpression class KotlinUBreakExpression( - override val psi: KtBreakExpression, + override val sourcePsi: KtBreakExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UBreakExpression { override val label: String? - get() = psi.getLabelName() + get() = sourcePsi.getLabelName() } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt index 2f2b06ce476..4182a6b569a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt @@ -24,29 +24,29 @@ import org.jetbrains.uast.* import org.jetbrains.uast.kotlin.internal.getResolveResultVariants class KotlinUCallableReferenceExpression( - override val psi: KtCallableReferenceExpression, + override val sourcePsi: KtCallableReferenceExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UCallableReferenceExpression, UMultiResolvable, KotlinUElementWithType { override val qualifierExpression: UExpression? get() { if (qualifierType != null) return null - val receiverExpression = psi.receiverExpression ?: return null + val receiverExpression = sourcePsi.receiverExpression ?: return null return KotlinConverter.convertExpression(receiverExpression, this, DEFAULT_EXPRESSION_TYPES_LIST) } override val qualifierType by lz { - val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null - ktType.toPsiType(this, psi, boxed = true) + val ktType = sourcePsi.analyze()[DOUBLE_COLON_LHS, sourcePsi.receiverExpression]?.type ?: return@lz null + ktType.toPsiType(this, sourcePsi, boxed = true) } override val callableName: String - get() = psi.callableReference.getReferencedName() + get() = sourcePsi.callableReference.getReferencedName() override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name - override fun resolve() = psi.callableReference.resolveCallToDeclaration() + override fun resolve() = sourcePsi.callableReference.resolveCallToDeclaration() - override fun multiResolve(): Iterable = getResolveResultVariants(psi.callableReference) + override fun multiResolve(): Iterable = getResolveResultVariants(sourcePsi.callableReference) } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.182 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.182 index 568e109c7ba..2de217a85b2 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.182 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.182 @@ -24,26 +24,26 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UExpression class KotlinUCallableReferenceExpression( - override val psi: KtCallableReferenceExpression, + override val sourcePsi: KtCallableReferenceExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UCallableReferenceExpression, KotlinUElementWithType { override val qualifierExpression: UExpression? get() { if (qualifierType != null) return null - val receiverExpression = psi.receiverExpression ?: return null + val receiverExpression = sourcePsi.receiverExpression ?: return null return KotlinConverter.convertExpression(receiverExpression, this) } override val qualifierType by lz { - val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null - ktType.toPsiType(this, psi, boxed = true) + val ktType = sourcePsi.analyze()[DOUBLE_COLON_LHS, sourcePsi.receiverExpression]?.type ?: return@lz null + ktType.toPsiType(this, sourcePsi, boxed = true) } override val callableName: String - get() = psi.callableReference.getReferencedName() + get() = sourcePsi.callableReference.getReferencedName() override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name - override fun resolve() = psi.callableReference.resolveCallToDeclaration() + override fun resolve() = sourcePsi.callableReference.resolveCallToDeclaration() } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.183 index 6dedf972075..5c4d4ff3b38 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCallableReferenceExpression.kt.183 @@ -27,29 +27,29 @@ import org.jetbrains.uast.UMultiResolvable import org.jetbrains.uast.kotlin.internal.getResolveResultVariants class KotlinUCallableReferenceExpression( - override val psi: KtCallableReferenceExpression, + override val sourcePsi: KtCallableReferenceExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UCallableReferenceExpression, UMultiResolvable, KotlinUElementWithType { override val qualifierExpression: UExpression? get() { if (qualifierType != null) return null - val receiverExpression = psi.receiverExpression ?: return null + val receiverExpression = sourcePsi.receiverExpression ?: return null return KotlinConverter.convertExpression(receiverExpression, this) } override val qualifierType by lz { - val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null - ktType.toPsiType(this, psi, boxed = true) + val ktType = sourcePsi.analyze()[DOUBLE_COLON_LHS, sourcePsi.receiverExpression]?.type ?: return@lz null + ktType.toPsiType(this, sourcePsi, boxed = true) } override val callableName: String - get() = psi.callableReference.getReferencedName() + get() = sourcePsi.callableReference.getReferencedName() override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name - override fun resolve() = psi.callableReference.resolveCallToDeclaration() + override fun resolve() = sourcePsi.callableReference.resolveCallToDeclaration() - override fun multiResolve(): Iterable = getResolveResultVariants(psi.callableReference) + override fun multiResolve(): Iterable = getResolveResultVariants(sourcePsi.callableReference) } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCatchClause.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCatchClause.kt index 4a827cf54c9..8438f0f2876 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCatchClause.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUCatchClause.kt @@ -16,6 +16,7 @@ package org.jetbrains.uast.kotlin +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtCatchClause import org.jetbrains.uast.UCatchClause import org.jetbrains.uast.UElement @@ -24,22 +25,23 @@ import org.jetbrains.uast.UTypeReferenceExpression import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter class KotlinUCatchClause( - override val psi: KtCatchClause, + override val sourcePsi: KtCatchClause, givenParent: UElement? ) : KotlinAbstractUElement(givenParent), UCatchClause { + override val psi: PsiElement? + get() = sourcePsi - override val javaPsi = null - override val sourcePsi = psi + override val javaPsi: PsiElement? get() = null - override val body by lz { KotlinConverter.convertOrEmpty(psi.catchBody, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.catchBody, this) } override val parameters by lz { - val parameter = psi.catchParameter ?: return@lz emptyList() - listOf(KotlinUParameter(UastKotlinPsiParameter.create(parameter, psi, this, 0), psi, this)) + val parameter = sourcePsi.catchParameter ?: return@lz emptyList() + listOf(KotlinUParameter(UastKotlinPsiParameter.create(parameter, sourcePsi, this, 0), sourcePsi, this)) } override val typeReferences by lz { - val parameter = psi.catchParameter ?: return@lz emptyList() + val parameter = sourcePsi.catchParameter ?: return@lz emptyList() val typeReference = parameter.typeReference ?: return@lz emptyList() listOf(LazyKotlinUTypeReferenceExpression(typeReference, this) { typeReference.toPsiType(this, boxed = true) } ) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt index 748ea720f53..8365e36666e 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt @@ -24,18 +24,18 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UExpression class KotlinUClassLiteralExpression( - override val psi: KtClassLiteralExpression, + override val sourcePsi: KtClassLiteralExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UClassLiteralExpression, KotlinUElementWithType { override val type by lz { - val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null - ktType.toPsiType(this, psi, boxed = true) + val ktType = sourcePsi.analyze()[DOUBLE_COLON_LHS, sourcePsi.receiverExpression]?.type ?: return@lz null + ktType.toPsiType(this, sourcePsi, boxed = true) } override val expression: UExpression? get() { if (type != null) return null - val receiverExpression = psi.receiverExpression ?: return null + val receiverExpression = sourcePsi.receiverExpression ?: return null return KotlinConverter.convertExpression(receiverExpression, this, DEFAULT_EXPRESSION_TYPES_LIST) } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt.183 index 28125ec5b28..14684154a92 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUClassLiteralExpression.kt.183 @@ -23,18 +23,18 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UExpression class KotlinUClassLiteralExpression( - override val psi: KtClassLiteralExpression, + override val sourcePsi: KtClassLiteralExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UClassLiteralExpression, KotlinUElementWithType { override val type by lz { - val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null - ktType.toPsiType(this, psi, boxed = true) + val ktType = sourcePsi.analyze()[DOUBLE_COLON_LHS, sourcePsi.receiverExpression]?.type ?: return@lz null + ktType.toPsiType(this, sourcePsi, boxed = true) } override val expression: UExpression? get() { if (type != null) return null - val receiverExpression = psi.receiverExpression ?: return null + val receiverExpression = sourcePsi.receiverExpression ?: return null return KotlinConverter.convertExpression(receiverExpression, this) } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUContinueExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUContinueExpression.kt index b8959e3ac7a..e520864356c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUContinueExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUContinueExpression.kt @@ -22,9 +22,9 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.kotlin.KotlinAbstractUExpression class KotlinUContinueExpression( - override val psi: KtContinueExpression, + override val sourcePsi: KtContinueExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UContinueExpression { override val label: String? - get() = psi.getLabelName() + get() = sourcePsi.getLabelName() } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUDoWhileExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUDoWhileExpression.kt index b79fd597717..7ddfb77200a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUDoWhileExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUDoWhileExpression.kt @@ -23,11 +23,11 @@ import org.jetbrains.uast.UIdentifier import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUDoWhileExpression( - override val psi: KtDoWhileExpression, + override val sourcePsi: KtDoWhileExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UDoWhileExpression { - override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) } - override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) } + override val condition by lz { KotlinConverter.convertOrEmpty(sourcePsi.condition, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.body, this) } override val doIdentifier: UIdentifier get() = KotlinUIdentifier(null, this) diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpression.kt index 3f384301391..6832a4e55f3 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpression.kt @@ -25,7 +25,7 @@ import org.jetbrains.uast.UExpression interface KotlinUElementWithType : UExpression { override fun getExpressionType(): PsiType? { - val ktElement = psi as? KtExpression ?: return null + val ktElement = sourcePsi as? KtExpression ?: return null val ktType = ktElement.analyze()[BindingContext.EXPRESSION_TYPE_INFO, ktElement]?.type ?: return null return ktType.toPsiType(this, ktElement, boxed = false) } @@ -33,7 +33,7 @@ interface KotlinUElementWithType : UExpression { interface KotlinEvaluatableUElement : UExpression { override fun evaluate(): Any? { - val ktElement = psi as? KtExpression ?: return null + val ktElement = sourcePsi as? KtExpression ?: return null val compileTimeConst = ktElement.analyze()[BindingContext.COMPILE_TIME_VALUE, ktElement] if (compileTimeConst is UnsignedErrorValueTypeConstant) return null diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpressionList.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpressionList.kt index 4442162aa11..1748119d49c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpressionList.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUExpressionList.kt @@ -27,7 +27,7 @@ import org.jetbrains.uast.UastSpecialExpressionKind import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds open class KotlinUExpressionList( - override val psi: PsiElement?, + override val sourcePsi: PsiElement?, override val kind: UastSpecialExpressionKind, // original element givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UExpressionList, KotlinUElementWithType, KotlinEvaluatableUElement { @@ -35,7 +35,7 @@ open class KotlinUExpressionList( internal set override fun evaluate(): Any? { - val ktElement = psi as? KtExpression ?: return null + val ktElement = sourcePsi as? KtExpression ?: return null val compileTimeConst = ktElement.analyze()[BindingContext.COMPILE_TIME_VALUE, ktElement] return compileTimeConst?.getValue(TypeUtils.NO_EXPECTED_TYPE) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUForEachExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUForEachExpression.kt index 4d6c8f2c6da..444421dfed6 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUForEachExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUForEachExpression.kt @@ -26,16 +26,16 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter import org.jetbrains.uast.psi.UastPsiParameterNotResolved class KotlinUForEachExpression( - override val psi: KtForExpression, + override val sourcePsi: KtForExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UForEachExpression { - override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) } - override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) } + override val iteratedValue by lz { KotlinConverter.convertOrEmpty(sourcePsi.loopRange, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.body, this) } override val variable by lz { - val parameter = psi.loopParameter?.let { UastKotlinPsiParameter.create(it, psi, this, 0) } - ?: UastPsiParameterNotResolved(psi, KotlinLanguage.INSTANCE) - KotlinUParameter(parameter, psi, this) + val parameter = sourcePsi.loopParameter?.let { UastKotlinPsiParameter.create(it, sourcePsi, this, 0) } + ?: UastPsiParameterNotResolved(sourcePsi, KotlinLanguage.INSTANCE) + KotlinUParameter(parameter, sourcePsi, this) } override val forIdentifier: UIdentifier diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt index e76eab82db1..974a05ab933 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt @@ -44,7 +44,7 @@ import org.jetbrains.uast.kotlin.internal.multiResolveResults import org.jetbrains.uast.visitor.UastVisitor class KotlinUFunctionCallExpression( - override val psi: KtCallElement, + override val sourcePsi: KtCallElement, givenParent: UElement?, private val _resolvedCall: ResolvedCall<*>? ) : KotlinAbstractUExpression(givenParent), UCallExpressionEx, KotlinUElementWithType, UMultiResolvable { @@ -52,22 +52,22 @@ class KotlinUFunctionCallExpression( constructor(psi: KtCallElement, uastParent: UElement?) : this(psi, uastParent, null) private val resolvedCall - get() = _resolvedCall ?: psi.getResolvedCall(psi.analyze()) + get() = _resolvedCall ?: sourcePsi.getResolvedCall(sourcePsi.analyze()) override val receiverType by lz { val resolvedCall = this.resolvedCall ?: return@lz null val receiver = resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver ?: return@lz null - receiver.type.toPsiType(this, psi, boxed = true) + receiver.type.toPsiType(this, sourcePsi, boxed = true) } override val methodName by lz { resolvedCall?.resultingDescriptor?.name?.asString() } override val classReference by lz { - KotlinClassViaConstructorUSimpleReferenceExpression(psi, methodName.orAnonymous("class"), this) + KotlinClassViaConstructorUSimpleReferenceExpression(sourcePsi, methodName.orAnonymous("class"), this) } override val methodIdentifier by lz { - val calleeExpression = psi.calleeExpression + val calleeExpression = sourcePsi.calleeExpression when (calleeExpression) { null -> null is KtNameReferenceExpression -> @@ -83,9 +83,9 @@ class KotlinUFunctionCallExpression( } override val valueArgumentCount: Int - get() = psi.valueArguments.size + get() = sourcePsi.valueArguments.size - override val valueArguments by lz { psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } + override val valueArguments by lz { sourcePsi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } override fun getArgumentForParameter(i: Int): UExpression? { val resolvedCall = resolvedCall @@ -121,9 +121,9 @@ class KotlinUFunctionCallExpression( } override val typeArgumentCount: Int - get() = psi.typeArguments.size + get() = sourcePsi.typeArguments.size - override val typeArguments by lz { psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } + override val typeArguments by lz { sourcePsi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } override val returnType: PsiType? get() = getExpressionType() @@ -143,7 +143,7 @@ class KotlinUFunctionCallExpression( if (it.selector == this) return it.receiver } - val ktNameReferenceExpression = psi.calleeExpression as? KtNameReferenceExpression ?: return null + val ktNameReferenceExpression = sourcePsi.calleeExpression as? KtNameReferenceExpression ?: return null val variableCallDescriptor = (resolvedCall as? VariableAsFunctionResolvedCall)?.variableCall?.resultingDescriptor ?: (resolvedCall?.resultingDescriptor as? FunctionDescriptor)?.takeIf { it.visibility == Visibilities.LOCAL } @@ -165,7 +165,7 @@ class KotlinUFunctionCallExpression( } private val multiResolved by lazy(fun(): Iterable> { - val contextElement = psi + val contextElement = sourcePsi if (!Registry.`is`("kotlin.uast.multiresolve.enabled", true)) { val calleeExpression = contextElement.calleeExpression ?: return emptyList() @@ -180,7 +180,7 @@ class KotlinUFunctionCallExpression( return variants.flatMap { when (val source = it.toSource()) { is KtClass -> source.toLightClass()?.constructors?.asSequence().orEmpty() - else -> resolveSource(psi, it, source)?.let { sequenceOf(it) }.orEmpty() + else -> resolveSource(sourcePsi, it, source)?.let { sequenceOf(it) }.orEmpty() } }.map { TypedResolveResult(it) }.asIterable() }) @@ -191,7 +191,7 @@ class KotlinUFunctionCallExpression( override fun resolve(): PsiMethod? { val descriptor = resolvedCall?.resultingDescriptor ?: return null val source = descriptor.toSource() - return resolveSource(psi, descriptor, source) + return resolveSource(sourcePsi, descriptor, source) } override fun accept(visitor: UastVisitor) { @@ -205,7 +205,7 @@ class KotlinUFunctionCallExpression( private fun isAnnotationArgumentArrayInitializer(): Boolean { // KtAnnotationEntry (or KtCallExpression when annotation is nested) -> KtValueArgumentList -> KtValueArgument -> arrayOf call - val isAnnotationArgument = when (val elementAt2 = psi.parents.elementAtOrNull(2)) { + val isAnnotationArgument = when (val elementAt2 = sourcePsi.parents.elementAtOrNull(2)) { is KtAnnotationEntry -> true is KtCallExpression -> elementAt2.getParentOfType(true, KtDeclaration::class.java) != null else -> false diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt.182 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt.182 index dfcf9a077ea..c91ffbd241c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt.182 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUFunctionCallExpression.kt.182 @@ -37,7 +37,7 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.visitor.UastVisitor class KotlinUFunctionCallExpression( - override val psi: KtCallElement, + override val sourcePsi: KtCallElement, givenParent: UElement?, private val _resolvedCall: ResolvedCall<*>? ) : KotlinAbstractUExpression(givenParent), UCallExpressionEx, KotlinUElementWithType { @@ -45,22 +45,22 @@ class KotlinUFunctionCallExpression( constructor(psi: KtCallElement, uastParent: UElement?) : this(psi, uastParent, null) private val resolvedCall - get() = _resolvedCall ?: psi.getResolvedCall(psi.analyze()) + get() = _resolvedCall ?: sourcePsi.getResolvedCall(sourcePsi.analyze()) override val receiverType by lz { val resolvedCall = this.resolvedCall ?: return@lz null val receiver = resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver ?: return@lz null - receiver.type.toPsiType(this, psi, boxed = true) + receiver.type.toPsiType(this, sourcePsi, boxed = true) } override val methodName by lz { resolvedCall?.resultingDescriptor?.name?.asString() } override val classReference by lz { - KotlinClassViaConstructorUSimpleReferenceExpression(psi, methodName.orAnonymous("class"), this) + KotlinClassViaConstructorUSimpleReferenceExpression(sourcePsi, methodName.orAnonymous("class"), this) } override val methodIdentifier by lz { - val calleeExpression = psi.calleeExpression + val calleeExpression = sourcePsi.calleeExpression when (calleeExpression) { null -> null is KtNameReferenceExpression -> @@ -76,9 +76,9 @@ class KotlinUFunctionCallExpression( } override val valueArgumentCount: Int - get() = psi.valueArguments.size + get() = sourcePsi.valueArguments.size - override val valueArguments by lz { psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } + override val valueArguments by lz { sourcePsi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } override fun getArgumentForParameter(i: Int): UExpression? { val resolvedCall = resolvedCall ?: return null @@ -89,9 +89,9 @@ class KotlinUFunctionCallExpression( override val typeArgumentCount: Int - get() = psi.typeArguments.size + get() = sourcePsi.typeArguments.size - override val typeArguments by lz { psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } + override val typeArguments by lz { sourcePsi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } override val returnType: PsiType? get() = getExpressionType() @@ -111,7 +111,7 @@ class KotlinUFunctionCallExpression( if (it.selector == this) return it.receiver } - val ktNameReferenceExpression = psi.calleeExpression as? KtNameReferenceExpression ?: return null + val ktNameReferenceExpression = sourcePsi.calleeExpression as? KtNameReferenceExpression ?: return null val variableCallDescriptor = (resolvedCall as? VariableAsFunctionResolvedCall)?.variableCall?.resultingDescriptor ?: (resolvedCall?.resultingDescriptor as? FunctionDescriptor)?.takeIf { it.visibility == Visibilities.LOCAL } @@ -135,7 +135,7 @@ class KotlinUFunctionCallExpression( override fun resolve(): PsiMethod? { val descriptor = resolvedCall?.resultingDescriptor ?: return null val source = descriptor.toSource() - return resolveSource(psi, descriptor, source) + return resolveSource(sourcePsi, descriptor, source) } override fun accept(visitor: UastVisitor) { @@ -149,7 +149,7 @@ class KotlinUFunctionCallExpression( private fun isAnnotationArgumentArrayInitializer(): Boolean { // KtAnnotationEntry (or KtCallExpression when annotation is nested) -> KtValueArgumentList -> KtValueArgument -> arrayOf call - val isAnnotationArgument = when (val elementAt2 = psi.parents.elementAtOrNull(2)) { + val isAnnotationArgument = when (val elementAt2 = sourcePsi.parents.elementAtOrNull(2)) { is KtAnnotationEntry -> true is KtCallExpression -> elementAt2.getParentOfType(true, KtDeclaration::class.java) != null else -> false diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUIfExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUIfExpression.kt index 158e2642a90..a5c16b93d65 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUIfExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUIfExpression.kt @@ -22,12 +22,12 @@ import org.jetbrains.uast.UIdentifier import org.jetbrains.uast.UIfExpression class KotlinUIfExpression( - override val psi: KtIfExpression, + override val sourcePsi: KtIfExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UIfExpression, KotlinUElementWithType, KotlinEvaluatableUElement { - override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) } - override val thenExpression by lz { KotlinConverter.convertOrNull(psi.then, this) } - override val elseExpression by lz { KotlinConverter.convertOrNull(psi.`else`, this) } + override val condition by lz { KotlinConverter.convertOrEmpty(sourcePsi.condition, this) } + override val thenExpression by lz { KotlinConverter.convertOrNull(sourcePsi.then, this) } + override val elseExpression by lz { KotlinConverter.convertOrNull(sourcePsi.`else`, this) } override val isTernary = false override val ifIdentifier: UIdentifier diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULabeledExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULabeledExpression.kt index e376f40d537..80b0f6ef977 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULabeledExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULabeledExpression.kt @@ -23,14 +23,14 @@ import org.jetbrains.uast.ULabeledExpression import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinULabeledExpression( - override val psi: KtLabeledExpression, + override val sourcePsi: KtLabeledExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), ULabeledExpression { override val label: String - get() = psi.getLabelName().orAnonymous("label") + get() = sourcePsi.getLabelName().orAnonymous("label") override val labelIdentifier: UIdentifier? - get() = psi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } + get() = sourcePsi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } - override val expression by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) } + override val expression by lz { KotlinConverter.convertOrEmpty(sourcePsi.baseExpression, this) } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt index 94a921e9df1..86b53dab6c6 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt @@ -25,17 +25,17 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter import org.jetbrains.uast.withMargin class KotlinULambdaExpression( - override val psi: KtLambdaExpression, + override val sourcePsi: KtLambdaExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), ULambdaExpression, KotlinUElementWithType { override val functionalInterfaceType: PsiType? get() = getFunctionalInterfaceType() - override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.bodyExpression, this) } override val valueParameters by lz { - psi.valueParameters.mapIndexed { i, p -> - KotlinUParameter(UastKotlinPsiParameter.create(p, psi, this, i), psi, this) + sourcePsi.valueParameters.mapIndexed { i, p -> + KotlinUParameter(UastKotlinPsiParameter.create(p, sourcePsi, this, i), sourcePsi, this) } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULiteralExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULiteralExpression.kt index 1d7d90e9ff5..4c71b4b9f29 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULiteralExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULiteralExpression.kt @@ -25,17 +25,17 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.ULiteralExpression class KotlinULiteralExpression( - override val psi: KtConstantExpression, + override val sourcePsi: KtConstantExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), ULiteralExpression, KotlinUElementWithType, KotlinEvaluatableUElement { override val isNull: Boolean - get() = psi.unwrapBlockOrParenthesis().node?.elementType == KtNodeTypes.NULL + get() = sourcePsi.unwrapBlockOrParenthesis().node?.elementType == KtNodeTypes.NULL override val value by lz { evaluate() } } class KotlinStringULiteralExpression( - override val psi: PsiElement, + override val sourcePsi: PsiElement, givenParent: UElement?, val text: String ) : KotlinAbstractUExpression(givenParent), ULiteralExpression, KotlinUElementWithType{ @@ -47,5 +47,5 @@ class KotlinStringULiteralExpression( override fun evaluate() = value - override fun getExpressionType(): PsiType? = PsiType.getJavaLangString(psi.manager, psi.resolveScope) + override fun getExpressionType(): PsiType? = PsiType.getJavaLangString(sourcePsi.manager, sourcePsi.resolveScope) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUNamedExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUNamedExpression.kt index 541f06841b9..2992c897140 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUNamedExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUNamedExpression.kt @@ -68,7 +68,7 @@ class KotlinUVarargExpression( valueArgs.map { it.getArgumentExpression()?.let { argumentExpression -> getLanguagePlugin().convert(argumentExpression, this) - } ?: UastEmptyExpression(null) + } ?: UastEmptyExpression(this) } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt index c06035e6ee1..f63b869d661 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt @@ -16,6 +16,7 @@ package org.jetbrains.uast.kotlin +import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.intellij.psi.PsiType import org.jetbrains.kotlin.asJava.toLightClass @@ -27,20 +28,20 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUObjectLiteralExpression( - override val psi: KtObjectLiteralExpression, + override val sourcePsi: KtObjectLiteralExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UObjectLiteralExpression, UCallExpressionEx, DelegatedMultiResolve, KotlinUElementWithType { override val declaration: UClass by lz { - psi.objectDeclaration.toLightClass() + sourcePsi.objectDeclaration.toLightClass() ?.let { getLanguagePlugin().convert(it, this) } - ?: KotlinInvalidUClass("", psi, this) + ?: KotlinInvalidUClass("", sourcePsi, this) } - override fun getExpressionType() = psi.objectDeclaration.toPsiType() + override fun getExpressionType() = sourcePsi.objectDeclaration.toPsiType() private val superClassConstructorCall by lz { - psi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry + sourcePsi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry } override val classReference: UReferenceExpression? by lz { superClassConstructorCall?.let { ObjectLiteralClassReference(it, this) } } @@ -67,14 +68,14 @@ class KotlinUObjectLiteralExpression( superClassConstructorCall?.let { it.getResolvedCall(it.analyze()) }?.let { getArgumentExpressionByIndex(i, it, this) } private class ObjectLiteralClassReference( - override val psi: KtSuperTypeCallEntry, + override val sourcePsi: KtSuperTypeCallEntry, givenParent: UElement? ) : KotlinAbstractUElement(givenParent), USimpleNameReferenceExpression { - override val javaPsi = null - override val sourcePsi = psi + override val javaPsi: PsiElement? get() = null + override val psi: KtSuperTypeCallEntry get() = sourcePsi - override fun resolve() = (psi.resolveCallToDeclaration() as? PsiMethod)?.containingClass + override fun resolve() = (sourcePsi.resolveCallToDeclaration() as? PsiMethod)?.containingClass override val annotations: List get() = emptyList() diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.183 index 3a0b23a12bb..25dcfc67a7e 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.183 @@ -16,6 +16,7 @@ package org.jetbrains.uast.kotlin +import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.intellij.psi.PsiType import org.jetbrains.kotlin.asJava.toLightClass @@ -26,20 +27,20 @@ import org.jetbrains.uast.* import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUObjectLiteralExpression( - override val psi: KtObjectLiteralExpression, + override val sourcePsi: KtObjectLiteralExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UObjectLiteralExpression, UCallExpressionEx, DelegatedMultiResolve, KotlinUElementWithType { override val declaration: UClass by lz { - psi.objectDeclaration.toLightClass() + sourcePsi.objectDeclaration.toLightClass() ?.let { getLanguagePlugin().convert(it, this) } - ?: KotlinInvalidUClass("", psi, this) + ?: KotlinInvalidUClass("", sourcePsi, this) } - override fun getExpressionType() = psi.objectDeclaration.toPsiType() + override fun getExpressionType() = sourcePsi.objectDeclaration.toPsiType() private val superClassConstructorCall by lz { - psi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry + sourcePsi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry } override val classReference: UReferenceExpression? by lz { superClassConstructorCall?.let { ObjectLiteralClassReference(it, this) } } @@ -66,14 +67,14 @@ class KotlinUObjectLiteralExpression( superClassConstructorCall?.let { it.getResolvedCall(it.analyze()) }?.let { getArgumentExpressionByIndex(i, it, this) } private class ObjectLiteralClassReference( - override val psi: KtSuperTypeCallEntry, + override val sourcePsi: KtSuperTypeCallEntry, givenParent: UElement? ) : KotlinAbstractUElement(givenParent), USimpleNameReferenceExpression { - override val javaPsi = null - override val sourcePsi = psi + override val javaPsi: PsiElement? get() = null + override val psi: KtSuperTypeCallEntry get() = sourcePsi - override fun resolve() = (psi.resolveCallToDeclaration() as? PsiMethod)?.containingClass + override fun resolve() = (sourcePsi.resolveCallToDeclaration() as? PsiMethod)?.containingClass override val annotations: List get() = emptyList() diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUParenthesizedExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUParenthesizedExpression.kt index 704fee58def..bb7a0e53776 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUParenthesizedExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUParenthesizedExpression.kt @@ -21,8 +21,8 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UParenthesizedExpression class KotlinUParenthesizedExpression( - override val psi: KtParenthesizedExpression, + override val sourcePsi: KtParenthesizedExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UParenthesizedExpression, KotlinUElementWithType { - override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) } + override val expression by lz { KotlinConverter.convertOrEmpty(sourcePsi.expression, this) } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPostfixExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPostfixExpression.kt index ec9f5e602a3..1583473d703 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPostfixExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPostfixExpression.kt @@ -24,13 +24,13 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUPostfixExpression( - override val psi: KtPostfixExpression, + override val sourcePsi: KtPostfixExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UPostfixExpression, KotlinUElementWithType, KotlinEvaluatableUElement, UResolvable, DelegatedMultiResolve { - override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) } + override val operand by lz { KotlinConverter.convertOrEmpty(sourcePsi.baseExpression, this) } - override val operator = when (psi.operationToken) { + override val operator = when (sourcePsi.operationToken) { KtTokens.PLUSPLUS -> UastPostfixOperator.INC KtTokens.MINUSMINUS -> UastPostfixOperator.DEC KtTokens.EXCLEXCL -> KotlinPostfixOperators.EXCLEXCL @@ -38,11 +38,11 @@ class KotlinUPostfixExpression( } override val operatorIdentifier: UIdentifier? - get() = KotlinUIdentifier(psi.operationReference, this) + get() = KotlinUIdentifier(sourcePsi.operationReference, this) - override fun resolveOperator() = psi.operationReference.resolveCallToDeclaration() as? PsiMethod + override fun resolveOperator() = sourcePsi.operationReference.resolveCallToDeclaration() as? PsiMethod - override fun resolve(): PsiMethod? = when (psi.operationToken) { + override fun resolve(): PsiMethod? = when (sourcePsi.operationToken) { KtTokens.EXCLEXCL -> operand.tryResolve() as? PsiMethod else -> null } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPrefixExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPrefixExpression.kt index c0d3bb2e79d..4b22f71870a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPrefixExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUPrefixExpression.kt @@ -26,17 +26,17 @@ import org.jetbrains.uast.UastPrefixOperator import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUPrefixExpression( - override val psi: KtPrefixExpression, + override val sourcePsi: KtPrefixExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UPrefixExpression, KotlinUElementWithType, KotlinEvaluatableUElement { - override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) } + override val operand by lz { KotlinConverter.convertOrEmpty(sourcePsi.baseExpression, this) } override val operatorIdentifier: UIdentifier? - get() = KotlinUIdentifier(psi.operationReference, this) + get() = KotlinUIdentifier(sourcePsi.operationReference, this) - override fun resolveOperator() = psi.operationReference.resolveCallToDeclaration() as? PsiMethod + override fun resolveOperator() = sourcePsi.operationReference.resolveCallToDeclaration() as? PsiMethod - override val operator = when (psi.operationToken) { + override val operator = when (sourcePsi.operationToken) { KtTokens.EXCL -> UastPrefixOperator.LOGICAL_NOT KtTokens.PLUS -> UastPrefixOperator.UNARY_PLUS KtTokens.MINUS -> UastPrefixOperator.UNARY_MINUS diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt index 5c060f991c8..0f58c5c8bde 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt @@ -25,15 +25,15 @@ import org.jetbrains.uast.UastQualifiedExpressionAccessType import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUQualifiedReferenceExpression( - override val psi: KtDotQualifiedExpression, + override val sourcePsi: KtDotQualifiedExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UQualifiedReferenceExpression, DelegatedMultiResolve, KotlinUElementWithType, KotlinEvaluatableUElement { - override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) } - override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) } + override val receiver by lz { KotlinConverter.convertOrEmpty(sourcePsi.receiverExpression, this) } + override val selector by lz { KotlinConverter.convertOrEmpty(sourcePsi.selectorExpression, this) } override val accessType = UastQualifiedExpressionAccessType.SIMPLE - override fun resolve() = psi.selectorExpression?.resolveCallToDeclaration() + override fun resolve() = sourcePsi.selectorExpression?.resolveCallToDeclaration() override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt.183 index eb90d47c3ec..9e9709798a3 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUQualifiedReferenceExpression.kt.183 @@ -24,15 +24,15 @@ import org.jetbrains.uast.UastQualifiedExpressionAccessType import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUQualifiedReferenceExpression( - override val psi: KtDotQualifiedExpression, + override val sourcePsi: KtDotQualifiedExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UQualifiedReferenceExpression, DelegatedMultiResolve, KotlinUElementWithType, KotlinEvaluatableUElement { - override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) } - override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) } + override val receiver by lz { KotlinConverter.convertOrEmpty(sourcePsi.receiverExpression, this) } + override val selector by lz { KotlinConverter.convertOrEmpty(sourcePsi.selectorExpression, this) } override val accessType = UastQualifiedExpressionAccessType.SIMPLE - override fun resolve() = psi.selectorExpression?.resolveCallToDeclaration() + override fun resolve() = sourcePsi.selectorExpression?.resolveCallToDeclaration() override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUReturnExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUReturnExpression.kt index 8371de4b306..5a3387faf4a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUReturnExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUReturnExpression.kt @@ -23,10 +23,10 @@ import org.jetbrains.uast.UExpression import org.jetbrains.uast.UReturnExpression class KotlinUReturnExpression( - override val psi: KtReturnExpression, + override val sourcePsi: KtReturnExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UReturnExpression, KotlinUElementWithType { - override val returnExpression by lz { KotlinConverter.convertOrNull(psi.returnedExpression, this) } + override val returnExpression by lz { KotlinConverter.convertOrNull(sourcePsi.returnedExpression, this) } } class KotlinUImplicitReturnExpression( diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt index 26198055511..bf827e782c2 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt @@ -25,17 +25,17 @@ import org.jetbrains.uast.UQualifiedReferenceExpression import org.jetbrains.uast.kotlin.internal.getResolveResultVariants class KotlinUSafeQualifiedExpression( - override val psi: KtSafeQualifiedExpression, + override val sourcePsi: KtSafeQualifiedExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UQualifiedReferenceExpression, UMultiResolvable, KotlinUElementWithType, KotlinEvaluatableUElement { - override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) } - override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) } + override val receiver by lz { KotlinConverter.convertOrEmpty(sourcePsi.receiverExpression, this) } + override val selector by lz { KotlinConverter.convertOrEmpty(sourcePsi.selectorExpression, this) } override val accessType = KotlinQualifiedExpressionAccessTypes.SAFE override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name - override fun resolve() = psi.selectorExpression?.resolveCallToDeclaration() - override fun multiResolve(): Iterable = getResolveResultVariants(psi.selectorExpression) + override fun resolve() = sourcePsi.selectorExpression?.resolveCallToDeclaration() + override fun multiResolve(): Iterable = getResolveResultVariants(sourcePsi.selectorExpression) } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt.182 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt.182 index dbbf27fb1cc..df04a763b3c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt.182 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSafeQualifiedExpression.kt.182 @@ -22,16 +22,16 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UQualifiedReferenceExpression class KotlinUSafeQualifiedExpression( - override val psi: KtSafeQualifiedExpression, + override val sourcePsi: KtSafeQualifiedExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UQualifiedReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement { - override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) } - override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) } + override val receiver by lz { KotlinConverter.convertOrEmpty(sourcePsi.receiverExpression, this) } + override val selector by lz { KotlinConverter.convertOrEmpty(sourcePsi.selectorExpression, this) } override val accessType = KotlinQualifiedExpressionAccessTypes.SAFE override val resolvedName: String? get() = (resolve() as? PsiNamedElement)?.name - override fun resolve() = psi.selectorExpression?.resolveCallToDeclaration() + override fun resolve() = sourcePsi.selectorExpression?.resolveCallToDeclaration() } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt index 9f21c28d36e..c8a9bc096b8 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt @@ -38,18 +38,18 @@ import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve import org.jetbrains.uast.visitor.UastVisitor open class KotlinUSimpleReferenceExpression( - override val psi: KtSimpleNameExpression, + override val sourcePsi: KtSimpleNameExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USimpleNameReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement { private val resolvedDeclaration: PsiElement? by lz { - psi.resolveCallToDeclaration()?.let { return@lz it } + sourcePsi.resolveCallToDeclaration()?.let { return@lz it } - var declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null + var declarationDescriptor = sourcePsi.analyze()[BindingContext.REFERENCE_TARGET, sourcePsi] ?: return@lz null if (declarationDescriptor is ImportedFromObjectCallableDescriptor<*>) { declarationDescriptor = declarationDescriptor.callableFromObject } if (declarationDescriptor is SyntheticJavaPropertyDescriptor) { - declarationDescriptor = when (psi.readWriteAccess()) { + declarationDescriptor = when (sourcePsi.readWriteAccess()) { ReferenceAccess.WRITE, ReferenceAccess.READ_WRITE -> declarationDescriptor.setMethod ?: declarationDescriptor.getMethod ReferenceAccess.READ -> declarationDescriptor.getMethod @@ -57,17 +57,17 @@ open class KotlinUSimpleReferenceExpression( } if (declarationDescriptor is PackageViewDescriptor) { - return@lz JavaPsiFacade.getInstance(psi.project).findPackage(declarationDescriptor.fqName.asString()) + return@lz JavaPsiFacade.getInstance(sourcePsi.project).findPackage(declarationDescriptor.fqName.asString()) } - resolveToPsiClass(this, declarationDescriptor, psi)?.let { return@lz it } + resolveToPsiClass(this, declarationDescriptor, sourcePsi)?.let { return@lz it } if (declarationDescriptor is DeclarationDescriptorWithSource) { declarationDescriptor.source.getPsi()?.let { it.getMaybeLightElement() ?: it }?.let { return@lz it } } - return@lz resolveDeserialized(psi, declarationDescriptor, psi.readWriteAccess()) + return@lz resolveDeserialized(sourcePsi, declarationDescriptor, sourcePsi.readWriteAccess()) } - override val identifier get() = psi.getReferencedName() + override val identifier get() = sourcePsi.getReferencedName() override fun resolve() = resolvedDeclaration @@ -77,24 +77,24 @@ open class KotlinUSimpleReferenceExpression( override fun accept(visitor: UastVisitor) { visitor.visitSimpleNameReferenceExpression(this) - if (psi.parent.destructuringDeclarationInitializer != true) { + if (sourcePsi.parent.destructuringDeclarationInitializer != true) { visitAccessorCalls(visitor) } visitor.afterVisitSimpleNameReferenceExpression(this) } - override val referenceNameElement: UElement? by lz { psi.getIdentifier()?.toUElement() } + override val referenceNameElement: UElement? by lz { sourcePsi.getIdentifier()?.toUElement() } private fun visitAccessorCalls(visitor: UastVisitor) { // Visit Kotlin get-set synthetic Java property calls as function calls - val bindingContext = psi.analyze() - val access = psi.readWriteAccess() - val resolvedCall = psi.getResolvedCall(bindingContext) + val bindingContext = sourcePsi.analyze() + val access = sourcePsi.readWriteAccess() + val resolvedCall = sourcePsi.getResolvedCall(bindingContext) val resultingDescriptor = resolvedCall?.resultingDescriptor as? SyntheticJavaPropertyDescriptor if (resultingDescriptor != null) { val setterValue = if (access.isWrite) { - findAssignment(psi, psi.parent)?.right ?: run { + findAssignment(sourcePsi, sourcePsi.parent)?.right ?: run { visitor.afterVisitSimpleNameReferenceExpression(this) return } @@ -104,13 +104,13 @@ open class KotlinUSimpleReferenceExpression( if (access.isRead) { val getDescriptor = resultingDescriptor.getMethod - KotlinAccessorCallExpression(psi, this, resolvedCall, getDescriptor, null).accept(visitor) + KotlinAccessorCallExpression(sourcePsi, this, resolvedCall, getDescriptor, null).accept(visitor) } if (access.isWrite && setterValue != null) { val setDescriptor = resultingDescriptor.setMethod if (setDescriptor != null) { - KotlinAccessorCallExpression(psi, this, resolvedCall, setDescriptor, setterValue).accept(visitor) + KotlinAccessorCallExpression(sourcePsi, this, resolvedCall, setDescriptor, setterValue).accept(visitor) } } } @@ -124,7 +124,7 @@ open class KotlinUSimpleReferenceExpression( } class KotlinAccessorCallExpression( - override val psi: KtSimpleNameExpression, + override val sourcePsi: KtSimpleNameExpression, override val uastParent: KotlinUSimpleReferenceExpression, private val resolvedCall: ResolvedCall<*>, private val accessorDescriptor: DeclarationDescriptor, @@ -142,18 +142,18 @@ open class KotlinUSimpleReferenceExpression( null } - override val javaPsi: PsiElement? = null - override val sourcePsi: PsiElement? = psi + override val javaPsi: PsiElement? get() = null + override val psi: PsiElement? get() = sourcePsi override val annotations: List get() = emptyList() override val receiverType by lz { val type = (resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver)?.type ?: return@lz null - type.toPsiType(this, psi, boxed = true) + type.toPsiType(this, sourcePsi, boxed = true) } - override val methodIdentifier: UIdentifier? by lazy { KotlinUIdentifier(psi.getReferencedNameElement(), this) } + override val methodIdentifier: UIdentifier? by lazy { KotlinUIdentifier(sourcePsi.getReferencedNameElement(), this) } override val classReference: UReferenceExpression? get() = null @@ -174,11 +174,11 @@ open class KotlinUSimpleReferenceExpression( get() = resolvedCall.typeArguments.size override val typeArguments by lz { - resolvedCall.typeArguments.values.map { it.toPsiType(this, psi, true) } + resolvedCall.typeArguments.values.map { it.toPsiType(this, sourcePsi, true) } } override val returnType by lz { - (accessorDescriptor as? CallableDescriptor)?.returnType?.toPsiType(this, psi, boxed = false) + (accessorDescriptor as? CallableDescriptor)?.returnType?.toPsiType(this, sourcePsi, boxed = false) } override val kind: UastCallKind @@ -186,7 +186,7 @@ open class KotlinUSimpleReferenceExpression( override fun resolve(): PsiMethod? { val source = accessorDescriptor.toSource() - return resolveSource(psi, accessorDescriptor, source) + return resolveSource(sourcePsi, accessorDescriptor, source) } } @@ -218,7 +218,7 @@ open class KotlinUSimpleReferenceExpression( } class KotlinClassViaConstructorUSimpleReferenceExpression( - override val psi: KtCallElement, + override val sourcePsi: KtCallElement, override val identifier: String, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USimpleNameReferenceExpression, KotlinUElementWithType { @@ -226,13 +226,13 @@ class KotlinClassViaConstructorUSimpleReferenceExpression( get() = (resolved as? PsiNamedElement)?.name private val resolved by lazy { - when (val resultingDescriptor = psi.getResolvedCall(psi.analyze())?.resultingDescriptor) { + when (val resultingDescriptor = sourcePsi.getResolvedCall(sourcePsi.analyze())?.resultingDescriptor) { is ConstructorDescriptor -> { resultingDescriptor.constructedClass.toSource()?.getMaybeLightElement() - ?: (resultingDescriptor as? DeserializedCallableMemberDescriptor)?.let { resolveContainingDeserializedClass(psi, it) } + ?: (resultingDescriptor as? DeserializedCallableMemberDescriptor)?.let { resolveContainingDeserializedClass(sourcePsi, it) } } is SamConstructorDescriptor -> - (resultingDescriptor.returnType?.getFunctionalInterfaceType(this, psi) as? PsiClassType)?.resolve() + (resultingDescriptor.returnType?.getFunctionalInterfaceType(this, sourcePsi) as? PsiClassType)?.resolve() else -> null } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt.183 index 91b0769bcdd..8e59ace6e13 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSimpleReferenceExpression.kt.183 @@ -38,18 +38,18 @@ import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve import org.jetbrains.uast.visitor.UastVisitor open class KotlinUSimpleReferenceExpression( - override val psi: KtSimpleNameExpression, + override val sourcePsi: KtSimpleNameExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USimpleNameReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement { private val resolvedDeclaration: PsiElement? by lz { - psi.resolveCallToDeclaration()?.let { return@lz it } + sourcePsi.resolveCallToDeclaration()?.let { return@lz it } - var declarationDescriptor = psi.analyze()[BindingContext.REFERENCE_TARGET, psi] ?: return@lz null + var declarationDescriptor = sourcePsi.analyze()[BindingContext.REFERENCE_TARGET, sourcePsi] ?: return@lz null if (declarationDescriptor is ImportedFromObjectCallableDescriptor<*>) { declarationDescriptor = declarationDescriptor.callableFromObject } if (declarationDescriptor is SyntheticJavaPropertyDescriptor) { - declarationDescriptor = when (psi.readWriteAccess()) { + declarationDescriptor = when (sourcePsi.readWriteAccess()) { ReferenceAccess.WRITE, ReferenceAccess.READ_WRITE -> declarationDescriptor.setMethod ?: declarationDescriptor.getMethod ReferenceAccess.READ -> declarationDescriptor.getMethod @@ -57,17 +57,17 @@ open class KotlinUSimpleReferenceExpression( } if (declarationDescriptor is PackageViewDescriptor) { - return@lz JavaPsiFacade.getInstance(psi.project).findPackage(declarationDescriptor.fqName.asString()) + return@lz JavaPsiFacade.getInstance(sourcePsi.project).findPackage(declarationDescriptor.fqName.asString()) } - resolveToPsiClass(this, declarationDescriptor, psi)?.let { return@lz it } + resolveToPsiClass(this, declarationDescriptor, sourcePsi)?.let { return@lz it } if (declarationDescriptor is DeclarationDescriptorWithSource) { declarationDescriptor.source.getPsi()?.let { it.getMaybeLightElement() ?: it }?.let { return@lz it } } - return@lz resolveDeserialized(psi, declarationDescriptor, psi.readWriteAccess()) + return@lz resolveDeserialized(sourcePsi, declarationDescriptor, sourcePsi.readWriteAccess()) } - override val identifier get() = psi.getReferencedName() + override val identifier get() = sourcePsi.getReferencedName() override fun resolve() = resolvedDeclaration @@ -77,7 +77,7 @@ open class KotlinUSimpleReferenceExpression( override fun accept(visitor: UastVisitor) { visitor.visitSimpleNameReferenceExpression(this) - if (psi.parent.destructuringDeclarationInitializer != true) { + if (sourcePsi.parent.destructuringDeclarationInitializer != true) { visitAccessorCalls(visitor) } @@ -86,13 +86,13 @@ open class KotlinUSimpleReferenceExpression( private fun visitAccessorCalls(visitor: UastVisitor) { // Visit Kotlin get-set synthetic Java property calls as function calls - val bindingContext = psi.analyze() - val access = psi.readWriteAccess() - val resolvedCall = psi.getResolvedCall(bindingContext) + val bindingContext = sourcePsi.analyze() + val access = sourcePsi.readWriteAccess() + val resolvedCall = sourcePsi.getResolvedCall(bindingContext) val resultingDescriptor = resolvedCall?.resultingDescriptor as? SyntheticJavaPropertyDescriptor if (resultingDescriptor != null) { val setterValue = if (access.isWrite) { - findAssignment(psi, psi.parent)?.right ?: run { + findAssignment(sourcePsi, sourcePsi.parent)?.right ?: run { visitor.afterVisitSimpleNameReferenceExpression(this) return } @@ -103,13 +103,13 @@ open class KotlinUSimpleReferenceExpression( if (resolvedCall != null) { if (access.isRead) { val getDescriptor = resultingDescriptor.getMethod - KotlinAccessorCallExpression(psi, this, resolvedCall, getDescriptor, null).accept(visitor) + KotlinAccessorCallExpression(sourcePsi, this, resolvedCall, getDescriptor, null).accept(visitor) } if (access.isWrite && setterValue != null) { val setDescriptor = resultingDescriptor.setMethod if (setDescriptor != null) { - KotlinAccessorCallExpression(psi, this, resolvedCall, setDescriptor, setterValue).accept(visitor) + KotlinAccessorCallExpression(sourcePsi, this, resolvedCall, setDescriptor, setterValue).accept(visitor) } } } @@ -124,7 +124,7 @@ open class KotlinUSimpleReferenceExpression( } class KotlinAccessorCallExpression( - override val psi: KtSimpleNameExpression, + override val sourcePsi: KtSimpleNameExpression, override val uastParent: KotlinUSimpleReferenceExpression, private val resolvedCall: ResolvedCall<*>, private val accessorDescriptor: DeclarationDescriptor, @@ -142,18 +142,18 @@ open class KotlinUSimpleReferenceExpression( null } - override val javaPsi: PsiElement? = null - override val sourcePsi: PsiElement? = psi + override val javaPsi: PsiElement? get() = null + override val psi: PsiElement? get() = sourcePsi override val annotations: List get() = emptyList() override val receiverType by lz { val type = (resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver)?.type ?: return@lz null - type.toPsiType(this, psi, boxed = true) + type.toPsiType(this, sourcePsi, boxed = true) } - override val methodIdentifier: UIdentifier? by lazy { KotlinUIdentifier(psi.getReferencedNameElement(), this) } + override val methodIdentifier: UIdentifier? by lazy { KotlinUIdentifier(sourcePsi.getReferencedNameElement(), this) } override val classReference: UReferenceExpression? get() = null @@ -174,11 +174,11 @@ open class KotlinUSimpleReferenceExpression( get() = resolvedCall.typeArguments.size override val typeArguments by lz { - resolvedCall.typeArguments.values.map { it.toPsiType(this, psi, true) } + resolvedCall.typeArguments.values.map { it.toPsiType(this, sourcePsi, true) } } override val returnType by lz { - (accessorDescriptor as? CallableDescriptor)?.returnType?.toPsiType(this, psi, boxed = false) + (accessorDescriptor as? CallableDescriptor)?.returnType?.toPsiType(this, sourcePsi, boxed = false) } override val kind: UastCallKind @@ -186,7 +186,7 @@ open class KotlinUSimpleReferenceExpression( override fun resolve(): PsiMethod? { val source = accessorDescriptor.toSource() - return resolveSource(psi, accessorDescriptor, source) + return resolveSource(sourcePsi, accessorDescriptor, source) } } @@ -218,7 +218,7 @@ open class KotlinUSimpleReferenceExpression( } class KotlinClassViaConstructorUSimpleReferenceExpression( - override val psi: KtCallElement, + override val sourcePsi: KtCallElement, override val identifier: String, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USimpleNameReferenceExpression, KotlinUElementWithType { @@ -226,13 +226,13 @@ class KotlinClassViaConstructorUSimpleReferenceExpression( get() = (resolved as? PsiNamedElement)?.name private val resolved by lazy { - when (val resultingDescriptor = psi.getResolvedCall(psi.analyze())?.resultingDescriptor) { + when (val resultingDescriptor = sourcePsi.getResolvedCall(sourcePsi.analyze())?.resultingDescriptor) { is ConstructorDescriptor -> { resultingDescriptor.constructedClass.toSource()?.getMaybeLightElement() - ?: (resultingDescriptor as? DeserializedCallableMemberDescriptor)?.let { resolveContainingDeserializedClass(psi, it) } + ?: (resultingDescriptor as? DeserializedCallableMemberDescriptor)?.let { resolveContainingDeserializedClass(sourcePsi, it) } } is SamConstructorDescriptor -> - (resultingDescriptor.returnType?.getFunctionalInterfaceType(this, psi) as? PsiClassType)?.resolve() + (resultingDescriptor.returnType?.getFunctionalInterfaceType(this, sourcePsi) as? PsiClassType)?.resolve() else -> null } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSuperExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSuperExpression.kt index 7a26bbc6a05..dcead5d9dfc 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSuperExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSuperExpression.kt @@ -25,14 +25,14 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUSuperExpression( - override val psi: KtSuperExpression, + override val sourcePsi: KtSuperExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USuperExpression, DelegatedMultiResolve, KotlinUElementWithType, KotlinEvaluatableUElement { override val label: String? - get() = psi.getLabelName() + get() = sourcePsi.getLabelName() override val labelIdentifier: UIdentifier? - get() = psi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } + get() = sourcePsi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } - override fun resolve() = psi.analyze()[BindingContext.LABEL_TARGET, psi.getTargetLabel()] + override fun resolve() = sourcePsi.analyze()[BindingContext.LABEL_TARGET, sourcePsi.getTargetLabel()] } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt index 21c3c8e3f9a..bc9bbf967e5 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt @@ -25,16 +25,16 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds class KotlinUSwitchExpression( - override val psi: KtWhenExpression, + override val sourcePsi: KtWhenExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USwitchExpression, KotlinUElementWithType { - override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) } + override val expression by lz { KotlinConverter.convertOrNull(sourcePsi.subjectExpression, this) } override val body: UExpressionList by lz { - object : KotlinUExpressionList(psi, KotlinSpecialExpressionKinds.WHEN, this@KotlinUSwitchExpression) { + object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN, this@KotlinUSwitchExpression) { override fun asRenderString() = expressions.joinToString("\n") { it.asRenderString().withMargin } }.apply { - expressions = this@KotlinUSwitchExpression.psi.entries.map { KotlinUSwitchEntry(it, this) } + expressions = this@KotlinUSwitchExpression.sourcePsi.entries.map { KotlinUSwitchEntry(it, this) } } } @@ -50,22 +50,22 @@ class KotlinUSwitchExpression( } class KotlinUSwitchEntry( - override val psi: KtWhenEntry, + override val sourcePsi: KtWhenEntry, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USwitchClauseExpressionWithBody { override val caseValues by lz { - psi.conditions.map { KotlinConverter.convertWhenCondition(it, this, DEFAULT_EXPRESSION_TYPES_LIST) ?: UastEmptyExpression(null) } + sourcePsi.conditions.map { KotlinConverter.convertWhenCondition(it, this, DEFAULT_EXPRESSION_TYPES_LIST) ?: UastEmptyExpression(null) } } override val body: UExpressionList by lz { - object : KotlinUExpressionList(psi, KotlinSpecialExpressionKinds.WHEN_ENTRY, this@KotlinUSwitchEntry) { + object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN_ENTRY, this@KotlinUSwitchEntry) { override fun asRenderString() = buildString { appendln("{") expressions.forEach { appendln(it.asRenderString().withMargin) } appendln("}") } }.apply { - val exprPsi = this@KotlinUSwitchEntry.psi.expression + val exprPsi = this@KotlinUSwitchEntry.sourcePsi.expression val userExpressions = when (exprPsi) { is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) } else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this)) @@ -86,7 +86,7 @@ class KotlinUSwitchEntry( } override fun convertParent(): UElement? { - val result = KotlinConverter.unwrapElements(psi.parent)?.let { parentUnwrapped -> + val result = KotlinConverter.unwrapElements(sourcePsi.parent)?.let { parentUnwrapped -> KotlinUastLanguagePlugin().convertElementWithParent(parentUnwrapped, null) } return (result as? KotlinUSwitchExpression)?.body ?: result diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.183 index 52052a319ed..160dceeaab7 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.183 @@ -25,16 +25,16 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds class KotlinUSwitchExpression( - override val psi: KtWhenExpression, + override val sourcePsi: KtWhenExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USwitchExpression, KotlinUElementWithType { - override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) } + override val expression by lz { KotlinConverter.convertOrNull(sourcePsi.subjectExpression, this) } override val body: UExpressionList by lz { - object : KotlinUExpressionList(psi, KotlinSpecialExpressionKinds.WHEN, this@KotlinUSwitchExpression) { + object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN, this@KotlinUSwitchExpression) { override fun asRenderString() = expressions.joinToString("\n") { it.asRenderString().withMargin } }.apply { - expressions = this@KotlinUSwitchExpression.psi.entries.map { KotlinUSwitchEntry(it, this) } + expressions = this@KotlinUSwitchExpression.sourcePsi.entries.map { KotlinUSwitchEntry(it, this) } } } @@ -50,22 +50,22 @@ class KotlinUSwitchExpression( } class KotlinUSwitchEntry( - override val psi: KtWhenEntry, + override val sourcePsi: KtWhenEntry, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), USwitchClauseExpressionWithBody { override val caseValues by lz { - psi.conditions.map { KotlinConverter.convertWhenCondition(it, this) ?: UastEmptyExpression } + sourcePsi.conditions.map { KotlinConverter.convertWhenCondition(it, this) ?: UastEmptyExpression } } override val body: UExpressionList by lz { - object : KotlinUExpressionList(psi, KotlinSpecialExpressionKinds.WHEN_ENTRY, this@KotlinUSwitchEntry) { + object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN_ENTRY, this@KotlinUSwitchEntry) { override fun asRenderString() = buildString { appendln("{") expressions.forEach { appendln(it.asRenderString().withMargin) } appendln("}") } }.apply { - val exprPsi = this@KotlinUSwitchEntry.psi.expression + val exprPsi = this@KotlinUSwitchEntry.sourcePsi.expression val userExpressions = when (exprPsi) { is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) } else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this)) @@ -86,7 +86,7 @@ class KotlinUSwitchEntry( } override fun convertParent(): UElement? { - val result = KotlinConverter.unwrapElements(psi.parent)?.let { parentUnwrapped -> + val result = KotlinConverter.unwrapElements(sourcePsi.parent)?.let { parentUnwrapped -> KotlinUastLanguagePlugin().convertElementWithParent(parentUnwrapped, null) } return (result as? KotlinUSwitchExpression)?.body ?: result diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt index a126192989f..c65f9235c48 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt @@ -25,14 +25,14 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUThisExpression( - override val psi: KtThisExpression, + override val sourcePsi: KtThisExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UThisExpression, DelegatedMultiResolve, KotlinUElementWithType, KotlinEvaluatableUElement { override val label: String? - get() = psi.getLabelName() + get() = sourcePsi.getLabelName() override val labelIdentifier: UIdentifier? - get() = psi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } + get() = sourcePsi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } - override fun resolve() = psi.analyze()[BindingContext.LABEL_TARGET, psi.getTargetLabel()] + override fun resolve() = sourcePsi.analyze()[BindingContext.LABEL_TARGET, sourcePsi.getTargetLabel()] } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt.182 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt.182 index a126192989f..c65f9235c48 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt.182 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThisExpression.kt.182 @@ -25,14 +25,14 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier import org.jetbrains.uast.kotlin.internal.DelegatedMultiResolve class KotlinUThisExpression( - override val psi: KtThisExpression, + override val sourcePsi: KtThisExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UThisExpression, DelegatedMultiResolve, KotlinUElementWithType, KotlinEvaluatableUElement { override val label: String? - get() = psi.getLabelName() + get() = sourcePsi.getLabelName() override val labelIdentifier: UIdentifier? - get() = psi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } + get() = sourcePsi.getTargetLabel()?.let { KotlinUIdentifier(it, this) } - override fun resolve() = psi.analyze()[BindingContext.LABEL_TARGET, psi.getTargetLabel()] + override fun resolve() = sourcePsi.analyze()[BindingContext.LABEL_TARGET, sourcePsi.getTargetLabel()] } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThrowExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThrowExpression.kt index 63eb33c6dd5..b46a6b59acd 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThrowExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUThrowExpression.kt @@ -21,8 +21,8 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UThrowExpression class KotlinUThrowExpression( - override val psi: KtThrowExpression, + override val sourcePsi: KtThrowExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UThrowExpression, KotlinUElementWithType { - override val thrownExpression by lz { KotlinConverter.convertOrEmpty(psi.thrownExpression, this) } + override val thrownExpression by lz { KotlinConverter.convertOrEmpty(sourcePsi.thrownExpression, this) } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt index 548d9520778..7d52c80ed8a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt @@ -21,13 +21,13 @@ import org.jetbrains.uast.* import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUTryExpression( - override val psi: KtTryExpression, + override val sourcePsi: KtTryExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UTryExpression, KotlinUElementWithType { - override val tryClause by lz { KotlinConverter.convertOrEmpty(psi.tryBlock, this) } - override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } } + override val tryClause by lz { KotlinConverter.convertOrEmpty(sourcePsi.tryBlock, this) } + override val catchClauses by lz { sourcePsi.catchClauses.map { KotlinUCatchClause(it, this) } } override val finallyClause by lz { - psi.finallyBlock?.finalExpression?.let { + sourcePsi.finallyBlock?.finalExpression?.let { KotlinConverter.convertExpression( it, this, diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt.183 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt.183 index db9c6cedd83..0dda625a878 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt.183 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTryExpression.kt.183 @@ -24,12 +24,12 @@ import org.jetbrains.uast.UVariable import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUTryExpression( - override val psi: KtTryExpression, + override val sourcePsi: KtTryExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UTryExpression, KotlinUElementWithType { - override val tryClause by lz { KotlinConverter.convertOrEmpty(psi.tryBlock, this) } - override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } } - override val finallyClause by lz { psi.finallyBlock?.finalExpression?.let { KotlinConverter.convertExpression(it, this) } } + override val tryClause by lz { KotlinConverter.convertOrEmpty(sourcePsi.tryBlock, this) } + override val catchClauses by lz { sourcePsi.catchClauses.map { KotlinUCatchClause(it, this) } } + override val finallyClause by lz { sourcePsi.finallyBlock?.finalExpression?.let { KotlinConverter.convertExpression(it, this) } } override val resourceVariables: List get() = emptyList() diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeCheckExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeCheckExpression.kt index bcc1e6e2250..d6f655d6436 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeCheckExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeCheckExpression.kt @@ -22,19 +22,19 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UastBinaryExpressionWithTypeKind class KotlinUTypeCheckExpression( - override val psi: KtIsExpression, + override val sourcePsi: KtIsExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UBinaryExpressionWithType, KotlinUElementWithType, KotlinEvaluatableUElement { - override val operand by lz { KotlinConverter.convertOrEmpty(psi.leftHandSide, this) } + override val operand by lz { KotlinConverter.convertOrEmpty(sourcePsi.leftHandSide, this) } - override val type by lz { psi.typeReference.toPsiType(this) } + override val type by lz { sourcePsi.typeReference.toPsiType(this) } - override val typeReference = psi.typeReference?.let { + override val typeReference = sourcePsi.typeReference?.let { LazyKotlinUTypeReferenceExpression(it, this) { it.toPsiType(this) } } override val operationKind = - if(psi.isNegated) + if(sourcePsi.isNegated) KotlinBinaryExpressionWithTypeKinds.NEGATED_INSTANCE_CHECK else UastBinaryExpressionWithTypeKind.INSTANCE_CHECK diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeReferenceExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeReferenceExpression.kt index 0916778b714..1c480406b60 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeReferenceExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUTypeReferenceExpression.kt @@ -14,11 +14,11 @@ open class KotlinUTypeReferenceExpression( class LazyKotlinUTypeReferenceExpression( - override val psi: KtTypeReference, + override val sourcePsi: KtTypeReference, givenParent: UElement?, private val typeSupplier: (() -> PsiType)? = null ) : KotlinAbstractUExpression(givenParent), UTypeReferenceExpression { override val type: PsiType by lz { - typeSupplier?.invoke() ?: psi.toPsiType(uastParent ?: this) + typeSupplier?.invoke() ?: sourcePsi.toPsiType(uastParent ?: this) } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUWhileExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUWhileExpression.kt index dd4dbf194e1..89082bbe296 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUWhileExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUWhileExpression.kt @@ -23,11 +23,11 @@ import org.jetbrains.uast.UWhileExpression import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier class KotlinUWhileExpression( - override val psi: KtWhileExpression, + override val sourcePsi: KtWhileExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UWhileExpression { - override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) } - override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) } + override val condition by lz { KotlinConverter.convertOrEmpty(sourcePsi.condition, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.body, this) } override val whileIdentifier: UIdentifier get() = KotlinUIdentifier(null, this) diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt index 606a409f92a..58913e38b53 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt @@ -13,12 +13,12 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable internal class KotlinLocalFunctionUVariable( val function: KtFunction, - override val psi: PsiVariable, + override val javaPsi: PsiVariable, givenParent: UElement? -) : KotlinAbstractUElement(givenParent), UVariableExPlaceHolder, PsiVariable by psi { +) : KotlinAbstractUElement(givenParent), UVariableExPlaceHolder, PsiVariable by javaPsi { - override val javaPsi = psi - override val sourcePsi: PsiElement? = (psi as? UastKotlinPsiVariable?)?.ktElement ?: psi + override val psi get() = javaPsi + override val sourcePsi: PsiElement? = (javaPsi as? UastKotlinPsiVariable?)?.ktElement ?: javaPsi override val uastInitializer: UExpression? by lz { createLocalFunctionLambdaExpression(function, this) @@ -37,16 +37,16 @@ internal class KotlinLocalFunctionUVariable( private class KotlinLocalFunctionULambdaExpression( - override val psi: KtFunction, + override val sourcePsi: KtFunction, givenParent: UElement? ): KotlinAbstractUExpression(givenParent), ULambdaExpression { override val functionalInterfaceType: PsiType? = null - override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) } + override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.bodyExpression, this) } override val valueParameters by lz { - psi.valueParameters.mapIndexed { i, p -> - KotlinUParameter(UastKotlinPsiParameter.create(p, psi, this, i), p, this) + sourcePsi.valueParameters.mapIndexed { i, p -> + KotlinUParameter(UastKotlinPsiParameter.create(p, sourcePsi, this, i), p, this) } } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/UnknownKotlinExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/UnknownKotlinExpression.kt index 9f25c732f1f..61a8b89a803 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/UnknownKotlinExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/UnknownKotlinExpression.kt @@ -21,8 +21,8 @@ import org.jetbrains.uast.UElement import org.jetbrains.uast.UExpression class UnknownKotlinExpression( - override val psi: KtExpression, + override val sourcePsi: KtExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UExpression { - override fun asLogString() = "[!] UnknownKotlinExpression ($psi)" + override fun asLogString() = "[!] UnknownKotlinExpression ($sourcePsi)" } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/KotlinUElementWithComments.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/KotlinUElementWithComments.kt index 2ce5065cac0..237232d4493 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/KotlinUElementWithComments.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/KotlinUElementWithComments.kt @@ -28,7 +28,7 @@ interface KotlinUElementWithComments : JvmDeclarationUElementPlaceholder { override val comments: List get() { - val psi = psi ?: return emptyList() + val psi = sourcePsi ?: return emptyList() val childrenComments = psi.children.filterIsInstance().map { UComment(it, this) } if (this !is UExpression) return childrenComments val childrenAndSiblingComments = childrenComments + diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt index 51c5cf8bbeb..b21dcea0ead 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt @@ -223,7 +223,7 @@ private fun getMethodSignatureFromDescriptor(context: KtElement, descriptor: Cal internal fun lz(initializer: () -> T) = lazy(LazyThreadSafetyMode.SYNCHRONIZED, initializer) internal fun KotlinType.toPsiType(source: UElement, element: KtElement, boxed: Boolean): PsiType = - toPsiType(source.getParentOfType(false)?.psi, element, boxed) + toPsiType(source.getParentOfType(false)?.javaPsi as? PsiModifierListOwner, element, boxed) internal fun KotlinType.toPsiType(lightDeclaration: PsiModifierListOwner?, context: KtElement, boxed: Boolean): PsiType { if (this.isError) return UastErrorType @@ -363,7 +363,7 @@ internal fun KtElement.analyze(): BindingContext { } internal inline fun unwrap(element: P): P { - val unwrapped = if (element is T) element.psi else element + val unwrapped = if (element is T) element.javaPsi else element assert(unwrapped !is UElement) return unwrapped as P } @@ -381,23 +381,23 @@ internal fun KotlinType.getFunctionalInterfaceType(source: UElement, element: Kt takeIf { it.isInterface() && !it.isBuiltinFunctionalTypeOrSubtype }?.toPsiType(source, element, false) internal fun KotlinULambdaExpression.getFunctionalInterfaceType(): PsiType? { - val parent = psi.parent - if (parent is KtBinaryExpressionWithTypeRHS) return parent.right?.getType()?.getFunctionalInterfaceType(this, psi) + val parent = sourcePsi.parent + if (parent is KtBinaryExpressionWithTypeRHS) return parent.right?.getType()?.getFunctionalInterfaceType(this, sourcePsi) if (parent is KtValueArgument) run { val callExpression = parent.parents.take(2).firstIsInstanceOrNull() ?: return@run val resolvedCall = callExpression.getResolvedCall(callExpression.analyze()) ?: return@run val candidateDescriptor = resolvedCall.candidateDescriptor as? SyntheticMemberDescriptor<*> ?: return@run when (candidateDescriptor) { - is SamConstructorDescriptor -> return candidateDescriptor.returnType?.getFunctionalInterfaceType(this, psi) + is SamConstructorDescriptor -> return candidateDescriptor.returnType?.getFunctionalInterfaceType(this, sourcePsi) is SamAdapterDescriptor<*>, is SamAdapterExtensionFunctionDescriptor -> { val index = (resolvedCall.getArgumentMapping(parent) as? ArgumentMatch)?.valueParameter?.index ?: return@run val functionDescriptor = candidateDescriptor.baseDescriptorForSynthetic as? FunctionDescriptor ?: return@run val parameterDescriptor = functionDescriptor.valueParameters.getOrNull(index) ?: return@run - return parameterDescriptor.type.getFunctionalInterfaceType(this, psi) + return parameterDescriptor.type.getFunctionalInterfaceType(this, sourcePsi) } } } - return psi.getExpectedType()?.getFunctionalInterfaceType(this, psi) + return sourcePsi.getExpectedType()?.getFunctionalInterfaceType(this, sourcePsi) } internal fun unwrapFakeFileForLightClass(file: PsiFile): PsiFile = (file as? FakeFileForLightClass)?.ktFile ?: file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiParameter.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiParameter.kt index 8c7f742783f..93542442a88 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiParameter.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiParameter.kt @@ -29,7 +29,7 @@ class UastKotlinPsiParameter( ) : LightParameter(name, type, parent, language, isVarArgs) { companion object { fun create(parameter: KtParameter, parent: PsiElement, containingElement: UElement, index: Int): PsiParameter { - val psiParent = containingElement.getParentOfType()?.psi ?: parent + val psiParent = containingElement.getParentOfType()?.javaPsi ?: parent return UastKotlinPsiParameter( parameter.name ?: "p$index", (parameter.analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, parameter] as? VariableDescriptor) diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiVariable.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiVariable.kt index b69fafbd722..ada8500e3fe 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiVariable.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/psi/UastKotlinPsiVariable.kt @@ -76,7 +76,7 @@ class UastKotlinPsiVariable private constructor( containingElement: KotlinUDeclarationsExpression, initializer: KtExpression? = null ): PsiLocalVariable { - val psi = containingElement.psiAnchor ?: containingElement.psi + val psi = containingElement.psiAnchor ?: containingElement.sourcePsi val psiParent = psi?.getNonStrictParentOfType() ?: parent val initializerExpression = initializer ?: declaration.initializer return UastKotlinPsiVariable(