HTML render of mapping improved again
This commit is contained in:
parent
b90aaa6336
commit
4b58f8af7c
@ -156,12 +156,15 @@ public class NMSReflect {
|
|||||||
background-color: #2F2F2F;
|
background-color: #2F2F2F;
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
font-family: Consolas, monospace;
|
||||||
|
}
|
||||||
|
a:not(.cl) {
|
||||||
|
color: #1290C3;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
font-family: Consolas, monospace;
|
|
||||||
}
|
}
|
||||||
tr:nth-child(2n) {
|
tr:nth-child(2n) {
|
||||||
background-color: #373737;
|
background-color: #373737;
|
||||||
@ -173,20 +176,18 @@ public class NMSReflect {
|
|||||||
padding-right: .5em;
|
padding-right: .5em;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.el-icon {
|
|
||||||
font-weight: bold;
|
b.pu {
|
||||||
}
|
|
||||||
.el-icon.publ {
|
|
||||||
color: #0C0;
|
color: #0C0;
|
||||||
}
|
}
|
||||||
.el-icon.prot {
|
b.pt {
|
||||||
color: #F80;
|
color: #FC0;
|
||||||
}
|
}
|
||||||
.el-icon.prvt {
|
b.pv {
|
||||||
color: #C00;
|
color: #F00;
|
||||||
}
|
}
|
||||||
.el-icon.pckg {
|
b.pk {
|
||||||
color: #44F;
|
color: #66F;
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
@ -216,10 +217,29 @@ public class NMSReflect {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
</head><body>
|
||||||
"""
|
"""
|
||||||
+ "</head><body>\n"
|
|
||||||
+ "<h1>" + title + "</h1>\n"
|
+ "<h1>" + title + "</h1>\n"
|
||||||
+ "<table>");
|
+ """
|
||||||
|
<p>
|
||||||
|
<b>C</b>: <span class='kw'>class</span>
|
||||||
|
<b>E</b>: <span class='kw'>enum</span>
|
||||||
|
<b>I</b>: <span class='kw'>interface</span>
|
||||||
|
<b>@</b>: <span class='kw'>@interface</span>
|
||||||
|
<b>R</b>: <span class='kw'>record</span><br>
|
||||||
|
<b>●</b>: field
|
||||||
|
<b>c</b>: constructor
|
||||||
|
<b>⬤</b>: method<br>
|
||||||
|
<b class='pu'>⬤</b>: <span class='kw'>public</span>
|
||||||
|
<b class='pt'>⬤</b>: <span class='kw'>protected</span>
|
||||||
|
<b class='pk'>⬤</b>: package
|
||||||
|
<b class='pv'>⬤</b>: <span class='kw'>private</span><br>
|
||||||
|
<sup>S</sup>: <span class='kw'>static</span>
|
||||||
|
<sup>A</sup>: <span class='kw'>abstract</span>
|
||||||
|
<sup>F</sup>: <span class='kw'>final</span>
|
||||||
|
</p>
|
||||||
|
<table>
|
||||||
|
""");
|
||||||
out.println("<tr><th>ns</th><th>" + OBF_NAMESPACE + "</th><th>" + MOJ_NAMESPACE + "</th></tr>");
|
out.println("<tr><th>ns</th><th>" + OBF_NAMESPACE + "</th><th>" + MOJ_NAMESPACE + "</th></tr>");
|
||||||
for (ClassMapping clazz : CLASSES_BY_OBF.values()) {
|
for (ClassMapping clazz : CLASSES_BY_OBF.values()) {
|
||||||
clazz.printHTML(out);
|
clazz.printHTML(out);
|
||||||
@ -362,9 +382,11 @@ public class NMSReflect {
|
|||||||
private void printHTML(PrintStream out) {
|
private void printHTML(PrintStream out) {
|
||||||
String modifiersHTML = classModifiersToHTML(runtimeClass());
|
String modifiersHTML = classModifiersToHTML(runtimeClass());
|
||||||
out.println("<tr id='c" + id + "'><th>" + modifiersHTML + "</th><th>" + nameToHTML(true) + "</th><th>" + nameToHTML(false) + "</th></tr>");
|
out.println("<tr id='c" + id + "'><th>" + modifiersHTML + "</th><th>" + nameToHTML(true) + "</th><th>" + nameToHTML(false) + "</th></tr>");
|
||||||
fieldsByObf.values().forEach(f -> f.printHTML(out));
|
fieldsByObf.values().stream().filter(mm -> mm.isStatic()).forEach(f -> f.printHTML(out));
|
||||||
|
methodsByObf.values().stream().filter(mm -> mm.isStatic()).forEach(m -> m.printHTML(out));
|
||||||
printConstructorsHTML(out);
|
printConstructorsHTML(out);
|
||||||
methodsByObf.values().forEach(m -> m.printHTML(out));
|
fieldsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(f -> f.printHTML(out));
|
||||||
|
methodsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(m -> m.printHTML(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String nameToHTML(boolean obf) {
|
private String nameToHTML(boolean obf) {
|
||||||
@ -423,8 +445,8 @@ public class NMSReflect {
|
|||||||
}
|
}
|
||||||
out.println("<tr>"
|
out.println("<tr>"
|
||||||
+ "<td>" + elementModifiersToHTML("c", ct.getModifiers()) + "</td>"
|
+ "<td>" + elementModifiersToHTML("c", ct.getModifiers()) + "</td>"
|
||||||
+ "<td><b class='mtd' title='Constructor'>" + classObfSimpleName + "</b>(" + obfParams.stream().map(t -> t.toHTML(true)).collect(Collectors.joining(", ")) + ")</td>"
|
+ "<td><b class='mtd'>" + classObfSimpleName + "</b>(" + obfParams.stream().map(t -> t.toHTML(true)).collect(Collectors.joining(", ")) + ")</td>"
|
||||||
+ "<td><b class='mtd' title='Constructor'>" + classMojSimpleName + "</b>(" + mojParams.stream().map(t -> t.toHTML(false)).collect(Collectors.joining(", ")) + ")</td>"
|
+ "<td><b class='mtd'>" + classMojSimpleName + "</b>(" + mojParams.stream().map(t -> t.toHTML(false)).collect(Collectors.joining(", ")) + ")</td>"
|
||||||
+ "</tr>");
|
+ "</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,6 +569,15 @@ public class NMSReflect {
|
|||||||
|
|
||||||
/* package */ abstract R getReflectMember() throws ReflectiveOperationException;
|
/* package */ abstract R getReflectMember() throws ReflectiveOperationException;
|
||||||
|
|
||||||
|
/* package */ boolean isStatic() {
|
||||||
|
try {
|
||||||
|
return Modifier.isStatic(getReflectMember().getModifiers());
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
Log.severe(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static MemberMapping<MethodId, ReflectMethod<?>> of(MappingTree.MethodMapping mioMapping) {
|
private static MemberMapping<MethodId, ReflectMethod<?>> of(MappingTree.MethodMapping mioMapping) {
|
||||||
return new MemberMapping<>("⬤", MemberDesc.of(mioMapping, OBF_NAMESPACE), MemberDesc.of(mioMapping, MOJ_NAMESPACE)) {
|
return new MemberMapping<>("⬤", MemberDesc.of(mioMapping, OBF_NAMESPACE), MemberDesc.of(mioMapping, MOJ_NAMESPACE)) {
|
||||||
@Override
|
@Override
|
||||||
@ -567,6 +598,8 @@ public class NMSReflect {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -601,27 +634,33 @@ public class NMSReflect {
|
|||||||
|
|
||||||
|
|
||||||
private static String elementModifiersToHTML(String elementHTMLType, int elModifiers) {
|
private static String elementModifiersToHTML(String elementHTMLType, int elModifiers) {
|
||||||
String html = "<b class='el-icon";
|
String html = "<b class='";
|
||||||
|
|
||||||
if (Modifier.isPublic(elModifiers))
|
if (Modifier.isPublic(elModifiers))
|
||||||
html += " publ";
|
html += "pu";
|
||||||
else if (Modifier.isProtected(elModifiers))
|
else if (Modifier.isProtected(elModifiers))
|
||||||
html += " prot";
|
html += "pt";
|
||||||
else if (Modifier.isPrivate(elModifiers))
|
else if (Modifier.isPrivate(elModifiers))
|
||||||
html += " prvt";
|
html += "pv";
|
||||||
else
|
else
|
||||||
html += " pckg";
|
html += "pk";
|
||||||
|
|
||||||
html += "'>" + elementHTMLType + "</b><sup>";
|
html += "'>" + elementHTMLType + "</b>";
|
||||||
|
|
||||||
if (Modifier.isStatic(elModifiers))
|
boolean isStatic = Modifier.isStatic(elModifiers);
|
||||||
html += "S";
|
boolean isAbstract = Modifier.isAbstract(elModifiers);
|
||||||
if (Modifier.isAbstract(elModifiers))
|
boolean isFinal = Modifier.isFinal(elModifiers);
|
||||||
html += "A";
|
|
||||||
if (Modifier.isFinal(elModifiers))
|
|
||||||
html += "F";
|
|
||||||
|
|
||||||
html += "</sup>";
|
if (isStatic || isAbstract || isFinal) {
|
||||||
|
html += "<sup>";
|
||||||
|
if (isStatic)
|
||||||
|
html += "S";
|
||||||
|
if (isAbstract)
|
||||||
|
html += "A";
|
||||||
|
if (isFinal)
|
||||||
|
html += "F";
|
||||||
|
html += "</sup>";
|
||||||
|
}
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
10
pom.xml
10
pom.xml
@ -54,11 +54,11 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>5.7.2</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user