Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!2Resolve "DumpAst Ast nodes without a constructor with parameters are not recognized as such"
Pipeline #12716 passed
...@@ -413,12 +413,9 @@ aspect GenerationBackend { ...@@ -413,12 +413,9 @@ aspect GenerationBackend {
// --- isAstNode --- // --- isAstNode ---
syn boolean DumpNode.isAstNode() { syn boolean DumpNode.isAstNode() {
Class<?> clazz = getObject().getClass(); Class<?> clazz = getObject().getClass();
for (java.lang.reflect.Constructor<?> constructor : clazz.getConstructors()) { for (java.lang.reflect.Method method : clazz.getMethods()) {
for (java.lang.annotation.Annotation annotation : constructor.getAnnotations()) { if ("init$Children".equals(method.getName()) && method.getParameterCount() == 0) {
if (annotation.annotationType().getCanonicalName().startsWith(astNodeAnnotationPrefix()) && return true;
annotation.annotationType().getSimpleName().equals("Constructor")) {
return true;
}
} }
} }
return false; return false;
...@@ -554,9 +551,11 @@ aspect GenerationBackend { ...@@ -554,9 +551,11 @@ aspect GenerationBackend {
} }
@Override @Override
public void flush() {} public void flush() {
}
@Override @Override
public void close() {} public void close() {
}
} }
} }
// testcases with global inclusion/exclusion // testcases with global inclusion/exclusion
Nameable ::= <Name> ; Nameable ::= <Name> ;
Root : Nameable ::= A B* [C] ; Root : Nameable ::= A B* [C];
A : Nameable ::= B MyC:C ; A : Nameable ::= B MyC:C D;
B : Nameable ::= <OtherValue> ; B : Nameable ::= <OtherValue> ;
C : Nameable ::= [A] <Unwanted:int> <RawReference:A> /Calculated:A/ /AlsoCalculated:B*/ ; C : Nameable ::= [A] <Unwanted:int> <RawReference:A> /Calculated:A/ /AlsoCalculated:B*/ ;
SubC : C ::= <RawReference:A> <Unwanted:int> [A] /Calculated:A/ /AlsoCalculated:B*/ ; SubC : C ::= <RawReference:A> <Unwanted:int> [A] /Calculated:A/ /AlsoCalculated:B*/ ;
D;
rel B.oneA -> A ; rel B.oneA -> A ;
rel B.maybeC? -> C ; rel B.maybeC? -> C ;
......
...@@ -2,15 +2,18 @@ package de.tudresden.inf.st.jastadd.testDumper; ...@@ -2,15 +2,18 @@ package de.tudresden.inf.st.jastadd.testDumper;
import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode;
import org.jastadd.testDumper.ast.C; import org.jastadd.testDumper.ast.C;
import org.jastadd.testDumper.ast.D;
import org.jastadd.testDumper.ast.Root; import org.jastadd.testDumper.ast.Root;
import org.jastadd.testDumper.ast.SubC; import org.jastadd.testDumper.ast.SubC;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.List; import java.util.List;
import java.util.Optional;
import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*; import static de.tudresden.inf.st.jastadd.testDumper.TestUtils.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestSimple { public class TestSimple {
...@@ -26,6 +29,14 @@ public class TestSimple { ...@@ -26,6 +29,14 @@ public class TestSimple {
assertEquals(0, actualRoot.getNumDumpRelation()); 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 @Test
public void testOneNormalChild() { public void testOneNormalChild() {
Root root = createRoot(createA(A_NAME), null); Root root = createRoot(createA(A_NAME), null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment