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


##########
zookeeper-jute/src/main/java/org/apache/jute/compiler/JRecord.java:
##########
@@ -767,4 +790,53 @@ public static String getCsharpFQName(String name) {
         }
         return fQName.toString();
     }
+
+    private String getJavaFieldComments(JField jField) {
+        StringJoiner javaFieldCommentsJoiner =
+                new StringJoiner("\n   * ", "  /**\n   * ", "\n   
*/\n").setEmptyValue("");
+        return getFieldComments(jField, javaFieldCommentsJoiner);
+    }
+
+    private String getCFieldComments(JField jField) {
+        StringJoiner cFieldCommentsJoiner =
+                new StringJoiner("\n     * ", "    /**\n     * ", "\n     
*/\n").setEmptyValue("");
+        return getFieldComments(jField, cFieldCommentsJoiner);
+    }
+
+    private String getFieldComments(JField jField, StringJoiner 
fieldCommentsJoiner) {
+        List<String> fieldSpecialToken = 
jCommentGenerator.getFieldCommentsList(jField);
+        return getComments(fieldCommentsJoiner, fieldSpecialToken);
+    }
+
+    private String getRecordComments() {
+        List<String> classSpecialToken = 
jCommentGenerator.getRecordCommentsList(this);
+
+        StringJoiner recordCommentsJoiner =
+                new StringJoiner("\n * ", "/**\n * ", "\n 
*/\n").setEmptyValue("");
+        return getComments(recordCommentsJoiner, classSpecialToken);
+    }
+
+    private static String getComments(StringJoiner commentsJoiner, 
List<String> commentList) {
+        if (commentList == null || commentList.isEmpty()) {
+            return commentsJoiner.toString();
+        }
+
+        for (String commentMulti : commentList) {
+            if (commentMulti == null || commentMulti.isEmpty()) {
+                continue;
+            }
+
+            String[] commentArray = commentMulti.split("\n");
+            for (String comment : commentArray) {
+
+                comment = comment.replaceAll("//|/\\*\\*|/\\*|\\*\\*/|\\*/", 
"")
+                        .replaceAll("^[* ]+", "").trim();
+
+                if (!comment.isEmpty()) {

Review Comment:
   The generated comments has no empty line which is not good.



##########
zookeeper-jute/src/main/java/org/apache/jute/compiler/JRecord.java:
##########
@@ -767,4 +790,53 @@ public static String getCsharpFQName(String name) {
         }
         return fQName.toString();
     }
+
+    private String getJavaFieldComments(JField jField) {
+        StringJoiner javaFieldCommentsJoiner =
+                new StringJoiner("\n   * ", "  /**\n   * ", "\n   
*/\n").setEmptyValue("");
+        return getFieldComments(jField, javaFieldCommentsJoiner);
+    }
+
+    private String getCFieldComments(JField jField) {
+        StringJoiner cFieldCommentsJoiner =
+                new StringJoiner("\n     * ", "    /**\n     * ", "\n     
*/\n").setEmptyValue("");
+        return getFieldComments(jField, cFieldCommentsJoiner);
+    }
+
+    private String getFieldComments(JField jField, StringJoiner 
fieldCommentsJoiner) {
+        List<String> fieldSpecialToken = 
jCommentGenerator.getFieldCommentsList(jField);
+        return getComments(fieldCommentsJoiner, fieldSpecialToken);
+    }
+
+    private String getRecordComments() {
+        List<String> classSpecialToken = 
jCommentGenerator.getRecordCommentsList(this);
+
+        StringJoiner recordCommentsJoiner =
+                new StringJoiner("\n * ", "/**\n * ", "\n 
*/\n").setEmptyValue("");
+        return getComments(recordCommentsJoiner, classSpecialToken);
+    }
+
+    private static String getComments(StringJoiner commentsJoiner, 
List<String> commentList) {
+        if (commentList == null || commentList.isEmpty()) {
+            return commentsJoiner.toString();
+        }
+
+        for (String commentMulti : commentList) {
+            if (commentMulti == null || commentMulti.isEmpty()) {
+                continue;
+            }
+
+            String[] commentArray = commentMulti.split("\n");
+            for (String comment : commentArray) {
+
+                comment = comment.replaceAll("//|/\\*\\*|/\\*|\\*\\*/|\\*/", 
"")

Review Comment:
   I do think people will want to maintain this kind of 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...@zookeeper.apache.org

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

Reply via email to