From ef88c708d0aeea9d79bf025543550a16043cc174 Mon Sep 17 00:00:00 2001 From: IlyaMuravjov Date: Mon, 26 Feb 2024 10:14:20 +0300 Subject: [PATCH] Deprecate `declaringClass` in favor of `referencedClass` in `JcRawCallExpr` and `JcRawFieldRef` --- .../kotlin/org/jacodb/api/cfg/JcRawInst.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/jacodb-api/src/main/kotlin/org/jacodb/api/cfg/JcRawInst.kt b/jacodb-api/src/main/kotlin/org/jacodb/api/cfg/JcRawInst.kt index 21fa62116..ad8131ed9 100644 --- a/jacodb-api/src/main/kotlin/org/jacodb/api/cfg/JcRawInst.kt +++ b/jacodb-api/src/main/kotlin/org/jacodb/api/cfg/JcRawInst.kt @@ -643,12 +643,25 @@ data class JcRawInstanceOfExpr( } sealed interface JcRawCallExpr : JcRawExpr { + @Deprecated( + "This property contains the name of the class via which the method is referenced, " + + "the method is declared in either directly that class or one of its superclasses. " + + "This property is deprecated in favor of a better named `referencedClass` property." + ) val declaringClass: TypeName val methodName: String val argumentTypes: List val returnType: TypeName val args: List + /** + * Name of the class via which the method is referenced. + * + * Referenced class may be a subclass of a class that actually declares the method, + * since static members can be accessed via subclasses. + */ + val referencedClass get() = declaringClass + override val typeName get() = returnType override val operands: List @@ -878,6 +891,11 @@ sealed interface JcRawComplexValue : JcRawValue data class JcRawFieldRef( val instance: JcRawValue?, + @Deprecated( + "This property contains the name of the class via which the field is referenced, " + + "the field is declared in either directly that class or one of its superclasses. " + + "This property is deprecated in favor of a better named `referencedClass` property." + ) val declaringClass: TypeName, val fieldName: String, override val typeName: TypeName @@ -889,6 +907,14 @@ data class JcRawFieldRef( typeName ) + /** + * Name of the class via which the field is referenced. + * + * Referenced class may be a subclass of a class that actually declares the field, + * since static members can be accessed via subclasses. + */ + val referencedClass: TypeName get() = declaringClass + override fun toString(): String = "${instance ?: declaringClass}.$fieldName" override fun accept(visitor: JcRawExprVisitor): T {