From 3862eede78e9ce50b486cb0fee91f0bcfedaef1f Mon Sep 17 00:00:00 2001
From: rschoene <rene.schoene@tu-dresden.de>
Date: Tue, 21 Jun 2022 14:31:58 +0200
Subject: [PATCH] 1.0.4

- relations with or without rank (configurable)
---
 dumpAst/src/main/jastadd/DumpAst.relast                  | 1 +
 dumpAst/src/main/jastadd/GenerationToYaml.jrag           | 3 +++
 dumpAst/src/main/jastadd/Navigation.jrag                 | 9 +++++++++
 .../inf/st/jastadd/dumpAst/ast/DumpBuilder.java          | 9 +++++++++
 dumpAst/src/main/resources/dumpAst.mustache              | 8 ++++----
 dumpAst/src/main/resources/dumpAstVersion.properties     | 4 ++--
 featureTest/.gitignore                                   | 1 +
 .../inf/st/jastadd/featureTest/FeatureTestMain.java      | 5 ++++-
 8 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/dumpAst/src/main/jastadd/DumpAst.relast b/dumpAst/src/main/jastadd/DumpAst.relast
index e847a08..035dfc4 100644
--- a/dumpAst/src/main/jastadd/DumpAst.relast
+++ b/dumpAst/src/main/jastadd/DumpAst.relast
@@ -62,5 +62,6 @@ StyleInformation ::= <NameMethod:StyleMethod> <BackgroundColorMethod:StyleMethod
 PrintConfig ::= Header*
  <Scale:double>
  <Version>
+ <RelationWithRank:boolean>
  <OrderChildren:boolean> ;
 Header ::= <Value> ;
diff --git a/dumpAst/src/main/jastadd/GenerationToYaml.jrag b/dumpAst/src/main/jastadd/GenerationToYaml.jrag
index a1dd78c..5f3d3b2 100644
--- a/dumpAst/src/main/jastadd/GenerationToYaml.jrag
+++ b/dumpAst/src/main/jastadd/GenerationToYaml.jrag
@@ -137,6 +137,7 @@ aspect GenerationToYaml {
     MappingElement result = super.toYaml(fromRelation);
     // attributes
     result.put("innerNodeName", innerNodeName());
+    result.put("innerNotNull", innerNotNull());
     result.put("outerNodeName", outerNodeName());
     return result;
   }
@@ -169,6 +170,7 @@ aspect GenerationToYaml {
     // attributes
     result.put("bothVisible", bothVisible());
     result.put("innerNodeName", innerNodeName());
+    result.put("innerNotNull", innerNotNull());
     return result;
   }
 
@@ -194,6 +196,7 @@ aspect GenerationToYaml {
     // attributes
     result.put("bothVisible", bothVisible());
     result.put("innerNodeName", innerNodeName());
+    result.put("innerNotNull", innerNotNull());
     result.put("outerNodeName", outerNodeName());
     result.put("label", label());
     return result;
diff --git a/dumpAst/src/main/jastadd/Navigation.jrag b/dumpAst/src/main/jastadd/Navigation.jrag
index 656556f..dc4ce9a 100644
--- a/dumpAst/src/main/jastadd/Navigation.jrag
+++ b/dumpAst/src/main/jastadd/Navigation.jrag
@@ -14,6 +14,10 @@ aspect Navigation {
 
   // --- printConfig ---
   inh PrintConfig BuildConfig.printConfig();
+  inh PrintConfig DumpNode.printConfig();
+  inh PrintConfig DumpNormalRelation.printConfig();
+  inh PrintConfig InnerRelationDumpNode.printConfig();
+  inh PrintConfig DumpReferenceToken.printConfig();
   eq DumpAst.getChild().printConfig() = getPrintConfig();
 
   // --- containingDumpNode ---
@@ -81,6 +85,11 @@ aspect Navigation {
     return result;
   }
 
+  // --- innerNotNull ---
+  syn boolean DumpNormalRelation.innerNotNull() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null;
+  syn boolean DumpReferenceToken.innerNotNull() = !printConfig().getRelationWithRank() && getValue() != null && getValue().getObject() != null;
+  syn boolean InnerRelationDumpNode.innerNotNull() = !printConfig().getRelationWithRank() && getDumpNode() != null && getDumpNode().getObject() != null;
+
   // === Method naviagtion ===
   coll java.util.List<SingleChildMethod> ClassAnalysisResult.singleChildMethods() [new java.util.ArrayList<>()] root ClassAnalysisResult;
   SingleChildMethod contributes this to ClassAnalysisResult.singleChildMethods();
diff --git a/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java b/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java
index 87466ee..424b05a 100644
--- a/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java
+++ b/dumpAst/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java
@@ -80,6 +80,15 @@ public class DumpBuilder {
     return this;
   }
 
+  /**
+   * Let all relations (and reference attributes) influence layouting of nodes (disabled by default).
+   * @return this
+   */
+  public DumpBuilder enableRelationWithRank() {
+    printConfig.setRelationWithRank(true);
+    return this;
+  }
+
   // --- Types ---
 
   /**
diff --git a/dumpAst/src/main/resources/dumpAst.mustache b/dumpAst/src/main/resources/dumpAst.mustache
index 051cd8c..da993c1 100644
--- a/dumpAst/src/main/resources/dumpAst.mustache
+++ b/dumpAst/src/main/resources/dumpAst.mustache
@@ -40,13 +40,13 @@ object "{{{labelAndTextColor}}}" as {{{name}}} {{{stereotypeList}}} {{#backgroun
       {{#isList}}
         {{#InnerRelationDumpNode}}
           {{#bothVisible}}
-{{{outerNodeName}}} .{{#computed}}[#{{{computedColor}}}]{{/computed}}.> {{{innerNodeName}}} : {{{label}}}
+{{{outerNodeName}}} .[#black{{#computed}},#{{{computedColor}}}{{/computed}}{{#innerNotNull}},norank{{/innerNotNull}}].> {{{innerNodeName}}} : {{{label}}}
           {{/bothVisible}}
         {{/InnerRelationDumpNode}}
       {{/isList}}
       {{^isList}}
         {{^isDumpValueToken}}
-{{{outerNodeName}}} .{{#computed}}[#{{{computedColor}}}]{{/computed}}.> {{{innerNodeName}}} : {{{label}}}
+{{{outerNodeName}}} .[#black{{#computed}},#{{{computedColor}}}{{/computed}}{{#innerNotNull}},norank{{/innerNotNull}}].> {{{innerNodeName}}} : {{{label}}}
         {{/isDumpValueToken}}
       {{/isList}}
     {{/invisible}}
@@ -69,13 +69,13 @@ object "{{{labelAndTextColor}}}" as {{{name}}} {{{stereotypeList}}} {{#backgroun
     {{#isList}}
       {{#InnerRelationDumpNode}}
         {{#bothVisible}}
-{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}--> {{{innerNodeName}}} : {{{label}}}
+{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}-{{#innerNotNull}}[norank]{{/innerNotNull}}-> {{{innerNodeName}}} : {{{label}}}
         {{/bothVisible}}
       {{/InnerRelationDumpNode}}
     {{/isList}}
     {{^isList}}
       {{#bothVisible}}
-{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}--> {{{innerNodeName}}} : {{{label}}}
+{{{outerNodeName}}} {{#bidirectional}}<{{/bidirectional}}-{{#innerNotNull}}[norank]{{/innerNotNull}}-> {{{innerNodeName}}} : {{{label}}}
       {{/bothVisible}}
     {{/isList}}
   {{/DumpRelations}}
diff --git a/dumpAst/src/main/resources/dumpAstVersion.properties b/dumpAst/src/main/resources/dumpAstVersion.properties
index bdaf360..eb7274f 100644
--- a/dumpAst/src/main/resources/dumpAstVersion.properties
+++ b/dumpAst/src/main/resources/dumpAstVersion.properties
@@ -1,2 +1,2 @@
-#Mon Jun 13 18:33:49 CEST 2022
-version=1.0.3
+#Tue Jun 21 14:31:38 CEST 2022
+version=1.0.4
diff --git a/featureTest/.gitignore b/featureTest/.gitignore
index 7609b23..464bb11 100644
--- a/featureTest/.gitignore
+++ b/featureTest/.gitignore
@@ -5,3 +5,4 @@ out/
 *.class
 /featureTest.png
 /featureTest.yml
+/featureTest.puml
diff --git a/featureTest/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java b/featureTest/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java
index 1a8177d..eb1cb8c 100644
--- a/featureTest/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java
+++ b/featureTest/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java
@@ -46,13 +46,16 @@ public class FeatureTestMain {
         .read(root)
 //        .customPreamble("hide empty members")
         .skinParam(SkinParamBooleanSetting.Shadowing, false)
+//        .enableRelationWithRank()
         .includeAttributes("referenceAttr"
             , "collectBs"
         )
         .includeNonterminalAttributes("Calculated")
         .includeNonterminalAttributes("AlsoCalculatedListNewSyntax")
         .dumpAsYaml(pathToYaml, true)
-        .dumpAsPNG(pathToPng);
+        .dumpAsPNG(pathToPng)
+        .dumpAsSource(Paths.get("featureTest.puml"))
+    ;
   }
 
   private void m() {
-- 
GitLab