Support equals() on UElements (comparation by psi)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.java
|
||||
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
abstract class JavaAbstractUElement : UElement {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this !is PsiElementBacked || other !is PsiElementBacked) {
|
||||
return this === other
|
||||
}
|
||||
|
||||
return this.psi == other.psi
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUDoWhileExpression(
|
||||
override val psi: PsiDoWhileStatement,
|
||||
override val parent: UElement
|
||||
) : UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUForEachExpression(
|
||||
override val psi: PsiForeachStatement,
|
||||
override val parent: UElement
|
||||
) : UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
override val variableName: String?
|
||||
get() = psi.iterationParameter.name
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUForExpression(
|
||||
override val psi: PsiForStatement,
|
||||
override val parent: UElement
|
||||
) : UForExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UForExpression, PsiElementBacked, NoEvaluate {
|
||||
override val declaration by lz { psi.initialization?.let { JavaConverter.convert(it, this) } }
|
||||
override val condition by lz { psi.condition?.let { JavaConverter.convert(it, this) } }
|
||||
override val update by lz { psi.update?.let { JavaConverter.convert(it, this) } }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUIfExpression(
|
||||
override val psi: PsiIfStatement,
|
||||
override val parent: UElement
|
||||
) : UIfExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked, NoEvaluate {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val thenBranch by lz { JavaConverter.convertOrEmpty(psi.thenBranch, this) }
|
||||
override val elseBranch by lz { JavaConverter.convertOrEmpty(psi.elseBranch, this) }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ open class JavaUSpecialExpressionList(
|
||||
override val psi: PsiElement,
|
||||
override val kind: UastSpecialExpressionKind, // original element
|
||||
override val parent: UElement
|
||||
) : USpecialExpressionList, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), USpecialExpressionList, PsiElementBacked {
|
||||
class Empty(psi: PsiElement, expressionType: UastSpecialExpressionKind, parent: UElement) :
|
||||
JavaUSpecialExpressionList(psi, expressionType, parent) {
|
||||
init { expressions = emptyList() }
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUSwitchExpression(
|
||||
override val psi: PsiSwitchStatement,
|
||||
override val parent: UElement
|
||||
) : USwitchExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USwitchExpression, PsiElementBacked, NoEvaluate {
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
@@ -34,6 +34,6 @@ class JavaUSwitchExpression(
|
||||
class JavaUExpressionSwitchClauseExpression(
|
||||
override val psi: PsiSwitchLabelStatement,
|
||||
override val parent: UElement
|
||||
) : UExpressionSwitchClauseExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UExpressionSwitchClauseExpression, PsiElementBacked, NoEvaluate {
|
||||
override val caseValue by lz { JavaConverter.convertOrEmpty(psi.caseValue, this) }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTernaryIfExpression(
|
||||
override val psi: PsiConditionalExpression,
|
||||
override val parent: UElement
|
||||
) : UIfExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val condition by lz { JavaConverter.convert(psi.condition, this) }
|
||||
override val thenBranch by lz { JavaConverter.convertOrEmpty(psi.thenExpression, this) }
|
||||
override val elseBranch by lz { JavaConverter.convertOrEmpty(psi.elseExpression, this) }
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTryExpression(
|
||||
override val psi: PsiTryStatement,
|
||||
override val parent: UElement
|
||||
) : UTryExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UTryExpression, PsiElementBacked, NoEvaluate {
|
||||
override val tryClause by lz { JavaConverter.convertOrEmpty(psi.tryBlock, this) }
|
||||
override val catchClauses by lz { psi.catchSections.map { JavaUCatchClause(it, this) } }
|
||||
override val finallyClause by lz { psi.finallyBlock?.let { JavaConverter.convert(it, this) } }
|
||||
@@ -35,7 +35,7 @@ class JavaUTryExpression(
|
||||
class JavaUCatchClause(
|
||||
override val psi: PsiCatchSection,
|
||||
override val parent: UElement
|
||||
) : UCatchClause, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UCatchClause, PsiElementBacked {
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.catchBlock, this) }
|
||||
override val parameters by lz { psi.parameter?.let { listOf(JavaConverter.convert(it, this)) } ?: emptyList() }
|
||||
override val types by lz { listOf(JavaConverter.convert(psi.catchType, this)) }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUWhileExpression(
|
||||
override val psi: PsiWhileStatement,
|
||||
override val parent: UElement
|
||||
) : UWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaClassInitializerUFunction(
|
||||
override val psi: PsiClassInitializer,
|
||||
override val parent: UElement
|
||||
) : UFunction, PsiElementBacked, NoAnnotations, NoModifiers {
|
||||
) : JavaAbstractUElement(), UFunction, PsiElementBacked, NoAnnotations, NoModifiers {
|
||||
override val kind: UastFunctionKind.UastInitializerKind
|
||||
get() = JavaFunctionKinds.STATIC_INITIALIZER
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaParameterUTypeReference(
|
||||
override val psi: PsiTypeParameter,
|
||||
override val parent: UElement
|
||||
) : UTypeReference, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UTypeReference, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUAnnotation(
|
||||
override val psi: PsiAnnotation,
|
||||
override val parent: UElement?
|
||||
) : UAnnotation, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UAnnotation, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.nameReferenceElement?.referenceName.orAnonymous()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class JavaUClass(
|
||||
override val psi: PsiClass,
|
||||
override val parent: UElement?,
|
||||
val newExpression: PsiNewExpression? = null
|
||||
) : UClass, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UClass, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
@@ -104,7 +104,7 @@ private class JavaUAnonymousClassConstructor(
|
||||
override val psi: PsiAnonymousClass,
|
||||
val newExpression: PsiNewExpression,
|
||||
override val parent: UElement
|
||||
) : UFunction, PsiElementBacked, NoAnnotations, NoModifiers {
|
||||
) : JavaAbstractUElement(), UFunction, PsiElementBacked, NoAnnotations, NoModifiers {
|
||||
override val kind = UastFunctionKind.CONSTRUCTOR
|
||||
|
||||
override val valueParameterCount by lz { newExpression.argumentList?.expressions?.size ?: 0 }
|
||||
@@ -145,7 +145,7 @@ private class JavaUAnonymousClassConstructorParameter(
|
||||
val psi: PsiExpressionList,
|
||||
val index: Int,
|
||||
override val parent: UElement
|
||||
) : UVariable, NoAnnotations, NoModifiers {
|
||||
) : JavaAbstractUElement(), UVariable, NoAnnotations, NoModifiers {
|
||||
override val initializer by lz { JavaConverter.convert(psi.expressions[index], this) }
|
||||
|
||||
override val kind: UastVariableKind
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.uast.UFile
|
||||
import org.jetbrains.uast.UImportStatement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUFile(override val psi: PsiJavaFile): UFile, PsiElementBacked {
|
||||
class JavaUFile(override val psi: PsiJavaFile): JavaAbstractUElement(), UFile, PsiElementBacked {
|
||||
override val packageFqName by lz { psi.packageName.let { if (it.isNotBlank()) it else null } }
|
||||
|
||||
override val importStatements: List<UImportStatement> by lz {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUFunction(
|
||||
override val psi: PsiMethod,
|
||||
override val parent: UElement
|
||||
) : UFunction, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UFunction, PsiElementBacked {
|
||||
override val kind: UastFunctionKind
|
||||
get() = if (psi.isConstructor) UastFunctionKind.CONSTRUCTOR else UastFunctionKind.FUNCTION
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUImportStatement(
|
||||
override val psi: PsiImportStatement,
|
||||
override val parent: UElement
|
||||
) : UImportStatement, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UImportStatement, PsiElementBacked {
|
||||
override val nameToImport: String?
|
||||
get() = psi.qualifiedName
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUStaticImportStatement(
|
||||
override val psi: PsiImportStaticStatement,
|
||||
override val parent: UElement
|
||||
) : UImportStatement, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UImportStatement, PsiElementBacked {
|
||||
override val nameToImport: String?
|
||||
get() = psi.referenceName
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.UastContext
|
||||
class JavaUType(
|
||||
val psi: PsiType?,
|
||||
override val parent: UElement
|
||||
) : UType {
|
||||
) : JavaAbstractUElement(), UType {
|
||||
override val name: String
|
||||
get() = when (psi) {
|
||||
is PsiClassType -> psi.className.substringAfterLast('.')
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUVariable(
|
||||
override val psi: PsiVariable,
|
||||
override val parent: UElement
|
||||
) : UVariable, PsiElementBacked {
|
||||
) : JavaAbstractUElement(), UVariable, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaValueParameterUVariable(
|
||||
override val psi: PsiParameter,
|
||||
override val parent: UElement
|
||||
) : UVariable, PsiElementBacked, NoModifiers {
|
||||
) : JavaAbstractUElement(), UVariable, PsiElementBacked, NoModifiers {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaCombinedUBinaryExpression(
|
||||
override val psi: PsiPolyadicExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override lateinit var leftOperand: UExpression
|
||||
override lateinit var rightOperand: UExpression
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUArrayAccessExpression(
|
||||
override val psi: PsiArrayAccessExpression,
|
||||
override val parent: UElement
|
||||
) : UArrayAccessExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UArrayAccessExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val receiver by lz { JavaConverter.convert(psi.arrayExpression, this) }
|
||||
override val indices by lz { singletonListOrEmpty(JavaConverter.convertOrNull(psi.indexExpression, this)) }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUAssignmentExpression(
|
||||
override val psi: PsiAssignmentExpression,
|
||||
override val parent: UElement
|
||||
) : UAssignmentExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UAssignmentExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val reference by lz { JavaConverter.convert(psi.lExpression, this) }
|
||||
|
||||
override val operator: String
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUBinaryExpression(
|
||||
override val psi: PsiBinaryExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val leftOperand by lz { JavaConverter.convert(psi.lOperand, this) }
|
||||
override val rightOperand by lz { JavaConverter.convertOrEmpty(psi.rOperand, this) }
|
||||
override val operator by lz { psi.operationTokenType.getOperatorType() }
|
||||
|
||||
@@ -24,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUBlockExpression(
|
||||
override val psi: PsiBlockStatement,
|
||||
override val parent: UElement
|
||||
) : UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val expressions by lz { psi.codeBlock.statements.map { JavaConverter.convert(it, this) } }
|
||||
}
|
||||
+1
-1
@@ -24,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUCallableReferenceExpression(
|
||||
override val psi: PsiMethodReferenceExpression,
|
||||
override val parent: UElement
|
||||
) : UCallableReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UCallableReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val qualifierType by lz { JavaConverter.convert(psi.qualifierType?.type, this) }
|
||||
}
|
||||
+1
-1
@@ -24,4 +24,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUClassLiteralExpression(
|
||||
override val psi: PsiClassObjectAccessExpression,
|
||||
override val parent: UElement
|
||||
) : UClassLiteralExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
) : JavaAbstractUElement(), UClassLiteralExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
+1
-1
@@ -24,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUCodeBlockExpression(
|
||||
override val psi: PsiCodeBlock,
|
||||
override val parent: UElement
|
||||
) : UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val expressions by lz { psi.statements.map { JavaConverter.convert(it, this) } }
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUCompositeQualifiedExpression(
|
||||
override val parent: UElement
|
||||
) : UQualifiedExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked, NoEvaluate {
|
||||
override lateinit var receiver: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUInstanceCheckExpression(
|
||||
override val psi: PsiInstanceOfExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
override val type by lz { JavaConverter.convert(psi.checkType?.type, this) }
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULabeledExpression(
|
||||
override val psi: PsiLabeledStatement,
|
||||
override val parent: UElement
|
||||
) : ULabeledExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), ULabeledExpression, PsiElementBacked, NoEvaluate {
|
||||
override val label by lz { psi.labelIdentifier.text }
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.statement, this) }
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULambdaExpression(
|
||||
override val psi: PsiLambdaExpression,
|
||||
override val parent: UElement
|
||||
) : ULambdaExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), ULambdaExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val valueParameters by lz { psi.parameterList.parameters.map { JavaConverter.convert(it, this) } }
|
||||
|
||||
override val body by lz {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULiteralExpression(
|
||||
override val psi: PsiLiteralExpression,
|
||||
override val parent: UElement
|
||||
) : ULiteralExpression, PsiElementBacked, JavaTypeHelper {
|
||||
) : JavaAbstractUElement(), ULiteralExpression, PsiElementBacked, JavaTypeHelper {
|
||||
override val text by lz { psi.text }
|
||||
override fun evaluate() = psi.value
|
||||
override val value by lz { evaluate() }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UObjectLiteralExpression
|
||||
class JavaUObjectLiteralExpression(
|
||||
override val psi: PsiNewExpression,
|
||||
override val parent: UElement
|
||||
) : UObjectLiteralExpression, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UObjectLiteralExpression, JavaTypeHelper, NoEvaluate {
|
||||
override val declaration by lz {
|
||||
psi.anonymousClass?.let { JavaUClass(it, this, psi) } ?: UClassNotResolved
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUParenthesizedExpression(
|
||||
override val psi: PsiParenthesizedExpression,
|
||||
override val parent: UElement
|
||||
) : UParenthesizedExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UParenthesizedExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) }
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUPostfixExpression(
|
||||
override val psi: PsiPostfixExpression,
|
||||
override val parent: UElement
|
||||
) : UPostfixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UPostfixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
|
||||
override val operator = when (psi.operationSign.text) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUPrefixExpression(
|
||||
override val psi: PsiPrefixExpression,
|
||||
override val parent: UElement
|
||||
) : UPrefixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UPrefixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
|
||||
override val operator = when (psi.operationSign.text) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUQualifiedExpression(
|
||||
override val psi: PsiReferenceExpression,
|
||||
override val parent: UElement
|
||||
) : UQualifiedExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override val receiver by lz { JavaConverter.convertOrEmpty(psi.qualifierExpression, this) }
|
||||
override val selector by lz { JavaConverter.convert(psi.referenceNameElement, this) as? UExpression ?: EmptyExpression(this) }
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ class JavaUSimpleReferenceExpression(
|
||||
override val psi: PsiElement,
|
||||
override val identifier: String,
|
||||
override val parent: UElement
|
||||
) : USimpleReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
override fun resolve(context: UastContext) = psi.reference?.resolve()?.let { context.convert(it) } as? UDeclaration
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class JavaClassUSimpleReferenceExpression(
|
||||
override val identifier: String,
|
||||
val ref: PsiJavaReference,
|
||||
override val parent: UElement
|
||||
) : USimpleReferenceExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, NoEvaluate {
|
||||
override val psi: PsiElement?
|
||||
get() = ref.element
|
||||
|
||||
|
||||
@@ -24,4 +24,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUSuperExpression(
|
||||
override val psi: PsiSuperExpression,
|
||||
override val parent: UElement
|
||||
) : USuperExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
) : JavaAbstractUElement(), USuperExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
@@ -24,4 +24,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUThisExpression(
|
||||
override val psi: PsiThisExpression,
|
||||
override val parent: UElement
|
||||
) : UThisExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
) : JavaAbstractUElement(), UThisExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTypeCastExpression(
|
||||
override val psi: PsiTypeCastExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
override val type by lz { JavaConverter.convert(psi.castType?.type, this) }
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ package org.jetbrains.uast.psi
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
interface PsiElementBacked {
|
||||
val psi: com.intellij.psi.PsiElement?
|
||||
val psi: PsiElement?
|
||||
}
|
||||
Reference in New Issue
Block a user