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
Pipeline #13621 passed with stages
in 2 minutes and 25 seconds
......@@ -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);
......
......@@ -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() + "]";
}
}
......@@ -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
*/
......
#Tue Mar 22 14:11:27 CET 2022
version=1.0.1
#Mon May 16 18:32:38 CEST 2022
version=1.0.2
......@@ -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;
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 {
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());
......
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