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?
|
||||
}
|
||||
@@ -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.kotlin.uast
|
||||
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
abstract class KotlinAbstractUElement : 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 KotlinPsiElementStub(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : UElement, PsiElementBacked, NoTraverse {
|
||||
) : KotlinAbstractUElement(), UElement, PsiElementBacked, NoTraverse {
|
||||
override fun logString() = "KotlinPsiElementStub"
|
||||
override fun renderString() = "<stub@$psi>"
|
||||
}
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinParameterUTypeReference(
|
||||
override val psi: KtTypeParameter,
|
||||
override val parent: UElement
|
||||
) : UTypeReference, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UTypeReference, PsiElementBacked {
|
||||
override fun resolve(context: UastContext): UClass? {
|
||||
val descriptor = psi.analyze(BodyResolveMode.PARTIAL)[BindingContext.TYPE_PARAMETER, psi]
|
||||
?.typeConstructor?.declarationDescriptor as? ClassDescriptor ?: return null
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUAnnotation(
|
||||
override val psi: KtAnnotationEntry,
|
||||
override val parent: UElement
|
||||
) : UAnnotation, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UAnnotation, PsiElementBacked {
|
||||
override val fqName: String?
|
||||
get() = resolveToDescriptor()?.fqNameSafe?.asString()
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUAnnotationList(
|
||||
override val psi: KtAnnotation,
|
||||
override val parent: UElement
|
||||
) : UElement, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UElement, PsiElementBacked {
|
||||
lateinit var annotations: List<UAnnotation>
|
||||
|
||||
override fun logString() = "KotlinUAnnotationList"
|
||||
|
||||
@@ -42,7 +42,7 @@ class KotlinUClass(
|
||||
override val psi: KtClassOrObject,
|
||||
override val parent: UElement,
|
||||
override val isAnonymous: Boolean = false
|
||||
) : UClass, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UClass, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.uast.UFile
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class KotlinUFile(override val psi: KtFile): UFile, PsiElementBacked {
|
||||
class KotlinUFile(override val psi: KtFile): KotlinAbstractUElement(), UFile, PsiElementBacked {
|
||||
override val packageFqName by lz {
|
||||
val packageName = psi.packageFqName.asString()
|
||||
if (packageName.isNotBlank()) packageName else null
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUImportStatement(
|
||||
override val psi: KtImportDirective,
|
||||
override val parent: UElement
|
||||
) : UImportStatement, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UImportStatement, PsiElementBacked {
|
||||
override val nameToImport = psi.importedFqName?.asString()
|
||||
|
||||
override val isStarImport: Boolean
|
||||
|
||||
@@ -29,7 +29,7 @@ class KotlinUType(
|
||||
val type: KotlinType,
|
||||
val project: Project,
|
||||
override val parent: UElement?
|
||||
) : UType {
|
||||
) : KotlinAbstractUElement(), UType {
|
||||
override val name: String
|
||||
get() = type.toString()
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
open class KotlinUVariable(
|
||||
override val psi: KtVariableDeclaration,
|
||||
override val parent: UElement
|
||||
) : UVariable, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UVariable, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
@@ -71,7 +71,7 @@ class KotlinDestructuredUVariable(
|
||||
class KotlinDestructuringUVariable(
|
||||
override val psi: KtDestructuringDeclaration,
|
||||
override val parent: UElement
|
||||
) : UVariable, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UVariable, PsiElementBacked {
|
||||
override val name = "var" + psi.text.hashCode()
|
||||
override val initializer by lz { KotlinConverter.convertOrEmpty(psi.initializer, this) }
|
||||
override val kind = UastVariableKind.LOCAL_VARIABLE
|
||||
@@ -86,7 +86,7 @@ class KotlinDestructuringUVariable(
|
||||
class KotlinParameterUVariable(
|
||||
override val psi: KtParameter,
|
||||
override val parent: UElement
|
||||
) : UVariable, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UVariable, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
abstract class KotlinAbstractUFunction : UFunction, PsiElementBacked {
|
||||
abstract class KotlinAbstractUFunction : KotlinAbstractUElement(), UFunction, PsiElementBacked {
|
||||
override abstract val psi: KtFunction
|
||||
|
||||
override val name by lz { psi.name.orAnonymous() }
|
||||
@@ -92,7 +92,7 @@ class KotlinUFunction(
|
||||
class KotlinAnonymousInitializerUFunction(
|
||||
override val psi: KtAnonymousInitializer,
|
||||
override val parent: UElement
|
||||
) : UFunction, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UFunction, PsiElementBacked {
|
||||
override val kind = KotlinFunctionKinds.INIT_BLOCK
|
||||
|
||||
override val valueParameters: List<UVariable>
|
||||
@@ -131,7 +131,7 @@ class KotlinAnonymousInitializerUFunction(
|
||||
open class KotlinDefaultPrimaryConstructorUFunction(
|
||||
override val psi: KtClassOrObject,
|
||||
override val parent: UClass
|
||||
) : UFunction, PsiElementBacked, NoModifiers, NoAnnotations {
|
||||
) : KotlinAbstractUElement(), UFunction, PsiElementBacked, NoModifiers, NoAnnotations {
|
||||
override val kind: UastFunctionKind
|
||||
get() = UastFunctionKind.CONSTRUCTOR
|
||||
|
||||
@@ -163,7 +163,7 @@ open class KotlinDefaultPrimaryConstructorUFunction(
|
||||
open class KotlinObjectLiteralConstructorUFunction(
|
||||
override val psi: KtObjectDeclaration,
|
||||
override val parent: UClass
|
||||
) : UFunction, PsiElementBacked, NoModifiers, NoAnnotations {
|
||||
) : KotlinAbstractUElement(), UFunction, PsiElementBacked, NoModifiers, NoAnnotations {
|
||||
private val resolvedCall by lz {
|
||||
val bindingContext = psi.analyze(BodyResolveMode.PARTIAL)
|
||||
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, psi] as? ClassDescriptor
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinStringTemplateUBinaryExpression(
|
||||
override val psi: KtStringTemplateExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override lateinit var leftOperand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUArrayAccessExpression(
|
||||
override val psi: KtArrayAccessExpression,
|
||||
override val parent: UElement
|
||||
) : UArrayAccessExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UArrayAccessExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) }
|
||||
override val indices by lz { psi.indexExpressions.map { KotlinConverter.convert(it, this) } }
|
||||
}
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBinaryExpression(
|
||||
override val psi: KtBinaryExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val leftOperand by lz { KotlinConverter.convertOrEmpty(psi.left, this) }
|
||||
override val rightOperand by lz { KotlinConverter.convertOrEmpty(psi.right, this) }
|
||||
|
||||
@@ -63,7 +63,7 @@ class KotlinUBinaryExpression(
|
||||
class KotlinCustomUBinaryExpression(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, NoEvaluate {
|
||||
lateinit override var leftOperand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBinaryExpressionWithType(
|
||||
override val psi: KtBinaryExpressionWithTypeRHS,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpressionWithType, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val operand by lz { KotlinConverter.convert(psi.left, this) }
|
||||
override val type by lz { KotlinConverter.convert(psi.right, this) }
|
||||
override val operationKind = when (psi.operationReference.getReferencedNameElementType()) {
|
||||
@@ -38,7 +38,7 @@ class KotlinUBinaryExpressionWithType(
|
||||
class KotlinCustomUBinaryExpressionWithType(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpressionWithType, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, NoEvaluate {
|
||||
lateinit override var operand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBlockExpression(
|
||||
override val psi: KtBlockExpression,
|
||||
override val parent: UElement
|
||||
) : UBlockExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBlockExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUCatchClause(
|
||||
override val psi: KtCatchClause,
|
||||
override val parent: UElement
|
||||
) : UCatchClause, PsiElementBacked {
|
||||
) : KotlinAbstractUElement(), UCatchClause, PsiElementBacked {
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.catchBody, this) }
|
||||
override val parameters by lz { psi.catchParameter?.let { listOf(KotlinConverter.convert(it, this)) } ?: emptyList<UVariable>() }
|
||||
override val types by lz {
|
||||
|
||||
+3
-1
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.uast
|
||||
|
||||
class KotlinUDeclarationsExpression(override val parent: UElement) : UDeclarationsExpression {
|
||||
import org.jetbrains.kotlin.uast.KotlinAbstractUElement
|
||||
|
||||
class KotlinUDeclarationsExpression(override val parent: UElement) : KotlinAbstractUElement(), UDeclarationsExpression {
|
||||
override lateinit var declarations: List<UElement>
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUDoWhileExpression(
|
||||
override val psi: KtDoWhileExpression,
|
||||
override val parent: UElement
|
||||
) : UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUForEachExpression(
|
||||
override val psi: KtForExpression,
|
||||
override val parent: UElement
|
||||
) : UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
override val variableName by lz { psi.loopParameter?.name }
|
||||
override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUFunctionCallExpression(
|
||||
override val psi: KtCallExpression,
|
||||
override val parent: UElement
|
||||
) : UCallExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UCallExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override val functionName: String?
|
||||
get() = (psi.calleeExpression as? KtSimpleNameExpression)?.getReferencedName()
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUIfExpression(
|
||||
override val psi: KtIfExpression,
|
||||
override val parent: UElement
|
||||
) : UIfExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UIfExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val thenBranch by lz { KotlinConverter.convertOrNull(psi.then, this) }
|
||||
override val elseBranch by lz { KotlinConverter.convertOrNull(psi.`else`, this) }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinULambdaExpression(
|
||||
override val psi: KtLambdaExpression,
|
||||
override val parent: UElement
|
||||
) : ULambdaExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), ULambdaExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||
override val valueParameters by lz { psi.valueParameters.map { KotlinConverter.convert(it, this) } }
|
||||
override fun renderString(): String {
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinULiteralExpression(
|
||||
override val psi: KtConstantExpression,
|
||||
override val parent: UElement
|
||||
) : ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val isNull: Boolean
|
||||
get() = psi.isNullExpression()
|
||||
|
||||
@@ -39,7 +39,7 @@ class KotlinULiteralExpression(
|
||||
class KotlinStringULiteralExpression(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val isNull = false
|
||||
override val text: String
|
||||
get() = '"' + psi.text + '"'
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUParenthesizedExpression(
|
||||
override val psi: KtParenthesizedExpression,
|
||||
override val parent: UElement
|
||||
) : UParenthesizedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UParenthesizedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) }
|
||||
}
|
||||
+1
-2
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtPostfixExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UPostfixExpression
|
||||
import org.jetbrains.uast.UastPostfixOperator
|
||||
@@ -27,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUPostfixExpression(
|
||||
override val psi: KtPostfixExpression,
|
||||
override val parent: UElement
|
||||
) : UPostfixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UPostfixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
override val operator = when (psi.operationToken) {
|
||||
|
||||
+1
-2
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtPrefixExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UPrefixExpression
|
||||
import org.jetbrains.uast.UastPrefixOperator
|
||||
@@ -27,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUPrefixExpression(
|
||||
override val psi: KtPrefixExpression,
|
||||
override val parent: UElement
|
||||
) : UPrefixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UPrefixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
override val operator = when (psi.operationToken) {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUQualifiedExpression(
|
||||
override val psi: KtDotQualifiedExpression,
|
||||
override val parent: UElement
|
||||
) : UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) }
|
||||
override val accessType = UastQualifiedExpressionAccessType.SIMPLE
|
||||
@@ -35,7 +35,7 @@ class KotlinUQualifiedExpression(
|
||||
class KotlinUComponentQualifiedExpression(
|
||||
override val psi: KtDestructuringDeclarationEntry,
|
||||
override val parent: UElement
|
||||
) : UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override lateinit var receiver: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UQualifiedExpression
|
||||
import org.jetbrains.uast.UastContext
|
||||
@@ -26,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUSafeQualifiedExpression(
|
||||
override val psi: KtSafeQualifiedExpression,
|
||||
override val parent: UElement
|
||||
) : UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) }
|
||||
override val accessType = KotlinQualifiedExpressionAccessTypes.SAFE
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ open class KotlinUSimpleReferenceExpression(
|
||||
override val psi: PsiElement,
|
||||
override val identifier: String,
|
||||
override val parent: UElement
|
||||
) : USimpleReferenceExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override fun resolve(context: UastContext) = context.convert(
|
||||
psi.references.firstOrNull()?.resolve()) as? UDeclaration
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
override val psi: KtCallExpression,
|
||||
override val identifier: String,
|
||||
override val parent: UElement
|
||||
) : USimpleReferenceExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override fun resolve(context: UastContext): UDeclaration? {
|
||||
val resolvedCall = psi.getResolvedCall(psi.analyze(BodyResolveMode.PARTIAL))
|
||||
val resultingDescriptor = resolvedCall?.resultingDescriptor as? ConstructorDescriptor ?: return null
|
||||
@@ -57,6 +57,6 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||
class KotlinStringUSimpleReferenceExpression(
|
||||
override val identifier: String,
|
||||
override val parent: UElement
|
||||
) : USimpleReferenceExpression, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), USimpleReferenceExpression, NoEvaluate {
|
||||
override fun resolve(context: UastContext) = null
|
||||
}
|
||||
+1
-1
@@ -32,7 +32,7 @@ open class KotlinUSpecialExpressionList(
|
||||
override val psi: PsiElement?,
|
||||
override val kind: UastSpecialExpressionKind, // original element
|
||||
override val parent: UElement
|
||||
) : USpecialExpressionList, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), USpecialExpressionList, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
class Empty(psi: PsiElement, expressionType: UastSpecialExpressionKind, parent: UElement) :
|
||||
KotlinUSpecialExpressionList(psi, expressionType, parent) {
|
||||
init { expressions = emptyList() }
|
||||
|
||||
+1
-1
@@ -24,4 +24,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUSuperExpression(
|
||||
override val psi: KtSuperExpression,
|
||||
override val parent: UElement
|
||||
) : USuperExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper
|
||||
) : KotlinAbstractUElement(), USuperExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUSwitchExpression(
|
||||
override val psi: KtWhenExpression,
|
||||
override val parent: UElement
|
||||
) : USwitchExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), USwitchExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) }
|
||||
|
||||
//TODO to entries
|
||||
@@ -47,7 +47,7 @@ class KotlinUSwitchExpression(
|
||||
class KotlinUSwitchEntry(
|
||||
override val psi: KtWhenEntry,
|
||||
override val parent: UExpression
|
||||
) : UExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UExpression, PsiElementBacked, NoEvaluate {
|
||||
val conditions by lz {
|
||||
psi.conditions.map { when (it) {
|
||||
is KtWhenConditionInRange -> KotlinCustomUBinaryExpression(it, this).apply {
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UThisExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -25,4 +24,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUThisExpression(
|
||||
override val psi: KtThisExpression,
|
||||
override val parent: UElement
|
||||
) : UThisExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper
|
||||
) : KotlinAbstractUElement(), UThisExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUTryExpression(
|
||||
override val psi: KtTryExpression,
|
||||
override val parent: UElement
|
||||
) : UTryExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UTryExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
override val tryClause by lz { KotlinConverter.convert(psi.tryBlock, this) }
|
||||
override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } }
|
||||
override val finallyClause by lz { psi.finallyBlock?.finalExpression?.let { KotlinConverter.convert(it, this) } }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUTypeCheckExpression(
|
||||
override val psi: KtIsExpression,
|
||||
override val parent: UElement
|
||||
) : UBinaryExpressionWithType, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
override val operand by lz { KotlinConverter.convert(psi.leftHandSide, this) }
|
||||
override val type by lz { KotlinConverter.convert(psi.typeReference, this) }
|
||||
override val operationKind = KotlinBinaryExpressionWithTypeKinds.NEGATED_INSTANCE_CHECK
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUWhileExpression(
|
||||
override val psi: KtWhileExpression,
|
||||
override val parent: UElement
|
||||
) : UWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class UnknownKotlinExpression(
|
||||
override val psi: KtExpression,
|
||||
override val parent: UElement
|
||||
) : UExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UExpression, PsiElementBacked, NoEvaluate {
|
||||
override fun traverse(handler: UastHandler) {}
|
||||
override fun logString() = "[!] UnknownKotlinExpression ($psi)"
|
||||
}
|
||||
Reference in New Issue
Block a user