Uast: removing deprecated JvmDeclarationUElement (KT-23887)
This commit is contained in:
-13
@@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.uast.kotlin
|
|
||||||
|
|
||||||
import org.jetbrains.uast.UElement
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Actual only for 173-bunch, please remove when 173 is over
|
|
||||||
*/
|
|
||||||
typealias JvmDeclarationUElementPlaceholder = UElement
|
|
||||||
@@ -37,8 +37,7 @@ import org.jetbrains.uast.kotlin.internal.KotlinUElementWithComments
|
|||||||
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
||||||
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
||||||
|
|
||||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments,
|
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
final override val uastParent: UElement? by lz {
|
final override val uastParent: UElement? by lz {
|
||||||
givenParent ?: convertParent()
|
givenParent ?: convertParent()
|
||||||
@@ -251,8 +250,7 @@ private fun findAnnotationClassFromConstructorParameter(parameter: KtParameter):
|
|||||||
|
|
||||||
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
||||||
KotlinAbstractUElement(givenParent),
|
KotlinAbstractUElement(givenParent),
|
||||||
UExpression,
|
UExpression {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
override val javaPsi: PsiElement? = null
|
override val javaPsi: PsiElement? = null
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ import org.jetbrains.uast.kotlin.internal.KotlinUElementWithComments
|
|||||||
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
||||||
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
||||||
|
|
||||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments,
|
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
final override val uastParent: UElement? by lz {
|
final override val uastParent: UElement? by lz {
|
||||||
givenParent ?: convertParent()
|
givenParent ?: convertParent()
|
||||||
@@ -247,8 +246,7 @@ private fun findAnnotationClassFromConstructorParameter(parameter: KtParameter):
|
|||||||
|
|
||||||
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
||||||
KotlinAbstractUElement(givenParent),
|
KotlinAbstractUElement(givenParent),
|
||||||
UExpression,
|
UExpression {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
override val javaPsi: PsiElement? = null
|
override val javaPsi: PsiElement? = null
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ import org.jetbrains.uast.kotlin.declarations.UastLightIdentifier
|
|||||||
import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUElement(givenParent), UClassTypeSpecific, UAnchorOwner,
|
abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUElement(givenParent), UClassTypeSpecific, UAnchorOwner {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
override val uastDeclarations by lz {
|
override val uastDeclarations by lz {
|
||||||
mutableListOf<UDeclaration>().apply {
|
mutableListOf<UDeclaration>().apply {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.*
|
|||||||
class KotlinUFile(
|
class KotlinUFile(
|
||||||
override val psi: KtFile,
|
override val psi: KtFile,
|
||||||
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
||||||
) : UFile, JvmDeclarationUElementPlaceholder {
|
) : UFile {
|
||||||
override val packageName: String
|
override val packageName: String
|
||||||
get() = psi.packageFqName.asString()
|
get() = psi.packageFqName.asString()
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.*
|
|||||||
class KotlinUFile(
|
class KotlinUFile(
|
||||||
override val psi: KtFile,
|
override val psi: KtFile,
|
||||||
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
||||||
) : UFile, JvmDeclarationUElementPlaceholder {
|
) : UFile {
|
||||||
override val packageName: String
|
override val packageName: String
|
||||||
get() = psi.packageFqName.asString()
|
get() = psi.packageFqName.asString()
|
||||||
|
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ abstract class AbstractKotlinUVariable(givenParent: UElement?) : KotlinAbstractU
|
|||||||
override fun equals(other: Any?) = other is AbstractKotlinUVariable && psi == other.psi
|
override fun equals(other: Any?) = other is AbstractKotlinUVariable && psi == other.psi
|
||||||
|
|
||||||
class WrappedUAnnotation(psiAnnotation: PsiAnnotation, override val uastParent: UElement) : UAnnotation, UAnchorOwner,
|
class WrappedUAnnotation(psiAnnotation: PsiAnnotation, override val uastParent: UElement) : UAnnotation, UAnchorOwner,
|
||||||
DelegatedMultiResolve,
|
DelegatedMultiResolve {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
|
|
||||||
override val javaPsi: PsiAnnotation = psiAnnotation
|
override val javaPsi: PsiAnnotation = psiAnnotation
|
||||||
override val psi: PsiAnnotation = javaPsi
|
override val psi: PsiAnnotation = javaPsi
|
||||||
@@ -132,8 +131,7 @@ abstract class AbstractKotlinUVariable(givenParent: UElement?) : KotlinAbstractU
|
|||||||
|
|
||||||
override val uastAnchor by lazy { KotlinUIdentifier(javaPsi.nameReferenceElement?.referenceNameElement, null, this) }
|
override val uastAnchor by lazy { KotlinUIdentifier(javaPsi.nameReferenceElement?.referenceNameElement, null, this) }
|
||||||
|
|
||||||
class WrappedUNamedExpression(pair: PsiNameValuePair, override val uastParent: UElement?) : UNamedExpression,
|
class WrappedUNamedExpression(pair: PsiNameValuePair, override val uastParent: UElement?) : UNamedExpression {
|
||||||
JvmDeclarationUElementPlaceholder {
|
|
||||||
override val name: String? = pair.name
|
override val name: String? = pair.name
|
||||||
override val psi = pair
|
override val psi = pair
|
||||||
override val javaPsi: PsiElement? = psi
|
override val javaPsi: PsiElement? = psi
|
||||||
@@ -240,7 +238,7 @@ class KotlinReceiverUParameter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class KotlinNullabilityUAnnotation(val annotatedElement: PsiElement, override val uastParent: UElement) : UAnnotationEx, UAnchorOwner,
|
class KotlinNullabilityUAnnotation(val annotatedElement: PsiElement, override val uastParent: UElement) : UAnnotationEx, UAnchorOwner,
|
||||||
DelegatedMultiResolve, JvmDeclarationUElementPlaceholder {
|
DelegatedMultiResolve {
|
||||||
|
|
||||||
private fun getTargetType(annotatedElement: PsiElement): KotlinType? {
|
private fun getTargetType(annotatedElement: PsiElement): KotlinType? {
|
||||||
if (annotatedElement is KtTypeReference) {
|
if (annotatedElement is KtTypeReference) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
|||||||
|
|
||||||
|
|
||||||
private fun createVariableReferenceExpression(variable: UVariable, containingElement: UElement?) =
|
private fun createVariableReferenceExpression(variable: UVariable, containingElement: UElement?) =
|
||||||
object : USimpleNameReferenceExpression, JvmDeclarationUElementPlaceholder {
|
object : USimpleNameReferenceExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override fun resolve(): PsiElement? = variable
|
override fun resolve(): PsiElement? = variable
|
||||||
override val uastParent: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
@@ -27,7 +27,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createNullLiteralExpression(containingElement: UElement?) =
|
private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||||
object : ULiteralExpression, JvmDeclarationUElementPlaceholder {
|
object : ULiteralExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val uastParent: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val value: Any? = null
|
override val value: Any? = null
|
||||||
@@ -37,7 +37,7 @@ private fun createNullLiteralExpression(containingElement: UElement?) =
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
||||||
object : UBinaryExpression, JvmDeclarationUElementPlaceholder {
|
object : UBinaryExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val uastParent: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val leftOperand: UExpression by lz { createVariableReferenceExpression(variable, this) }
|
override val leftOperand: UExpression by lz { createVariableReferenceExpression(variable, this) }
|
||||||
@@ -60,7 +60,7 @@ private fun createElvisExpressions(
|
|||||||
val tempVariable = KotlinULocalVariable(UastKotlinPsiVariable.create(left, declaration, psiParent), null, declaration)
|
val tempVariable = KotlinULocalVariable(UastKotlinPsiVariable.create(left, declaration, psiParent), null, declaration)
|
||||||
declaration.declarations = listOf(tempVariable)
|
declaration.declarations = listOf(tempVariable)
|
||||||
|
|
||||||
val ifExpression = object : UIfExpression, JvmDeclarationUElementPlaceholder {
|
val ifExpression = object : UIfExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val uastParent: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val javaPsi: PsiElement? = null
|
override val javaPsi: PsiElement? = null
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ open class KotlinUBlockExpression(
|
|||||||
class KotlinLazyUBlockExpression(
|
class KotlinLazyUBlockExpression(
|
||||||
override val uastParent: UElement?,
|
override val uastParent: UElement?,
|
||||||
expressionProducer: (expressionParent: UElement) -> List<UExpression>
|
expressionProducer: (expressionParent: UElement) -> List<UExpression>
|
||||||
) : UBlockExpression, JvmDeclarationUElementPlaceholder {
|
) : UBlockExpression {
|
||||||
override val psi: PsiElement? get() = null
|
override val psi: PsiElement? get() = null
|
||||||
override val javaPsi: PsiElement? get() = null
|
override val javaPsi: PsiElement? get() = null
|
||||||
override val sourcePsi: PsiElement? get() = null
|
override val sourcePsi: PsiElement? get() = null
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
private val resolvedCall: ResolvedCall<*>,
|
private val resolvedCall: ResolvedCall<*>,
|
||||||
private val accessorDescriptor: DeclarationDescriptor,
|
private val accessorDescriptor: DeclarationDescriptor,
|
||||||
val setterValue: KtExpression?
|
val setterValue: KtExpression?
|
||||||
) : UCallExpressionEx, DelegatedMultiResolve, JvmDeclarationUElementPlaceholder {
|
) : UCallExpressionEx, DelegatedMultiResolve {
|
||||||
override val methodName: String?
|
override val methodName: String?
|
||||||
get() = accessorDescriptor.name.asString()
|
get() = accessorDescriptor.name.asString()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ class KotlinUSwitchEntry(
|
|||||||
}
|
}
|
||||||
expressions =
|
expressions =
|
||||||
if (userExpressions.isNotEmpty())
|
if (userExpressions.isNotEmpty())
|
||||||
userExpressions.subList(0, userExpressions.lastIndex) + object : UYieldExpression, JvmDeclarationUElementPlaceholder {
|
userExpressions.subList(0, userExpressions.lastIndex) + object : UYieldExpression {
|
||||||
override val javaPsi: PsiElement? = null
|
override val javaPsi: PsiElement? = null
|
||||||
override val sourcePsi: PsiElement? = null
|
override val sourcePsi: PsiElement? = null
|
||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ class KotlinUSwitchEntry(
|
|||||||
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
||||||
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
||||||
}
|
}
|
||||||
expressions = userExpressions + object : UBreakExpression, JvmDeclarationUElementPlaceholder {
|
expressions = userExpressions + object : UBreakExpression {
|
||||||
override val javaPsi: PsiElement? = null
|
override val javaPsi: PsiElement? = null
|
||||||
override val sourcePsi: PsiElement? = null
|
override val sourcePsi: PsiElement? = null
|
||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
|
|||||||
+2
-2
@@ -21,10 +21,10 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import org.jetbrains.kotlin.psi.KtValueArgument
|
import org.jetbrains.kotlin.psi.KtValueArgument
|
||||||
import org.jetbrains.uast.UComment
|
import org.jetbrains.uast.UComment
|
||||||
|
import org.jetbrains.uast.UElement
|
||||||
import org.jetbrains.uast.UExpression
|
import org.jetbrains.uast.UExpression
|
||||||
import org.jetbrains.uast.kotlin.JvmDeclarationUElementPlaceholder
|
|
||||||
|
|
||||||
interface KotlinUElementWithComments : JvmDeclarationUElementPlaceholder {
|
interface KotlinUElementWithComments : UElement {
|
||||||
|
|
||||||
override val comments: List<UComment>
|
override val comments: List<UComment>
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.assertedCast
|
|||||||
import org.jetbrains.uast.UAnchorOwner
|
import org.jetbrains.uast.UAnchorOwner
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
import org.jetbrains.uast.UFile
|
import org.jetbrains.uast.UFile
|
||||||
import org.jetbrains.uast.kotlin.JvmDeclarationUElementPlaceholder
|
|
||||||
import org.jetbrains.uast.kotlin.KOTLIN_CACHED_UELEMENT_KEY
|
import org.jetbrains.uast.kotlin.KOTLIN_CACHED_UELEMENT_KEY
|
||||||
import org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin
|
import org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin
|
||||||
import org.jetbrains.uast.sourcePsiElement
|
import org.jetbrains.uast.sourcePsiElement
|
||||||
@@ -131,16 +130,13 @@ interface AbstractKotlinRenderLogTest : RenderLogTestBase {
|
|||||||
node.uastAnchor?.let { visitElement(it) }
|
node.uastAnchor?.let { visitElement(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val jvmDeclaration = node as? JvmDeclarationUElementPlaceholder
|
node.sourcePsi?.let {
|
||||||
?: throw AssertionError("${node.javaClass} should implement 'JvmDeclarationUElement'")
|
|
||||||
|
|
||||||
jvmDeclaration.sourcePsi?.let {
|
|
||||||
assertTrue("sourcePsi should be physical but ${it.javaClass} found for [${it.text}] " +
|
assertTrue("sourcePsi should be physical but ${it.javaClass} found for [${it.text}] " +
|
||||||
"for ${jvmDeclaration.javaClass}->${jvmDeclaration.uastParent?.javaClass}",it is LeafPsiElement || it is KtElement|| it is LeafPsiElement)
|
"for ${node.javaClass}->${node.uastParent?.javaClass}", it is LeafPsiElement || it is KtElement|| it is LeafPsiElement)
|
||||||
}
|
}
|
||||||
jvmDeclaration.javaPsi?.let {
|
node.javaPsi?.let {
|
||||||
assertTrue("javaPsi should be light but ${it.javaClass} found for [${it.text}] " +
|
assertTrue("javaPsi should be light but ${it.javaClass} found for [${it.text}] " +
|
||||||
"for ${jvmDeclaration.javaClass}->${jvmDeclaration.uastParent?.javaClass}", it !is KtElement)
|
"for ${node.javaClass}->${node.uastParent?.javaClass}", it !is KtElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user