Uast: deprecating JvmDeclarationUElement

This commit is contained in:
Nicolay Mitropolsky
2018-01-16 11:26:17 +03:00
parent 38d7f010f4
commit b55c3e7714
2 changed files with 24 additions and 34 deletions
@@ -32,9 +32,29 @@ interface UElement {
/**
* Returns the PSI element underlying this element. Note that some UElements are synthetic and do not have
* an underlying PSI element; this doesn't mean that they are invalid.
*
* **Node for implementors**: please implement both [sourcePsi] and [javaPsi] fields or make them return `null` explicitly
* if implementing is not possible. Redirect `psi` to one of them keeping existing behavior, use [sourcePsi] if nothing else is specified.
*/
@Deprecated("ambiguous psi element, use `sourcePsi` or `javaPsi`", ReplaceWith("javaPsi"))
val psi: PsiElement?
/**
* Returns the PSI element in original (physical) tree to which this UElement corresponds.
* **Note**: that some UElements are synthetic and do not have an underlying PSI element;
* this doesn't mean that they are invalid.
*/
val sourcePsi: PsiElement?
get() = psi
/**
* Returns the element which try to mimic Java-api psi element: [com.intellij.psi.PsiClass], [com.intellij.psi.PsiMethod] or [com.intellij.psi.PsiAnnotation] etc.
* Will return null if this UElement doesn't have Java representation or it is not implemented.
*/
val javaPsi: PsiElement?
get() = psi
/**
* Returns true if this element is valid, false otherwise.
*/
@@ -102,38 +122,8 @@ interface UElement {
fun <D, R> accept(visitor: UastTypedVisitor<D, R>, data: D): R = visitor.visitElement(this, data)
}
/**
* This is transitional type, all its content will be moved to `UElement` as soon as all implementations will implement it,
* and someday this interface will be dropped.
*/
@ApiStatus.Experimental
interface JvmDeclarationUElement : UElement {
/**
* Returns the PSI element in original (physical) tree to which this UElement corresponds.
* **Note**: that some UElements are synthetic and do not have an underlying PSI element;
* this doesn't mean that they are invalid.
*/
val sourcePsi: PsiElement?
get() = psi
/**
* Returns the element which try to mimic Java-api psi element: [com.intellij.psi.PsiClass], [com.intellij.psi.PsiMethod] or [com.intellij.psi.PsiAnnotation] etc.
* Will return null if this UElement doesn't have Java representation or it is not implemented.
*/
val javaPsi: PsiElement?
get() = psi
/**
* Returns the PSI element underlying this element. Note that some UElements are synthetic and do not have
* an underlying PSI element; this doesn't mean that they are invalid.
*
* **Node for implementors**: please implement both [sourcePsi] and [javaPsi] fields or make them return `null` explicitly
* if implementing is not possible. Redirect `psi` to one of them keeping existing behavior, use [sourcePsi] if nothing else is specified.
*/
@Deprecated("ambiguous psi element, use `sourcePsi` or `javaPsi`", ReplaceWith("javaPsi"))
override val psi: PsiElement?
}
@Deprecated("No use anymore, all declarations were moved to UElement. To be removed in 2018.2")
interface JvmDeclarationUElement : UElement
/**
* Experimental API
@@ -60,9 +60,9 @@ abstract class JavaAbstractUElement(givenParent: UElement?) : JavaUElementWithCo
override val comments: List<UComment>
get() = super<JavaUElementWithComments>.comments
override val sourcePsi: PsiElement?
get() = super.sourcePsi
get() = super<JavaUElementWithComments>.sourcePsi
override val javaPsi: PsiElement?
get() = super.javaPsi
get() = super<JavaUElementWithComments>.javaPsi
}