diff --git a/dumpAst/src/main/jastadd/DumpAst.relast b/dumpAst/src/main/jastadd/DumpAst.relast index e1ca0cd437443c3035b156a31d3baa77b3daba5b..13d438ede1180d96e49a780b817e5db0ffff3050 100644 --- a/dumpAst/src/main/jastadd/DumpAst.relast +++ b/dumpAst/src/main/jastadd/DumpAst.relast @@ -8,12 +8,12 @@ DumpNode ::= <Name> <Label> <Object:Object> <Invisible:boolean> DumpChildNode* D InnerDumpNode ; rel InnerDumpNode.DumpNode -> DumpNode ; -abstract DumpChildNode ::= <Name> ; +abstract DumpChildNode ::= <Name> <Computed:boolean> ; DumpNormalChildNode : DumpChildNode ; rel DumpNormalChildNode.DumpNode -> DumpNode ; DumpListChildNode : DumpChildNode ::= InnerDumpNode* ; -abstract DumpToken ::= <Name> ; +abstract DumpToken ::= <Name> <Computed:boolean> ; DumpReferenceToken : DumpToken ; rel DumpReferenceToken.Value -> DumpNode ; DumpValueToken : DumpToken ::= <Value:Object> ; @@ -25,3 +25,21 @@ DumpListRelation : DumpRelation ::= InnerDumpNode* ; // type of NTA InvisiblePath ::= InnerDumpNode* ; + +ClassAnalysisResult ::= AnalysedMethod* ; +abstract AnalysedMethod ::= <Method:java.lang.reflect.Method> <Name> ; + +abstract SingleChildMethod : AnalysedMethod ; +NormalSingleChildMethod : SingleChildMethod ; +NTASingleChildMethod : SingleChildMethod ; + +abstract ListChildMethod : AnalysedMethod ; +NormalListChildMethod : ListChildMethod ; +NTAListChildMethod : ListChildMethod ; + +SingleRelationMethod : AnalysedMethod ; +ListRelationMethod : AnalysedMethod ; + +abstract TokenMethod : AnalysedMethod ; +IntrinsicTokenMethod : TokenMethod ; +AttributeMethod : TokenMethod ; diff --git a/dumpAst/src/main/jastadd/Generation.jadd b/dumpAst/src/main/jastadd/Generation.jadd index f0e7dc5735e5768b07fb111b41cc82995d8d028c..d6a2a37f358923affb9fae608adc8dc8ea96b5dc 100644 --- a/dumpAst/src/main/jastadd/Generation.jadd +++ b/dumpAst/src/main/jastadd/Generation.jadd @@ -74,12 +74,28 @@ import java.lang.String;aspect GenerationFrontend { updateRegexes(() -> buildConfig.getTokenIgnore(), s -> buildConfig.setTokenIgnore(s), regexes); return this; } - // not supported yet + + /** + * Include attributes (as tokens) and their value if the attribute name matches at least on of the given regex strings. + * @param regexes regex patterns to match token names + * @return this + * @see java.util.regex.Pattern#compile(java.lang.String) + */ public DumpBuilder includeAttributes(String... regexes) { updateRegexes(() -> buildConfig.getAttributeInclude(), s -> buildConfig.setAttributeInclude(s), regexes); return this; } - // not supported yet + + /** + * Includes nonterminal-attributes (as children) and their values if + * their attribute name matches at least on of the given regex strings. + * <br> + * <b>Note</b>: A leading "get" and a trailing "List" in the name will be removed prior to matching. + * Thus, it should not be contained in the regex either. + * @param regexes regex patterns to match token names + * @return this + * @see java.util.regex.Pattern#compile(java.lang.String) + */ public DumpBuilder includeNonterminalAttributes(String... regexes) { updateRegexes(() -> buildConfig.getNonterminalAttributeInclude(), s -> buildConfig.setNonterminalAttributeInclude(s), regexes); return this; @@ -245,32 +261,26 @@ aspect GenerationBackend { if (source == Source.INVISIBLE_PARENT || matches(getBuildConfig().typeIgnorePattern(), obj.getClass().getSimpleName())) { node.setInvisible(true); } - // only caching node.analyseClass does not help, since we want to do this only once per class of a node - final ClassAnalysisResult car; - Class<?> clazz = obj.getClass(); - if (tti.classAnalysisResults.containsKey(clazz)) { - car = tti.classAnalysisResults.get(clazz); - } else { - car = node.analyzeClass(); - tti.classAnalysisResults.put(clazz, car); - } + final ClassAnalysisResult car = analyzeClass(obj.getClass()); // -- singleChild -- - for (java.lang.reflect.Method method : car.singleChildMethods) { - Object target = method.invoke(obj); - String childName = car.names.get(method); + for (SingleChildMethod singleChildMethod : car.singleChildMethods()) { + Object target = singleChildMethod.getMethod().invoke(obj); + String childName = singleChildMethod.getName(); DumpNode targetNode = transform(tti, target, nextSource(source, matches(getBuildConfig().childIgnorePattern(), childName))); if (target != null && targetNode != null) { DumpNormalChildNode normalChild = new DumpNormalChildNode(); normalChild.setName(childName); normalChild.setDumpNode(targetNode); + normalChild.setComputed(singleChildMethod.isNTASingleChildMethod()); node.addDumpChildNode(normalChild); } } // -- listChild -- - for (java.lang.reflect.Method method : car.listChildMethods) { - Iterable<?> targetList = (Iterable<?>) method.invoke(obj); + for (ListChildMethod listChildMethod : car.listChildMethods()) { + Iterable<?> targetList = (Iterable<?>) listChildMethod.getMethod().invoke(obj); DumpListChildNode listChild = new DumpListChildNode(); - String childName = car.names.get(method); + listChild.setComputed(listChildMethod.isNTAListChildMethod()); + String childName = listChildMethod.getName(); boolean shouldBeInvisisble = matches(getBuildConfig().childIgnorePattern(), childName); listChild.setName(childName); for (Object target : targetList) { @@ -284,21 +294,21 @@ aspect GenerationBackend { } } // -- singleRelation -- - for (java.lang.reflect.Method method : car.singleRelationMethods) { - Object target = method.invoke(obj); + for (SingleRelationMethod singleRelationMethod : car.singleRelationMethods()) { + Object target = singleRelationMethod.getMethod().invoke(obj); DumpNode targetNode = transform(tti, target, Source.RELATION); if (target != null && targetNode != null) { DumpNormalRelation normalRelation = new DumpNormalRelation(); - normalRelation.setName(car.names.get(method)); + normalRelation.setName(singleRelationMethod.getName()); normalRelation.setDumpNode(targetNode); node.addDumpRelation(normalRelation); } } // -- listRelation -- - for (java.lang.reflect.Method method : car.listRelationMethods) { - Iterable<?> targetList = (Iterable<?>) method.invoke(obj); + for (ListRelationMethod listRelationMethod : car.listRelationMethods()) { + Iterable<?> targetList = (Iterable<?>) listRelationMethod.getMethod().invoke(obj); DumpListRelation listRelation = new DumpListRelation(); - listRelation.setName(car.names.get(method)); + listRelation.setName(listRelationMethod.getName()); for (Object target : targetList) { DumpNode targetNode = transform(tti, target, Source.RELATION); if (target != null && targetNode != null) { @@ -310,8 +320,8 @@ aspect GenerationBackend { } } // -- token -- - for (java.lang.reflect.Method method : car.tokenMethods) { - Object target = method.invoke(obj); + for (TokenMethod tokenMethod : car.tokenMethods()) { + Object target = tokenMethod.getMethod().invoke(obj); if (target != null) { DumpNode targetNode = transform(tti, target, Source.RELATION); DumpToken token = null; @@ -327,7 +337,8 @@ aspect GenerationBackend { } } if (token != null) { - token.setName(car.names.get(method)); + token.setName(tokenMethod.getName()); + token.setComputed(tokenMethod.isAttributeMethod()); node.addDumpToken(token); } } @@ -341,10 +352,8 @@ aspect GenerationBackend { (shouldBeInvisible ? Source.INVISIBLE_PARENT : Source.PARENT); } - ClassAnalysisResult DumpNode.analyzeClass() - throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException { + syn nta ClassAnalysisResult DumpAst.analyzeClass(java.lang.Class<?> clazz) { ClassAnalysisResult result = new ClassAnalysisResult(); - Class<?> clazz = getObject().getClass(); for (java.lang.reflect.Method method : clazz.getMethods()) { for (java.lang.annotation.Annotation annotation : method.getAnnotations()) { String canonicalName = annotation.annotationType().getCanonicalName(); @@ -353,16 +362,20 @@ aspect GenerationBackend { switch (simpleName) { case "Child": String singleChildName = invokeName(annotation); - result.singleChildMethods.add(method); - result.names.put(method, singleChildName); + NormalSingleChildMethod singleChildMethod = new NormalSingleChildMethod(); + singleChildMethod.setMethod(method); + singleChildMethod.setName(singleChildName); + result.addAnalysedMethod(singleChildMethod); break; case "OptChild": String optChildName = invokeName(annotation); try { // the annotated method is "get???Opt", but we want "get???" java.lang.reflect.Method realGetter = clazz.getMethod("get" + optChildName); - result.singleChildMethods.add(realGetter); - result.names.put(realGetter, optChildName); + NormalSingleChildMethod normalSingleChildMethod = new NormalSingleChildMethod(); + normalSingleChildMethod.setMethod(realGetter); + normalSingleChildMethod.setName(optChildName); + result.addAnalysedMethod(normalSingleChildMethod); } catch (NoSuchMethodException e) { System.err.println("Could not find getter for Opt-child " + optChildName + " in " + clazz.getName()); throw new RuntimeException(e); @@ -370,8 +383,10 @@ aspect GenerationBackend { break; case "ListChild": String listChildName = invokeName(annotation); - result.listChildMethods.add(method); - result.names.put(method, listChildName); + NormalListChildMethod normalListChildMethod = new NormalListChildMethod(); + normalListChildMethod.setMethod(method); + normalListChildMethod.setName(listChildName); + result.addAnalysedMethod(normalListChildMethod); break; case "Token": // heuristic for relations @@ -381,9 +396,11 @@ aspect GenerationBackend { try { java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName); // normal get + token-name -> singleRelation - if (!matches(buildConfig().relationIgnorePattern(), relationName)) { - result.singleRelationMethods.add(relationMethod); - result.names.put(relationMethod, relationName); + if (!matches(getBuildConfig().relationIgnorePattern(), relationName)) { + SingleRelationMethod singleRelationMethod = new SingleRelationMethod(); + singleRelationMethod.setMethod(relationMethod); + singleRelationMethod.setName(relationName); + result.addAnalysedMethod(singleRelationMethod); } continue; } catch (NoSuchMethodException e) { @@ -393,37 +410,55 @@ aspect GenerationBackend { try { java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName + "List"); // normal get + token-name + "List" -> listRelation - if (!matches(buildConfig().relationIgnorePattern(), relationName)) { - result.listRelationMethods.add(relationMethod); - result.names.put(relationMethod, relationName); + if (!matches(getBuildConfig().relationIgnorePattern(), relationName)) { + ListRelationMethod listRelationMethod = new ListRelationMethod(); + listRelationMethod.setMethod(relationMethod); + listRelationMethod.setName(relationName); + result.addAnalysedMethod(listRelationMethod); } continue; } catch (NoSuchMethodException e) { // ignore, but we know this is probably not a relation at all } } - if (!matches(buildConfig().tokenIgnorePattern(), tokenName)) { - result.tokenMethods.add(method); - result.names.put(method, tokenName); + if (!matches(getBuildConfig().tokenIgnorePattern(), tokenName)) { + IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod(); + tokenMethod.setMethod(method); + tokenMethod.setName(tokenName); + result.addAnalysedMethod(tokenMethod); } break; case "Attribute": String attributeName = method.getName(); - boolean isNTA = (boolean) annotation.annotationType().getMethod("isNTA").invoke(annotation); + boolean isNTA = (boolean) invokeMethod("isNTA", annotation); if (isNTA) { - if (matches(buildConfig().ntaIncludePattern(), attributeName)) { + // remove leading "get" + if (attributeName.startsWith("get")) { + attributeName = attributeName.substring(3); + } + // remove trailing "List" + if (attributeName.endsWith("List")) { + attributeName = attributeName.substring(0, attributeName.length() - 4); + } + if (matches(getBuildConfig().ntaIncludePattern(), attributeName)) { if (Iterable.class.isAssignableFrom(method.getReturnType())) { - result.listChildMethods.add(method); - result.names.put(method, attributeName + "()"); + NTAListChildMethod ntaListChildMethod = new NTAListChildMethod(); + ntaListChildMethod.setMethod(method); + ntaListChildMethod.setName(attributeName); + result.addAnalysedMethod(ntaListChildMethod); } else { - result.singleChildMethods.add(method); - result.names.put(method, attributeName + "()"); + NTASingleChildMethod ntaSingleChildMethod = new NTASingleChildMethod(); + ntaSingleChildMethod.setMethod(method); + ntaSingleChildMethod.setName(attributeName); + result.addAnalysedMethod(ntaSingleChildMethod); } } - } else if (matches(buildConfig().attributeIncludePattern(), attributeName)) { + } else if (matches(getBuildConfig().attributeIncludePattern(), attributeName)) { // normal attribute - result.tokenMethods.add(method); - result.names.put(method, attributeName + "()"); + AttributeMethod attributeMethod = new AttributeMethod(); + attributeMethod.setMethod(method); + attributeMethod.setName(attributeName); + result.addAnalysedMethod(attributeMethod); } break; } @@ -433,7 +468,7 @@ aspect GenerationBackend { return result; } - private String DumpNode.titleCase(String s) { + private String DumpAst.titleCase(String s) { if (s.isEmpty()) { return s; } @@ -453,9 +488,19 @@ aspect GenerationBackend { // --- version --- (mustache has buildConfig as context) syn String BuildConfig.version() = printConfig().getVersion(); - private static String DumpNode.invokeName(java.lang.annotation.Annotation annotation) - throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException { - return (String) annotation.annotationType().getMethod("name").invoke(annotation); + private static String DumpAst.invokeName(java.lang.annotation.Annotation annotation) { + return (String) invokeMethod("name", annotation); + } + private static Object DumpAst.invokeMethod(String name, java.lang.annotation.Annotation annotation) { + try { + return annotation.annotationType().getMethod(name).invoke(annotation); + } catch (java.lang.reflect.InvocationTargetException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } } // --- isAstNode --- @@ -473,8 +518,9 @@ aspect GenerationBackend { } // --- astNodeAnnotationPrefix --- + syn String DumpAst.astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation"; inh String DumpNode.astNodeAnnotationPrefix(); - eq DumpAst.getDumpNode().astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation"; + eq DumpAst.getDumpNode().astNodeAnnotationPrefix() = astNodeAnnotationPrefix(); // --- NTA: InvisiblePath --- syn InvisiblePath DumpNode.getInvisiblePath() { @@ -503,16 +549,6 @@ aspect GenerationBackend { class TransformationTransferInformation { java.util.Map<Object, DumpNode> transformed = new java.util.HashMap<>(); java.util.Map<DumpNode, Boolean> relationTargetsUnprocessed = new java.util.HashMap<>(); - java.util.Map<Class<?>, ClassAnalysisResult> classAnalysisResults = new java.util.HashMap<>(); - } - - class ClassAnalysisResult { - java.util.List<java.lang.reflect.Method> singleChildMethods = new java.util.ArrayList<>(); - java.util.List<java.lang.reflect.Method> listChildMethods = new java.util.ArrayList<>(); - java.util.List<java.lang.reflect.Method> singleRelationMethods = new java.util.ArrayList<>(); - java.util.List<java.lang.reflect.Method> listRelationMethods = new java.util.ArrayList<>(); - java.util.List<java.lang.reflect.Method> tokenMethods = new java.util.ArrayList<>(); - java.util.Map<java.lang.reflect.Method, String> names = new java.util.HashMap<>(); } syn String DumpAst.toPlantUml() { @@ -550,9 +586,9 @@ aspect GenerationBackend { // tokens are key-value-pairs for (DumpToken token : getDumpTokenList()) { if (token.isDumpValueToken()) { - result.put(cleanLabel(token.label()), makeValueElement(token.asDumpValueToken().getValue())); + result.put(token.getName(), makeValueElement(token.asDumpValueToken().getValue())); } else { - result.put(cleanLabel(token.label()), token.asDumpReferenceToken().getValue().toYaml()); + result.put(token.getName(), token.asDumpReferenceToken().getValue().toYaml()); } } // children @@ -562,9 +598,9 @@ aspect GenerationBackend { list.add(inner.toYaml()); } if (child.isList()) { - result.put(cleanLabel(child.label()), list); + result.put(child.getName(), list); } else if (list.getNumElement() == 1) { - result.put(cleanLabel(child.label()), list.getElement(0)); + result.put(child.getName(), list.getElement(0)); } } // relations @@ -574,9 +610,9 @@ aspect GenerationBackend { list.add(inner.toYaml()); } if (relation.isList()) { - result.put(cleanLabel(relation.label()), list); + result.put(relation.getName(), list); } else if (list.getNumElement() == 1) { - result.put(cleanLabel(relation.label()), list.getElement(0)); + result.put(relation.getName(), list.getElement(0)); } } return result; @@ -593,10 +629,6 @@ aspect GenerationBackend { } } - private String DumpNode.cleanLabel(String originalLabel) { - return originalLabel.replace("()", ""); - } - public class AppendableWriter extends java.io.Writer { private final StringBuilder sb; diff --git a/dumpAst/src/main/jastadd/Navigation.jrag b/dumpAst/src/main/jastadd/Navigation.jrag index 0f4687dbcb5af2c3f222ef43c9b957d79d3cf780..8783503bbcac55eac737c6777227a7b9bd18b70f 100644 --- a/dumpAst/src/main/jastadd/Navigation.jrag +++ b/dumpAst/src/main/jastadd/Navigation.jrag @@ -70,4 +70,33 @@ aspect Navigation { }); return result; } + + // === Method naviagtion === + coll java.util.List<SingleChildMethod> ClassAnalysisResult.singleChildMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; + SingleChildMethod contributes this to ClassAnalysisResult.singleChildMethods(); + + coll java.util.List<ListChildMethod> ClassAnalysisResult.listChildMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; + ListChildMethod contributes this to ClassAnalysisResult.listChildMethods(); + + coll java.util.List<SingleRelationMethod> ClassAnalysisResult.singleRelationMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; + SingleRelationMethod contributes this to ClassAnalysisResult.singleRelationMethods(); + + coll java.util.List<ListRelationMethod> ClassAnalysisResult.listRelationMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; + ListRelationMethod contributes this to ClassAnalysisResult.listRelationMethods(); + + coll java.util.List<TokenMethod> ClassAnalysisResult.tokenMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult; + TokenMethod contributes this to ClassAnalysisResult.tokenMethods(); + + // --- isAttributeMethod --- + syn boolean TokenMethod.isAttributeMethod() = false; + eq AttributeMethod.isAttributeMethod() = true; + + // --- isNTASingleChildMethod --- + syn boolean SingleChildMethod.isNTASingleChildMethod() = false; + eq NTASingleChildMethod.isNTASingleChildMethod() = true; + + // --- isNTAListChildMethod --- + syn boolean ListChildMethod.isNTAListChildMethod() = false; + eq NTAListChildMethod.isNTAListChildMethod() = true; + } diff --git a/dumpAst/src/main/jastadd/Printing.jrag b/dumpAst/src/main/jastadd/Printing.jrag index a2ba999560eb4f412895b9236016581affd2647f..362451e3dfd3873f481ef6939793ba04c5dc7628 100644 --- a/dumpAst/src/main/jastadd/Printing.jrag +++ b/dumpAst/src/main/jastadd/Printing.jrag @@ -16,9 +16,9 @@ aspect Printing { syn String DumpNode.name() = getName(); // might change in the future // --- label --- - syn String DumpChildNode.label() = getName(); + syn String DumpChildNode.label() = getName() + (getComputed() ? "()" : ""); syn String DumpRelation.label() = getName(); - syn String DumpToken.label() = getName(); + syn String DumpToken.label() = getName() + (getComputed() ? "()" : ""); syn String DumpNode.label() = getLabel(); // --- bothVisible --- diff --git a/dumpAst/src/main/resources/dumpAstVersion.properties b/dumpAst/src/main/resources/dumpAstVersion.properties index 6ce4cb95a493166c5aea2af024e01a7da6fbaf15..e84543a0b98ea95827bbef389daf25d35812cbc0 100644 --- a/dumpAst/src/main/resources/dumpAstVersion.properties +++ b/dumpAst/src/main/resources/dumpAstVersion.properties @@ -1,2 +1,2 @@ -#Sat Sep 26 11:23:37 CEST 2020 -version=0.3.2 +#Sat Oct 10 18:35:22 CEST 2020 +version=0.3.3 diff --git a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java index 7973addd20f1ba2afbd78626af9e2927b4c26546..7a6a360efd8bcb6e56b6438f9c07cd4c229d320d 100644 --- a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java +++ b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java @@ -29,7 +29,7 @@ public class TestIncluded { List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeAttributes("simpleAttr")); assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactly(ROOT_NAME); DumpNode actualRoot = TestUtils.findByName(nodes, ROOT_NAME); - assertThat(valueTokens(actualRoot)).containsOnly(entry("Name", ROOT_NAME), entry("simpleAttr()", 42)); + assertThat(valueTokens(actualRoot)).containsOnly(entry("Name", ROOT_NAME), entry("simpleAttr", 42)); } @Test @@ -49,7 +49,7 @@ public class TestIncluded { List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeAttributes("referenceAttr")); assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactly(ROOT_NAME, A_NAME); DumpNode actualRoot = TestUtils.findByName(nodes, ROOT_NAME); - assertThatMapOf(referenceTokens(actualRoot)).containsOnly(tuple("referenceAttr()", A_NAME)); + assertThatMapOf(referenceTokens(actualRoot)).containsOnly(tuple("referenceAttr", A_NAME)); } @Test @@ -62,14 +62,14 @@ public class TestIncluded { assertThatMapOf(normalChildren(actualC)).isEmpty(); } - @Test + @Test public void testNormalNTAIncluded() { Root root = createRoot(null, createC(C_NAME)); - List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeNonterminalAttributes("getCalculated")); + List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeNonterminalAttributes("Calculated")); assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactly(ROOT_NAME, C_NAME, "Calculated-" + C_NAME); DumpNode actualC = TestUtils.findByName(nodes, C_NAME); - assertThatMapOf(normalChildren(actualC)).containsOnly(tuple("getCalculated()", "Calculated-" + C_NAME)); + assertThatMapOf(normalChildren(actualC)).containsOnly(tuple("Calculated", "Calculated-" + C_NAME)); } @Test @@ -83,15 +83,13 @@ public class TestIncluded { } - @Disabled("NTA lists not working at the moment") @Test public void testListNTAIncluded() { - // TODO make the test not failing Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeNonterminalAttributes("AlsoCalculated")); assertThat(nodes).flatExtracting(NAME_EXTRACTOR).containsExactly(ROOT_NAME, C_NAME, "AlsoCalculated-" + C_NAME); DumpNode actualC = TestUtils.findByName(nodes, C_NAME); - assertThatMapOf(listChildren(actualC), "getAlsoCalculated()").containsExactly("AlsoCalculated-" + C_NAME); + assertThatMapOf(listChildren(actualC), "AlsoCalculated").containsExactly("AlsoCalculated-" + C_NAME); } } diff --git a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java index b5b1fcf332a68076bb36cefb6fc31e1e82e303f9..89e7e7dccb5dbaf456c404bd6210979877500e73 100644 --- a/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java +++ b/testDumper/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java @@ -150,7 +150,7 @@ public class TestUtils { // then it is a DumpNormalChildNode DumpNode target = ((DumpNormalChildNode) dumpChildNode).getDumpNode(); if (!target.getInvisible()) { - result.put(dumpChildNode.label(), target); + result.put(dumpChildNode.getName(), target); } } } @@ -164,7 +164,7 @@ public class TestUtils { // then it is a DumpListChildNode ((DumpListChildNode) dumpChildNode).getInnerDumpNodeList().forEach(inner -> { if (!inner.getDumpNode().getInvisible()) { - result.computeIfAbsent(dumpChildNode.label(), key -> new ArrayList<>()).add(inner.getDumpNode()); + result.computeIfAbsent(dumpChildNode.getName(), key -> new ArrayList<>()).add(inner.getDumpNode()); } }); } @@ -179,7 +179,7 @@ public class TestUtils { // then it is a DumpNormalRelation DumpNode target = ((DumpNormalRelation) dumpRelation).getDumpNode(); if (!target.getInvisible()) { - result.put(dumpRelation.label(), target); + result.put(dumpRelation.getName(), target); } } } @@ -193,7 +193,7 @@ public class TestUtils { // then it is a DumpListRelation ((DumpListRelation) dumpRelation).getInnerDumpNodeList().forEach(inner -> { if (!inner.getDumpNode().getInvisible()) { - result.computeIfAbsent(dumpRelation.label(), key -> new ArrayList<>()).add(inner.getDumpNode()); + result.computeIfAbsent(dumpRelation.getName(), key -> new ArrayList<>()).add(inner.getDumpNode()); } }); } @@ -208,7 +208,7 @@ public class TestUtils { // then it is a DumpReferenceToken DumpNode target = ((DumpReferenceToken) dumpToken).getValue(); if (!target.getInvisible()) { - result.put(dumpToken.label(), target); + result.put(dumpToken.getName(), target); } } } @@ -221,7 +221,7 @@ public class TestUtils { if (dumpToken.isDumpValueToken()) { // then it is a DumpValueToken DumpValueToken dumpValueToken = (DumpValueToken) dumpToken; - result.put(dumpValueToken.label(), dumpValueToken.getValue()); + result.put(dumpValueToken.getName(), dumpValueToken.getValue()); } } return result;