mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8151777: Add "@index" tag to the sampleapi generator
Reviewed-by: ksrini, bpatel
This commit is contained in:
parent
ecfc09db16
commit
25c9be01d5
6 changed files with 80 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -53,5 +53,8 @@ public class SampleApi {
|
||||||
public Fault(String msg) {
|
public Fault(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
public Fault(String msg, Throwable th) {
|
||||||
|
super(msg, th);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -32,6 +32,8 @@ import javax.lang.model.element.Modifier;
|
||||||
import com.sun.tools.javac.tree.JCTree;
|
import com.sun.tools.javac.tree.JCTree;
|
||||||
import com.sun.tools.javac.tree.JCTree.*;
|
import com.sun.tools.javac.tree.JCTree.*;
|
||||||
import com.sun.tools.javac.util.List;
|
import com.sun.tools.javac.util.List;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
class DocCommentGenerator {
|
class DocCommentGenerator {
|
||||||
|
|
||||||
|
@ -99,14 +101,25 @@ class DocCommentGenerator {
|
||||||
LITERAL("@literal", "Use < and > brackets instead of < and > escapes."),
|
LITERAL("@literal", "Use < and > brackets instead of < and > escapes."),
|
||||||
CODE("@code", "(i) -> new Abc<Object>((i > 0) ? (i << 1) : 0)"),
|
CODE("@code", "(i) -> new Abc<Object>((i > 0) ? (i << 1) : 0)"),
|
||||||
LINK("@link", ""),
|
LINK("@link", ""),
|
||||||
VALUE("@value", "");
|
VALUE("@value", ""),
|
||||||
|
INDEX("@index", "", true);
|
||||||
|
|
||||||
String tagName;
|
String tagName;
|
||||||
String tagValue;
|
String tagValue;
|
||||||
|
boolean counted;
|
||||||
|
Map<String, Integer> counters;
|
||||||
|
|
||||||
InlineTag(String tagName, String tagValue) {
|
InlineTag(String tagName, String tagValue) {
|
||||||
|
this(tagName, tagValue, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineTag(String tagName, String tagValue, boolean counted) {
|
||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
this.tagValue = tagValue;
|
this.tagValue = tagValue;
|
||||||
|
this.counted = counted;
|
||||||
|
if (counted) {
|
||||||
|
counters = new HashMap<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -114,9 +127,14 @@ class DocCommentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String value(String value) {
|
public String value(String value) {
|
||||||
|
String name = ((tagValue.length() != 0) ? " " + tagValue : "")
|
||||||
|
+ ((value.length() != 0) ? " " + value : "");
|
||||||
|
if (counted && !counters.containsKey(name)) {
|
||||||
|
counters.put(name, 0);
|
||||||
|
}
|
||||||
return "{" + tagName
|
return "{" + tagName
|
||||||
+ ((tagValue.length() != 0) ? " " + tagValue : "")
|
+ name
|
||||||
+ ((value.length() != 0) ? " " + value : "")
|
+ (counted ? "_" + counters.put(name, counters.get(name) + 1) : "")
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +197,8 @@ class DocCommentGenerator {
|
||||||
//
|
//
|
||||||
|
|
||||||
public String getPackageComment() {
|
public String getPackageComment() {
|
||||||
return Text.LOREMIPSUM
|
return InlineTag.INDEX.value("PackageCommentLabel") + " "
|
||||||
|
+ Text.LOREMIPSUM
|
||||||
+ "\n <p>" + Text.LIEUROPANLINGUES
|
+ "\n <p>" + Text.LIEUROPANLINGUES
|
||||||
+ "\n" + Text.CODE
|
+ "\n" + Text.CODE
|
||||||
+ "\n" + LinkTag.nextLink()
|
+ "\n" + LinkTag.nextLink()
|
||||||
|
@ -192,7 +211,9 @@ class DocCommentGenerator {
|
||||||
static int serialValIdx = 0;
|
static int serialValIdx = 0;
|
||||||
|
|
||||||
public String getBaseComment(JCClassDecl baseDecl, boolean toplevel) {
|
public String getBaseComment(JCClassDecl baseDecl, boolean toplevel) {
|
||||||
String buildComment = Text.LIEUROPANLINGUES + "\n";
|
String buildComment = InlineTag.INDEX.value("BaseCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.LIEUROPANLINGUES + "\n";
|
||||||
|
|
||||||
buildComment += "<p>It is possible to see inlined code:\n"
|
buildComment += "<p>It is possible to see inlined code:\n"
|
||||||
+ InlineTag.CODE
|
+ InlineTag.CODE
|
||||||
|
@ -237,8 +258,9 @@ class DocCommentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConstComment() {
|
public String getConstComment() {
|
||||||
String buildComment = Text.NOWISTHETIME + " " + Text.BROWNFOX + "\n";
|
String buildComment = InlineTag.INDEX.value("ConstCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.NOWISTHETIME + " " + Text.BROWNFOX + "\n";
|
||||||
buildComment += LinkTag.nextLink() + "\n";
|
buildComment += LinkTag.nextLink() + "\n";
|
||||||
buildComment += LinkTag.nextSee() + "\n";
|
buildComment += LinkTag.nextSee() + "\n";
|
||||||
buildComment += Tag.SINCE + "\n";
|
buildComment += Tag.SINCE + "\n";
|
||||||
|
@ -249,8 +271,9 @@ class DocCommentGenerator {
|
||||||
public String getFieldComment(JCClassDecl baseDecl,
|
public String getFieldComment(JCClassDecl baseDecl,
|
||||||
JCVariableDecl varDecl,
|
JCVariableDecl varDecl,
|
||||||
boolean isFxStyle) {
|
boolean isFxStyle) {
|
||||||
String buildComment = Text.BROWNFOX + "<p>" + Text.NOWISTHETIME + "\n";
|
String buildComment = InlineTag.INDEX.value("FieldCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.BROWNFOX + "<p>" + Text.NOWISTHETIME + "\n";
|
||||||
Set<Modifier> mods = varDecl.getModifiers().getFlags();
|
Set<Modifier> mods = varDecl.getModifiers().getFlags();
|
||||||
String varName = varDecl.getName().toString();
|
String varName = varDecl.getName().toString();
|
||||||
|
|
||||||
|
@ -299,7 +322,9 @@ class DocCommentGenerator {
|
||||||
public String getMethodComment(JCClassDecl baseDecl,
|
public String getMethodComment(JCClassDecl baseDecl,
|
||||||
JCMethodDecl methodDecl,
|
JCMethodDecl methodDecl,
|
||||||
boolean isFxStyle) {
|
boolean isFxStyle) {
|
||||||
String buildComment = Text.BROWNFOX + "\n<p>" + Text.THISPANGRAM + "\n";
|
String buildComment = InlineTag.INDEX.value("MethodCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.BROWNFOX + "\n<p>" + Text.THISPANGRAM + "\n";
|
||||||
|
|
||||||
buildComment += "<p>" + LinkTag.nextLink() + "\n";
|
buildComment += "<p>" + LinkTag.nextLink() + "\n";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -125,7 +125,7 @@ public class PackageGenerator {
|
||||||
processTopLevel((Element)node);
|
processTopLevel((Element)node);
|
||||||
}
|
}
|
||||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||||
throw new Fault("Error parsing dataset " + dsName);
|
throw new Fault("Error parsing dataset " + dsName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx = false;
|
fx = false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -53,5 +53,8 @@ public class SampleApi {
|
||||||
public Fault(String msg) {
|
public Fault(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
public Fault(String msg, Throwable th) {
|
||||||
|
super(msg, th);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -32,6 +32,8 @@ import javax.lang.model.element.Modifier;
|
||||||
import com.sun.tools.javac.tree.JCTree;
|
import com.sun.tools.javac.tree.JCTree;
|
||||||
import com.sun.tools.javac.tree.JCTree.*;
|
import com.sun.tools.javac.tree.JCTree.*;
|
||||||
import com.sun.tools.javac.util.List;
|
import com.sun.tools.javac.util.List;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
class DocCommentGenerator {
|
class DocCommentGenerator {
|
||||||
|
|
||||||
|
@ -99,14 +101,25 @@ class DocCommentGenerator {
|
||||||
LITERAL("@literal", "Use < and > brackets instead of < and > escapes."),
|
LITERAL("@literal", "Use < and > brackets instead of < and > escapes."),
|
||||||
CODE("@code", "(i) -> new Abc<Object>((i > 0) ? (i << 1) : 0)"),
|
CODE("@code", "(i) -> new Abc<Object>((i > 0) ? (i << 1) : 0)"),
|
||||||
LINK("@link", ""),
|
LINK("@link", ""),
|
||||||
VALUE("@value", "");
|
VALUE("@value", ""),
|
||||||
|
INDEX("@index", "", true);
|
||||||
|
|
||||||
String tagName;
|
String tagName;
|
||||||
String tagValue;
|
String tagValue;
|
||||||
|
boolean counted;
|
||||||
|
Map<String, Integer> counters;
|
||||||
|
|
||||||
InlineTag(String tagName, String tagValue) {
|
InlineTag(String tagName, String tagValue) {
|
||||||
|
this(tagName, tagValue, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineTag(String tagName, String tagValue, boolean counted) {
|
||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
this.tagValue = tagValue;
|
this.tagValue = tagValue;
|
||||||
|
this.counted = counted;
|
||||||
|
if (counted) {
|
||||||
|
counters = new HashMap<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -114,9 +127,14 @@ class DocCommentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String value(String value) {
|
public String value(String value) {
|
||||||
|
String name = ((tagValue.length() != 0) ? " " + tagValue : "")
|
||||||
|
+ ((value.length() != 0) ? " " + value : "");
|
||||||
|
if (counted && !counters.containsKey(name)) {
|
||||||
|
counters.put(name, 0);
|
||||||
|
}
|
||||||
return "{" + tagName
|
return "{" + tagName
|
||||||
+ ((tagValue.length() != 0) ? " " + tagValue : "")
|
+ name
|
||||||
+ ((value.length() != 0) ? " " + value : "")
|
+ (counted ? "_" + counters.put(name, counters.get(name) + 1) : "")
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +197,8 @@ class DocCommentGenerator {
|
||||||
//
|
//
|
||||||
|
|
||||||
public String getPackageComment() {
|
public String getPackageComment() {
|
||||||
return Text.LOREMIPSUM
|
return InlineTag.INDEX.value("PackageCommentLabel") + " "
|
||||||
|
+ Text.LOREMIPSUM
|
||||||
+ "\n <p>" + Text.LIEUROPANLINGUES
|
+ "\n <p>" + Text.LIEUROPANLINGUES
|
||||||
+ "\n" + Text.CODE
|
+ "\n" + Text.CODE
|
||||||
+ "\n" + LinkTag.nextLink()
|
+ "\n" + LinkTag.nextLink()
|
||||||
|
@ -192,7 +211,9 @@ class DocCommentGenerator {
|
||||||
static int serialValIdx = 0;
|
static int serialValIdx = 0;
|
||||||
|
|
||||||
public String getBaseComment(JCClassDecl baseDecl, boolean toplevel) {
|
public String getBaseComment(JCClassDecl baseDecl, boolean toplevel) {
|
||||||
String buildComment = Text.LIEUROPANLINGUES + "\n";
|
String buildComment = InlineTag.INDEX.value("BaseCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.LIEUROPANLINGUES + "\n";
|
||||||
|
|
||||||
buildComment += "<p>It is possible to see inlined code:\n"
|
buildComment += "<p>It is possible to see inlined code:\n"
|
||||||
+ InlineTag.CODE
|
+ InlineTag.CODE
|
||||||
|
@ -237,8 +258,9 @@ class DocCommentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConstComment() {
|
public String getConstComment() {
|
||||||
String buildComment = Text.NOWISTHETIME + " " + Text.BROWNFOX + "\n";
|
String buildComment = InlineTag.INDEX.value("ConstCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.NOWISTHETIME + " " + Text.BROWNFOX + "\n";
|
||||||
buildComment += LinkTag.nextLink() + "\n";
|
buildComment += LinkTag.nextLink() + "\n";
|
||||||
buildComment += LinkTag.nextSee() + "\n";
|
buildComment += LinkTag.nextSee() + "\n";
|
||||||
buildComment += Tag.SINCE + "\n";
|
buildComment += Tag.SINCE + "\n";
|
||||||
|
@ -249,8 +271,9 @@ class DocCommentGenerator {
|
||||||
public String getFieldComment(JCClassDecl baseDecl,
|
public String getFieldComment(JCClassDecl baseDecl,
|
||||||
JCVariableDecl varDecl,
|
JCVariableDecl varDecl,
|
||||||
boolean isFxStyle) {
|
boolean isFxStyle) {
|
||||||
String buildComment = Text.BROWNFOX + "<p>" + Text.NOWISTHETIME + "\n";
|
String buildComment = InlineTag.INDEX.value("FieldCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.BROWNFOX + "<p>" + Text.NOWISTHETIME + "\n";
|
||||||
Set<Modifier> mods = varDecl.getModifiers().getFlags();
|
Set<Modifier> mods = varDecl.getModifiers().getFlags();
|
||||||
String varName = varDecl.getName().toString();
|
String varName = varDecl.getName().toString();
|
||||||
|
|
||||||
|
@ -299,7 +322,9 @@ class DocCommentGenerator {
|
||||||
public String getMethodComment(JCClassDecl baseDecl,
|
public String getMethodComment(JCClassDecl baseDecl,
|
||||||
JCMethodDecl methodDecl,
|
JCMethodDecl methodDecl,
|
||||||
boolean isFxStyle) {
|
boolean isFxStyle) {
|
||||||
String buildComment = Text.BROWNFOX + "\n<p>" + Text.THISPANGRAM + "\n";
|
String buildComment = InlineTag.INDEX.value("MethodCommentLabel") + " ";
|
||||||
|
|
||||||
|
buildComment += Text.BROWNFOX + "\n<p>" + Text.THISPANGRAM + "\n";
|
||||||
|
|
||||||
buildComment += "<p>" + LinkTag.nextLink() + "\n";
|
buildComment += "<p>" + LinkTag.nextLink() + "\n";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -125,7 +125,7 @@ public class PackageGenerator {
|
||||||
processTopLevel((Element)node);
|
processTopLevel((Element)node);
|
||||||
}
|
}
|
||||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||||
throw new Fault("Error parsing dataset " + dsName);
|
throw new Fault("Error parsing dataset " + dsName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx = false;
|
fx = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue