Skip to content

Commit 2814601

Browse files
author
duke
committedJun 4, 2024
Automatic merge of jdk:master into master
2 parents 3c3f053 + 8d3de45 commit 2814601

File tree

8 files changed

+403
-36
lines changed

8 files changed

+403
-36
lines changed
 

‎src/jdk.compiler/share/classes/module-info.java

-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@
268268
jdk.javadoc,
269269
jdk.jshell,
270270
jdk.internal.md;
271-
exports jdk.internal.shellsupport.doc to
272-
jdk.jshell;
273271

274272
uses javax.annotation.processing.Processor;
275273
uses com.sun.source.util.Plugin;

‎src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java ‎src/jdk.jshell/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java

+247-23
Large diffs are not rendered by default.

‎src/jdk.jshell/share/classes/module-info.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -71,6 +71,7 @@
7171
requires jdk.compiler;
7272
requires jdk.internal.ed;
7373
requires jdk.internal.le;
74+
requires jdk.internal.md;
7475
requires jdk.internal.opt;
7576

7677
requires transitive java.compiler;

‎test/langtools/jdk/internal/shellsupport/doc/FullJavadocHelperTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @library /tools/lib
2929
* @modules jdk.compiler/com.sun.tools.javac.api
3030
* jdk.compiler/com.sun.tools.javac.main
31-
* jdk.compiler/jdk.internal.shellsupport.doc
31+
* jdk.jshell/jdk.internal.shellsupport.doc
3232
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
3333
* @run testng/timeout=900/othervm -Xmx1024m FullJavadocHelperTest
3434
*/

‎test/langtools/jdk/internal/shellsupport/doc/JavadocFormatterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
2626
* @bug 8131019 8169561 8261450
2727
* @summary Test JavadocFormatter
2828
* @library /tools/lib
29-
* @modules jdk.compiler/jdk.internal.shellsupport.doc
29+
* @modules jdk.jshell/jdk.internal.shellsupport.doc
3030
* @run testng JavadocFormatterTest
3131
*/
3232

‎test/langtools/jdk/internal/shellsupport/doc/JavadocHelperTest.java

+151-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @library /tools/lib
2929
* @modules jdk.compiler/com.sun.tools.javac.api
3030
* jdk.compiler/com.sun.tools.javac.main
31-
* jdk.compiler/jdk.internal.shellsupport.doc
31+
* jdk.jshell/jdk.internal.shellsupport.doc
3232
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
3333
* @run testng JavadocHelperTest
3434
* @key randomness
@@ -93,12 +93,6 @@ public void testJavadoc() throws Exception {
9393
" @return value\n");
9494
}
9595

96-
private Element getFirstMethod(JavacTask task, String typeName) {
97-
return ElementFilter.methodsIn(task.getElements().getTypeElement(typeName).getEnclosedElements()).get(0);
98-
}
99-
100-
private Function<JavacTask, Element> getSubTest = t -> getFirstMethod(t, "test.Sub");
101-
10296
public void testInheritNoJavadoc() throws Exception {
10397
doTestJavadoc("",
10498
getSubTest,
@@ -301,6 +295,150 @@ public void testShortComment() throws Exception {
301295
"@return value\n");
302296
}
303297

298+
public void testMarkdown() throws Exception {
299+
doTestJavadoc("""
300+
/// Prefix {@inheritDoc} suffix.
301+
///
302+
/// *Another* __paragraph__.
303+
///
304+
/// Paragraph \ufffc with \ufffc replacement \ufffc character.
305+
///
306+
/// @param p1 prefix {@inheritDoc} suffix
307+
/// @param p2 prefix {@inheritDoc} suffix
308+
/// @param p3 prefix {@inheritDoc} suffix
309+
/// @throws IllegalStateException prefix {@inheritDoc} suffix
310+
/// @throws IllegalArgumentException prefix {@inheritDoc} suffix
311+
/// @throws IllegalAccessException prefix {@inheritDoc} suffix
312+
/// @return prefix {@inheritDoc} suffix
313+
""",
314+
getSubTest,
315+
"""
316+
Prefix javadoc1 suffix.
317+
318+
<p><em>Another</em> <strong>paragraph</strong>.
319+
320+
<p>Paragraph \ufffc with \ufffc replacement \ufffc character.
321+
322+
@param p1 prefix param1 suffix
323+
@param p2 prefix param2 suffix
324+
@param p3 prefix param3 suffix
325+
@throws IllegalStateException prefix exc1 suffix
326+
@throws IllegalArgumentException prefix exc2 suffix
327+
@throws IllegalAccessException prefix exc3 suffix
328+
@return prefix value suffix""");
329+
}
330+
331+
public void testMarkdown2() throws Exception {
332+
doTestJavadoc("""
333+
/// {@inheritDoc}
334+
///
335+
/// *Another* __paragraph__. [java.lang.Object]
336+
///
337+
/// @since snc
338+
""",
339+
getSubTest,
340+
"""
341+
javadoc1
342+
343+
<p><em>Another</em> <strong>paragraph</strong>. {@link java.lang.Object}
344+
345+
@param p1 param1
346+
@param p2 param2
347+
@param p3 param3
348+
@throws java.lang.IllegalStateException exc1
349+
@throws java.lang.IllegalArgumentException exc2
350+
@throws java.lang.IllegalAccessException exc3
351+
@return value
352+
@since snc""");
353+
}
354+
355+
public void testMarkdown3() throws Exception {
356+
doTestJavadoc("""
357+
/// {@inheritDoc}
358+
///
359+
/// *Another* __paragraph__.
360+
""",
361+
getSubTest,
362+
//the formatting could be improved:
363+
"""
364+
javadoc1
365+
366+
<p><em>Another</em> <strong>paragraph</strong>.@param p1 param1
367+
@param p2 param2
368+
@param p3 param3
369+
@throws java.lang.IllegalStateException exc1
370+
@throws java.lang.IllegalArgumentException exc2
371+
@throws java.lang.IllegalAccessException exc3
372+
@return value
373+
""");
374+
}
375+
376+
public void testMarkdown4() throws Exception {
377+
doTestJavadoc("""
378+
/// {@inheritDoc}
379+
///
380+
/// *Another* __paragraph__. [test][java.lang.Object]
381+
///
382+
/// @since snc
383+
""",
384+
getSubTest,
385+
"""
386+
javadoc1
387+
388+
<p><em>Another</em> <strong>paragraph</strong>. {@linkplain java.lang.Object test}
389+
390+
@param p1 param1
391+
@param p2 param2
392+
@param p3 param3
393+
@throws java.lang.IllegalStateException exc1
394+
@throws java.lang.IllegalArgumentException exc2
395+
@throws java.lang.IllegalAccessException exc3
396+
@return value
397+
@since snc""");
398+
}
399+
400+
public void testMarkdown5() throws Exception {
401+
doTestJavadoc("""
402+
///[define classes][java.lang.invoke.MethodHandles.Lookup#defineClass(byte\\[\\])]
403+
///
404+
/// @since snc
405+
""",
406+
getSubTest,
407+
"""
408+
{@linkplain java.lang.invoke.MethodHandles.Lookup#defineClass(byte[]) define classes}
409+
410+
@param p1 param1
411+
@param p2 param2
412+
@param p3 param3
413+
@throws java.lang.IllegalStateException exc1
414+
@throws java.lang.IllegalArgumentException exc2
415+
@throws java.lang.IllegalAccessException exc3
416+
@return value
417+
@since snc""");
418+
}
419+
420+
public void testMarkdown6() throws Exception {
421+
doTestJavadoc("""
422+
///Text1 [define classes][java.lang.invoke.MethodHandles.Lookup#defineClass(byte\\[\\])]
423+
///text2
424+
///
425+
/// @since snc
426+
""",
427+
getSubTest,
428+
"""
429+
Text1 {@linkplain java.lang.invoke.MethodHandles.Lookup#defineClass(byte[]) define classes}
430+
text2
431+
432+
@param p1 param1
433+
@param p2 param2
434+
@param p3 param3
435+
@throws java.lang.IllegalStateException exc1
436+
@throws java.lang.IllegalArgumentException exc2
437+
@throws java.lang.IllegalAccessException exc3
438+
@return value
439+
@since snc""");
440+
}
441+
304442
private void doTestJavadoc(String origJavadoc, Function<JavacTask, Element> getElement, String expectedJavadoc) throws Exception {
305443
doTestJavadoc(origJavadoc,
306444
" /**\n" +
@@ -370,6 +508,12 @@ private void doTestJavadoc(String origJavadoc,
370508
}
371509
}
372510

511+
private Element getFirstMethod(JavacTask task, String typeName) {
512+
return ElementFilter.methodsIn(task.getElements().getTypeElement(typeName).getEnclosedElements()).get(0);
513+
}
514+
515+
private Function<JavacTask, Element> getSubTest = t -> getFirstMethod(t, "test.Sub");
516+
373517
private static final class JFOImpl extends SimpleJavaFileObject {
374518

375519
private final String code;

0 commit comments

Comments
 (0)
Please sign in to comment.