Skip to content

Commit b88ee1e

Browse files
6251738: Want a top-level summary page that itemizes all spec documents referenced from javadocs (OEM spec)
Reviewed-by: hannesw
1 parent aca4276 commit b88ee1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1514
-46
lines changed

make/Docs.gmk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ JAVADOC_TAGS := \
6969
-tag beaninfo:X \
7070
-tag revised:X \
7171
-tag since.unbundled:X \
72-
-tag spec:X \
73-
-tag specdefault:X \
7472
-tag Note:X \
7573
-tag ToDo:X \
7674
-tag 'apiNote:a:API Note:' \
@@ -86,6 +84,7 @@ JAVADOC_TAGS := \
8684
-tag since \
8785
-tag serialData \
8886
-tag factory \
87+
-tag spec \
8988
-tag see \
9089
-taglet build.tools.taglet.ExtLink \
9190
-taglet build.tools.taglet.Incubating \

src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, 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
@@ -218,6 +218,14 @@ enum Kind {
218218
*/
219219
SNIPPET("snippet"),
220220

221+
/**
222+
* Used for instances of {@link SpecTree}
223+
* representing an {@code @spec} tag.
224+
*
225+
* @since 20
226+
*/
227+
SPEC("spec"),
228+
221229
/**
222230
* Used for instances of {@link EndElementTree}
223231
* representing the start of an HTML element.

src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, 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
@@ -302,6 +302,22 @@ default R visitSnippet(SnippetTree node, P p) {
302302
return visitOther(node, p);
303303
}
304304

305+
/**
306+
* Visits a {@code SpecTree} node.
307+
*
308+
* @implSpec Visits the provided {@code SpecTree} node
309+
* by calling {@code visitOther(node, p)}.
310+
*
311+
* @param node the node being visited
312+
* @param p a parameter value
313+
* @return a result value
314+
*
315+
* @since 20
316+
*/
317+
default R visitSpec(SpecTree node, P p) {
318+
return visitOther(node, p);
319+
}
320+
305321
/**
306322
* Visits a {@code StartElementTree} node.
307323
* @param node the node being visited
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.sun.source.doctree;
27+
28+
import java.util.List;
29+
30+
/**
31+
* A tree node for an {@code @spec} block tag.
32+
*
33+
* <pre>
34+
* &#064;spec url title
35+
* </pre>
36+
*
37+
* @since 20
38+
*/
39+
public interface SpecTree extends BlockTagTree {
40+
/**
41+
* {@return the URL}
42+
*/
43+
TextTree getURL();
44+
45+
/**
46+
* {@return the title}
47+
*/
48+
List<? extends DocTree> getTitle();
49+
}

src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import com.sun.source.doctree.SerialTree;
6060
import com.sun.source.doctree.SinceTree;
6161
import com.sun.source.doctree.SnippetTree;
62+
import com.sun.source.doctree.SpecTree;
6263
import com.sun.source.doctree.StartElementTree;
6364
import com.sun.source.doctree.SummaryTree;
6465
import com.sun.source.doctree.SystemPropertyTree;
@@ -336,6 +337,15 @@ default ReturnTree newReturnTree(boolean isInline, List<? extends DocTree> descr
336337
*/
337338
SnippetTree newSnippetTree(List<? extends DocTree> attributes, TextTree text);
338339

340+
/**
341+
* Creates a new {@code SpecTree} object, to represent an {@code @spec} tag.
342+
* @param url the url
343+
* @param title the title
344+
* @return a {@code SpecTree} object
345+
* @since 20
346+
*/
347+
SpecTree newSpecTree(TextTree url, List<? extends DocTree> title);
348+
339349
/**
340350
* Creates a new {@code StartElementTree} object, to represent the start of an HTML element.
341351
* @param name the name of the HTML element

src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,23 @@ public R visitSnippet(SnippetTree node, P p) {
515515
return r;
516516
}
517517

518+
/**
519+
* {@inheritDoc}
520+
*
521+
* @implSpec This implementation scans the children in left to right order.
522+
*
523+
* @param node {@inheritDoc}
524+
* @param p {@inheritDoc}
525+
* @return the result of scanning
526+
* @since 20
527+
*/
528+
@Override
529+
public R visitSpec(SpecTree node, P p) {
530+
R r = scan(node.getURL(), p);
531+
r = scanAndReduce(node.getTitle(), p, r);
532+
return r;
533+
}
534+
518535
/**
519536
* {@inheritDoc}
520537
*

src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2022, 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
@@ -463,6 +463,23 @@ public R visitSnippet(SnippetTree node, P p) {
463463
return defaultAction(node, p);
464464
}
465465

466+
/**
467+
* {@inheritDoc}
468+
*
469+
* @implSpec This implementation calls {@code defaultAction}.
470+
*
471+
* @param node {@inheritDoc}
472+
* @param p {@inheritDoc}
473+
*
474+
* @return the result of {@code defaultAction}
475+
*
476+
* @since 20
477+
*/
478+
@Override
479+
public R visitSpec(SpecTree node, P p) {
480+
return defaultAction(node, p);
481+
}
482+
466483
/**
467484
* {@inheritDoc}
468485
*

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,24 @@ private List<DCTree> tagAttrs() {
15511551
}
15521552
},
15531553

1554+
// @spec url label
1555+
new TagParser(TagParser.Kind.BLOCK, DCTree.Kind.SPEC) {
1556+
@Override
1557+
public DCTree parse(int pos) throws ParseException {
1558+
skipWhitespace();
1559+
DCText url = inlineWord();
1560+
if (url == null || url.isBlank()) {
1561+
throw new ParseException("dc.no.url");
1562+
}
1563+
skipWhitespace();
1564+
List<DCTree> title = blockContent();
1565+
if (title.isEmpty() || DCTree.isBlank(title)) {
1566+
throw new ParseException("dc.no.title");
1567+
}
1568+
return m.at(pos).newSpecTree(url, title);
1569+
}
1570+
},
1571+
15541572
// {@summary summary-text}
15551573
new TagParser(TagParser.Kind.INLINE, DCTree.Kind.SUMMARY) {
15561574
@Override

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3322,6 +3322,12 @@ compiler.err.dc.no.content=\
33223322
compiler.err.dc.no.tag.name=\
33233323
no tag name after '@'
33243324

3325+
compiler.err.dc.no.url=\
3326+
no URL
3327+
3328+
compiler.err.dc.no.title=\
3329+
no title
3330+
33253331
compiler.err.dc.gt.expected=\
33263332
''>'' expected
33273333

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.sun.tools.javac.util.DefinedBy;
4343
import com.sun.tools.javac.util.DefinedBy.Api;
4444
import com.sun.tools.javac.util.JCDiagnostic;
45-
import com.sun.tools.javac.util.Position;
4645

4746
import static com.sun.tools.javac.util.Position.NOPOS;
4847

@@ -225,6 +224,14 @@ public int getEndPosition() {
225224
return NOPOS;
226225
}
227226

227+
public boolean isBlank() {
228+
return false;
229+
}
230+
231+
public static boolean isBlank(List<? extends DCTree> list) {
232+
return list.stream().allMatch(DCTree::isBlank);
233+
}
234+
228235
/**
229236
* Convert a tree to a pretty-printed string.
230237
*/
@@ -1080,6 +1087,41 @@ public TextTree getBody() {
10801087
}
10811088
}
10821089

1090+
public static class DCSpec extends DCBlockTag implements SpecTree {
1091+
public final DCText uri;
1092+
public final List<DCTree> title;
1093+
1094+
DCSpec(DCText uri, List<DCTree> title) {
1095+
this.uri = uri;
1096+
this.title = title;
1097+
}
1098+
1099+
@Override
1100+
public String getTagName() {
1101+
return "spec";
1102+
}
1103+
1104+
@Override @DefinedBy(Api.COMPILER_TREE)
1105+
public Kind getKind() {
1106+
return Kind.SPEC;
1107+
}
1108+
1109+
@Override @DefinedBy(Api.COMPILER_TREE)
1110+
public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
1111+
return v.visitSpec(this, d);
1112+
}
1113+
1114+
@Override @DefinedBy(Api.COMPILER_TREE)
1115+
public TextTree getURL() {
1116+
return uri;
1117+
}
1118+
1119+
@Override @DefinedBy(Api.COMPILER_TREE)
1120+
public List<? extends DocTree> getTitle() {
1121+
return title;
1122+
}
1123+
}
1124+
10831125
public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
10841126
public final Name name;
10851127
public final List<DCTree> attrs;
@@ -1170,6 +1212,11 @@ public static class DCText extends DCTree implements TextTree {
11701212
this.text = text;
11711213
}
11721214

1215+
@Override
1216+
public boolean isBlank() {
1217+
return text.isBlank();
1218+
}
1219+
11731220
@Override @DefinedBy(Api.COMPILER_TREE)
11741221
public Kind getKind() {
11751222
return Kind.TEXT;

0 commit comments

Comments
 (0)