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.UastKotlinPsiVariable
|
||||
|
||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments {
|
||||
|
||||
final override val uastParent: UElement? by lz {
|
||||
givenParent ?: convertParent()
|
||||
@@ -251,8 +250,7 @@ private fun findAnnotationClassFromConstructorParameter(parameter: KtParameter):
|
||||
|
||||
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
||||
KotlinAbstractUElement(givenParent),
|
||||
UExpression,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
UExpression {
|
||||
|
||||
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.UastKotlinPsiVariable
|
||||
|
||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments {
|
||||
|
||||
final override val uastParent: UElement? by lz {
|
||||
givenParent ?: convertParent()
|
||||
@@ -247,8 +246,7 @@ private fun findAnnotationClassFromConstructorParameter(parameter: KtParameter):
|
||||
|
||||
abstract class KotlinAbstractUExpression(givenParent: UElement?) :
|
||||
KotlinAbstractUElement(givenParent),
|
||||
UExpression,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
UExpression {
|
||||
|
||||
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.visitor.UastVisitor
|
||||
|
||||
abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUElement(givenParent), UClassTypeSpecific, UAnchorOwner,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
abstract class AbstractKotlinUClass(givenParent: UElement?) : KotlinAbstractUElement(givenParent), UClassTypeSpecific, UAnchorOwner {
|
||||
|
||||
override val uastDeclarations by lz {
|
||||
mutableListOf<UDeclaration>().apply {
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.*
|
||||
class KotlinUFile(
|
||||
override val psi: KtFile,
|
||||
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
||||
) : UFile, JvmDeclarationUElementPlaceholder {
|
||||
) : UFile {
|
||||
override val packageName: String
|
||||
get() = psi.packageFqName.asString()
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.*
|
||||
class KotlinUFile(
|
||||
override val psi: KtFile,
|
||||
override val languagePlugin: UastLanguagePlugin = kotlinUastPlugin
|
||||
) : UFile, JvmDeclarationUElementPlaceholder {
|
||||
) : UFile {
|
||||
override val packageName: String
|
||||
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
|
||||
|
||||
class WrappedUAnnotation(psiAnnotation: PsiAnnotation, override val uastParent: UElement) : UAnnotation, UAnchorOwner,
|
||||
DelegatedMultiResolve,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
DelegatedMultiResolve {
|
||||
|
||||
override val javaPsi: PsiAnnotation = psiAnnotation
|
||||
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) }
|
||||
|
||||
class WrappedUNamedExpression(pair: PsiNameValuePair, override val uastParent: UElement?) : UNamedExpression,
|
||||
JvmDeclarationUElementPlaceholder {
|
||||
class WrappedUNamedExpression(pair: PsiNameValuePair, override val uastParent: UElement?) : UNamedExpression {
|
||||
override val name: String? = pair.name
|
||||
override val psi = pair
|
||||
override val javaPsi: PsiElement? = psi
|
||||
@@ -240,7 +238,7 @@ class KotlinReceiverUParameter(
|
||||
}
|
||||
|
||||
class KotlinNullabilityUAnnotation(val annotatedElement: PsiElement, override val uastParent: UElement) : UAnnotationEx, UAnchorOwner,
|
||||
DelegatedMultiResolve, JvmDeclarationUElementPlaceholder {
|
||||
DelegatedMultiResolve {
|
||||
|
||||
private fun getTargetType(annotatedElement: PsiElement): KotlinType? {
|
||||
if (annotatedElement is KtTypeReference) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
||||
|
||||
|
||||
private fun createVariableReferenceExpression(variable: UVariable, containingElement: UElement?) =
|
||||
object : USimpleNameReferenceExpression, JvmDeclarationUElementPlaceholder {
|
||||
object : USimpleNameReferenceExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override fun resolve(): PsiElement? = variable
|
||||
override val uastParent: UElement? = containingElement
|
||||
@@ -27,7 +27,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
||||
}
|
||||
|
||||
private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||
object : ULiteralExpression, JvmDeclarationUElementPlaceholder {
|
||||
object : ULiteralExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val value: Any? = null
|
||||
@@ -37,7 +37,7 @@ private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||
}
|
||||
|
||||
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
||||
object : UBinaryExpression, JvmDeclarationUElementPlaceholder {
|
||||
object : UBinaryExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val uastParent: UElement? = containingElement
|
||||
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)
|
||||
declaration.declarations = listOf(tempVariable)
|
||||
|
||||
val ifExpression = object : UIfExpression, JvmDeclarationUElementPlaceholder {
|
||||
val ifExpression = object : UIfExpression {
|
||||
override val psi: PsiElement? = null
|
||||
override val uastParent: UElement? = containingElement
|
||||
override val javaPsi: PsiElement? = null
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ open class KotlinUBlockExpression(
|
||||
class KotlinLazyUBlockExpression(
|
||||
override val uastParent: UElement?,
|
||||
expressionProducer: (expressionParent: UElement) -> List<UExpression>
|
||||
) : UBlockExpression, JvmDeclarationUElementPlaceholder {
|
||||
) : UBlockExpression {
|
||||
override val psi: PsiElement? get() = null
|
||||
override val javaPsi: PsiElement? get() = null
|
||||
override val sourcePsi: PsiElement? get() = null
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
private val resolvedCall: ResolvedCall<*>,
|
||||
private val accessorDescriptor: DeclarationDescriptor,
|
||||
val setterValue: KtExpression?
|
||||
) : UCallExpressionEx, DelegatedMultiResolve, JvmDeclarationUElementPlaceholder {
|
||||
) : UCallExpressionEx, DelegatedMultiResolve {
|
||||
override val methodName: String?
|
||||
get() = accessorDescriptor.name.asString()
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class KotlinUSwitchEntry(
|
||||
}
|
||||
expressions =
|
||||
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 sourcePsi: PsiElement? = null
|
||||
override val psi: PsiElement?
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class KotlinUSwitchEntry(
|
||||
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
||||
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
||||
}
|
||||
expressions = userExpressions + object : UBreakExpression, JvmDeclarationUElementPlaceholder {
|
||||
expressions = userExpressions + object : UBreakExpression {
|
||||
override val javaPsi: PsiElement? = null
|
||||
override val sourcePsi: PsiElement? = null
|
||||
override val psi: PsiElement?
|
||||
|
||||
+2
-2
@@ -21,10 +21,10 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.psi.KtValueArgument
|
||||
import org.jetbrains.uast.UComment
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UExpression
|
||||
import org.jetbrains.uast.kotlin.JvmDeclarationUElementPlaceholder
|
||||
|
||||
interface KotlinUElementWithComments : JvmDeclarationUElementPlaceholder {
|
||||
interface KotlinUElementWithComments : UElement {
|
||||
|
||||
override val comments: List<UComment>
|
||||
get() {
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.assertedCast
|
||||
import org.jetbrains.uast.UAnchorOwner
|
||||
import org.jetbrains.uast.UElement
|
||||
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.KotlinUastLanguagePlugin
|
||||
import org.jetbrains.uast.sourcePsiElement
|
||||
@@ -131,16 +130,13 @@ interface AbstractKotlinRenderLogTest : RenderLogTestBase {
|
||||
node.uastAnchor?.let { visitElement(it) }
|
||||
}
|
||||
|
||||
val jvmDeclaration = node as? JvmDeclarationUElementPlaceholder
|
||||
?: throw AssertionError("${node.javaClass} should implement 'JvmDeclarationUElement'")
|
||||
|
||||
jvmDeclaration.sourcePsi?.let {
|
||||
node.sourcePsi?.let {
|
||||
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}] " +
|
||||
"for ${jvmDeclaration.javaClass}->${jvmDeclaration.uastParent?.javaClass}", it !is KtElement)
|
||||
"for ${node.javaClass}->${node.uastParent?.javaClass}", it !is KtElement)
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user