Commit 128cf6e3 authored by René Schöne's avatar René Schöne
Browse files

Merge branch '35-cleanup' into 'master'

Resolve "Cleanup"

Closes #35

See merge request jastadd/ros2rag!4
parents 07accb5e 368abea3
...@@ -3,7 +3,7 @@ apply plugin: 'application' ...@@ -3,7 +3,7 @@ apply plugin: 'application'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
mainClassName = 'org.jastadd.ros2rag.compiler.Compiler' mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
repositories { repositories {
jcenter() jcenter()
...@@ -17,12 +17,32 @@ buildscript { ...@@ -17,12 +17,32 @@ buildscript {
} }
dependencies { dependencies {
implementation project(':relast.preprocessor')
implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6' implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2' implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4' runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11' api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
} }
def versionFile = 'src/main/resources/ragConnectVersion.properties'
def oldProps = new Properties()
try {
file(versionFile).withInputStream { stream -> oldProps.load(stream) }
version = oldProps['version']
} catch (e) {
// this happens, if either the properties file is not present, or cannot be read from
throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e)
}
task newVersion() {
doFirst {
def props = new Properties()
props['version'] = value
props.store(file(versionFile).newWriter(), null)
}
}
sourceSets { sourceSets {
main { main {
java.srcDir "src/gen/java" java.srcDir "src/gen/java"
...@@ -37,7 +57,7 @@ test { ...@@ -37,7 +57,7 @@ test {
jar { jar {
manifest { manifest {
attributes "Main-Class": 'org.jastadd.ros2rag.compiler.Compiler' attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
} }
from { from {
...@@ -51,47 +71,47 @@ task relast(type: JavaExec) { ...@@ -51,47 +71,47 @@ task relast(type: JavaExec) {
doFirst { doFirst {
delete "src/gen/jastadd/*.ast" delete "src/gen/jastadd/*.ast"
delete "src/gen/jastadd/Ros2Rag.jadd" delete "src/gen/jastadd/RagConnect.jadd"
delete "src/gen/jastadd/Ros2RagRefResolver.jadd" delete "src/gen/jastadd/RagConnectRefResolver.jadd"
delete "src/gen/jastadd/Ros2RagResolverStubs.jrag" delete "src/gen/jastadd/RagConnectResolverStubs.jrag"
mkdir "src/gen/jastadd/" mkdir "src/gen/jastadd/"
} }
args = [ args = [
"../libs/relast.jar", "../libs/relast.jar",
"../relast.preprocessor/src/main/jastadd/RelAst.relast", "../relast.preprocessor/src/main/jastadd/RelAst.relast",
"./src/main/jastadd/Ros2Rag.relast", "./src/main/jastadd/RagConnect.relast",
"./src/main/jastadd/MustacheNodes.relast", "./src/main/jastadd/MustacheNodes.relast",
"--listClass=java.util.ArrayList", "--listClass=java.util.ArrayList",
"--jastAddList=JastAddList", "--jastAddList=JastAddList",
"--useJastAddNames", "--useJastAddNames",
"--file", "--file",
"--resolverHelper", "--resolverHelper",
"--grammarName=./src/gen/jastadd/Ros2Rag" "--grammarName=./src/gen/jastadd/RagConnect"
] ]
inputs.files file("../libs/relast.jar"), inputs.files file("../libs/relast.jar"),
file("../relast.preprocessor/src/main/jastadd/RelAST.relast"), file("../relast.preprocessor/src/main/jastadd/RelAST.relast"),
file("./src/main/jastadd/Ros2Rag.relast") file("./src/main/jastadd/RagConnect.relast")
file("./src/main/jastadd/MustacheNodes.relast") file("./src/main/jastadd/MustacheNodes.relast")
outputs.files file("./src/gen/jastadd/Ros2Rag.ast"), outputs.files file("./src/gen/jastadd/RagConnect.ast"),
file("./src/gen/jastadd/Ros2Rag.jadd"), file("./src/gen/jastadd/RagConnect.jadd"),
file("./src/gen/jastadd/Ros2RagRefResolver.jadd"), file("./src/gen/jastadd/RagConnectRefResolver.jadd"),
file('./src/gen/jastadd/Ros2RagResolverStubs.jrag') file('./src/gen/jastadd/RagConnectResolverStubs.jrag')
} }
jastadd { jastadd {
configureModuleBuild() configureModuleBuild()
modules { modules {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
module("Ros2Rag") { module("RagConnect") {
java { java {
basedir ".." basedir ".."
include "relast.preprocessor/main/**/*.java" include "relast.preprocessor/main/**/*.java"
include "relast.preprocessor/gen/**/*.java" include "relast.preprocessor/gen/**/*.java"
include "ros2rag.base/src/main/**/*.java" include "ragconnect.base/src/main/**/*.java"
include "ros2rag.base/src/gen/**/*.java" include "ragconnect.base/src/gen/**/*.java"
} }
jastadd { jastadd {
...@@ -99,23 +119,23 @@ jastadd { ...@@ -99,23 +119,23 @@ jastadd {
include "relast.preprocessor/src/main/jastadd/**/*.ast" include "relast.preprocessor/src/main/jastadd/**/*.ast"
include "relast.preprocessor/src/main/jastadd/**/*.jadd" include "relast.preprocessor/src/main/jastadd/**/*.jadd"
include "relast.preprocessor/src/main/jastadd/**/*.jrag" include "relast.preprocessor/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/main/jastadd/**/*.ast" include "ragconnect.base/src/main/jastadd/**/*.ast"
include "ros2rag.base/src/main/jastadd/**/*.jadd" include "ragconnect.base/src/main/jastadd/**/*.jadd"
include "ros2rag.base/src/main/jastadd/**/*.jrag" include "ragconnect.base/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/gen/jastadd/**/*.ast" include "ragconnect.base/src/gen/jastadd/**/*.ast"
include "ros2rag.base/src/gen/jastadd/**/*.jadd" include "ragconnect.base/src/gen/jastadd/**/*.jadd"
include "ros2rag.base/src/gen/jastadd/**/*.jrag" include "ragconnect.base/src/gen/jastadd/**/*.jrag"
} }
scanner { scanner {
basedir ".." basedir ".."
include "ros2rag.base/src/main/jastadd/scanner/Header.flex", [-5] include "ragconnect.base/src/main/jastadd/scanner/Header.flex", [-5]
include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex", [-4] include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex", [-4]
include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3] include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3]
include "ros2rag.base/src/main/jastadd/scanner/Macros.flex", [-3] include "ragconnect.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2] include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
include "ros2rag.base/src/main/jastadd/scanner/MappingContent.flex", [-1] include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ros2rag.base/src/main/jastadd/scanner/Keywords.flex" include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex" include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1] include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2] include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
...@@ -123,8 +143,8 @@ jastadd { ...@@ -123,8 +143,8 @@ jastadd {
parser { parser {
basedir ".." basedir ".."
include "ros2rag.base/src/main/jastadd/parser/Preamble.parser" include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
include "ros2rag.base/src/main/jastadd/parser/Ros2Rag.parser" include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser" include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
} }
} }
...@@ -141,18 +161,18 @@ jastadd { ...@@ -141,18 +161,18 @@ jastadd {
} }
module = "Ros2Rag" module = "RagConnect"
astPackage = 'org.jastadd.ros2rag.ast' astPackage = 'org.jastadd.ragconnect.ast'
parser.name = 'Ros2RagParser' parser.name = 'RagConnectParser'
genDir = 'src/gen/java' genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res' buildInfoDir = 'src/gen-res'
scanner.genDir = "src/gen/java/org/jastadd/ros2rag/scanner" scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
parser.genDir = "src/gen/java/org/jastadd/ros2rag/parser" parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"] jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
} }
......
aspect Analysis { aspect Analysis {
// --- lookupTokenUpdateDefinition --- // --- lookupTokenEndpointDefinition ---
inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token); inh TokenEndpointDefinition TokenEndpointDefinition.lookupTokenEndpointDefinition(TokenComponent token);
eq Ros2Rag.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) { eq RagConnect.getEndpointDefinition().lookupTokenEndpointDefinition(TokenComponent token) {
for (UpdateDefinition def : getUpdateDefinitionList()) { for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) { if (def.isTokenEndpointDefinition() && def.asTokenEndpointDefinition().getToken().equals(token)) {
return def.asTokenUpdateDefinition(); return def.asTokenEndpointDefinition();
} }
} }
return null; return null;
...@@ -12,7 +12,7 @@ aspect Analysis { ...@@ -12,7 +12,7 @@ aspect Analysis {
// --- lookupDependencyDefinition --- // --- lookupDependencyDefinition ---
inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id); inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id);
eq Ros2Rag.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) { eq RagConnect.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) {
for (DependencyDefinition def : getDependencyDefinitionList()) { for (DependencyDefinition def : getDependencyDefinitionList()) {
if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) { if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) {
return def; return def;
...@@ -22,6 +22,6 @@ aspect Analysis { ...@@ -22,6 +22,6 @@ aspect Analysis {
} }
// --- isAlreadyDefined --- // --- isAlreadyDefined ---
syn boolean TokenUpdateDefinition.isAlreadyDefined() = lookupTokenUpdateDefinition(getToken()) != this; syn boolean TokenEndpointDefinition.isAlreadyDefined() = lookupTokenEndpointDefinition(getToken()) != this;
syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this; syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this;
} }
...@@ -3,50 +3,50 @@ import java.util.TreeSet; ...@@ -3,50 +3,50 @@ import java.util.TreeSet;
import java.util.LinkedList; import java.util.LinkedList;
aspect Errors { aspect Errors {
coll Set<ErrorMessage> Ros2Rag.errors() coll Set<ErrorMessage> RagConnect.errors()
[new TreeSet<ErrorMessage>()] [new TreeSet<ErrorMessage>()]
root Ros2Rag; root RagConnect;
ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName()) ReceiveFromMqttDefinition contributes error("Receive definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to Ros2Rag.errors(); to RagConnect.errors();
ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!") ReceiveFromMqttDefinition contributes error("Receiving target token must not be an NTA token!")
when getToken().getNTA() when getToken().getNTA()
to Ros2Rag.errors(); to RagConnect.errors();
// if first mapping is null, then suitableDefaultMapping() == null // if first mapping is null, then suitableDefaultMapping() == null
ReadFromMqttDefinition contributes error("No suitable default mapping found for type " + ReceiveFromMqttDefinition contributes error("No suitable default mapping found for type " +
((getMappingList().isEmpty()) ((getMappingList().isEmpty())
? getToken().getJavaTypeUse().prettyPrint() ? getToken().getJavaTypeUse().prettyPrint()
: getMappingList().get(0).getFromType().prettyPrint())) : getMappingList().get(0).getFromType().prettyPrint()))
when effectiveMappings().get(0) == null when effectiveMappings().get(0) == null
to Ros2Rag.errors(); to RagConnect.errors();
ReadFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!") ReceiveFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
when getToken().getJavaTypeUse().prettyPrint().equals( when getToken().getJavaTypeUse().prettyPrint().equals(
effectiveMappings().get(effectiveMappings().size() - 1)) effectiveMappings().get(effectiveMappings().size() - 1))
to Ros2Rag.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Writing target token must be an NTA token!") SendToMqttDefinition contributes error("Sending target token must be an NTA token!")
when !getToken().getNTA() when !getToken().getNTA()
to Ros2Rag.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName()) SendToMqttDefinition contributes error("Send definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to Ros2Rag.errors(); to RagConnect.errors();
DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID()) DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID())
when isAlreadyDefined() when isAlreadyDefined()
to Ros2Rag.errors(); to RagConnect.errors();
DependencyDefinition contributes error("The name of a dependency definition must not be equal to a list-node on the source") DependencyDefinition contributes error("The name of a dependency definition must not be equal to a list-node on the source")
when isAlreadyDefinedAsList() when isAlreadyDefinedAsList()
to Ros2Rag.errors(); to RagConnect.errors();
DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID()) DependencyDefinition contributes error("There must be a send update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetUpdateDefinition() == null when targetEndpointDefinition() == null
to Ros2Rag.errors(); to RagConnect.errors();
} }
aspect ErrorHelpers { aspect ErrorHelpers {
......
//TypeComponentMustache ; //TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ; //rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRos2Rag ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*; MRagConnect ::= ReceiveDefinition:MReceiveDefinition* SendDefinition:MSendDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*; abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MUpdateDefinition; MReceiveDefinition : MEndpointDefinition;
MWriteDefinition : MUpdateDefinition; MSendDefinition : MEndpointDefinition;
MMappingDefinition; MMappingDefinition;
MInnerMappingDefinition; MInnerMappingDefinition;
MDependencyDefinition; MDependencyDefinition;
MTypeComponent; MTypeComponent;
MTokenComponent; MTokenComponent;
rel MRos2Rag.Ros2Rag -> Ros2Rag; rel MRagConnect.RagConnect -> RagConnect;
rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition; rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition; rel MReceiveDefinition.ReceiveFromMqttDefinition -> ReceiveFromMqttDefinition;
rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition; rel MSendDefinition.SendToMqttDefinition -> SendToMqttDefinition;
rel MMappingDefinition.MappingDefinition -> MappingDefinition; rel MMappingDefinition.MappingDefinition -> MappingDefinition;
rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition; rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition;
rel MTypeComponent.TypeComponent -> TypeComponent; rel MTypeComponent.TypeComponent -> TypeComponent;
......
aspect NameResolution { aspect NameResolution {
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) { refine RefResolverStubs eq EndpointDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition // return a MappingDefinition
for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) { for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) { if (mappingDefinition.getID().equals(id)) {
return mappingDefinition; return mappingDefinition;
} }
......
aspect Navigation { aspect Navigation {
// --- program --- // --- program ---
eq Ros2Rag.getChild().program() = getProgram(); eq RagConnect.getChild().program() = getProgram();
eq MRos2Rag.getChild().program() = getRos2Rag().program(); eq MRagConnect.getChild().program() = getRagConnect().program();
// --- ros2rag --- // --- ragconnect ---
inh Ros2Rag ASTNode.ros2rag(); inh RagConnect ASTNode.ragconnect();
eq Ros2Rag.getChild().ros2rag() = this; eq RagConnect.getChild().ragconnect() = this;
eq MRos2Rag.getChild().ros2rag() = getRos2Rag(); eq MRagConnect.getChild().ragconnect() = getRagConnect();
// --- containedFile (first equation should be in preprocessor) --- // --- containedFile
eq Program.getChild().containedFile() = null; eq RagConnect.getChild().containedFile() = null;
eq Ros2Rag.getChild().containedFile() = null;
// --- isTypeComponent (should be in preprocessor) --- // --- containedFileName ---
syn boolean Component.isTypeComponent() = false; eq RagConnect.getChild().containedFileName() = getFileName();
eq TypeComponent.isTypeComponent() = true; eq MRagConnect.getChild().containedFileName() = null;
// --- asTypeComponent (should be in preprocessor) --- // --- isTokenEndpointDefinition ---
syn TypeComponent Component.asTypeComponent() = null; syn boolean EndpointDefinition.isTokenEndpointDefinition() = false;
eq TypeComponent.asTypeComponent() = this; eq TokenEndpointDefinition.isTokenEndpointDefinition() = true;
// --- isListComponent (should be in preprocessor) --- // --- asTokenEndpointDefinition ---
syn boolean Component.isListComponent() = false; syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null;
eq ListComponent.isListComponent() = true; eq TokenEndpointDefinition.asTokenEndpointDefinition() = this;
// --- asListComponent (should be in preprocessor) --- // --- isSendToMqttDefinition ---
syn ListComponent Component.asListComponent() = null; syn boolean EndpointDefinition.isSendToMqttDefinition() = false;
eq ListComponent.asListComponent() = this; eq SendToMqttDefinition.isSendToMqttDefinition() = true;
// --- containedFileName (should replace containedFile in preprocessor) --- // --- asSendToMqttDefinition ---
inh String ASTNode.containedFileName(); syn SendToMqttDefinition EndpointDefinition.asSendToMqttDefinition() = null;
eq GrammarFile.getChild().containedFileName() = getFileName(); eq SendToMqttDefinition.asSendToMqttDefinition() = this;
eq Ros2Rag.getChild().containedFileName() = getFileName();
eq Program.getChild().containedFileName() = null;
eq MRos2Rag.getChild().containedFileName() = null;
// --- isTokenUpdateDefinition --- // --- asReceiveFromMqttDefinition ---
syn boolean UpdateDefinition.isTokenUpdateDefinition() = false; syn ReceiveFromMqttDefinition EndpointDefinition.asReceiveFromMqttDefinition() = null;
eq TokenUpdateDefinition.isTokenUpdateDefinition() = true; eq ReceiveFromMqttDefinition.asReceiveFromMqttDefinition() = this;
// --- asTokenUpdateDefinition --- // --- targetEndpointDefinition ---
syn TokenUpdateDefinition UpdateDefinition.asTokenUpdateDefinition() = null; syn SendToMqttDefinition DependencyDefinition.targetEndpointDefinition() {
eq TokenUpdateDefinition.asTokenUpdateDefinition() = this;
// --- isWriteToMqttDefinition ---
syn boolean UpdateDefinition.isWriteToMqttDefinition() = false;
eq WriteToMqttDefinition.isWriteToMqttDefinition() = true;
// --- asWriteToMqttDefinition ---
syn WriteToMqttDefinition UpdateDefinition.asWriteToMqttDefinition() = null;
eq WriteToMqttDefinition.asWriteToMqttDefinition() = this;
// --- asReadFromMqttDefinition ---
syn ReadFromMqttDefinition UpdateDefinition.asReadFromMqttDefinition() = null;
eq ReadFromMqttDefinition.asReadFromMqttDefinition() = this;
// --- targetUpdateDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetUpdateDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet) // resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (UpdateDefinition updateDefinition : ros2rag().getUpdateDefinitionList()) { for (EndpointDefinition endpointDefinition : ragconnect().getEndpointDefinitionList()) {
if (updateDefinition.isWriteToMqttDefinition() && if (endpointDefinition.isSendToMqttDefinition() &&
updateDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) { endpointDefinition.asSendToMqttDefinition().getToken().equals(this.getTarget())) {
return updateDefinition.asWriteToMqttDefinition(); return endpointDefinition.asSendToMqttDefinition();
} }
} }
return null; return null;
...@@ -71,10 +51,4 @@ aspect Navigation { ...@@ -71,10 +51,4 @@ aspect Navigation {
// --- isDefaultMappingDefinition --- // --- isDefaultMappingDefinition ---
syn boolean MappingDefinition.isDefaultMappingDefinition() = false; syn boolean MappingDefinition.isDefaultMappingDefinition() = false;
eq DefaultMappingDefinition.isDefaultMappingDefinition() = true; eq DefaultMappingDefinition.isDefaultMappingDefinition() = true;
// --- allTokenComponents ---
coll java.util.Set<TokenComponent> Program.allTokenComponents() [new java.util.HashSet<>()] root Program;
TokenComponent contributes this
to Program.allTokenComponents()
for program();
} }
Ros2Rag ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ; RagConnect ::= EndpointDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
abstract UpdateDefinition ::= <AlwaysApply:boolean> ; abstract EndpointDefinition ::= <AlwaysApply:boolean> ;
rel UpdateDefinition.Mapping* -> MappingDefinition; rel EndpointDefinition.Mapping* -> MappingDefinition;
abstract TokenUpdateDefinition : UpdateDefinition; abstract TokenEndpointDefinition : EndpointDefinition;
rel TokenUpdateDefinition.Token -> TokenComponent; rel TokenEndpointDefinition.Token -> TokenComponent;
ReadFromMqttDefinition : TokenUpdateDefinition; ReceiveFromMqttDefinition : TokenEndpointDefinition;
WriteToMqttDefinition : TokenUpdateDefinition; SendToMqttDefinition : TokenEndpointDefinition;
DependencyDefinition ::= <ID>; DependencyDefinition ::= <ID>;
rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*; rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*;
......
...@@ -26,39 +26,40 @@ aspect GenerationUtils { ...@@ -26,39 +26,40 @@ aspect GenerationUtils {
*/ */
aspect AttributesForMustache { aspect AttributesForMustache {
// --- MRos2Rag --- // --- MRagConnect ---
eq MRos2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute(); eq MRagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRos2Rag.getChild().mqttHandlerField() = mqttHandlerField(); eq MRagConnect.getChild().mqttHandlerField() = mqttHandlerField();
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRos2Rag.mqttHandlerAttribute() = getRos2Rag().mqttHandlerAttribute(); syn String MRagConnect.mqttHandlerAttribute() = getRagConnect().mqttHandlerAttribute();
syn String MRos2Rag.mqttHandlerField() = getRos2Rag().mqttHandlerField(); syn String MRagConnect.mqttHandlerField() = getRagConnect().mqttHandlerField();
syn String MRos2Rag.mqttSetHostMethod() = getRos2Rag().mqttSetHostMethod(); syn String MRagConnect.mqttSetHostMethod() = getRagConnect().mqttSetHostMethod();
syn String MRos2Rag.mqttWaitUntilReadyMethod() = getRos2Rag().mqttWaitUntilReadyMethod(); syn String MRagConnect.mqttWaitUntilReadyMethod() = getRagConnect().mqttWaitUntilReadyMethod();
syn String MRos2Rag.mqttCloseMethod() = getRos2Rag().mqttCloseMethod(); syn String MRagConnect.mqttCloseMethod() = getRagConnect().mqttCloseMethod();
// --- MUpdateDefinition --- // --- MEndpointDefinition ---
syn String MUpdateDefinition.preemptiveExpectedValue(); syn String MEndpointDefinition.preemptiveExpectedValue();
syn String MUpdateDefinition.preemptiveReturn(); syn String MEndpointDefinition.preemptiveReturn();
syn TokenUpdateDefinition MUpdateDefinition.updateDef(); syn TokenEndpointDefinition MEndpointDefinition.endpointDef();
syn String MUpdateDefinition.firstInputVarName(); syn String MEndpointDefinition.firstInputVarName();
eq MUpdateDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1; eq MEndpointDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
eq MUpdateDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix(); eq MEndpointDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix();
eq MUpdateDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName(); eq MEndpointDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName();
inh String MUpdateDefinition.mqttHandlerAttribute(); inh String MEndpointDefinition.mqttHandlerAttribute();