From a291f002cdd3daffeccab36ec713d9e59fe50f16 Mon Sep 17 00:00:00 2001 From: Guoxiong Li Date: Thu, 25 May 2023 03:25:50 +0000 Subject: [PATCH] 8288619: Unexpected parsing for @see Reviewed-by: jjg --- .../tools/javac/parser/DocCommentParser.java | 2 + .../tools/javac/doctree/DocCommentTester.java | 5 ++- .../tools/javac/doctree/SeeTest.java | 42 ++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index 73d7a7b09a8..2b0deb66b02 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -284,6 +284,7 @@ public class DocCommentParser { * Non-standard tags are represented by {@link UnknownBlockTagTree}. */ protected DCTree blockTag() { + newline = false; int p = bp; try { nextChar(); @@ -520,6 +521,7 @@ public class DocCommentParser { * It is an error if the beginning of the next tag is detected. */ protected DCText quotedString() { + newline = false; int pos = bp; nextChar(); diff --git a/test/langtools/tools/javac/doctree/DocCommentTester.java b/test/langtools/tools/javac/doctree/DocCommentTester.java index 641e58a379d..1ae6fa768ee 100644 --- a/test/langtools/tools/javac/doctree/DocCommentTester.java +++ b/test/langtools/tools/javac/doctree/DocCommentTester.java @@ -907,7 +907,10 @@ public class DocCommentTester { var annos = (path.getLeaf() instanceof MethodTree m) ? m.getModifiers().getAnnotations().toString() : ""; - boolean normalizeTags = !annos.equals("@NormalizeTags(false)"); + if (annos.contains("@PrettyCheck(false)")) { + return; + } + boolean normalizeTags = !annos.contains("@NormalizeTags(false)"); String raw = trees.getDocComment(path); String normRaw = normalize(raw, normalizeTags); diff --git a/test/langtools/tools/javac/doctree/SeeTest.java b/test/langtools/tools/javac/doctree/SeeTest.java index ef2d5188038..5d3502914e2 100644 --- a/test/langtools/tools/javac/doctree/SeeTest.java +++ b/test/langtools/tools/javac/doctree/SeeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7021614 8031212 8273244 8284908 8200337 + * @bug 7021614 8031212 8273244 8284908 8200337 8288619 * @summary extend com.sun.source API to support parsing javadoc comments * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.file @@ -50,6 +50,44 @@ DocComment[DOC_COMMENT, pos:1 Text[TEXT, pos:12, "String"] ] ] +*/ + + /** + * Test '@' in quoted string. + * @see "{@code}" + */ + void at_sign_in_quoted_string() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, Test_'@'_in_quoted_string.] + body: empty + block tags: 1 + See[SEE, pos:29 + reference: 1 + Text[TEXT, pos:34, "{@code}"] + ] +] +*/ + + /** + * Test new line before quoted string. + * @see + * "{@code}" + */ + @PrettyCheck(false) + void new_line_before_quoted_string() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 1 + Text[TEXT, pos:1, Test_new_line_before_quoted_string.] + body: empty + block tags: 1 + See[SEE, pos:38 + reference: 1 + Text[TEXT, pos:47, "{@code}"] + ] +] */ /**