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


##########
modules/error-code-annotation-processor/src/main/java/org/apache/ignite/internal/error/code/processor/ErrorCodeGroupProcessor.java:
##########
@@ -140,16 +142,30 @@ 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:
   It produces `@Deprecated` on JDK 21 and `@Deprecated()` on JDK 11. It may 
still be possible to find the package info of the annotation somewhere in the 
metadata. The only thing not available in the tree is the actual fully loaded 
class of the annotation (which makes sense since the class shouldn't need to be 
loaded when parsing the code).



-- 
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