You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2021/11/24 08:23:00 UTC

[GitHub] [avro] opwvhk commented on a change in pull request #1377: AVRO-3239: IDL parsing silently ignores dangling documentation comments

opwvhk commented on a change in pull request #1377:
URL: https://github.com/apache/avro/pull/1377#discussion_r755796226



##########
File path: lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
##########
@@ -95,12 +95,57 @@ public class Idl implements Closeable {
   String namespace;
   Map<String,Schema> names = new LinkedHashMap<String,Schema>();
 
-  private static final ThreadLocal<String> DOC = new ThreadLocal<String>();
-  static void setDoc(String doc) { DOC.set(doc.trim()); }
+  private static class DocComment {
+      private String text;
+      private int line;
+      private int column;
+      DocComment(Token token) {
+          // The token is everything after the initial '/**', including all whitespace and the ending '*/'
+          int tokenLength = token.image.length();
+          this.text = token.image.substring(0, tokenLength-2)./*replaceAll("[ \\t]*(\\r|\\r\\n|\\n)[ \\t]*\\*?[ \\t]*", "$1").*/trim();
+          this.line = token.beginLine;
+          this.column = token.beginColumn - 3; // The preceding token was "/**", and the current match includes everything since (also all whitespace).
+      }
+  }

Review comment:
       Using this class instead of a `String` allows warnings with proper location information.




-- 
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: issues-unsubscribe@avro.apache.org

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