Skip to content
Snippets Groups Projects
Commit 42ec0a70 authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'release-1.0.0' into 'master'

1.0.0

See merge request jastadd/relast2uml!10
parents ec2ab792 fb67ef02
Branches
Tags
1 merge request!101.0.0
Pipeline #12961 passed
Showing
with 339 additions and 112 deletions
../../../../dumpAst/src/main/resources/dumpAstVersion.properties
\ No newline at end of file
...@@ -3,3 +3,5 @@ src/gen-res/ ...@@ -3,3 +3,5 @@ src/gen-res/
src/gen/ src/gen/
out/ out/
*.class *.class
/featureTest.png
/featureTest.yml
// --- Buildscripts (must be at the top) ---
buildscript { buildscript {
repositories.mavenLocal()
repositories.mavenCentral() repositories.mavenCentral()
dependencies { dependencies {
classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3' classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3'
} }
} }
// --- Plugin definitions ---
plugins { plugins {
id 'relast2uml.java-jastadd-conventions' id 'java'
id 'relast2uml.java-publishing-conventions' id 'java-library'
id 'idea'
id 'application'
id 'com.github.ben-manes.versions'
} }
apply plugin: 'jastadd' apply plugin: 'jastadd'
// --- Dependencies ---
repositories {
mavenCentral()
}
dependencies { dependencies {
implementation fileTree(include: ['plantuml.jar'], dir: '../libs') implementation project(":dumpAst")
implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}" api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${jupiter_version}"
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.18.1'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${jupiter_version}"
} }
File dumpAstGrammar = file('../dumpAst/src/main/jastadd/DumpAst.relast') // --- Preprocessors ---
File genSrc = file("src/gen/java")
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
File testingGrammar = file('./src/main/jastadd/featureTest.relast')
task relast(type: JavaExec) { task relast(type: JavaExec) {
group = 'Build' group = 'Build'
...@@ -27,73 +45,67 @@ task relast(type: JavaExec) { ...@@ -27,73 +45,67 @@ task relast(type: JavaExec) {
doFirst { doFirst {
delete "src/gen/jastadd/*.ast" delete "src/gen/jastadd/*.ast"
delete "src/gen/jastadd/DumpAst.jadd" delete "src/gen/jastadd/featureTest.jadd"
delete "src/gen/jastadd/DumpAstRefResolver.jadd" delete "src/gen/jastadd/featureTestRefResolver.jadd"
delete "src/gen/jastadd/DumpAstResolverStubs.jrag" delete "src/gen/jastadd/featureTestResolverStubs.jrag"
mkdir "src/gen/jastadd/" mkdir "src/gen/jastadd/"
} }
args = [ args = [
"../libs/relast.jar", "../libs/relast.jar",
dumpAstGrammar, testingGrammar,
// "./src/main/jastadd/MustacheNodes.relast", // "./src/main/jastadd/MustacheNodes.relast",
"--listClass=java.util.ArrayList", "--listClass=java.util.ArrayList",
"--jastAddList=JastAddList", "--jastAddList=JastAddList",
"--useJastAddNames", "--useJastAddNames",
"--file", "--file",
"--resolverHelper", "--resolverHelper",
"--grammarName=./src/gen/jastadd/DumpAst" "--grammarName=./src/gen/jastadd/featureTest"
] ]
inputs.files(file("../libs/relast.jar"), inputs.files(file("../libs/relast.jar"),
dumpAstGrammar) testingGrammar)
outputs.files(file("./src/gen/jastadd/DumpAst.ast"), outputs.files(file("./src/gen/jastadd/featureTest.ast"),
file("./src/gen/jastadd/DumpAst.jadd"), file("./src/gen/jastadd/featureTest.jadd"),
file("./src/gen/jastadd/DumpAstRefResolver.jadd"), file("./src/gen/jastadd/featureTestRefResolver.jadd"),
file('./src/gen/jastadd/DumpAstResolverStubs.jrag')) file('./src/gen/jastadd/featureTestResolverStubs.jrag'))
} }
// --- JastAdd ---
jastadd { jastadd {
configureModuleBuild() configureModuleBuild()
modules { modules {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
module("DumpAstWithPlantuml") { module("featureTest") {
java {
basedir "."
include "src/main/**/*.java"
include "src/gen/**/*.java"
}
jastadd { jastadd {
basedir ".." basedir ".."
include "dumpAst/src/main/jastadd/**/*.ast" include "featureTest/src/main/jastadd/**/*.ast"
include "dumpAst/src/main/jastadd/**/*.jadd" include "featureTest/src/main/jastadd/**/*.jadd"
include "dumpAst/src/main/jastadd/**/*.jrag" include "featureTest/src/main/jastadd/**/*.jrag"
include "dumpAstWithPlantuml/src/main/jastadd/**/*.jadd" include "featureTest/src/gen/jastadd/**/*.ast"
include "dumpAst/src/gen/jastadd/**/*.ast" include "featureTest/src/gen/jastadd/**/*.jadd"
include "dumpAst/src/gen/jastadd/**/*.jadd" include "featureTest/src/gen/jastadd/**/*.jrag"
include "dumpAst/src/gen/jastadd/**/*.jrag"
} }
} }
} }
cleanGen.doFirst { cleanGen.doFirst {
delete "src/gen/java/de" delete "src/gen/java/org"
delete "src/gen-res/BuildInfo.properties" delete "src/gen-res/BuildInfo.properties"
} }
preprocessParser.doFirst { module = "featureTest"
astPackage = 'org.jastadd.featureTest.ast'
args += ["--no-beaver-symbol"]
}
module = "DumpAstWithPlantuml"
astPackage = 'de.tudresden.inf.st.jastadd.dumpAst.ast'
genDir = 'src/gen/java' genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res' buildInfoDir = 'src/gen-res'
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"] jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
} }
// --- Tests ---
test.useJUnitPlatform()
// --- Versioning and Publishing ---
mainClassName = 'de.tudresden.inf.st.jastadd.featureTest.FeatureTestMain'
// --- Task order ---
generateAst.dependsOn relast generateAst.dependsOn relast
aspect GrammarGlobal {
syn A C.getCalculated() {
A result = new A();
result.setName("Calculated-" + getName());
D innerD = new D();
result.setD(innerD);
return result;
}
syn JastAddList<B> C.getAlsoCalculatedList() {
JastAddList<B> result = new JastAddList<>();
B inner = new B();
inner.setName("AlsoCalculated-" + getName());
result.add(inner);
return result;
}
syn nta A C.getCalculatedNewSyntax() {
A result = new A();
result.setName("Calculated-" + getName());
return result;
}
syn nta JastAddList<B> C.getAlsoCalculatedListNewSyntax() {
JastAddList<B> result = new JastAddList<>();
B inner = new B();
inner.setName("AlsoCalculated-" + getName());
result.add(inner);
return result;
}
syn int Root.simpleAttr() = 42;
syn A Root.referenceAttr() = getA();
syn boolean ASTNode.isA() = false;
eq A.isA() = true;
}
aspect GrammarTypeLevel {
syn int AbstractT.simpleAttr() = 43;
syn nta A AbstractT.getCalculated() {
A result = new A();
result.setName("Calculated-" + getName());
return result;
}
}
// testcases with global inclusion/exclusion
Nameable ::= <Name> ;
Root : Nameable ::= A B* [C];
A : Nameable ::= B MyC:C D;
B : Nameable ::= <OtherValue> ;
C : Nameable ::= [A] <Unwanted:int> <RawReference:A> /Calculated:A/ /AlsoCalculated:B*/ ;
SubC : C ::= <RawReference:A> <Unwanted:int> [A] /Calculated:A/ /AlsoCalculated:B*/ ;
D;
rel B.oneA -> A ;
rel B.maybeC? -> C ;
rel B.manyA* -> A ;
rel C.biA1 <-> A.biC1 ;
rel C.biA2* <-> A.biC2 ;
rel C.biA3? <-> A.biC3 ;
// testcases with type-level inclusion/exclusion
TRoot : Nameable ::= A T1 T2 T3 ;
abstract AbstractT : Nameable ::= B Bee:B* <SomeValue> <Unwanted:int> ;
T1 : AbstractT ;
T2 : AbstractT ;
T3 : AbstractT ;
rel AbstractT.oneA -> A ;
rel AbstractT.maybeA? -> A ;
rel AbstractT.manyA* -> A ;
package de.tudresden.inf.st.jastadd.featureTest;
import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamBooleanSetting;
import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamStringSetting;
import org.jastadd.featureTest.ast.*;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Main class of feature test.
*
* @author rschoene - Initial contribution
*/
public class FeatureTestMain {
public static void main(String[] args) throws IOException {
Root 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);
Path pathToYaml = Paths.get("featureTest.yml");
Path pathToPng = Paths.get("featureTest.png");
// Dumper.read(null).dumpAsPNG(pathToPng);
Dumper
// .read(null)
.read(root)
// .customPreamble("hide empty members")
.skinParam(SkinParamBooleanSetting.Shadowing, false)
.includeAttributes("referenceAttr")
.includeNonterminalAttributes("Calculated")
.includeNonterminalAttributes("AlsoCalculatedListNewSyntax")
.dumpAsYaml(pathToYaml, true)
.dumpAsPNG(pathToPng);
}
private void m() {
//noinspection UnnecessaryReturnStatement
return;
}
}
# Add relast2uml to your project # Add DumpAst to your project
If you want to use `Relast2Uml`, either use the latest [pre-build version](#use-packaged-version) or clone the repository and [build it yourself](#build-from-source). If you want to use `DumpAst`, either use the latest [pre-build version](#use-packaged-version) or clone the repository and [build it yourself](#build-from-source).
## Use packaged version ## Use packaged version
Check the [package overview page](https://git-st.inf.tu-dresden.de/jastadd/relast2uml/-/packages) to find the latest versions of the individual packages. Check the [package overview page](https://git-st.inf.tu-dresden.de/jastadd/relast2uml/-/packages) to find the latest versions of the individual packages.
First add this GitLab as a repository in your `build.gradle`: Add this GitLab as a repository, and `dumpAst` as a dependency in your `build.gradle`:
``` ```
repositories { repositories {
...@@ -15,68 +15,32 @@ repositories { ...@@ -15,68 +15,32 @@ repositories {
url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven" url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven"
} }
} }
```
### grammar2uml
To use `Grammar2uml`, add it as a dependency:
```
configurations {
grammar2umlClasspath
}
dependencies {
grammar2umlClasspath group: 'de.tudresden.inf.st', name: 'grammar2uml', version: '0.1.1'
}
```
Finally, add a task to create your visualization:
```
task grammar2uml(type: JavaExec) {
main = 'de.tudresden.inf.st.jastadd.grammar2uml.compiler.Compiler'
classpath = configurations.grammar2umlClasspath
args([
'--verbose',
'src/main/jastadd/GoalModel.relast'
])
}
```
### dumpAst
To use `DumpAst` or `DumpAstWithPlantuml`, add it as a dependency:
```
dependencies { dependencies {
implementation group: 'de.tudresden.inf.st', name: 'dumpAst', version: '0.3.4' implementation group: 'de.tudresden.inf.st', name: 'dumpAst', version: '0.3.7'
// or
implementation group: 'de.tudresden.inf.st', name: 'dumpAstWithPlantuml', version: '0.3.4'
} }
``` ```
## Build from source ## Build from source
If you want to build the tools of `Relast2Uml` from source, first build the jar from the [Relast2Uml repository](https://git-st.inf.tu-dresden.de/jastadd/relast2uml): If you want to build the tools of `DumpAst` from source, first build the jar from the [repository](https://git-st.inf.tu-dresden.de/jastadd/relast2uml):
```bash ```bash
git clone https://git-st.inf.tu-dresden.de/jastadd/relast2uml.git git clone https://git-st.inf.tu-dresden.de/jastadd/relast2uml.git
cd relast2uml cd relast2uml
./gradlew jar ./gradlew jar
ls dumpAst/build/libs/ dumpAstWithPlantuml/build/libs/ ls dumpAst/build/libs/
``` ```
Those JARs can then be copied to your project. This JAR can then be copied to your project.
```bash ```bash
cp dumpAst/build/libs/dumpAst-<version>.jar ../your-project/libs/dumpAst.jar cp dumpAst/build/libs/dumpAst-<version>.jar ../your-project/libs/dumpAst.jar
cd ../your-project/ cd ../your-project/
``` ```
Finally, this JAR has to be integrated into your build process. In case [Gradle](https://gradle.org/) is used, the JAR file needs to be added as dependency using: Finally, this JAR has to be integrated into your build process.
In case [Gradle](https://gradle.org/) is used, the JAR file needs to be added as dependency using:
```groovy ```groovy
dependencies { dependencies {
......
pages/docs/img/dumpAst.png

22.7 KiB | W: | H:

pages/docs/img/dumpAst.png

45.3 KiB | W: | H:

pages/docs/img/dumpAst.png
pages/docs/img/dumpAst.png
pages/docs/img/dumpAst.png
pages/docs/img/dumpAst.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -23,9 +23,9 @@ Using the return value, the following methods are supported and can be chained t ...@@ -23,9 +23,9 @@ Using the return value, the following methods are supported and can be chained t
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| customPreamble | Add the given string as preamble to the visualization. | | customPreamble | Add the given string as preamble to the visualization. |
| disableTypes | Disable all objects with types matching at least one of the given regex strings. Disabled objects won't be included in any output. However, their children are still processed. | | disableTypes | Disable all objects with types matching at least one of the given regex strings. Disabled objects won't be included in any output. However, their children are still processed. |
| dumpAsPNG | Write out content as PNG image generated by plantuml. (**Only available in dumpAstWithPlantuml**) | | dumpAsPNG | Write out content as PNG image generated by plantuml. |
| dumpAsSource | Write out content as plantuml source code | | dumpAsSource | Write out content as plantuml source code |
| dumpAsSVG | Write out content as SVG image generated by plantuml. (**Only available in dumpAstWithPlantuml**) | | dumpAsSVG | Write out content as SVG image generated by plantuml. |
| dumpAsYaml | Write out content as YAML representation of the ASTNode | | dumpAsYaml | Write out content as YAML representation of the ASTNode |
| enableDebug | Add debug information in dumped content, mainly version numbers. | | enableDebug | Add debug information in dumped content, mainly version numbers. |
| excludeAttributesFor | *experimental, documentation missing* | | excludeAttributesFor | *experimental, documentation missing* |
......
...@@ -2,5 +2,6 @@ rootProject.name = 'relast2uml' ...@@ -2,5 +2,6 @@ rootProject.name = 'relast2uml'
include 'relast.preprocessor' include 'relast.preprocessor'
include 'dumpAst' include 'dumpAst'
include 'dumpAstWithPlantuml'
include 'testDumper' include 'testDumper'
include 'featureTest'
// --- Buildscripts (must be at the top) ---
buildscript { buildscript {
repositories.mavenLocal()
repositories.mavenCentral() repositories.mavenCentral()
dependencies { dependencies {
classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3' classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3'
} }
} }
// --- Plugin definitions ---
plugins { plugins {
id 'relast2uml.java-jastadd-conventions' id 'java'
id 'java-library'
id 'idea'
id 'com.github.ben-manes.versions'
} }
apply plugin: 'jastadd' apply plugin: 'jastadd'
// --- Dependencies ---
repositories {
mavenCentral()
}
dependencies { dependencies {
testImplementation project(':dumpAst') implementation project(':dumpAst')
api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${jupiter_version}"
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.18.1'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${jupiter_version}"
} }
// --- Preprocessors ---
File genSrc = file("src/gen/java")
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
File testingGrammar = file('./src/main/jastadd/testDumper.relast') File testingGrammar = file('./src/main/jastadd/testDumper.relast')
task relast(type: JavaExec) { task relast(type: JavaExec) {
...@@ -50,6 +71,7 @@ task relast(type: JavaExec) { ...@@ -50,6 +71,7 @@ task relast(type: JavaExec) {
file('./src/gen/jastadd/testDumperResolverStubs.jrag')) file('./src/gen/jastadd/testDumperResolverStubs.jrag'))
} }
// --- JastAdd ---
jastadd { jastadd {
configureModuleBuild() configureModuleBuild()
modules { modules {
...@@ -92,4 +114,10 @@ jastadd { ...@@ -92,4 +114,10 @@ jastadd {
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"] jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
} }
// --- Tests ---
test.useJUnitPlatform()
// --- Versioning and Publishing ---
// --- Task order ---
generateAst.dependsOn relast 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.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.util.stream.Collectors;
public class TestDumperMain {
public static void main(String[] args) {
Root 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);
TestUtils.ExposingDumpBuilder builder = new TestUtils.ExposingDumpBuilder(root);
builder.includeAttributes("simpleAttr")
.orderChildren()
.includeNonterminalAttributes("getCalculated")
.setNameMethod(n -> n == null ? "null" : n.getClass().getSimpleName());
System.out.println(">> PlantUml");
DumpAst dumpAst = builder.build();
System.out.println(dumpAst.toPlantUml());
DumpNode node = dumpAst.getDumpNode(0);
System.out.println(node.getName());
System.out.println(node.myChildren().stream().map(DumpNode::getName).collect(Collectors.joining(", ")));
// System.out.println(">> YAML begin");
// System.out.println(builder.build().toYaml(true));
// System.out.println(">> YAML end");
}
}
...@@ -6,13 +6,16 @@ import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; ...@@ -6,13 +6,16 @@ import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode;
import org.jastadd.testDumper.ast.*; import org.jastadd.testDumper.ast.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*; import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestSimple { public class TestSimple {
...@@ -28,6 +31,22 @@ public class TestSimple { ...@@ -28,6 +31,22 @@ public class TestSimple {
assertEquals(0, actualRoot.getNumDumpRelation()); assertEquals(0, actualRoot.getNumDumpRelation());
} }
@Test
public void testCustomPreamble() throws IOException {
Root root = createRoot(null, null);
String preamble = "{<\n>\n}";
ExposingDumpBuilder builder = new ExposingDumpBuilder(root);
builder.excludeNullNodes().customPreamble(preamble);
Path path = Paths.get("src/gen/resources/");
Files.createDirectories(path);
builder.dumpAsYaml(path.resolve("customPreamble.yaml"), true);
DumpAst dumpAst = builder.build();
String puml = dumpAst.toPlantUml();
assertThat(puml).contains(preamble);
}
@Test void testChildlessNonterminal() { @Test void testChildlessNonterminal() {
Root root = createRoot(createA(A_NAME, a -> a.setD(new D())), null); Root root = createRoot(createA(A_NAME, a -> a.setD(new D())), null);
List<DumpNode> nodes = TestUtils.dumpModel(root); List<DumpNode> nodes = TestUtils.dumpModel(root);
...@@ -80,10 +99,11 @@ public class TestSimple { ...@@ -80,10 +99,11 @@ public class TestSimple {
@Test @Test
public void testOrderedListChildren() { public void testOrderedListChildren() {
Root root = createRoot(null, null, createB(B1_NAME), createB(B2_NAME), createB(B3_NAME)); Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B1_NAME), createB(B2_NAME), createB(B3_NAME));
List<DumpNode> nodes = TestUtils.dumpModel(root, DumpBuilder::orderChildren); List<DumpNode> nodes = TestUtils.dumpModel(root, DumpBuilder::orderChildren);
assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactlyInAnyOrder(ROOT_NAME, B1_NAME, B2_NAME, B3_NAME); assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactlyInAnyOrder(
ROOT_NAME, A_NAME, B1_NAME, B2_NAME, B3_NAME, C_NAME);
DumpNode actualRoot = TestUtils.findByName(nodes, ROOT_NAME); DumpNode actualRoot = TestUtils.findByName(nodes, ROOT_NAME);
// in grammar: DumpAst ::= [...] DumpNode* [...]; // in grammar: DumpAst ::= [...] DumpNode* [...];
...@@ -91,7 +111,30 @@ public class TestSimple { ...@@ -91,7 +111,30 @@ public class TestSimple {
assertTrue(((DumpAst) actualRoot.getParent().getParent()).getPrintConfig().getOrderChildren()); assertTrue(((DumpAst) actualRoot.getParent().getParent()).getPrintConfig().getOrderChildren());
List<DumpNode> children = actualRoot.myChildren(); List<DumpNode> children = actualRoot.myChildren();
assertThat(children).extracting(NAME_EXTRACTOR).containsExactlyInAnyOrder(B1_NAME, B2_NAME, B3_NAME); assertThat(children).extracting(NAME_EXTRACTOR).containsExactly(
A_NAME, B1_NAME, B2_NAME, B3_NAME, C_NAME);
DumpNode actualA = TestUtils.findByName(nodes, A_NAME);
DumpNode actualB1 = TestUtils.findByName(nodes, B1_NAME);
DumpNode actualB2 = TestUtils.findByName(nodes, B2_NAME);
DumpNode actualB3 = TestUtils.findByName(nodes, B3_NAME);
DumpNode actualC = TestUtils.findByName(nodes, C_NAME);
for (DumpNode d : children) {
System.out.println(d.getName() + "/" + d.getLabel() + " = " + d);
}
assertEquals(actualB1, actualA.successor(), actualA.successor().getName());
assertEquals(actualB2, actualB1.successor(), actualB1.successor().getName());
assertEquals(actualB3, actualB2.successor(), actualB2.successor().getName());
assertEquals(actualC, actualB3.successor(), actualB3.successor().getName());
assertNull(actualC.successor());
assertTrue(actualA.hasSuccessor());
assertTrue(actualB1.hasSuccessor());
assertTrue(actualB2.hasSuccessor());
assertTrue(actualB3.hasSuccessor());
assertFalse(actualC.hasSuccessor());
} }
@Test @Test
......
...@@ -163,7 +163,7 @@ public class TestUtils { ...@@ -163,7 +163,7 @@ public class TestUtils {
dumpAst.toPlantUml(); dumpAst.toPlantUml();
List<DumpNode> result = new ArrayList<>(); List<DumpNode> result = new ArrayList<>();
for (DumpNode dumpNode : dumpAst.getDumpNodeList()) { for (DumpNode dumpNode : dumpAst.getDumpNodeList()) {
if (dumpNode.isAstNode() && !dumpNode.getInvisible()) { if ((dumpNode.isAstNode() || dumpNode.isNull()) && !dumpNode.getInvisible()) {
result.add(dumpNode); result.add(dumpNode);
} }
} }
...@@ -187,7 +187,7 @@ public class TestUtils { ...@@ -187,7 +187,7 @@ public class TestUtils {
if (!dumpChildNode.isList()) { if (!dumpChildNode.isList()) {
// then it is a DumpNormalChildNode // then it is a DumpNormalChildNode
DumpNode target = ((DumpNormalChildNode) dumpChildNode).getDumpNode(); DumpNode target = ((DumpNormalChildNode) dumpChildNode).getDumpNode();
if (!target.getInvisible()) { if (target != null && !target.getInvisible()) {
result.put(dumpChildNode.getName(), target); result.put(dumpChildNode.getName(), target);
} }
} }
...@@ -201,7 +201,7 @@ public class TestUtils { ...@@ -201,7 +201,7 @@ public class TestUtils {
if (dumpChildNode.isList()) { if (dumpChildNode.isList()) {
// then it is a DumpListChildNode // then it is a DumpListChildNode
((DumpListChildNode) dumpChildNode).getInnerDumpNodeList().forEach(inner -> { ((DumpListChildNode) dumpChildNode).getInnerDumpNodeList().forEach(inner -> {
if (!inner.getDumpNode().getInvisible()) { if (inner.getDumpNode() != null && !inner.getDumpNode().getInvisible()) {
result.computeIfAbsent(dumpChildNode.getName(), key -> new ArrayList<>()).add(inner.getDumpNode()); result.computeIfAbsent(dumpChildNode.getName(), key -> new ArrayList<>()).add(inner.getDumpNode());
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment