1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 | package Torello.Browser.JsonAST;
import Torello.Java.UnreachableError;
/**
* Generates HTML for all Properties, Parameters and Return-Values, which are all stored in the
* AST as {@link PPR} nodes.
*/
@Torello.JavaDoc.Annotations.StaticFunctional
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="TOHTML_JDHBI")
public class HTML$PPR
{
private HTML$PPR() { }
static String run(final PPR ppr)
{
final TypeNode REFERENCE = ppr.reference();
final TypeNode REFERENCE_ARRAY = ppr.referenceArray();
String tempFlagsStr =
(ppr.optional ? "[OPTIONAL]<BR />\n" : "") +
(ppr.experimental ? "[EXPERIMENTAL]<BR />\n" : "") +
(ppr.deprecated ? "[DEPRECATED]<BR />\n" : "");
final String flagsStr = (tempFlagsStr.length() == 0) ? "-" : tempFlagsStr;
final String typeStr, anchor;
if (ppr.ref != null)
anchor =
"<A HREF=\"javascript:GOTO(" +
"'" + fixAPIName(REFERENCE.ownerDomain.ownerAPI.name) + "', '" +
REFERENCE.ownerDomain.name + "', '" +
REFERENCE.name + "')\">";
else if (ppr.refArray != null)
anchor =
"<A HREF=\"javascript:GOTO(" +
"'" + fixAPIName(REFERENCE_ARRAY.ownerDomain.ownerAPI.name) + "', '" +
REFERENCE_ARRAY.ownerDomain.name + "', '" +
REFERENCE_ARRAY.name + "')\">";
else anchor = null;
// Must be a 'string' (see: 'Entity' constructor !)
if (ppr.enumValsStr != null) typeStr =
"<DIV CLASS=tooltip><SPAN CLASS=tooltiptext>" +
ppr.enumValsStr + "</SPAN>String<BR />[Hover] Enum</DIV>\n" +
"<BR />\"type\": " + ppr.typeProp + '\n';
else
{
// Perfectly impossible, No need to check this, but it looks nice here
if ((ppr.typeProp == null) && (ppr.ref == null))
throw (Error) ppr.verifyThrow("*BOTH* typeProp *AND* ref are null!");
final String typePropStr = (ppr.typeProp == null)
? ""
: "<BR />\"type\": " + ppr.typeProp + '\n';
final String refPropStr = (ppr.ref == null)
? ""
: "<BR />\"$ref\": " + anchor + ppr.ref + "</A>\n";
final String itemsPropStr;
if (ppr.arrItemsTypeProp != null) itemsPropStr =
"<BR />\"items\":<BR />{ \"type\": " + ppr.arrItemsTypeProp + " }\n";
else if (REFERENCE_ARRAY != null) itemsPropStr =
"<BR />\"items\":<BR />{ \"$ref\": " + anchor + ppr.refArray + "</A> }\n";
else itemsPropStr = "";
// final String T = typePropStr + refPropStr + itemsPropStr;
// if (T.length() == 0) throw (Error) ppr.verifyThrow("nothing is there!");
typeStr = (typePropStr + refPropStr + itemsPropStr).substring("<BR />".length());
}
final String descStr = ppr.description.replace("<", "<").replace(">", ">");
return
"<TR>\n" +
" <TD>" + ppr.name + "</TD>\n" +
" <TD>" + typeStr + "</TD>\n" +
" <TD>" + descStr + "</TD>\n" +
" <TD>" + flagsStr + "</TD>\n" +
"</TR>\n";
}
private static String fixAPIName(final String apiName)
{
if (! apiName.endsWith("API")) throw new UnreachableError();
return apiName.substring(0, apiName.length() - "API".length()).toLowerCase();
}
}
|