luozongle01 commented on code in PR #2206:
URL: https://github.com/apache/zookeeper/pull/2206#discussion_r1862113457


##########
zookeeper-jute/src/main/java/org/apache/jute/compiler/JRecord.java:
##########
@@ -767,4 +795,127 @@ public static String getCsharpFQName(String name) {
         }
         return fQName.toString();
     }
+
+    public String getJavaFieldComments(JField jField) {
+        return getFieldComments(jField, "  ");
+    }
+
+    public String getCFieldComments(JField jField) {
+        return getFieldComments(jField, "    ");
+    }
+
+    private String getFieldComments(JField jField, String indent) {
+        if (jField == null || jField.getTypeToken() == null || 
jField.getNextToken() == null) {
+            return "";
+        }
+
+        // get the comment before the line
+        List<String> comments = 
extractLeadingComments(getCommentToken(jField.getTypeToken().specialToken));
+
+        // get the end-of-line comments of fields
+        // If the current field and the next field are on the same line,
+        // the leading field comment of the next field should be discarded
+        Token commentToken = 
getCommentToken(jField.getNextToken().specialToken);
+        if (commentToken != null && jField.getTypeToken().beginLine == 
commentToken.beginLine) {
+
+            if (jField.getNextToken().specialToken == commentToken) {
+                jField.getNextToken().specialToken = null;
+            }
+
+            if (commentToken.next != null) {
+                commentToken.next.specialToken = null;
+                commentToken.next = null;

Review Comment:
   > I am thinking whether we should have a `previousToken`. This way 
`getCommentToken` can skip end-line comment for previous entry without 
modifying things in code generation. I expect code generation is reproducible.
   
   That makes sense, I understand, I'll change it.



-- 
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...@zookeeper.apache.org

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

Reply via email to