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

1.0.2

- avoid duplicate token values (#14)
- add debugging information if enabled
parent e72bde21
No related branches found
No related tags found
1 merge request!111.1.0
Pipeline #13621 passed
...@@ -119,6 +119,9 @@ aspect GenerationBackend { ...@@ -119,6 +119,9 @@ aspect GenerationBackend {
return node; return node;
} }
final ClassAnalysisResult car = analyzeClass(obj.getClass()); 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()) { for (AnalysedMethod containmentMethod : car.getContainmentMethodList()) {
if (containmentMethod.isSingleChildMethod()) { if (containmentMethod.isSingleChildMethod()) {
// -- singleChild -- // -- singleChild --
...@@ -138,10 +141,10 @@ aspect GenerationBackend { ...@@ -138,10 +141,10 @@ aspect GenerationBackend {
DumpListChildNode listChild = new DumpListChildNode(); DumpListChildNode listChild = new DumpListChildNode();
listChild.setComputed(false); listChild.setComputed(false);
String childName = containmentMethod.getName(); String childName = containmentMethod.getName();
boolean shouldBeInvisisble = !isChildEnabled(objClassName, childName); boolean shouldBeInvisible = !isChildEnabled(objClassName, childName);
listChild.setName(childName); listChild.setName(childName);
for (Object target : targetList) { 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) { if (target != null && targetNode != null) {
listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode)); listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode));
} }
...@@ -174,10 +177,10 @@ aspect GenerationBackend { ...@@ -174,10 +177,10 @@ aspect GenerationBackend {
boolean computed = otherMethod.asListChildMethod().isNTAListChildMethod(); boolean computed = otherMethod.asListChildMethod().isNTAListChildMethod();
listChild.setComputed(computed); listChild.setComputed(computed);
String childName = otherMethod.getName(); String childName = otherMethod.getName();
boolean shouldBeInvisisble = !isChildEnabled(objClassName, childName); boolean shouldBeInvisible = !isChildEnabled(objClassName, childName);
listChild.setName(childName); listChild.setName(childName);
for (Object target : targetList) { 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) { if (target != null && targetNode != null) {
listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode)); listChild.addInnerDumpNode(new InnerDumpNode().setDumpNode(targetNode));
} }
...@@ -251,7 +254,7 @@ aspect GenerationBackend { ...@@ -251,7 +254,7 @@ aspect GenerationBackend {
ClassAnalysisResult result = new ClassAnalysisResult(); ClassAnalysisResult result = new ClassAnalysisResult();
String clazzName = clazz.getSimpleName(); String clazzName = clazz.getSimpleName();
java.util.List<String> targetOrder = targetOrder(clazz); 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()) { for (java.lang.annotation.Annotation annotation : method.getAnnotations()) {
String canonicalName = annotation.annotationType().getCanonicalName(); String canonicalName = annotation.annotationType().getCanonicalName();
if (canonicalName.startsWith(astNodeAnnotationPrefix())) { if (canonicalName.startsWith(astNodeAnnotationPrefix())) {
...@@ -366,11 +369,11 @@ aspect GenerationBackend { ...@@ -366,11 +369,11 @@ aspect GenerationBackend {
int indexOfContextInTarget = targetOrder.indexOf(contextNameToAdd); int indexOfContextInTarget = targetOrder.indexOf(contextNameToAdd);
if (indexOfContextInTarget == 0) { if (indexOfContextInTarget == 0) {
result.getContainmentMethodList().insertChild(containmentMethodToAdd, 0); result.getContainmentMethodList().insertChild(containmentMethodToAdd, 0);
continue; continue methodLoop;
} }
if (indexOfContextInTarget == targetOrder.size() - 1) { if (indexOfContextInTarget == targetOrder.size() - 1) {
result.addContainmentMethod(containmentMethodToAdd); result.addContainmentMethod(containmentMethodToAdd);
continue; continue methodLoop;
} }
for (int i = 0, size = result.getNumContainmentMethod(); i < size; i++) { for (int i = 0, size = result.getNumContainmentMethod(); i < size; i++) {
...@@ -378,7 +381,7 @@ aspect GenerationBackend { ...@@ -378,7 +381,7 @@ aspect GenerationBackend {
int indexOfCurrentInTarget = targetOrder.indexOf(currentContextName); int indexOfCurrentInTarget = targetOrder.indexOf(currentContextName);
if (indexOfCurrentInTarget > indexOfContextInTarget) { if (indexOfCurrentInTarget > indexOfContextInTarget) {
result.getContainmentMethodList().insertChild(containmentMethodToAdd, i); result.getContainmentMethodList().insertChild(containmentMethodToAdd, i);
break; continue methodLoop;
} }
} }
result.addContainmentMethod(containmentMethodToAdd); result.addContainmentMethod(containmentMethodToAdd);
......
...@@ -33,3 +33,31 @@ aspect Printing { ...@@ -33,3 +33,31 @@ aspect Printing {
syn boolean DumpNormalChildNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode()); syn boolean DumpNormalChildNode.bothVisible() = bothVisible(containingDumpNode(), getDumpNode());
syn boolean DumpNormalRelation.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() + "]";
}
}
...@@ -51,6 +51,7 @@ public class DumpBuilder { ...@@ -51,6 +51,7 @@ public class DumpBuilder {
/** /**
* Add debug information in dumped content, mainly version numbers. * Add debug information in dumped content, mainly version numbers.
* Also dump debugging information while reading in object.
* *
* @return this * @return this
*/ */
......
#Tue Mar 22 14:11:27 CET 2022 #Mon May 16 18:32:38 CEST 2022
version=1.0.1 version=1.0.2
...@@ -24,3 +24,9 @@ T3 : AbstractT ; ...@@ -24,3 +24,9 @@ T3 : AbstractT ;
rel AbstractT.oneA -> A ; rel AbstractT.oneA -> A ;
rel AbstractT.maybeA? -> A ; rel AbstractT.maybeA? -> A ;
rel AbstractT.manyA* -> 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;
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));
}
}
...@@ -120,10 +120,6 @@ public class TestSimple { ...@@ -120,10 +120,6 @@ public class TestSimple {
DumpNode actualB3 = TestUtils.findByName(nodes, B3_NAME); DumpNode actualB3 = TestUtils.findByName(nodes, B3_NAME);
DumpNode actualC = TestUtils.findByName(nodes, C_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(actualB1, actualA.successor(), actualA.successor().getName());
assertEquals(actualB2, actualB1.successor(), actualB1.successor().getName()); assertEquals(actualB2, actualB1.successor(), actualB1.successor().getName());
assertEquals(actualB3, actualB2.successor(), actualB2.successor().getName()); assertEquals(actualB3, actualB2.successor(), actualB2.successor().getName());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment