Commit 52bb3ef7 authored by René Schöne's avatar René Schöne
Browse files

clean up

- remove application from testDumper module
parent 4620d93e
Pipeline #12957 failed with stages
in 3 minutes and 19 seconds
......@@ -11,7 +11,6 @@ plugins {
id 'java'
id 'java-library'
id 'idea'
id 'application'
id 'com.github.ben-manes.versions'
}
......@@ -115,7 +114,6 @@ jastadd {
test.useJUnitPlatform()
// --- Versioning and Publishing ---
mainClassName = 'de.tudresden.inf.st.jastadd.testDumper.TestDumperMain'
// --- Task order ---
generateAst.dependsOn relast
package de.tudresden.inf.st.jastadd.testDumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpAst;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpBuilder;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpListChildNode;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode;
import org.jastadd.testDumper.ast.A;
import org.jastadd.testDumper.ast.B;
import org.jastadd.testDumper.ast.C;
import org.jastadd.testDumper.ast.Root;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Function;
import java.util.stream.Collectors;
@SuppressWarnings({"unused", "CommentedOutCode"})
public class TestDumperMain {
private Root root;
private DumpAst dumpAst;
public static void main(String[] args) throws IOException {
new TestDumperMain().run();
}
void run() throws IOException {
createRoot();
ExposingDumpBuilder builder = new ExposingDumpBuilder(root);
String preamble = "{<\n>\n}";
builder.includeAttributes("simpleAttr")
.orderChildren()
.includeNonterminalAttributes("getCalculated")
.setNameMethod(n -> n == null ? "null" : n.getClass().getSimpleName())
.customPreamble(preamble);
System.out.println(">> PlantUml");
dumpAst = builder.build();
System.out.println(dumpAst.toPlantUml());
Path path = Paths.get("src/gen/resources/");
Files.createDirectories(path);
builder.dumpAsYaml(path.resolve("testDumperMain.yaml"), true);
// printAdditionalInformation();
}
private void createRoot() {
root = new Root();
root.setName("Root1");
A a = new A();
a.setName("A2");
B b1 = new B();
b1.setName("B3");
C c = new C();
c.setName("C4");
c.setRawReference(a);
b1.setOneA(a);
B b2 = new B();
b2.setName("B5");
C myC = new C();
myC.setName("C6");
a.setMyC(myC);
root.setA(a);
root.addB(b1);
root.addB(b2);
root.setC(c);
}
private void printAdditionalInformation() {
DumpNode node = dumpAst.getDumpNode(0);
System.out.println(node.getName());
Function<? super DumpNode, String> printInfo = d ->
d.getName() + "(" + d.getLabel() +
", container: " + d.container() +
", succ: " + (d.successor() == null ? "null" : d.successor().getName()) +
", has_succ: " + d.hasSuccessor() + ")";
dumpAst.flushTreeCache();
dumpAst.treeResolveAll();
dumpAst.getRootNode().getDumpChildNodeList().forEach(d -> {
if (d instanceof DumpListChildNode) {
System.out.println("dump-list-node " + d.getName());
((DumpListChildNode) d).getInnerDumpNodeList().forEach(inner -> {
System.out.println(" inner: " + inner.getDumpNode().getName());
System.out.println(" <- " + inner.getDumpNode().getContainerOfInner());
});
}
});
System.out.println(node.myChildren().stream().map(printInfo).collect(Collectors.joining(", ")));
// System.out.println(">> YAML begin");
// System.out.println(builder.build().toYaml(true));
// System.out.println(">> YAML end");
}
static class ExposingDumpBuilder extends DumpBuilder {
protected ExposingDumpBuilder(Object target) {
super(target);
}
@Override
public DumpAst build() {
return super.build();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment