diff --git a/dumpAst/src/main/jastadd/GenerationBackend.jadd b/dumpAst/src/main/jastadd/GenerationBackend.jadd index be9aaff9334285645c3e4581838566d683879f5c..fa8b0df9677e79d2ffa8f2553eb0acb9d38bf8e8 100644 --- a/dumpAst/src/main/jastadd/GenerationBackend.jadd +++ b/dumpAst/src/main/jastadd/GenerationBackend.jadd @@ -119,6 +119,9 @@ aspect GenerationBackend { return node; } final ClassAnalysisResult car = analyzeClass(obj.getClass()); + if (getBuildConfig().getDebug()) { + System.out.println("for node " + obj + ", analysis was:\n" + car.prettyPrint()); + } for (AnalysedMethod containmentMethod : car.getContainmentMethodList()) { if (containmentMethod.isSingleChildMethod()) { // -- singleChild -- @@ -138,10 +141,10 @@ aspect GenerationBackend { DumpListChildNode listChild = new DumpListChildNode(); listChild.setComputed(false); String childName = containmentMethod.getName(); - boolean shouldBeInvisisble = !isChildEnabled(objClassName, childName); + boolean shouldBeInvisible = !isChildEnabled(objClassName, childName); listChild.setName(childName); for (Object target : targetList) { - DumpNode targetNode = transform(tti, target, options.asNormal(shouldBeInvisisble)); + DumpNode targetNode = transform(tti, target, options.asNormal(shouldBeInvisible)); if (target != null && targetNode != null) { listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode)); } @@ -174,10 +177,10 @@ aspect GenerationBackend { boolean computed = otherMethod.asListChildMethod().isNTAListChildMethod(); listChild.setComputed(computed); String childName = otherMethod.getName(); - boolean shouldBeInvisisble = !isChildEnabled(objClassName, childName); + boolean shouldBeInvisible = !isChildEnabled(objClassName, childName); listChild.setName(childName); for (Object target : targetList) { - DumpNode targetNode = transform(tti, target, options.asNormal(shouldBeInvisisble).computed(computed)); + DumpNode targetNode = transform(tti, target, options.asNormal(shouldBeInvisible).computed(computed)); if (target != null && targetNode != null) { listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode)); } @@ -251,7 +254,7 @@ aspect GenerationBackend { ClassAnalysisResult result = new ClassAnalysisResult(); String clazzName = clazz.getSimpleName(); java.util.List<String> targetOrder = targetOrder(clazz); - for (java.lang.reflect.Method method : clazz.getMethods()) { + methodLoop: for (java.lang.reflect.Method method : clazz.getMethods()) { for (java.lang.annotation.Annotation annotation : method.getAnnotations()) { String canonicalName = annotation.annotationType().getCanonicalName(); if (canonicalName.startsWith(astNodeAnnotationPrefix())) { @@ -366,11 +369,11 @@ aspect GenerationBackend { int indexOfContextInTarget = targetOrder.indexOf(contextNameToAdd); if (indexOfContextInTarget == 0) { result.getContainmentMethodList().insertChild(containmentMethodToAdd, 0); - continue; + continue methodLoop; } if (indexOfContextInTarget == targetOrder.size() - 1) { result.addContainmentMethod(containmentMethodToAdd); - continue; + continue methodLoop; } for (int i = 0, size = result.getNumContainmentMethod(); i < size; i++) { @@ -378,7 +381,7 @@ aspect GenerationBackend { int indexOfCurrentInTarget = targetOrder.indexOf(currentContextName); if (indexOfCurrentInTarget > indexOfContextInTarget) { result.getContainmentMethodList().insertChild(containmentMethodToAdd, i); - break; + continue methodLoop; } } result.addContainmentMethod(containmentMethodToAdd); diff --git a/dumpAst/src/main/jastadd/Printing.jrag b/dumpAst/src/main/jastadd/Printing.jrag index e4565af809152de0c654dd6bc613dd5aab2c3e02..8fdcc8ee044699fabfbbdcd940c6f751cbad9f4b 100644 --- a/dumpAst/src/main/jastadd/Printing.jrag +++ b/dumpAst/src/main/jastadd/Printing.jrag @@ -33,3 +33,31 @@ aspect Printing { syn boolean DumpNormalChildNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode()); syn boolean DumpNormalRelation.bothVisible() = bothVisible(containingDumpNode(), getDumpNode()); } + +aspect Debugging { + syn String ClassAnalysisResult.prettyPrint() { + StringBuilder sb = new StringBuilder(); + sb.append("ContainmentMethods:"); + for (AnalysedMethod method : getContainmentMethodList()) { + sb.append(method.prettyPrint()).append(","); + } + if (getNumContainmentMethod() == 0) { + sb.append("none. "); + } + sb.append("other methods:"); + for (AnalysedMethod method : getOtherMethodList()) { + sb.append(method.prettyPrint()).append(","); + } + if (getNumOtherMethod() == 0) { + sb.append("none."); + } + return sb.toString(); + } + syn String AnalysedMethod.prettyPrint() { + String methodString = "?"; + try { + methodString = getMethod().toString(); + } catch (Exception ignore) {} + return this.getClass().getSimpleName() + "[Method: " + methodString + ", Name: " + getName() + "]"; + } +} diff --git a/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java b/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java index 176896a158ddf15d02d92893a7c42273762149da..87466ee2adb6dbd79d7f97dd682f82c6f6f5461f 100644 --- a/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java +++ b/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java @@ -51,6 +51,7 @@ public class DumpBuilder { /** * Add debug information in dumped content, mainly version numbers. + * Also dump debugging information while reading in object. * * @return this */ diff --git a/dumpAst/src/main/resources/dumpAstVersion.properties b/dumpAst/src/main/resources/dumpAstVersion.properties index e6d184e339ee10496e7839b977a58afdff99caa7..6e2bce737359ddcd9a0a3f7bc29e7d8813e12751 100644 --- a/dumpAst/src/main/resources/dumpAstVersion.properties +++ b/dumpAst/src/main/resources/dumpAstVersion.properties @@ -1,2 +1,2 @@ -#Tue Mar 22 14:11:27 CET 2022 -version=1.0.1 +#Mon May 16 18:32:38 CEST 2022 +version=1.0.2 diff --git a/testDumper/src/main/jastadd/testDumper.relast b/testDumper/src/main/jastadd/testDumper.relast index 7b66cc96e3e0af88dd7c124928fca2ae86fa5e53..cf9d37f4899b1af59099341292e3ecd111200e4d 100644 --- a/testDumper/src/main/jastadd/testDumper.relast +++ b/testDumper/src/main/jastadd/testDumper.relast @@ -24,3 +24,9 @@ T3 : AbstractT ; rel AbstractT.oneA -> A ; rel AbstractT.maybeA? -> A ; rel AbstractT.manyA* -> A ; + +Position : Nameable ::= <X:double> <Y:double> <Z:double>; +Size : Nameable ::= <Length:double> <Width:double> <Height:double>; +Orientation : Nameable ::= <X:double> <Y:double> <Z:double> <W:double>; +ObjectOfInterest : Nameable ::= Position Size Orientation; +DropOffLocation : ObjectOfInterest; diff --git a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java new file mode 100644 index 0000000000000000000000000000000000000000..856bab384ff5d2ade9b7dacf4704a0a5e90cc648 --- /dev/null +++ b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java @@ -0,0 +1,37 @@ +package de.tudresden.inf.st.jastadd.testDumper; + +import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import org.jastadd.testDumper.ast.DropOffLocation; +import org.jastadd.testDumper.ast.Orientation; +import org.jastadd.testDumper.ast.Position; +import org.jastadd.testDumper.ast.Size; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*; +import static org.assertj.core.api.Assertions.*; + +/** + * More complex test cases. + * + * @author rschoene - Initial contribution + */ +public class TestComplex { + + @Test + public void testRegressionIssue16() { + DropOffLocation location = new DropOffLocation(); + location.setName(ROOT_NAME); + location.setPosition(new Position(T1_NAME, 1, 2, 3)); + location.setOrientation(new Orientation(T2_NAME, 4, 5, 6, 7)); + location.setSize(new Size(T3_NAME, 8, 9, 10)); + + List<DumpNode> nodes = TestUtils.dumpModel(location); + assertThat(valueTokens(findByName(nodes, T1_NAME))).containsOnly( + entry("Name", T1_NAME), + entry("X", 1.0), + entry("Y", 2.0), + entry("Z", 3.0)); + } +} diff --git a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java index 1b9be71cc6a27b381a94127d8cab991f06a87479..ec0037e8f3fc280319a172fe49467c7447251868 100644 --- a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java +++ b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java @@ -120,10 +120,6 @@ public class TestSimple { 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());