adityamukho commented on code in PR #6299:
URL: https://github.com/apache/ignite-3/pull/6299#discussion_r2225712016


##########
modules/error-code-annotation-processor/src/main/java/org/apache/ignite/internal/error/code/processor/ErrorCodeGroupProcessor.java:
##########
@@ -140,16 +141,29 @@ private Object visitErrorCodeField(VariableTree 
variableTree, Trees trees) {
             var initializer = variableTree.getInitializer();
             var name = variableTree.getName().toString();
             try {
-                // example: args = {"(short) 1"} as List<ExpressionTree>.
-                var args = ((MethodInvocationTree) initializer).getArguments();
-                // example: expr = "(short) 1" as TypeCastTree.
-                var expr = ((TypeCastTree) args.get(0)).getExpression();
-                // example: if expr is "(short) (1)" we should remove 
parentheses
-                if (expr instanceof ParenthesizedTree) {
-                    expr = ((ParenthesizedTree) expr).getExpression();
+                if 
(MethodInvocationTree.class.isAssignableFrom(initializer.getClass())) {
+                    // example: args = {"(short) 1"} as List<ExpressionTree>.
+                    var args = ((MethodInvocationTree) 
initializer).getArguments();
+                    // example: expr = "(short) 1" as TypeCastTree.
+                    var expr = ((TypeCastTree) args.get(0)).getExpression();
+                    // example: if expr is "(short) (1)" we should remove 
parentheses
+                    if (expr instanceof ParenthesizedTree) {
+                        expr = ((ParenthesizedTree) expr).getExpression();
+                    }
+                    // example: extract 1 from "(short) 1" expression.
+                    this.descriptor.errorCodes.add(new ErrorCode((Integer) 
((LiteralTree) expr).getValue(), name));
+                } else if 
(IdentifierTree.class.isAssignableFrom(initializer.getClass())) {
+                    boolean hasDeprecated = 
variableTree.getModifiers().getAnnotations().stream()
+                            .anyMatch(annotation -> 
annotation.toString().contains("Deprecated"));

Review Comment:
   I'm not too happy with this approach either, but couldn't find a (reasonably 
simple) path to `Deprecated.class` in the object tree through the debugger. 
However, I will explore this some more.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to