Commit 45b09e3f authored by René Schöne's avatar René Schöne
Browse files

Merge branch...

Merge branch 'bugfix/dumpast-ast-nodes-without-a-constructor-with-parameters-are-not-recognized-as-such' into 'master'

Resolve "DumpAst Ast nodes without a constructor with parameters are not recognized as such"

Closes #6

See merge request jastadd/relast2uml!2
parents 48fc8dff 11e8b42b
Pipeline #12716 passed with stages
in 2 minutes and 28 seconds
......@@ -413,12 +413,9 @@ aspect GenerationBackend {
// --- isAstNode ---
syn boolean DumpNode.isAstNode() {
Class<?> clazz = getObject().getClass();
for (java.lang.reflect.Constructor<?> constructor : clazz.getConstructors()) {
for (java.lang.annotation.Annotation annotation : constructor.getAnnotations()) {
if (annotation.annotationType().getCanonicalName().startsWith(astNodeAnnotationPrefix()) &&
annotation.annotationType().getSimpleName().equals("Constructor")) {
return true;
}
for (java.lang.reflect.Method method : clazz.getMethods()) {
if ("init$Children".equals(method.getName()) && method.getParameterCount() == 0) {
return true;
}
}
return false;
......@@ -554,9 +551,11 @@ aspect GenerationBackend {
}
@Override
public void flush() {}
public void flush() {
}
@Override
public void close() {}
public void close() {
}
}
}
// testcases with global inclusion/exclusion
Nameable ::= <Name> ;
Root : Nameable ::= A B* [C] ;
A : Nameable ::= B MyC:C ;
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 ;
......
......@@ -2,15 +2,18 @@ package de.tudresden.inf.st.jastadd.testDumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode;
import org.jastadd.testDumper.ast.C;
import org.jastadd.testDumper.ast.D;
import org.jastadd.testDumper.ast.Root;
import org.jastadd.testDumper.ast.SubC;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestSimple {
......@@ -26,6 +29,14 @@ public class TestSimple {
assertEquals(0, actualRoot.getNumDumpRelation());
}
@Test void testChildlessNonterminal() {
Root root = createRoot(createA(A_NAME, a -> a.setD(new D())), null);
List<DumpNode> nodes = TestUtils.dumpModel(root);
Optional<DumpNode> optionalCDumpNode = nodes.stream().filter(n -> n.getObject() instanceof D).findFirst();
assertTrue(optionalCDumpNode.isPresent());
assertTrue(optionalCDumpNode.get().isAstNode());
}
@Test
public void testOneNormalChild() {
Root root = createRoot(createA(A_NAME), null);
......
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