From 8dd7a3fa7d1ac8602e7f0d7cf8d1631e5c5a55bd Mon Sep 17 00:00:00 2001
From: rschoene <rene.schoene@tu-dresden.de>
Date: Mon, 29 Nov 2021 16:35:21 +0100
Subject: [PATCH] working on concise grammar

- resolve todos, mainly renaming
- fix negative test cases
- run negative test cases also in CI
- move generateAspect into Compiler.java
---
 .gitlab-ci.yml                                |   1 +
 .../main/jastadd/intermediate/Generation.jadd | 120 ++++++------------
 .../jastadd/intermediate/MustacheNodes.relast |  16 +--
 .../main/jastadd/parser/ParserRewrites.jrag   |   2 +-
 .../jastadd/ragconnect/compiler/Compiler.java |  34 ++++-
 .../resources/dependencyDefinition.mustache   |   2 +-
 .../src/main/resources/handler.mustache       |   2 +-
 .../src/main/resources/mqtt.mustache          |   2 +-
 .../main/resources/receiveDefinition.mustache |  16 +--
 .../main/resources/sendDefinition.mustache    |  36 +++---
 .../main/resources/tokenComponent.mustache    |   8 +-
 .../src/test/01-input/errors/Part.expected    |  14 +-
 .../test/01-input/errors/Standard.expected    |  14 +-
 13 files changed, 123 insertions(+), 144 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3325755..8ab105a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -38,6 +38,7 @@ test:
   needs:
     - build
   script:
+    - ./gradlew --console=plain --no-daemon test
     - ./gradlew --console=plain --no-daemon allTests
   artifacts:
     when: always
diff --git a/ragconnect.base/src/main/jastadd/intermediate/Generation.jadd b/ragconnect.base/src/main/jastadd/intermediate/Generation.jadd
index 3b0137e..d52f627 100644
--- a/ragconnect.base/src/main/jastadd/intermediate/Generation.jadd
+++ b/ragconnect.base/src/main/jastadd/intermediate/Generation.jadd
@@ -1,9 +1,9 @@
 /*
 Design considerations
-- [OLD] InnerMappingDefinition needed for iteration attribute (first, last) - not possible with list-relation
-- [NEW in 1.0.0] no complete intermediate structure, but instead single nodes where applicable
+- InnerMappingDefinition needed for iteration attribute (first, last) - not possible with list-relation
+- no complete intermediate structure, but instead single nodes where applicable/needed
 */
-aspect NewStuff {
+aspect AttributesForMustache {
   syn List<TypeComponent> RagConnect.rootTypeComponents() {
     List<TypeComponent> result = new ArrayList<>();
     for (Component child : rootNode.getComponentList()) {
@@ -15,13 +15,10 @@ aspect NewStuff {
   }
   syn boolean RagConnect.hasRootTypeComponents() = !rootTypeComponents().isEmpty();
 
-//  inh boolean TypeComponent.isFirst();
-//  eq RagConnect.getRootTypeComponentList(int i).isFirst() = i == 0;
-
-  syn String RagConnect.closeMethod() = "ragconnectCloseConnections";
+  syn String RagConnect.closeMethodName() = "ragconnectCloseConnections";
   syn String RagConnect.mqttHandlerAttribute() = "_mqttHandler";
   syn String RagConnect.mqttHandlerField() = "_mqttHandler";
-  syn String RagConnect.mqttSetupWaitUntilReadyMethod() = "ragconnectSetupMqttWaitUntilReady";
+  syn String RagConnect.mqttSetupWaitUntilReadyMethodName() = "ragconnectSetupMqttWaitUntilReady";
 
   syn String RagConnect.restHandlerAttribute() = "_restHandler";
   syn String RagConnect.restHandlerField() = "_restHandler";
@@ -47,20 +44,20 @@ aspect NewStuff {
   syn String EndpointDefinition.preemptiveExpectedValue() = toMustache().preemptiveExpectedValue();
   syn String EndpointDefinition.preemptiveReturn() = toMustache().preemptiveReturn();
   syn String EndpointDefinition.firstInputVarName() = toMustache().firstInputVarName();
-  syn String EndpointDefinition.updateMethod() = toMustache().updateMethod();
-  syn String EndpointDefinition.writeMethod() = toMustache().writeMethod();
+  syn String EndpointDefinition.updateMethodName() = toMustache().updateMethodName();
+  syn String EndpointDefinition.writeMethodName() = toMustache().writeMethodName();
 
   syn String EndpointDefinition.parentTypeName() = getEndpointTarget().parentTypeName();
   syn String EndpointDefinition.entityName() = getEndpointTarget().entityName();
-  syn String EndpointDefinition.getterMethod() = getEndpointTarget().getterMethod();
+  syn String EndpointDefinition.getterMethodName() = getEndpointTarget().getterMethodName();
 
   syn String EndpointDefinition.uniqueSuffix() = getSend() ? "Send" : "Receive";
 
   syn String EndpointDefinition.connectParameterName() = "uriString";
-  syn String EndpointDefinition.connectMethod() = "connect" + entityName();
-  syn String EndpointDefinition.internalConnectMethod() = "_internal_" + connectMethod();
+  syn String EndpointDefinition.connectMethodName() = "connect" + entityName();
+  syn String EndpointDefinition.internalConnectMethodName() = "_internal_" + connectMethodName();
 
-  syn String EndpointDefinition.disconnectMethod() {
+  syn String EndpointDefinition.disconnectMethodName() {
     // if both (send and receive) are defined for an endpoint, ensure methods with different names
     String extra;
     if (getEndpointTarget().isTokenEndpointTarget()) {
@@ -72,7 +69,7 @@ aspect NewStuff {
     }
     return "disconnect" + extra + entityName();
   }
-  // TODO [OLD] potentially dangerous because asXEndpointDefinition can return null
+  // token and type are potentially dangerous because asXEndpointTarget can return null
   syn TokenComponent EndpointDefinition.token() = getEndpointTarget().asTokenEndpointTarget().getToken();
   syn TypeComponent EndpointDefinition.type() = getEndpointTarget().asTypeEndpointTarget().getType();
   syn String EndpointDefinition.tokenName() = token().getName();
@@ -85,7 +82,7 @@ aspect NewStuff {
   syn MInnerMappingDefinition MEndpointDefinition.lastDefinition() = getInnerMappingDefinition(getNumInnerMappingDefinition() - 1);
   syn String EndpointDefinition.lastDefinitionToType() = lastDefinition().toType();
   syn String EndpointDefinition.lastResult() = lastDefinition().outputVarName();
-  // TODO check, whether this works
+
   inh boolean MInnerMappingDefinition.isLast();
   eq MEndpointDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
   eq MEndpointDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : getInnerMappingDefinition(i - 1).outputVarName();
@@ -112,45 +109,42 @@ aspect NewStuff {
     return preemptiveExpectedValue() + " != null ? " + preemptiveExpectedValue() + ".equals(" + lastResult() + ") : " + lastResult() + " == null";
   }
 
-  // TODO rename sender to senderName
-  syn String EndpointDefinition.sender() = getEndpointTarget().senderName(); // only needed for send endpoints
+  syn String EndpointDefinition.senderName() = getEndpointTarget().senderName(); // only needed for send endpoints
   syn String EndpointTarget.senderName();
   eq TokenEndpointTarget.senderName() = "_sender_" + getToken().getName();
   eq TypeEndpointTarget.senderName() = "_sender_" + getType().getName();
-  syn String EndpointDefinition.lastValue() = sender() + ".lastValue"; // only needed for send endpoints
+  syn String EndpointDefinition.lastValue() = senderName() + ".lastValue"; // only needed for send endpoints
   syn String MEndpointDefinition.lastValue() = getEndpointDefinition().lastValue();
 
-  // TODO rename getterMethod to getterMethodName
-  syn String EndpointTarget.getterMethod();
+  syn String EndpointTarget.getterMethodName();
   syn String EndpointTarget.parentTypeName();
   syn String EndpointTarget.entityName();
-  eq TokenEndpointTarget.getterMethod() = "get" + getToken().getName();
+  eq TokenEndpointTarget.getterMethodName() = "get" + getToken().getName();
   eq TokenEndpointTarget.parentTypeName() = getToken().containingTypeDecl().getName();
   eq TokenEndpointTarget.entityName() = getToken().getName();
-  eq TypeEndpointTarget.getterMethod() = "get" + getType().getName() + (typeIsList() ? "List" : "");
+  eq TypeEndpointTarget.getterMethodName() = "get" + getType().getName() + (typeIsList() ? "List" : "");
   eq TypeEndpointTarget.parentTypeName() = getType().containingTypeDecl().getName();
   eq TypeEndpointTarget.entityName() = getType().getName() + (typeIsList() && !containingEndpointDefinition().getIndexBasedListAccess() ? "List" : "");
 
   // only for token + send
-  // TODO rename tokenResetMethod to tokenResetMethodName
-  syn String EndpointDefinition.tokenResetMethod() = getterMethod() + "_reset";
+  syn String EndpointDefinition.tokenResetMethodName() = getterMethodName() + "_reset";
 
   // only for type + receive
   syn String EndpointDefinition.resolveInListMethodName() = "_ragconnect_resolve" + entityName() + "InList";
 
-  // --- MMappingDefinition ---
+  // --- MappingDefinition ---
   syn String MappingDefinition.toType() = getToType().prettyPrint();
   syn String MappingDefinition.methodName() = "_apply_" + getID();
   syn String MappingDefinition.fromType() = getFromType().prettyPrint();
   syn boolean MappingDefinition.isUsed() = !effectiveUsedAt().isEmpty();
 
-  // --- MDependencyDefinition ---
+  // --- DependencyDefinition ---
   syn String DependencyDefinition.targetParentTypeName() = getTarget().containingTypeDecl().getName();
-  syn String DependencyDefinition.dependencyMethod() = "add" + capitalize(getID());
+  syn String DependencyDefinition.dependencyMethodName() = "add" + capitalize(getID());
   syn String DependencyDefinition.sourceParentTypeName() = getSource().containingTypeDecl().getName();
   syn String DependencyDefinition.internalRelationPrefix() = "_internal_" + getID();
 
-  // --- MTokenComponent ---
+  // --- TokenComponent ---
   syn String TokenComponent.parentTypeName() = containingTypeDecl().getName();
   syn String TokenComponent.javaType() = effectiveJavaTypeUse().prettyPrint();
   syn String TokenComponent.internalName() = needProxyToken() ? "_internal_" + getName() : externalName();
@@ -203,9 +197,8 @@ aspect NewStuff {
 
   syn JastAddList<MInnerMappingDefinition> EndpointDefinition.innerMappingDefinitions() = toMustache().getInnerMappingDefinitionList();
   syn boolean EndpointDefinition.hasTypeEndpointTarget() = getEndpointTarget().isTypeEndpointTarget();
-}
 
-aspect OldStuff { // copied unchanged, but should work
+  // === OldStuff (copied unchanged, but should work) ===
   // --- EndpointDefinition ---
   syn String EndpointDefinition.idTokenName() = "InternalRagconnectTopicInList";
 
@@ -215,9 +208,9 @@ aspect OldStuff { // copied unchanged, but should work
   syn String MEndpointDefinition.firstInputVarName();
   syn String MEndpointDefinition.parentTypeName() = getEndpointDefinition().parentTypeName();
   syn String MEndpointDefinition.entityName() = getEndpointDefinition().entityName();
-  syn String MEndpointDefinition.updateMethod();
-  syn String MEndpointDefinition.writeMethod();
-  syn String MEndpointDefinition.getterMethod() = getEndpointDefinition().getterMethod();
+  syn String MEndpointDefinition.updateMethodName();
+  syn String MEndpointDefinition.writeMethodName();
+  syn String MEndpointDefinition.getterMethodName() = getEndpointDefinition().getterMethodName();
 
   // --- MInnerMappingDefinition ---
   inh String MInnerMappingDefinition.inputVarName();
@@ -226,72 +219,37 @@ aspect OldStuff { // copied unchanged, but should work
   syn String MInnerMappingDefinition.outputVarName() = "result" + methodName();  // we do not need "_" in between here, because methodName begins with one
 
   // --- MTokenReceiveDefinition ---
-  eq MTokenReceiveDefinition.preemptiveExpectedValue() = getterMethod() + "()";
+  eq MTokenReceiveDefinition.preemptiveExpectedValue() = getterMethodName() + "()";
   eq MTokenReceiveDefinition.preemptiveReturn() = "return;";
   eq MTokenReceiveDefinition.firstInputVarName() = "message";
-  eq MTokenReceiveDefinition.updateMethod() = null;
-  eq MTokenReceiveDefinition.writeMethod() = null;
+  eq MTokenReceiveDefinition.updateMethodName() = null;
+  eq MTokenReceiveDefinition.writeMethodName() = null;
 
   // --- MTokenSendDefinition ---
   eq MTokenSendDefinition.preemptiveExpectedValue() = lastValue();
   eq MTokenSendDefinition.preemptiveReturn() = "return false;";
-  eq MTokenSendDefinition.firstInputVarName() = getterMethod() + "()";
-  eq MTokenSendDefinition.updateMethod() = "_update_" + tokenName();
-  eq MTokenSendDefinition.writeMethod() = "_writeLastValue_" + tokenName();
+  eq MTokenSendDefinition.firstInputVarName() = getterMethodName() + "()";
+  eq MTokenSendDefinition.updateMethodName() = "_update_" + tokenName();
+  eq MTokenSendDefinition.writeMethodName() = "_writeLastValue_" + tokenName();
 
   // MTypeReceiveDefinition
-  eq MTypeReceiveDefinition.preemptiveExpectedValue() = getterMethod() + "()";
+  eq MTypeReceiveDefinition.preemptiveExpectedValue() = getterMethodName() + "()";
   eq MTypeReceiveDefinition.preemptiveReturn() = "return;";
   eq MTypeReceiveDefinition.firstInputVarName() = "message";
-  eq MTypeReceiveDefinition.updateMethod() = null;
-  eq MTypeReceiveDefinition.writeMethod() = null;
+  eq MTypeReceiveDefinition.updateMethodName() = null;
+  eq MTypeReceiveDefinition.writeMethodName() = null;
 
   // MTypeSendDefinition
   eq MTypeSendDefinition.preemptiveExpectedValue() = lastValue();
   eq MTypeSendDefinition.preemptiveReturn() = "return false;";
-  eq MTypeSendDefinition.firstInputVarName() = getterMethod() + "()";
-  eq MTypeSendDefinition.updateMethod() = "_update_" + typeName();
-  eq MTypeSendDefinition.writeMethod() = "_writeLastValue_" + typeName();
+  eq MTypeSendDefinition.firstInputVarName() = getterMethodName() + "()";
+  eq MTypeSendDefinition.updateMethodName() = "_update_" + typeName();
+  eq MTypeSendDefinition.writeMethodName() = "_writeLastValue_" + typeName();
 }
 
 aspect AspectGeneration {
   // --- rootNodeName ---
   syn String ASTNode.rootNodeName() = rootNode.getName();
-
-  public String RagConnect.generateAspect(String rootNodeName) {
-    rootNode = getProgram().resolveTypeDecl(rootNodeName);
-    return generateAspect();
-  }
-
-  public String RagConnect.generateAspect() {
-    // TODO move this to Compiler.java
-    // Handler ::= <ClassName> <Construction> <AttributeName> <FieldName> <InUse:boolean>;
-    this.addHandler(new Handler("MqttServerHandler", "new MqttServerHandler(\"RagConnectMQTT\")",
-                                mqttHandlerAttribute(), mqttHandlerField(), usesMqtt));
-    this.addHandler(new Handler("RestServerHandler", "new RestServerHandler(\"RagConnectREST\")",
-                                restHandlerAttribute(), restHandlerField(), usesRest));
-    StringBuilder sb = new StringBuilder();
-    com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() {
-      @Override
-      public com.github.mustachejava.Binding createBinding(String name, final com.github.mustachejava.TemplateContext tc, com.github.mustachejava.Code code) {
-        return new com.github.mustachejava.reflect.GuardedBinding(this, name, tc, code) {
-          @Override
-          protected synchronized com.github.mustachejava.util.Wrapper getWrapper(String name, java.util.List<Object> scopes) {
-            com.github.mustachejava.util.Wrapper wrapper = super.getWrapper(name, scopes);
-            if (wrapper instanceof com.github.mustachejava.reflect.MissingWrapper) {
-              throw new com.github.mustachejava.MustacheException(name + " not found in " + tc);
-            }
-            return wrapper;
-          }
-        };
-      }
-    };
-    com.github.mustachejava.DefaultMustacheFactory mf = new com.github.mustachejava.DefaultMustacheFactory();
-    mf.setObjectHandler(roh);
-    com.github.mustachejava.Mustache m = mf.compile("ragconnect.mustache");
-    m.execute(new java.io.PrintWriter(new org.jastadd.ragconnect.compiler.AppendableWriter(sb)), this);
-    return sb.toString();
-  }
 }
 
 aspect GrammarGeneration {
diff --git a/ragconnect.base/src/main/jastadd/intermediate/MustacheNodes.relast b/ragconnect.base/src/main/jastadd/intermediate/MustacheNodes.relast
index 08b5b50..d7afd2e 100644
--- a/ragconnect.base/src/main/jastadd/intermediate/MustacheNodes.relast
+++ b/ragconnect.base/src/main/jastadd/intermediate/MustacheNodes.relast
@@ -1,6 +1,6 @@
-//MRagConnect ::= TokenReceiveDefinition:MTokenReceiveDefinition* TokenSendDefinition:MTokenSendDefinition* TypeReceiveDefinition:MTypeReceiveDefinition* TypeSendDefinition:MTypeSendDefinition* ;
-
 abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
+rel MEndpointDefinition.EndpointDefinition -> EndpointDefinition;
+
 abstract MTokenEndpointDefinition : MEndpointDefinition;
 MTokenReceiveDefinition : MTokenEndpointDefinition;
 MTokenSendDefinition : MTokenEndpointDefinition;
@@ -8,17 +8,5 @@ abstract MTypeEndpointDefinition : MEndpointDefinition;
 MTypeReceiveDefinition : MTypeEndpointDefinition;
 MTypeSendDefinition : MTypeEndpointDefinition;
 
-//MMappingDefinition;
 MInnerMappingDefinition;
-//MDependencyDefinition;
-//MTypeComponent;
-//MTokenComponent;
-
-//rel MRagConnect.RagConnect -> RagConnect;
 rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
-rel MEndpointDefinition.EndpointDefinition -> EndpointDefinition;
-//rel MMappingDefinition.MappingDefinition -> MappingDefinition;
-//rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition;
-//rel MTypeComponent.TypeComponent -> TypeComponent;
-//rel MTokenComponent.TokenComponent -> TokenComponent;
-//rel MTokenComponent.DependencyDefinition* -> MDependencyDefinition;
diff --git a/ragconnect.base/src/main/jastadd/parser/ParserRewrites.jrag b/ragconnect.base/src/main/jastadd/parser/ParserRewrites.jrag
index 4d9cd9d..bbf0c11 100644
--- a/ragconnect.base/src/main/jastadd/parser/ParserRewrites.jrag
+++ b/ragconnect.base/src/main/jastadd/parser/ParserRewrites.jrag
@@ -15,7 +15,7 @@ aspect ParserRewrites {
   }
 
   eq UntypedEndpointTarget.senderName() = "<untyped.senderName>";
-  eq UntypedEndpointTarget.getterMethod() = "<untyped.getterMethod>";
+  eq UntypedEndpointTarget.getterMethodName() = "<untyped.getterMethodName>";
   eq UntypedEndpointTarget.parentTypeName() = "<untyped.parentTypeName>";
   eq UntypedEndpointTarget.entityName() = "<untyped.entityName>";
   eq UntypedEndpointTarget.isAlreadyDefined() = false;
diff --git a/ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java b/ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java
index b07429e..1f57a7a 100644
--- a/ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java
+++ b/ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java
@@ -113,7 +113,8 @@ public class Compiler extends AbstractCompiler {
       Path outputFile = getConfiguration().outputDir().toPath().resolve(grammarFile.getFileName());
       writeToFile(outputFile, grammarFile.generateAbstractGrammar());
     }
-    writeToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.jadd"), ragConnect.generateAspect(optionRootNode.value()));
+    writeToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.jadd"),
+        generateAspect(ragConnect, optionRootNode.value()));
     return 0;
   }
 
@@ -292,4 +293,35 @@ public class Compiler extends AbstractCompiler {
 //    System.out.println("Options:");
 //    System.out.print(commandLine.printOptionHelp());
 //  }
+
+
+  public String generateAspect(RagConnect ragConnectSpec, String rootNodeName) {
+    ASTNode.rootNode = ragConnectSpec.getProgram().resolveTypeDecl(rootNodeName);
+    // Handler ::= <ClassName> <Construction> <AttributeName> <FieldName> <InUse:boolean>;
+    ragConnectSpec.addHandler(new Handler("MqttServerHandler", "new MqttServerHandler(\"RagConnectMQTT\")",
+        ragConnectSpec.mqttHandlerAttribute(), ragConnectSpec.mqttHandlerField(), ASTNode.usesMqtt));
+    ragConnectSpec.addHandler(new Handler("RestServerHandler", "new RestServerHandler(\"RagConnectREST\")",
+        ragConnectSpec.restHandlerAttribute(), ragConnectSpec.restHandlerField(), ASTNode.usesRest));
+    StringBuilder sb = new StringBuilder();
+    com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() {
+      @Override
+      public com.github.mustachejava.Binding createBinding(String name, final com.github.mustachejava.TemplateContext tc, com.github.mustachejava.Code code) {
+        return new com.github.mustachejava.reflect.GuardedBinding(this, name, tc, code) {
+          @Override
+          protected synchronized com.github.mustachejava.util.Wrapper getWrapper(String name, java.util.List<Object> scopes) {
+            com.github.mustachejava.util.Wrapper wrapper = super.getWrapper(name, scopes);
+            if (wrapper instanceof com.github.mustachejava.reflect.MissingWrapper) {
+              throw new com.github.mustachejava.MustacheException(name + " not found in " + tc);
+            }
+            return wrapper;
+          }
+        };
+      }
+    };
+    com.github.mustachejava.DefaultMustacheFactory mf = new com.github.mustachejava.DefaultMustacheFactory();
+    mf.setObjectHandler(roh);
+    com.github.mustachejava.Mustache m = mf.compile("ragconnect.mustache");
+    m.execute(new java.io.PrintWriter(new org.jastadd.ragconnect.compiler.AppendableWriter(sb)), ragConnectSpec);
+    return sb.toString();
+  }
 }
diff --git a/ragconnect.base/src/main/resources/dependencyDefinition.mustache b/ragconnect.base/src/main/resources/dependencyDefinition.mustache
index 0ab8d55..8919350 100644
--- a/ragconnect.base/src/main/resources/dependencyDefinition.mustache
+++ b/ragconnect.base/src/main/resources/dependencyDefinition.mustache
@@ -1,3 +1,3 @@
-public void {{targetParentTypeName}}.{{dependencyMethod}}({{sourceParentTypeName}} source) {
+public void {{targetParentTypeName}}.{{dependencyMethodName}}({{sourceParentTypeName}} source) {
   add{{internalRelationPrefix}}Source(source);
 }
diff --git a/ragconnect.base/src/main/resources/handler.mustache b/ragconnect.base/src/main/resources/handler.mustache
index 24a87dc..874eba4 100644
--- a/ragconnect.base/src/main/resources/handler.mustache
+++ b/ragconnect.base/src/main/resources/handler.mustache
@@ -9,7 +9,7 @@ aspect RagConnectHandler {
   syn {{ClassName}} {{rootNodeName}}.{{AttributeName}}() = {{FieldName}};
   {{/InUse}}
 {{/Handlers}}
-  public void {{rootNodeName}}.{{closeMethod}}() {
+  public void {{rootNodeName}}.{{closeMethodName}}() {
     {{#Handlers}}
     {{#InUse}}{{FieldName}}.close();{{/InUse}}
     {{/Handlers}}
diff --git a/ragconnect.base/src/main/resources/mqtt.mustache b/ragconnect.base/src/main/resources/mqtt.mustache
index f12cb89..5561c2d 100644
--- a/ragconnect.base/src/main/resources/mqtt.mustache
+++ b/ragconnect.base/src/main/resources/mqtt.mustache
@@ -1,5 +1,5 @@
 aspect MQTT {
-  public void {{rootNodeName}}.{{mqttSetupWaitUntilReadyMethod}}(long time, java.util.concurrent.TimeUnit unit) {
+  public void {{rootNodeName}}.{{mqttSetupWaitUntilReadyMethodName}}(long time, java.util.concurrent.TimeUnit unit) {
     {{mqttHandlerField}}.setupWaitUntilReady(time, unit);
   }
 }
diff --git a/ragconnect.base/src/main/resources/receiveDefinition.mustache b/ragconnect.base/src/main/resources/receiveDefinition.mustache
index 347d3d1..379633d 100644
--- a/ragconnect.base/src/main/resources/receiveDefinition.mustache
+++ b/ragconnect.base/src/main/resources/receiveDefinition.mustache
@@ -23,7 +23,7 @@ private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) {
  * @return true if connect was successful, false otherwise
  * @throws java.io.IOException if connect failed
  */
-public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterName}}{{#typeIsList}}{{#IndexBasedListAccess}}{{^WithAdd}}, int index{{/WithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}) throws java.io.IOException {
+public boolean {{parentTypeName}}.{{connectMethodName}}(String {{connectParameterName}}{{#typeIsList}}{{#IndexBasedListAccess}}{{^WithAdd}}, int index{{/WithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}) throws java.io.IOException {
   java.util.function.BiConsumer<String, byte[]> consumer = (topic, message) -> {
     {{> mappingApplication}}
 {{#loggingEnabledForReads}}
@@ -34,7 +34,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
  {{#typeIsList}}
   {{^IndexBasedListAccess}}
    {{#WithAdd}}
-    {{getterMethod}}().addAll({{lastResult}});
+    {{getterMethodName}}().addAll({{lastResult}});
    {{/WithAdd}}
    {{^WithAdd}}
     set{{entityName}}({{lastResult}});
@@ -43,7 +43,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
   {{#IndexBasedListAccess}}
     {{lastResult}}.set{{idTokenName}}(topic);
    {{#WithAdd}}
-    {{getterMethod}}().add({{lastResult}});
+    {{getterMethodName}}().add({{lastResult}});
    {{/WithAdd}}
    {{^WithAdd}}
     set{{entityName}}({{lastResult}}, index);
@@ -58,7 +58,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
     set{{entityName}}({{lastResult}});
 {{/hasTypeEndpointTarget}}
   };
-  return {{internalConnectMethod}}({{connectParameterName}}, consumer);
+  return {{internalConnectMethodName}}({{connectParameterName}}, consumer);
 }
 
 {{#typeIsList}}{{#IndexBasedListAccess}}{{^WithAdd}}
@@ -68,7 +68,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
  * @return true if connect was successful, false otherwise
  * @throws java.io.IOException if connect failed
 */
-public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterName}}) throws java.io.IOException {
+public boolean {{parentTypeName}}.{{connectMethodName}}(String {{connectParameterName}}) throws java.io.IOException {
   java.util.function.BiConsumer<String, byte[]> consumer = (topic, message) -> {
     {{> mappingApplication}}
 {{#loggingEnabledForReads}}
@@ -82,11 +82,11 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
       set{{entityName}}({{lastResult}}, resolvedIndex);
     }
   };
-  return {{internalConnectMethod}}({{connectParameterName}}, consumer);
+  return {{internalConnectMethodName}}({{connectParameterName}}, consumer);
 }
 {{/WithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}
 
-private boolean {{parentTypeName}}.{{internalConnectMethod}}(String {{connectParameterName}},
+private boolean {{parentTypeName}}.{{internalConnectMethodName}}(String {{connectParameterName}},
     java.util.function.BiConsumer<String, byte[]> consumer) throws java.io.IOException {
   {{>handleUri}}
   RagConnectToken connectToken = new RagConnectToken(uri, "{{entityName}}");
@@ -115,7 +115,7 @@ private boolean {{parentTypeName}}.{{internalConnectMethod}}(String {{connectPar
   return success;
 }
 
-public boolean {{parentTypeName}}.{{disconnectMethod}}(String {{connectParameterName}}) throws java.io.IOException {
+public boolean {{parentTypeName}}.{{disconnectMethodName}}(String {{connectParameterName}}) throws java.io.IOException {
   {{>handleUri}}
   java.util.List<RagConnectToken> connectTokens = connectTokenMap.removeAll(this, true, uri, "{{entityName}}");
   if (connectTokens.isEmpty()) {
diff --git a/ragconnect.base/src/main/resources/sendDefinition.mustache b/ragconnect.base/src/main/resources/sendDefinition.mustache
index 5cee6a4..a07265f 100644
--- a/ragconnect.base/src/main/resources/sendDefinition.mustache
+++ b/ragconnect.base/src/main/resources/sendDefinition.mustache
@@ -1,6 +1,6 @@
-private RagConnectPublisher {{parentTypeName}}.{{sender}} = new RagConnectPublisher();
+private RagConnectPublisher {{parentTypeName}}.{{senderName}} = new RagConnectPublisher();
 
-public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterName}}, boolean writeCurrentValue) throws java.io.IOException {
+public boolean {{parentTypeName}}.{{connectMethodName}}(String {{connectParameterName}}, boolean writeCurrentValue) throws java.io.IOException {
   {{>handleUri}}
   RagConnectToken connectToken = new RagConnectToken(uri, "{{entityName}}");
   boolean success;
@@ -9,15 +9,15 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
     case "mqtt":
       final MqttHandler handler = {{mqttHandlerAttribute}}().resolveHandler(uri);
       final String topic = {{mqttHandlerAttribute}}().extractTopic(uri);
-      {{sender}}.add(() -> {
+      {{senderName}}.add(() -> {
         {{#loggingEnabledForWrites}}
-        System.out.println("[Send] {{entityName}} = " + {{getterMethod}}() + " -> " + {{connectParameterName}});
+        System.out.println("[Send] {{entityName}} = " + {{getterMethodName}}() + " -> " + {{connectParameterName}});
         {{/loggingEnabledForWrites}}
         handler.publish(topic, {{lastValue}});
         }, connectToken);
-      {{updateMethod}}();
+      {{updateMethodName}}();
       if (writeCurrentValue) {
-        {{writeMethod}}();
+        {{writeMethodName}}();
       }
       success = true;
       break;
@@ -25,7 +25,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
   {{#usesRest}}
     case "rest":
       success = {{restHandlerAttribute}}().newGETConnection(connectToken, () -> {
-        {{updateMethod}}();
+        {{updateMethodName}}();
         return new String({{lastValue}});
       });
       break;
@@ -37,9 +37,9 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
   if (success) {
     connectTokenMap.add(this, false, connectToken);
     {{#incrementalOptionActive}}
-    _ragConnectObserver().add(connectToken, this, "{{getterMethod}}", () -> {
-      if (this.{{updateMethod}}()) {
-        this.{{writeMethod}}();
+    _ragConnectObserver().add(connectToken, this, "{{getterMethodName}}", () -> {
+      if (this.{{updateMethodName}}()) {
+        this.{{writeMethodName}}();
       }
     });
     {{/incrementalOptionActive}}
@@ -47,7 +47,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
   return success;
 }
 
-public boolean {{parentTypeName}}.{{disconnectMethod}}(String {{connectParameterName}}) throws java.io.IOException {
+public boolean {{parentTypeName}}.{{disconnectMethodName}}(String {{connectParameterName}}) throws java.io.IOException {
   {{>handleUri}}
   java.util.List<RagConnectToken> connectTokens = connectTokenMap.removeAll(this, false, uri, "{{entityName}}");
   if (connectTokens.isEmpty()) {
@@ -61,7 +61,7 @@ public boolean {{parentTypeName}}.{{disconnectMethod}}(String {{connectParameter
   switch (scheme) {
   {{#usesMqtt}}
     case "mqtt":
-      disconnectingMethod = {{sender}}::remove;
+      disconnectingMethod = {{senderName}}::remove;
       break;
   {{/usesMqtt}}
   {{#usesRest}}
@@ -80,16 +80,16 @@ public boolean {{parentTypeName}}.{{disconnectMethod}}(String {{connectParameter
   return success;
 }
 
-protected boolean {{parentTypeName}}.{{updateMethod}}() {
+protected boolean {{parentTypeName}}.{{updateMethodName}}() {
   {{^shouldSendValue}}
-  {{tokenResetMethod}}();
+  {{tokenResetMethodName}}();
   {{/shouldSendValue}}
   {{> mappingApplication}}
   {{lastValue}} = {{lastResult}};
-  // normally we would return true here. unless no connect method was called so far to initialize {{sender}} yet
-  return {{sender}} != null;
+  // normally we would return true here. unless no connect method was called so far to initialize {{senderName}} yet
+  return {{senderName}} != null;
 }
 
-protected void {{parentTypeName}}.{{writeMethod}}() {
-  {{sender}}.run();
+protected void {{parentTypeName}}.{{writeMethodName}}() {
+  {{senderName}}.run();
 }
diff --git a/ragconnect.base/src/main/resources/tokenComponent.mustache b/ragconnect.base/src/main/resources/tokenComponent.mustache
index bbf364a..f0a79a8 100644
--- a/ragconnect.base/src/main/resources/tokenComponent.mustache
+++ b/ragconnect.base/src/main/resources/tokenComponent.mustache
@@ -3,15 +3,15 @@ public {{parentTypeName}} {{parentTypeName}}.set{{name}}({{javaType}} value) {
   {{#DependencySourceDefinitions}}
   for ({{targetParentTypeName}} target : get{{internalRelationPrefix}}TargetList()) {
     {{#targetEndpointDefinition}}
-    if (target.{{updateMethod}}()) {
-      target.{{writeMethod}}();
+    if (target.{{updateMethodName}}()) {
+      target.{{writeMethodName}}();
     }
     {{/targetEndpointDefinition}}
   }
   {{/DependencySourceDefinitions}}
   {{#normalTokenSendDef}}
-  if ({{updateMethod}}()) {
-    {{writeMethod}}();
+  if ({{updateMethodName}}()) {
+    {{writeMethodName}}();
   }
   {{/normalTokenSendDef}}
   return this;
diff --git a/ragconnect.tests/src/test/01-input/errors/Part.expected b/ragconnect.tests/src/test/01-input/errors/Part.expected
index 70ea4a4..86bb6dd 100644
--- a/ragconnect.tests/src/test/01-input/errors/Part.expected
+++ b/ragconnect.tests/src/test/01-input/errors/Part.expected
@@ -1,11 +1,11 @@
-Part1.connect Line 3, column 1: Receive definition already defined for DoubledValue
-Part1.connect Line 4, column 1: Receive definition already defined for DoubledValue
+Part1.connect Line 3, column 1: Endpoint definition already defined for B.DoubledValue
+Part1.connect Line 4, column 1: Endpoint definition already defined for B.DoubledValue
 Part1.connect Line 10, column 1: Receiving target token must not be an NTA token!
 Part1.connect Line 13, column 1: No suitable default mapping found for type java.util.List
-Part1.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the Token (String)!
-Part1.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the Token (String)!
-Part1.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the Token (String)!
-Part2.connect Line 5, column 1: Send definition already defined for DoubledValue
-Part2.connect Line 6, column 1: Send definition already defined for DoubledValue
+Part1.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the token (String)!
+Part1.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the token (String)!
+Part1.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the token (String)!
+Part2.connect Line 5, column 1: Endpoint definition already defined for C.DoubledValue
+Part2.connect Line 6, column 1: Endpoint definition already defined for C.DoubledValue
 Part2.connect Line 17, column 1: The name of a dependency definition must not be equal to a list-node on the source
 Part2.connect Line 22, column 1: Dependency definition already defined for D with name DoubledValue
diff --git a/ragconnect.tests/src/test/01-input/errors/Standard.expected b/ragconnect.tests/src/test/01-input/errors/Standard.expected
index 3ee6605..2e14612 100644
--- a/ragconnect.tests/src/test/01-input/errors/Standard.expected
+++ b/ragconnect.tests/src/test/01-input/errors/Standard.expected
@@ -1,11 +1,11 @@
-Standard.connect Line 3, column 1: Receive definition already defined for DoubledValue
-Standard.connect Line 4, column 1: Receive definition already defined for DoubledValue
+Standard.connect Line 3, column 1: Endpoint definition already defined for B.DoubledValue
+Standard.connect Line 4, column 1: Endpoint definition already defined for B.DoubledValue
 Standard.connect Line 10, column 1: Receiving target token must not be an NTA token!
 Standard.connect Line 13, column 1: No suitable default mapping found for type java.util.List
-Standard.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the Token (String)!
-Standard.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the Token (String)!
-Standard.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the Token (String)!
-Standard.connect Line 39, column 1: Send definition already defined for DoubledValue
-Standard.connect Line 40, column 1: Send definition already defined for DoubledValue
+Standard.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the token (String)!
+Standard.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the token (String)!
+Standard.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the token (String)!
+Standard.connect Line 39, column 1: Endpoint definition already defined for C.DoubledValue
+Standard.connect Line 40, column 1: Endpoint definition already defined for C.DoubledValue
 Standard.connect Line 51, column 1: The name of a dependency definition must not be equal to a list-node on the source
 Standard.connect Line 56, column 1: Dependency definition already defined for D with name DoubledValue
-- 
GitLab