From 05394f627d13b7b9bc93c168c16a5800d7a22c36 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 21 Sep 2021 20:26:05 +0300 Subject: [PATCH] Using reflection to find and report deprecated uniques (#5276) * Using reflection to find and report deprecated uniques * No kotlin reflection needed thank you very much --- core/src/com/unciv/models/ruleset/Ruleset.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 7b9a0e8790..1dd5d0bcb7 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -312,11 +312,19 @@ class Ruleset { if (unique.type == null) continue val complianceErrors = unique.type.getComplianceErrors(unique, this) for (complianceError in complianceErrors) { - if (complianceError.errorSeverity == severityToReport) + if (complianceError.errorSeverity == severityToReport) lines += "$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," + " which does not fit parameter type" + " ${complianceError.acceptableParameterTypes.joinToString(" or ") { it.parameterName }} !" } + + val deprecationAnnotation = unique.type.declaringClass.getField(unique.type.name) + .getAnnotation(Deprecated::class.java) + if (deprecationAnnotation != null) { + // Not user-visible + println("$name's unique \"${unique.text}\" is deprecated ${deprecationAnnotation.message}," + + " replace with \"${deprecationAnnotation.replaceWith.expression}\"") + } } }