Uast: Migrate to UAnnotation
This commit is contained in:
committed by
Yan Zhulanow
parent
fee54d9b86
commit
6ff29f473b
@@ -65,10 +65,12 @@ fun <T : UElement> UElement.getParentOfType(
|
|||||||
|
|
||||||
fun UElement.getContainingFile() = getParentOfType<UFile>(UFile::class.java)
|
fun UElement.getContainingFile() = getParentOfType<UFile>(UFile::class.java)
|
||||||
|
|
||||||
|
fun UElement.getContainingUClass() = getParentOfType<UClass>(UClass::class.java)
|
||||||
fun UElement.getContainingUMethod() = getParentOfType<UMethod>(UMethod::class.java)
|
fun UElement.getContainingUMethod() = getParentOfType<UMethod>(UMethod::class.java)
|
||||||
fun UElement.getContainingUVariable() = getParentOfType<UVariable>(UVariable::class.java)
|
fun UElement.getContainingUVariable() = getParentOfType<UVariable>(UVariable::class.java)
|
||||||
|
|
||||||
fun UElement.getContainingMethod() = getContainingUMethod()?.psi
|
fun UElement.getContainingMethod() = getContainingUMethod()?.psi
|
||||||
|
fun UElement.getContainingClass() = getContainingUClass()?.psi
|
||||||
fun UElement.getContainingVariable() = getContainingUVariable()?.psi
|
fun UElement.getContainingVariable() = getContainingUVariable()?.psi
|
||||||
|
|
||||||
fun PsiElement?.getContainingClass() = this?.let { PsiTreeUtil.getParentOfType(it, PsiClass::class.java) }
|
fun PsiElement?.getContainingClass() = this?.let { PsiTreeUtil.getParentOfType(it, PsiClass::class.java) }
|
||||||
|
|||||||
@@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotation
|
|
||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an expression or statement (which is considered as an expression in Uast).
|
* Represents an expression or statement (which is considered as an expression in Uast).
|
||||||
*/
|
*/
|
||||||
interface UExpression : UElement {
|
interface UExpression : UElement, UAnnotated {
|
||||||
/**
|
/**
|
||||||
* Returns the expression value or null if the value can't be calculated.
|
* Returns the expression value or null if the value can't be calculated.
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +45,7 @@ interface UAnnotated : UElement {
|
|||||||
/**
|
/**
|
||||||
* Returns the list of annotations applied to the current element.
|
* Returns the list of annotations applied to the current element.
|
||||||
*/
|
*/
|
||||||
val annotations: List<PsiAnnotation>
|
val annotations: List<UAnnotation>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up for annotation element using the annotation qualified name.
|
* Looks up for annotation element using the annotation qualified name.
|
||||||
@@ -54,7 +53,22 @@ interface UAnnotated : UElement {
|
|||||||
* @param fqName the qualified name to search
|
* @param fqName the qualified name to search
|
||||||
* @return the first annotation element with the specified qualified name, or null if there is no annotation with such name.
|
* @return the first annotation element with the specified qualified name, or null if there is no annotation with such name.
|
||||||
*/
|
*/
|
||||||
fun findAnnotation(fqName: String): PsiAnnotation? = annotations.firstOrNull { it.qualifiedName == fqName }
|
fun findAnnotation(fqName: String): UAnnotation? = annotations.firstOrNull { it.qualifiedName == fqName }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a labeled element.
|
||||||
|
*/
|
||||||
|
interface ULabeled : UElement {
|
||||||
|
/**
|
||||||
|
* Returns the label name, or null if the label is empty.
|
||||||
|
*/
|
||||||
|
val label: String?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the label identifier, or null if the label is empty.
|
||||||
|
*/
|
||||||
|
val labelIdentifier: UIdentifier?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,5 +83,8 @@ object UastEmptyExpression : UExpression {
|
|||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
get() = null
|
get() = null
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override fun asLogString() = "EmptyExpression"
|
override fun asLogString() = "EmptyExpression"
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ interface UDoWhileExpression : ULoopExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitDoWhileExpression(this)) return
|
if (visitor.visitDoWhileExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
condition.accept(visitor)
|
condition.accept(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitDoWhileExpression(this)
|
visitor.afterVisitDoWhileExpression(this)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ interface UForEachExpression : ULoopExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitForEachExpression(this)) return
|
if (visitor.visitForEachExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
iteratedValue.accept(visitor)
|
iteratedValue.accept(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitForEachExpression(this)
|
visitor.afterVisitForEachExpression(this)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ interface UForExpression : ULoopExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitForExpression(this)) return
|
if (visitor.visitForExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
declaration?.accept(visitor)
|
declaration?.accept(visitor)
|
||||||
condition?.accept(visitor)
|
condition?.accept(visitor)
|
||||||
update?.accept(visitor)
|
update?.accept(visitor)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ interface UIfExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitIfExpression(this)) return
|
if (visitor.visitIfExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
condition.accept(visitor)
|
condition.accept(visitor)
|
||||||
thenExpression?.accept(visitor)
|
thenExpression?.accept(visitor)
|
||||||
elseExpression?.accept(visitor)
|
elseExpression?.accept(visitor)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ interface USwitchExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitSwitchExpression(this)) return
|
if (visitor.visitSwitchExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expression?.accept(visitor)
|
expression?.accept(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitSwitchExpression(this)
|
visitor.afterVisitSwitchExpression(this)
|
||||||
@@ -78,6 +79,7 @@ interface USwitchClauseExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitSwitchClauseExpression(this)) return
|
if (visitor.visitSwitchClauseExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
caseValues?.acceptList(visitor)
|
caseValues?.acceptList(visitor)
|
||||||
visitor.afterVisitSwitchClauseExpression(this)
|
visitor.afterVisitSwitchClauseExpression(this)
|
||||||
}
|
}
|
||||||
@@ -100,6 +102,7 @@ interface USwitchClauseExpressionWithBody : USwitchClauseExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitSwitchClauseExpression(this)) return
|
if (visitor.visitSwitchClauseExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
caseValues?.acceptList(visitor)
|
caseValues?.acceptList(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitSwitchClauseExpression(this)
|
visitor.afterVisitSwitchClauseExpression(this)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ interface UTryExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitTryExpression(this)) return
|
if (visitor.visitTryExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
tryClause.accept(visitor)
|
tryClause.accept(visitor)
|
||||||
catchClauses.acceptList(visitor)
|
catchClauses.acceptList(visitor)
|
||||||
finallyClause?.accept(visitor)
|
finallyClause?.accept(visitor)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ interface UWhileExpression : ULoopExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitWhileExpression(this)) return
|
if (visitor.visitWhileExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
condition.accept(visitor)
|
condition.accept(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitWhileExpression(this)
|
visitor.afterVisitWhileExpression(this)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package org.jetbrains.uast
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotation
|
|
||||||
|
|
||||||
class SimpleUAnnotation(
|
|
||||||
psi: PsiAnnotation,
|
|
||||||
override val containingElement: UElement?
|
|
||||||
) : UAnnotation, PsiAnnotation by psi {
|
|
||||||
override val psi: PsiAnnotation = unwrap(psi)
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
fun unwrap(psi: PsiAnnotation): PsiAnnotation {
|
|
||||||
val unwrapped = if (psi is UAnnotation) psi.psi else psi
|
|
||||||
assert(unwrapped !is UElement)
|
|
||||||
return unwrapped
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +1,38 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotation
|
import com.intellij.psi.PsiClass
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation wrapper to be used in [UastVisitor].
|
* An annotation wrapper to be used in [UastVisitor].
|
||||||
*/
|
*/
|
||||||
interface UAnnotation : UElement, PsiAnnotation, PsiElementBacked {
|
interface UAnnotation : UElement, PsiElementBacked, UResolvable {
|
||||||
/**
|
/**
|
||||||
* Returns the original annotation (which is *always* unwrapped [PsiAnnotation], never a [UAnnotation]).
|
* Returns the annotation qualified name.
|
||||||
*/
|
*/
|
||||||
override val psi: PsiAnnotation
|
val qualifiedName: String?
|
||||||
|
|
||||||
override fun getOriginalElement() = psi.originalElement
|
/**
|
||||||
|
* Returns the annotation class, or null if the class reference was not resolved.
|
||||||
|
*/
|
||||||
|
override fun resolve(): PsiClass?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the annotation values.
|
||||||
|
*/
|
||||||
|
val attributeValues: List<UNamedExpression>
|
||||||
|
|
||||||
|
fun findAttributeValue(name: String?): UNamedExpression?
|
||||||
|
|
||||||
|
fun findDeclaredAttributeValue(name: String?): UNamedExpression?
|
||||||
|
|
||||||
override fun asLogString() = "UAnnotation"
|
override fun asLogString() = "UAnnotation"
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitAnnotation(this)) return
|
if (visitor.visitAnnotation(this)) return
|
||||||
|
attributeValues.acceptList(visitor)
|
||||||
visitor.afterVisitAnnotation(this)
|
visitor.afterVisitAnnotation(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ interface UClass : UDeclaration, PsiClass {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitClass(this)) return
|
if (visitor.visitClass(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
uastDeclarations.acceptList(visitor)
|
uastDeclarations.acceptList(visitor)
|
||||||
visitor.afterVisitClass(this)
|
visitor.afterVisitClass(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface UClassInitializer : UDeclaration, PsiClassInitializer {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitInitializer(this)) return
|
if (visitor.visitInitializer(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
uastBody.accept(visitor)
|
uastBody.accept(visitor)
|
||||||
visitor.afterVisitInitializer(this)
|
visitor.afterVisitInitializer(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
|||||||
/**
|
/**
|
||||||
* A [PsiElement] declaration wrapper.
|
* A [PsiElement] declaration wrapper.
|
||||||
*/
|
*/
|
||||||
interface UDeclaration : UElement, PsiElementBacked, PsiModifierListOwner {
|
interface UDeclaration : UElement, PsiElementBacked, PsiModifierListOwner, UAnnotated {
|
||||||
/**
|
/**
|
||||||
* Returns the original declaration (which is *always* unwrapped, never a [UDeclaration]).
|
* Returns the original declaration (which is *always* unwrapped, never a [UDeclaration]).
|
||||||
*/
|
*/
|
||||||
@@ -21,8 +21,6 @@ interface UDeclaration : UElement, PsiElementBacked, PsiModifierListOwner {
|
|||||||
*/
|
*/
|
||||||
val uastAnchor: UElement?
|
val uastAnchor: UElement?
|
||||||
|
|
||||||
val uastAnnotations: List<UAnnotation>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if this declaration has a [PsiModifier.STATIC] modifier.
|
* Returns `true` if this declaration has a [PsiModifier.STATIC] modifier.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.jetbrains.uast.visitor.UastVisitor
|
|||||||
/**
|
/**
|
||||||
* Represents a Uast file.
|
* Represents a Uast file.
|
||||||
*/
|
*/
|
||||||
interface UFile : UElement {
|
interface UFile : UElement, UAnnotated {
|
||||||
/**
|
/**
|
||||||
* Returns the original [PsiFile].
|
* Returns the original [PsiFile].
|
||||||
*/
|
*/
|
||||||
@@ -49,6 +49,7 @@ interface UFile : UElement {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitFile(this)) return
|
if (visitor.visitFile(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
imports.acceptList(visitor)
|
imports.acceptList(visitor)
|
||||||
classes.acceptList(visitor)
|
classes.acceptList(visitor)
|
||||||
visitor.afterVisitFile(this)
|
visitor.afterVisitFile(this)
|
||||||
|
|||||||
@@ -21,12 +21,17 @@ interface UMethod : UDeclaration, PsiMethod {
|
|||||||
*/
|
*/
|
||||||
val uastParameters: List<UParameter>
|
val uastParameters: List<UParameter>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if the method overrides a method of a super class.
|
||||||
|
*/
|
||||||
|
val isOverride: Boolean
|
||||||
|
|
||||||
@Deprecated("Use uastBody instead.", ReplaceWith("uastBody"))
|
@Deprecated("Use uastBody instead.", ReplaceWith("uastBody"))
|
||||||
override fun getBody() = psi.body
|
override fun getBody() = psi.body
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitMethod(this)) return
|
if (visitor.visitMethod(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
uastParameters.acceptList(visitor)
|
uastParameters.acceptList(visitor)
|
||||||
uastBody?.accept(visitor)
|
uastBody?.accept(visitor)
|
||||||
visitor.afterVisitMethod(this)
|
visitor.afterVisitMethod(this)
|
||||||
@@ -47,7 +52,7 @@ interface UAnnotationMethod : UMethod, PsiAnnotationMethod {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitMethod(this)) return
|
if (visitor.visitMethod(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
uastParameters.acceptList(visitor)
|
uastParameters.acceptList(visitor)
|
||||||
uastBody?.accept(visitor)
|
uastBody?.accept(visitor)
|
||||||
uastDefaultValue?.accept(visitor)
|
uastDefaultValue?.accept(visitor)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface UVariable : UDeclaration, PsiVariable {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitVariable(this)) return
|
if (visitor.visitVariable(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
uastInitializer?.accept(visitor)
|
uastInitializer?.accept(visitor)
|
||||||
visitor.afterVisitVariable(this)
|
visitor.afterVisitVariable(this)
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ interface UEnumConstant : UField, UCallExpression, PsiEnumConstant {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitVariable(this)) return
|
if (visitor.visitVariable(this)) return
|
||||||
uastAnnotations.acceptList(visitor)
|
annotations.acceptList(visitor)
|
||||||
methodIdentifier?.accept(visitor)
|
methodIdentifier?.accept(visitor)
|
||||||
classReference?.accept(visitor)
|
classReference?.accept(visitor)
|
||||||
valueArguments.acceptList(visitor)
|
valueArguments.acceptList(visitor)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ interface UArrayAccessExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitArrayAccessExpression(this)) return
|
if (visitor.visitArrayAccessExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
receiver.accept(visitor)
|
receiver.accept(visitor)
|
||||||
indices.acceptList(visitor)
|
indices.acceptList(visitor)
|
||||||
visitor.afterVisitArrayAccessExpression(this)
|
visitor.afterVisitArrayAccessExpression(this)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +52,7 @@ interface UBinaryExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitBinaryExpression(this)) return
|
if (visitor.visitBinaryExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
leftOperand.accept(visitor)
|
leftOperand.accept(visitor)
|
||||||
rightOperand.accept(visitor)
|
rightOperand.accept(visitor)
|
||||||
visitor.afterVisitBinaryExpression(this)
|
visitor.afterVisitBinaryExpression(this)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.uast
|
|||||||
|
|
||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
import org.jetbrains.uast.expressions.UTypeReferenceExpression
|
import org.jetbrains.uast.expressions.UTypeReferenceExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ interface UBinaryExpressionWithType : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitBinaryExpressionWithType(this)) return
|
if (visitor.visitBinaryExpressionWithType(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
operand.accept(visitor)
|
operand.accept(visitor)
|
||||||
visitor.afterVisitBinaryExpressionWithType(this)
|
visitor.afterVisitBinaryExpressionWithType(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ interface UBlockExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitBlockExpression(this)) return
|
if (visitor.visitBlockExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expressions.acceptList(visitor)
|
expressions.acceptList(visitor)
|
||||||
visitor.afterVisitBlockExpression(this)
|
visitor.afterVisitBlockExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,8 @@ interface UBreakExpression : UExpression {
|
|||||||
val label: String?
|
val label: String?
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitBreakExpression(this)
|
if (visitor.visitBreakExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitBreakExpression(this)
|
visitor.afterVisitBreakExpression(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ interface UCallExpression : UExpression, UResolvable {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitCallExpression(this)) return
|
if (visitor.visitCallExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
methodIdentifier?.accept(visitor)
|
methodIdentifier?.accept(visitor)
|
||||||
classReference?.accept(visitor)
|
classReference?.accept(visitor)
|
||||||
valueArguments.acceptList(visitor)
|
valueArguments.acceptList(visitor)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.jetbrains.uast
|
|||||||
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +43,7 @@ interface UCallableReferenceExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitCallableReferenceExpression(this)) return
|
if (visitor.visitCallableReferenceExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
qualifierExpression?.accept(visitor)
|
qualifierExpression?.accept(visitor)
|
||||||
visitor.afterVisitCallableReferenceExpression(this)
|
visitor.afterVisitCallableReferenceExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.jetbrains.uast
|
|||||||
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +39,8 @@ interface UClassLiteralExpression : UExpression {
|
|||||||
val expression: UExpression?
|
val expression: UExpression?
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitClassLiteralExpression(this)
|
if (visitor.visitClassLiteralExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expression?.accept(visitor)
|
expression?.accept(visitor)
|
||||||
visitor.afterVisitClassLiteralExpression(this)
|
visitor.afterVisitClassLiteralExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,8 @@ interface UContinueExpression : UExpression {
|
|||||||
val label: String?
|
val label: String?
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitContinueExpression(this)
|
if (visitor.visitContinueExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitContinueExpression(this)
|
visitor.afterVisitContinueExpression(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a generic list of expressions.
|
* Represents a generic list of expressions.
|
||||||
*/
|
*/
|
||||||
interface USpecialExpressionList : UExpression {
|
interface UExpressionList : UExpression {
|
||||||
/**
|
/**
|
||||||
* Returns the list of expressions.
|
* Returns the list of expressions.
|
||||||
*/
|
*/
|
||||||
@@ -32,13 +34,14 @@ interface USpecialExpressionList : UExpression {
|
|||||||
val kind: UastSpecialExpressionKind
|
val kind: UastSpecialExpressionKind
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitSpecialExpressionList(this)) return
|
if (visitor.visitExpressionList(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expressions.acceptList(visitor)
|
expressions.acceptList(visitor)
|
||||||
visitor.afterVisitSpecialExpressionList(this)
|
visitor.afterVisitExpressionList(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun firstOrNull(): UExpression? = expressions.firstOrNull()
|
fun firstOrNull(): UExpression? = expressions.firstOrNull()
|
||||||
|
|
||||||
override fun logString() = log("USpecialExpressionList (${kind.name})", expressions)
|
override fun asLogString() = log("USpecialExpressionList (${kind.name})", expressions)
|
||||||
override fun renderString() = kind.name + " " + expressions.joinToString(" : ") { it.renderString() }
|
override fun asRenderString() = kind.name + " " + expressions.joinToString(" : ") { it.asRenderString() }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.uast.expressions
|
||||||
|
|
||||||
|
import org.jetbrains.uast.UExpression
|
||||||
|
import org.jetbrains.uast.ULabeled
|
||||||
|
import org.jetbrains.uast.UResolvable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A common parent for "this" and "super" expressions.
|
||||||
|
*/
|
||||||
|
interface UInstanceExpression : UExpression, ULabeled, UResolvable
|
||||||
@@ -15,17 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an expression with the label specified.
|
* Represents an expression with the label specified.
|
||||||
*/
|
*/
|
||||||
interface ULabeledExpression : UExpression {
|
interface ULabeledExpression : UExpression, ULabeled {
|
||||||
/**
|
/**
|
||||||
* Returns the expression label.
|
* Returns the expression label.
|
||||||
*/
|
*/
|
||||||
val label: String
|
override val label: String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the expression itself.
|
* Returns the expression itself.
|
||||||
@@ -34,6 +35,7 @@ interface ULabeledExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitLabeledExpression(this)) return
|
if (visitor.visitLabeledExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expression.accept(visitor)
|
expression.accept(visitor)
|
||||||
visitor.afterVisitLabeledExpression(this)
|
visitor.afterVisitLabeledExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ interface ULambdaExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitLambdaExpression(this)) return
|
if (visitor.visitLambdaExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
valueParameters.acceptList(visitor)
|
valueParameters.acceptList(visitor)
|
||||||
body.accept(visitor)
|
body.accept(visitor)
|
||||||
visitor.afterVisitLambdaExpression(this)
|
visitor.afterVisitLambdaExpression(this)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +47,8 @@ interface ULiteralExpression : UExpression {
|
|||||||
get() = evaluate() is Boolean
|
get() = evaluate() is Boolean
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitLiteralExpression(this)
|
if (visitor.visitLiteralExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitLiteralExpression(this)
|
visitor.afterVisitLiteralExpression(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -24,8 +25,12 @@ class UNamedExpression(
|
|||||||
): UExpression, UNamed {
|
): UExpression, UNamed {
|
||||||
lateinit var expression: UExpression
|
lateinit var expression: UExpression
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitElement(this)) return
|
if (visitor.visitElement(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expression.accept(visitor)
|
expression.accept(visitor)
|
||||||
visitor.afterVisitElement(this)
|
visitor.afterVisitElement(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ interface UObjectLiteralExpression : UCallExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitObjectLiteralExpression(this)) return
|
if (visitor.visitObjectLiteralExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
declaration.accept(visitor)
|
declaration.accept(visitor)
|
||||||
visitor.afterVisitObjectLiteralExpression(this)
|
visitor.afterVisitObjectLiteralExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ interface UParenthesizedExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitParenthesizedExpression(this)) return
|
if (visitor.visitParenthesizedExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
expression.accept(visitor)
|
expression.accept(visitor)
|
||||||
visitor.afterVisitParenthesizedExpression(this)
|
visitor.afterVisitParenthesizedExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import org.jetbrains.uast.expressions.UReferenceExpression
|
import org.jetbrains.uast.expressions.UReferenceExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ interface UQualifiedReferenceExpression : UReferenceExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitQualifiedReferenceExpression(this)) return
|
if (visitor.visitQualifiedReferenceExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
receiver.accept(visitor)
|
receiver.accept(visitor)
|
||||||
selector.accept(visitor)
|
selector.accept(visitor)
|
||||||
visitor.afterVisitQualifiedReferenceExpression(this)
|
visitor.afterVisitQualifiedReferenceExpression(this)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ interface UReturnExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitReturnExpression(this)) return
|
if (visitor.visitReturnExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
returnExpression?.accept(visitor)
|
returnExpression?.accept(visitor)
|
||||||
visitor.afterVisitReturnExpression(this)
|
visitor.afterVisitReturnExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import org.jetbrains.uast.expressions.UReferenceExpression
|
import org.jetbrains.uast.expressions.UReferenceExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +29,8 @@ interface USimpleNameReferenceExpression : UReferenceExpression {
|
|||||||
val identifier: String
|
val identifier: String
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitSimpleNameReferenceExpression(this)
|
if (visitor.visitSimpleNameReferenceExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitSimpleNameReferenceExpression(this)
|
visitor.afterVisitSimpleNameReferenceExpression(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,18 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.expressions.UInstanceExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a `super` expression.
|
* Represents a `super` expression.
|
||||||
* Qualified `super` is not supported at the moment.
|
* Qualified `super` is not supported at the moment.
|
||||||
*/
|
*/
|
||||||
interface USuperExpression : UExpression {
|
interface USuperExpression : UInstanceExpression {
|
||||||
override fun asLogString() = "USuperExpression"
|
override fun asLogString() = "USuperExpression"
|
||||||
override fun asRenderString() = "super"
|
override fun asRenderString() = "super"
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitSuperExpression(this)
|
if (visitor.visitSuperExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitSuperExpression(this)
|
visitor.afterVisitSuperExpression(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,18 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.expressions.UInstanceExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a `this` expression.
|
* Represents a `this` expression.
|
||||||
* Qualified `this` is not supported at the moment.
|
* Qualified `this` is not supported at the moment.
|
||||||
*/
|
*/
|
||||||
interface UThisExpression : UExpression {
|
interface UThisExpression : UInstanceExpression {
|
||||||
override fun asLogString() = "UThisExpression"
|
override fun asLogString() = "UThisExpression"
|
||||||
override fun asRenderString() = "this"
|
override fun asRenderString() = "this"
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitThisExpression(this)
|
if (visitor.visitThisExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitThisExpression(this)
|
visitor.afterVisitThisExpression(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ interface UThrowExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitThrowExpression(this)) return
|
if (visitor.visitThrowExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
thrownExpression.accept(visitor)
|
thrownExpression.accept(visitor)
|
||||||
visitor.afterVisitThrowExpression(this)
|
visitor.afterVisitThrowExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.jetbrains.uast.expressions
|
|||||||
import com.intellij.psi.PsiType
|
import com.intellij.psi.PsiType
|
||||||
import com.intellij.psi.util.PsiTypesUtil
|
import com.intellij.psi.util.PsiTypesUtil
|
||||||
import org.jetbrains.uast.UExpression
|
import org.jetbrains.uast.UExpression
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.name
|
import org.jetbrains.uast.name
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -18,7 +19,8 @@ interface UTypeReferenceExpression : UExpression {
|
|||||||
fun getQualifiedName() = PsiTypesUtil.getPsiClass(type)?.qualifiedName
|
fun getQualifiedName() = PsiTypesUtil.getPsiClass(type)?.qualifiedName
|
||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
visitor.visitTypeReferenceExpression(this)
|
if (visitor.visitTypeReferenceExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
visitor.afterVisitTypeReferenceExpression(this)
|
visitor.afterVisitTypeReferenceExpression(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast
|
package org.jetbrains.uast
|
||||||
|
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
|
import org.jetbrains.uast.internal.acceptList
|
||||||
import org.jetbrains.uast.internal.log
|
import org.jetbrains.uast.internal.log
|
||||||
import org.jetbrains.uast.visitor.UastVisitor
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ interface UUnaryExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitUnaryExpression(this)) return
|
if (visitor.visitUnaryExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
operand.accept(visitor)
|
operand.accept(visitor)
|
||||||
visitor.afterVisitUnaryExpression(this)
|
visitor.afterVisitUnaryExpression(this)
|
||||||
}
|
}
|
||||||
@@ -54,6 +56,7 @@ interface UPrefixExpression : UUnaryExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitPrefixExpression(this)) return
|
if (visitor.visitPrefixExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
operand.accept(visitor)
|
operand.accept(visitor)
|
||||||
visitor.afterVisitPrefixExpression(this)
|
visitor.afterVisitPrefixExpression(this)
|
||||||
}
|
}
|
||||||
@@ -67,6 +70,7 @@ interface UPostfixExpression : UUnaryExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitPostfixExpression(this)) return
|
if (visitor.visitPostfixExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
operand.accept(visitor)
|
operand.accept(visitor)
|
||||||
visitor.afterVisitPostfixExpression(this)
|
visitor.afterVisitPostfixExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -31,6 +31,7 @@ interface UVariableDeclarationsExpression : UExpression {
|
|||||||
|
|
||||||
override fun accept(visitor: UastVisitor) {
|
override fun accept(visitor: UastVisitor) {
|
||||||
if (visitor.visitDeclarationsExpression(this)) return
|
if (visitor.visitDeclarationsExpression(this)) return
|
||||||
|
annotations.acceptList(visitor)
|
||||||
variables.acceptList(visitor)
|
variables.acceptList(visitor)
|
||||||
visitor.afterVisitDeclarationsExpression(this)
|
visitor.afterVisitDeclarationsExpression(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ fun UElement.isNewArrayWithDimensions() = (this as? UCallExpression)?.kind == Ua
|
|||||||
|
|
||||||
fun UElement.isNewArrayWithInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NEW_ARRAY_WITH_INITIALIZER
|
fun UElement.isNewArrayWithInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NEW_ARRAY_WITH_INITIALIZER
|
||||||
|
|
||||||
fun UElement.isNestedArrayInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NESTED_ARRAY_INITIALIZER
|
@Deprecated("Use isArrayInitializer()", ReplaceWith("isArrayInitializer()"))
|
||||||
|
fun UElement.isNestedArrayInitializer() = isArrayInitializer()
|
||||||
|
|
||||||
|
fun UElement.isArrayInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NESTED_ARRAY_INITIALIZER
|
||||||
|
|
||||||
fun UElement.isTypeCast() = (this as? UBinaryExpressionWithType)?.operationKind is UastBinaryExpressionWithTypeKind.TypeCast
|
fun UElement.isTypeCast() = (this as? UBinaryExpressionWithType)?.operationKind is UastBinaryExpressionWithTypeKind.TypeCast
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast.java
|
package org.jetbrains.uast.java
|
||||||
|
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.JavaPsiFacade
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiExpression
|
||||||
|
import com.intellij.psi.PsiType
|
||||||
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UExpression
|
import org.jetbrains.uast.UExpression
|
||||||
import org.jetbrains.uast.java.internal.JavaUElementWithComments
|
import org.jetbrains.uast.java.internal.JavaUElementWithComments
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
@@ -49,7 +53,10 @@ abstract class JavaAbstractUExpression : JavaAbstractUElement(), UExpression {
|
|||||||
val psi = (this as? PsiElementBacked)?.psi ?: return null
|
val psi = (this as? PsiElementBacked)?.psi ?: return null
|
||||||
return JavaPsiFacade.getInstance(psi.project).constantEvaluationHelper.computeConstantExpression(psi)
|
return JavaPsiFacade.getInstance(psi.project).constantEvaluationHelper.computeConstantExpression(psi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override fun getExpressionType(): PsiType? {
|
override fun getExpressionType(): PsiType? {
|
||||||
val expression = (this as? PsiElementBacked)?.psi as? PsiExpression ?: return null
|
val expression = (this as? PsiElementBacked)?.psi as? PsiExpression ?: return null
|
||||||
return expression.type
|
return expression.type
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class JavaUastLanguagePlugin(override val project: Project) : UastLanguagePlugin
|
|||||||
is PsiMethod -> el<UMethod> { JavaUMethod.create(element, this@JavaUastLanguagePlugin, parent) }
|
is PsiMethod -> el<UMethod> { JavaUMethod.create(element, this@JavaUastLanguagePlugin, parent) }
|
||||||
is PsiClassInitializer -> el<UClassInitializer> { JavaUClassInitializer(element, parent) }
|
is PsiClassInitializer -> el<UClassInitializer> { JavaUClassInitializer(element, parent) }
|
||||||
is PsiVariable -> el<UVariable> { JavaUVariable.create(element, parent) }
|
is PsiVariable -> el<UVariable> { JavaUVariable.create(element, parent) }
|
||||||
is UAnnotation -> el<UAnnotation> { SimpleUAnnotation(element, parent) } //???
|
is PsiAnnotation -> el<UAnnotation> { JavaUAnnotation(element, parent) } //???
|
||||||
else -> null
|
else -> null
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -46,6 +46,9 @@ class DefaultUSwitchClauseExpression(override val containingElement: UElement?)
|
|||||||
override val caseValues: List<UExpression>?
|
override val caseValues: List<UExpression>?
|
||||||
get() = null
|
get() = null
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override fun asLogString() = "DefaultUSwitchClauseExpression"
|
override fun asLogString() = "DefaultUSwitchClauseExpression"
|
||||||
override fun asRenderString() = "else -> "
|
override fun asRenderString() = "else -> "
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package org.jetbrains.uast.java
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiAnnotation
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
|
import org.jetbrains.uast.*
|
||||||
|
|
||||||
|
class JavaUAnnotation(
|
||||||
|
override val psi: PsiAnnotation,
|
||||||
|
override val containingElement: UElement?
|
||||||
|
) : UAnnotation {
|
||||||
|
override val qualifiedName: String?
|
||||||
|
get() = psi.qualifiedName
|
||||||
|
|
||||||
|
override val attributeValues: List<UNamedExpression> by lz {
|
||||||
|
val context = getUastContext()
|
||||||
|
val attributes = psi.parameterList.attributes
|
||||||
|
|
||||||
|
attributes.map { attribute ->
|
||||||
|
UNamedExpression(attribute.name ?: "", this).apply {
|
||||||
|
val value = attribute.value?.let { context.convertElement(it, this, null) } as? UExpression
|
||||||
|
expression = value ?: UastEmptyExpression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resolve(): PsiClass? = psi.nameReferenceElement?.resolve() as? PsiClass
|
||||||
|
|
||||||
|
override fun findAttributeValue(name: String?): UNamedExpression? {
|
||||||
|
val context = getUastContext()
|
||||||
|
val attributeValue = psi.findAttributeValue(name) ?: return null
|
||||||
|
val value = context.convertElement(attributeValue, this, null)
|
||||||
|
return UNamedExpression(name ?: "", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun findDeclaredAttributeValue(name: String?): UNamedExpression? {
|
||||||
|
val context = getUastContext()
|
||||||
|
val attributeValue = psi.findDeclaredAttributeValue(name) ?: return null
|
||||||
|
val value = context.convertElement(attributeValue, this, null)
|
||||||
|
return UNamedExpression(name ?: "", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun wrap(annotation: PsiAnnotation): UAnnotation = JavaUAnnotation(annotation, null)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun wrap(annotations: List<PsiAnnotation>): List<UAnnotation> = annotations.map { JavaUAnnotation(it, null) }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun wrap(annotations: Array<PsiAnnotation>): List<UAnnotation> = annotations.map { JavaUAnnotation(it, null) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,12 +34,24 @@ abstract class AbstractJavaUClass : UClass, JavaUElementWithComments {
|
|||||||
override val uastAnchor: UElement?
|
override val uastAnchor: UElement?
|
||||||
get() = UIdentifier(psi.nameIdentifier, this)
|
get() = UIdentifier(psi.nameIdentifier, this)
|
||||||
|
|
||||||
override val uastAnnotations by lz { psi.annotations.map { SimpleUAnnotation(it, this) } }
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = psi.annotations.map { JavaUAnnotation(it, this) }
|
||||||
override val uastFields: List<UVariable> by lz { psi.fields.map { getLanguagePlugin().convert<UVariable>(it, this) } }
|
|
||||||
override val uastInitializers: List<UClassInitializer> by lz { psi.initializers.map { getLanguagePlugin().convert<UClassInitializer>(it, this) } }
|
override val uastFields: List<UVariable> by lz {
|
||||||
override val uastMethods: List<UMethod> by lz { psi.methods.map { getLanguagePlugin().convert<UMethod>(it, this) } }
|
psi.fields.map { getLanguagePlugin().convert<UVariable>(it, this) }
|
||||||
override val uastNestedClasses: List<UClass> by lz { psi.innerClasses.map { getLanguagePlugin().convert<UClass>(it, this) } }
|
}
|
||||||
|
|
||||||
|
override val uastInitializers: List<UClassInitializer> by lz {
|
||||||
|
psi.initializers.map { getLanguagePlugin().convert<UClassInitializer>(it, this) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override val uastMethods: List<UMethod> by lz {
|
||||||
|
psi.methods.map { getLanguagePlugin().convert<UMethod>(it, this) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override val uastNestedClasses: List<UClass> by lz {
|
||||||
|
psi.innerClasses.map { getLanguagePlugin().convert<UClass>(it, this) }
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?) = this === other
|
override fun equals(other: Any?) = this === other
|
||||||
override fun hashCode() = psi.hashCode()
|
override fun hashCode() = psi.hashCode()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class JavaUClassInitializer(
|
|||||||
getLanguagePlugin().convertElement(psi.body, this, null) as? UExpression ?: UastEmptyExpression
|
getLanguagePlugin().convertElement(psi.body, this, null) as? UExpression ?: UastEmptyExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
override val uastAnnotations by lz { psi.annotations.map { SimpleUAnnotation(it, this) } }
|
override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } }
|
||||||
|
|
||||||
override fun equals(other: Any?) = this === other
|
override fun equals(other: Any?) = this === other
|
||||||
override fun hashCode() = psi.hashCode()
|
override fun hashCode() = psi.hashCode()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.jetbrains.uast.java
|
|||||||
import com.intellij.psi.PsiComment
|
import com.intellij.psi.PsiComment
|
||||||
import com.intellij.psi.PsiJavaFile
|
import com.intellij.psi.PsiJavaFile
|
||||||
import com.intellij.psi.PsiRecursiveElementWalkingVisitor
|
import com.intellij.psi.PsiRecursiveElementWalkingVisitor
|
||||||
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UComment
|
import org.jetbrains.uast.UComment
|
||||||
import org.jetbrains.uast.UFile
|
import org.jetbrains.uast.UFile
|
||||||
import org.jetbrains.uast.UastLanguagePlugin
|
import org.jetbrains.uast.UastLanguagePlugin
|
||||||
@@ -16,6 +17,9 @@ class JavaUFile(override val psi: PsiJavaFile, override val languagePlugin: Uast
|
|||||||
psi.importList?.allImportStatements?.map { JavaUImportStatement(it, this) } ?: listOf()
|
psi.importList?.allImportStatements?.map { JavaUImportStatement(it, this) } ?: listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override val classes by lz { psi.classes.map { JavaUClass.create(it, this) } }
|
override val classes by lz { psi.classes.map { JavaUClass.create(it, this) } }
|
||||||
|
|
||||||
override val allCommentsInFile by lz {
|
override val allCommentsInFile by lz {
|
||||||
|
|||||||
@@ -33,12 +33,15 @@ open class JavaUMethod(
|
|||||||
getLanguagePlugin().convertElement(body, this) as? UExpression
|
getLanguagePlugin().convertElement(body, this) as? UExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
override val uastAnnotations by lz { psi.annotations.map { SimpleUAnnotation(it, this) } }
|
override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } }
|
||||||
|
|
||||||
override val uastParameters by lz {
|
override val uastParameters by lz {
|
||||||
psi.parameterList.parameters.map { JavaUParameter(it, this) }
|
psi.parameterList.parameters.map { JavaUParameter(it, this) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val isOverride: Boolean
|
||||||
|
get() = psi.modifierList.findAnnotation("java.lang.Override") != null
|
||||||
|
|
||||||
override val uastAnchor: UElement
|
override val uastAnchor: UElement
|
||||||
get() = UIdentifier((psi.originalElement as? PsiNameIdentifierOwner)?.nameIdentifier ?: psi.nameIdentifier, this)
|
get() = UIdentifier((psi.originalElement as? PsiNameIdentifierOwner)?.nameIdentifier ?: psi.nameIdentifier, this)
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ abstract class AbstractJavaUVariable : PsiVariable, UVariable, JavaUElementWithC
|
|||||||
getLanguagePlugin().convertElement(initializer, this) as? UExpression
|
getLanguagePlugin().convertElement(initializer, this) as? UExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
override val uastAnnotations by lz { psi.annotations.map { SimpleUAnnotation(it, this) } }
|
override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } }
|
||||||
override val typeReference by lz { getLanguagePlugin().convertOpt<UTypeReferenceExpression>(psi.typeElement, this) }
|
override val typeReference by lz { getLanguagePlugin().convertOpt<UTypeReferenceExpression>(psi.typeElement, this) }
|
||||||
|
|
||||||
override val uastAnchor: UElement
|
override val uastAnchor: UElement
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.jetbrains.uast.java
|
|||||||
|
|
||||||
import com.intellij.psi.PsiLabeledStatement
|
import com.intellij.psi.PsiLabeledStatement
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.ULabeledExpression
|
import org.jetbrains.uast.ULabeledExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
@@ -24,7 +25,13 @@ class JavaULabeledExpression(
|
|||||||
override val psi: PsiLabeledStatement,
|
override val psi: PsiLabeledStatement,
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : JavaAbstractUExpression(), ULabeledExpression, PsiElementBacked {
|
) : JavaAbstractUExpression(), ULabeledExpression, PsiElementBacked {
|
||||||
override val label by lz { psi.labelIdentifier.text }
|
override val label: String
|
||||||
|
get() = psi.labelIdentifier.text
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = UIdentifier(psi.labelIdentifier, this)
|
||||||
|
|
||||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.statement, this) }
|
override val expression by lz { JavaConverter.convertOrEmpty(psi.statement, this) }
|
||||||
|
|
||||||
override fun evaluate() = expression.evaluate()
|
override fun evaluate() = expression.evaluate()
|
||||||
}
|
}
|
||||||
@@ -17,10 +17,19 @@ package org.jetbrains.uast.java
|
|||||||
|
|
||||||
import com.intellij.psi.PsiSuperExpression
|
import com.intellij.psi.PsiSuperExpression
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.USuperExpression
|
import org.jetbrains.uast.USuperExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
class JavaUSuperExpression(
|
class JavaUSuperExpression(
|
||||||
override val psi: PsiSuperExpression,
|
override val psi: PsiSuperExpression,
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : JavaAbstractUExpression(), USuperExpression, PsiElementBacked
|
) : JavaAbstractUExpression(), USuperExpression, PsiElementBacked {
|
||||||
|
override val label: String?
|
||||||
|
get() = psi.qualifier?.qualifiedName
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = psi.qualifier?.let { UIdentifier(it, this) }
|
||||||
|
|
||||||
|
override fun resolve() = psi.qualifier?.resolve()
|
||||||
|
}
|
||||||
@@ -17,10 +17,19 @@ package org.jetbrains.uast.java
|
|||||||
|
|
||||||
import com.intellij.psi.PsiThisExpression
|
import com.intellij.psi.PsiThisExpression
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.UThisExpression
|
import org.jetbrains.uast.UThisExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
class JavaUThisExpression(
|
class JavaUThisExpression(
|
||||||
override val psi: PsiThisExpression,
|
override val psi: PsiThisExpression,
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : JavaAbstractUExpression(), UThisExpression, PsiElementBacked
|
) : JavaAbstractUExpression(), UThisExpression, PsiElementBacked {
|
||||||
|
override val label: String?
|
||||||
|
get() = psi.qualifier?.qualifiedName
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = psi.qualifier?.let { UIdentifier(it, this) }
|
||||||
|
|
||||||
|
override fun resolve() = psi.qualifier?.resolve()
|
||||||
|
}
|
||||||
+4
@@ -1,5 +1,6 @@
|
|||||||
package org.jetbrains.uast.java
|
package org.jetbrains.uast.java
|
||||||
|
|
||||||
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
import org.jetbrains.uast.UVariable
|
import org.jetbrains.uast.UVariable
|
||||||
import org.jetbrains.uast.UVariableDeclarationsExpression
|
import org.jetbrains.uast.UVariableDeclarationsExpression
|
||||||
@@ -13,4 +14,7 @@ class JavaUVariableDeclarationsExpression(
|
|||||||
constructor(parent: UElement?, variables: List<UVariable>) : this(parent) {
|
constructor(parent: UElement?, variables: List<UVariable>) : this(parent) {
|
||||||
this.variables = variables
|
this.variables = variables
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.jetbrains.uast.java
|
package org.jetbrains.uast.java
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
import org.jetbrains.uast.UExpression
|
import org.jetbrains.uast.UExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
@@ -25,4 +26,7 @@ class UnknownJavaExpression(
|
|||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : UExpression, PsiElementBacked {
|
) : UExpression, PsiElementBacked {
|
||||||
override fun asLogString() = "[!] UnknownJavaExpression ($psi)"
|
override fun asLogString() = "[!] UnknownJavaExpression ($psi)"
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,6 @@ import com.intellij.psi.PsiAnnotation
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiModifierListOwner
|
import com.intellij.psi.PsiModifierListOwner
|
||||||
import com.intellij.psi.impl.source.tree.CompositeElement
|
import com.intellij.psi.impl.source.tree.CompositeElement
|
||||||
import com.intellij.psi.impl.source.tree.java.PsiDoWhileStatementImpl
|
|
||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
import org.jetbrains.uast.UDeclaration
|
import org.jetbrains.uast.UDeclaration
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast.kotlin
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtAnnotatedExpression
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
|
import org.jetbrains.uast.UAnnotation
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
import org.jetbrains.uast.UExpression
|
import org.jetbrains.uast.UExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
@@ -32,4 +33,11 @@ abstract class KotlinAbstractUElement : UElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KotlinAbstractUExpression : KotlinAbstractUElement(), UExpression
|
abstract class KotlinAbstractUExpression : KotlinAbstractUElement(), UExpression {
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() {
|
||||||
|
val psi = (this as? PsiElementBacked)?.psi as? KtExpression ?: return emptyList()
|
||||||
|
val annotatedExpression = psi.parent as? KtAnnotatedExpression ?: return emptyList()
|
||||||
|
return annotatedExpression.annotationEntries.map { KotlinUAnnotation(it, this) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,9 @@ package org.jetbrains.uast.kotlin
|
|||||||
|
|
||||||
import com.intellij.lang.Language
|
import com.intellij.lang.Language
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
|
import com.intellij.psi.PsiVariable
|
||||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||||
import org.jetbrains.kotlin.asJava.LightClassUtil
|
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
|
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
|
import org.jetbrains.uast.*
|
||||||
|
|
||||||
|
class KotlinUAnnotation(
|
||||||
|
override val psi: KtAnnotationEntry,
|
||||||
|
override val containingElement: UElement?
|
||||||
|
) : UAnnotation {
|
||||||
|
private val resolvedAnnotation by lz { psi.analyze()[BindingContext.ANNOTATION, psi] }
|
||||||
|
|
||||||
|
override val qualifiedName: String?
|
||||||
|
get() = resolvedAnnotation?.type?.constructor?.declarationDescriptor?.fqNameSafe?.asString()
|
||||||
|
|
||||||
|
override val attributeValues by lz {
|
||||||
|
val context = getUastContext()
|
||||||
|
psi.valueArguments.map { arg ->
|
||||||
|
val name = arg.getArgumentName()?.asName?.asString() ?: ""
|
||||||
|
UNamedExpression(name, this).apply {
|
||||||
|
val value = arg.getArgumentExpression()?.let { context.convertElement(it, this) } as? UExpression
|
||||||
|
expression = value ?: UastEmptyExpression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resolve(): PsiClass? {
|
||||||
|
val descriptor = resolvedAnnotation?.type?.constructor?.declarationDescriptor ?: return null
|
||||||
|
return descriptor.toSource()?.getMaybeLightElement(this) as? PsiClass
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
override fun findAttributeValue(name: String?) = findDeclaredAttributeValue(name)
|
||||||
|
|
||||||
|
override fun findDeclaredAttributeValue(name: String?): UNamedExpression? {
|
||||||
|
return attributeValues.firstOrNull { it.matchesName(name ?: "value") }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,9 @@ class KotlinUClass private constructor(
|
|||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
get() = containingMethod
|
get() = containingMethod
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override val expressions by lz {
|
override val expressions by lz {
|
||||||
initializers.map {
|
initializers.map {
|
||||||
getLanguagePlugin().convertOpt<UExpression>(it.body, this) ?: UastEmptyExpression
|
getLanguagePlugin().convertOpt<UExpression>(it.body, this) ?: UastEmptyExpression
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class KotlinUFile(override val psi: KtFile, override val languagePlugin: UastLan
|
|||||||
override val packageName: String
|
override val packageName: String
|
||||||
get() = psi.packageFqName.asString()
|
get() = psi.packageFqName.asString()
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = psi.annotationEntries.map { KotlinUAnnotation(it, this) }
|
||||||
|
|
||||||
override val allCommentsInFile by lz {
|
override val allCommentsInFile by lz {
|
||||||
val comments = ArrayList<UComment>(0)
|
val comments = ArrayList<UComment>(0)
|
||||||
psi.accept(object : PsiRecursiveElementWalkingVisitor() {
|
psi.accept(object : PsiRecursiveElementWalkingVisitor() {
|
||||||
|
|||||||
-1
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.uast.kotlin
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.idea.references.mainReference
|
import org.jetbrains.kotlin.idea.references.mainReference
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package org.jetbrains.uast.kotlin.declarations
|
|||||||
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethodImpl
|
import org.jetbrains.kotlin.asJava.elements.KtLightMethodImpl
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
|
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtFunction
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
import org.jetbrains.uast.*
|
import org.jetbrains.uast.*
|
||||||
@@ -37,7 +39,10 @@ open class KotlinUMethod(
|
|||||||
val bodyExpression = (kotlinOrigin as? KtFunction)?.bodyExpression ?: return@lz null
|
val bodyExpression = (kotlinOrigin as? KtFunction)?.bodyExpression ?: return@lz null
|
||||||
getLanguagePlugin().convertElement(bodyExpression, this) as? UExpression
|
getLanguagePlugin().convertElement(bodyExpression, this) as? UExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val isOverride: Boolean
|
||||||
|
get() = (kotlinOrigin as? KtCallableDeclaration)?.hasModifier(KtTokens.OVERRIDE_KEYWORD) ?: false
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(psi: KtLightMethod, containingElement: UElement?) = when (psi) {
|
fun create(psi: KtLightMethod, containingElement: UElement?) = when (psi) {
|
||||||
is KtLightMethodImpl.KtLightAnnotationMethod -> KotlinUAnnotationMethod(psi, containingElement)
|
is KtLightMethodImpl.KtLightAnnotationMethod -> KotlinUAnnotationMethod(psi, containingElement)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.jetbrains.uast.expressions.UReferenceExpression
|
|||||||
import org.jetbrains.uast.expressions.UTypeReferenceExpression
|
import org.jetbrains.uast.expressions.UTypeReferenceExpression
|
||||||
import org.jetbrains.uast.java.AbstractJavaUVariable
|
import org.jetbrains.uast.java.AbstractJavaUVariable
|
||||||
import org.jetbrains.uast.java.JavaAbstractUExpression
|
import org.jetbrains.uast.java.JavaAbstractUExpression
|
||||||
|
import org.jetbrains.uast.java.JavaUAnnotation
|
||||||
import org.jetbrains.uast.java.annotations
|
import org.jetbrains.uast.java.annotations
|
||||||
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
|
||||||
@@ -49,7 +50,7 @@ class KotlinUVariable(
|
|||||||
) : AbstractKotlinUVariable(), UVariable, PsiVariable by psi {
|
) : AbstractKotlinUVariable(), UVariable, PsiVariable by psi {
|
||||||
override val psi = unwrap<UVariable, PsiVariable>(psi)
|
override val psi = unwrap<UVariable, PsiVariable>(psi)
|
||||||
|
|
||||||
override val uastAnnotations by lz { psi.annotations.map { SimpleUAnnotation(it, this) } }
|
override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } }
|
||||||
override val typeReference by lz { getLanguagePlugin().convertOpt<UTypeReferenceExpression>(psi.typeElement, this) }
|
override val typeReference by lz { getLanguagePlugin().convertOpt<UTypeReferenceExpression>(psi.typeElement, this) }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+4
@@ -18,6 +18,7 @@ package org.jetbrains.uast.kotlin
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.psi.KtLabeledExpression
|
import org.jetbrains.kotlin.psi.KtLabeledExpression
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.ULabeledExpression
|
import org.jetbrains.uast.ULabeledExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
@@ -28,5 +29,8 @@ class KotlinULabeledExpression(
|
|||||||
override val label: String
|
override val label: String
|
||||||
get() = psi.getLabelName().orAnonymous("label")
|
get() = psi.getLabelName().orAnonymous("label")
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = psi.getTargetLabel()?.let { UIdentifier(it, this) }
|
||||||
|
|
||||||
override val expression by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
override val expression by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||||
}
|
}
|
||||||
+3
@@ -63,6 +63,9 @@ class KotlinUObjectLiteralExpression(
|
|||||||
) : KotlinAbstractUElement(), USimpleNameReferenceExpression, PsiElementBacked {
|
) : KotlinAbstractUElement(), USimpleNameReferenceExpression, PsiElementBacked {
|
||||||
override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass
|
override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override val resolvedName: String?
|
override val resolvedName: String?
|
||||||
get() = identifier
|
get() = identifier
|
||||||
|
|
||||||
|
|||||||
+3
@@ -109,6 +109,9 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
override val receiverType by lz {
|
override val receiverType by lz {
|
||||||
val type = (resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver)?.type ?: return@lz null
|
val type = (resolvedCall.dispatchReceiver ?: resolvedCall.extensionReceiver)?.type ?: return@lz null
|
||||||
type.toPsiType(this, psi, boxed = true)
|
type.toPsiType(this, psi, boxed = true)
|
||||||
|
|||||||
+11
-1
@@ -17,11 +17,21 @@
|
|||||||
package org.jetbrains.uast.kotlin
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.USuperExpression
|
import org.jetbrains.uast.USuperExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
class KotlinUSuperExpression(
|
class KotlinUSuperExpression(
|
||||||
override val psi: KtSuperExpression,
|
override val psi: KtSuperExpression,
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : KotlinAbstractUExpression(), USuperExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement
|
) : KotlinAbstractUExpression(), USuperExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
|
override val label: String?
|
||||||
|
get() = psi.getLabelName()
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = psi.getTargetLabel()?.let { UIdentifier(it, this) }
|
||||||
|
|
||||||
|
override fun resolve() = psi.analyze()[BindingContext.LABEL_TARGET, psi.getTargetLabel()]
|
||||||
|
}
|
||||||
+2
@@ -95,6 +95,8 @@ class KotlinUSwitchEntry(
|
|||||||
get() = null
|
get() = null
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
get() = this@KotlinUSwitchEntry
|
get() = this@KotlinUSwitchEntry
|
||||||
|
override val annotations: List<UAnnotation>
|
||||||
|
get() = emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -17,11 +17,21 @@
|
|||||||
package org.jetbrains.uast.kotlin
|
package org.jetbrains.uast.kotlin
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.uast.UElement
|
import org.jetbrains.uast.UElement
|
||||||
|
import org.jetbrains.uast.UIdentifier
|
||||||
import org.jetbrains.uast.UThisExpression
|
import org.jetbrains.uast.UThisExpression
|
||||||
import org.jetbrains.uast.psi.PsiElementBacked
|
import org.jetbrains.uast.psi.PsiElementBacked
|
||||||
|
|
||||||
class KotlinUThisExpression(
|
class KotlinUThisExpression(
|
||||||
override val psi: KtThisExpression,
|
override val psi: KtThisExpression,
|
||||||
override val containingElement: UElement?
|
override val containingElement: UElement?
|
||||||
) : KotlinAbstractUExpression(), UThisExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement
|
) : KotlinAbstractUExpression(), UThisExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
|
override val label: String?
|
||||||
|
get() = psi.getLabelName()
|
||||||
|
|
||||||
|
override val labelIdentifier: UIdentifier?
|
||||||
|
get() = psi.getTargetLabel()?.let { UIdentifier(it, this) }
|
||||||
|
|
||||||
|
override fun resolve() = psi.analyze()[BindingContext.LABEL_TARGET, psi.getTargetLabel()]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user