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

Rename UpdateDefinition to EndpointDefinition

parent 896d89ec
aspect Analysis {
// --- lookupTokenUpdateDefinition ---
inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token);
eq RagConnect.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) {
for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) {
return def.asTokenUpdateDefinition();
// --- lookupTokenEndpointDefinition ---
inh TokenEndpointDefinition TokenEndpointDefinition.lookupTokenEndpointDefinition(TokenComponent token);
eq RagConnect.getEndpointDefinition().lookupTokenEndpointDefinition(TokenComponent token) {
for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isTokenEndpointDefinition() && def.asTokenEndpointDefinition().getToken().equals(token)) {
return def.asTokenEndpointDefinition();
}
}
return null;
......@@ -22,6 +22,6 @@ aspect Analysis {
}
// --- isAlreadyDefined ---
syn boolean TokenUpdateDefinition.isAlreadyDefined() = lookupTokenUpdateDefinition(getToken()) != this;
syn boolean TokenEndpointDefinition.isAlreadyDefined() = lookupTokenEndpointDefinition(getToken()) != this;
syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this;
}
......@@ -45,7 +45,7 @@ aspect Errors {
to RagConnect.errors();
DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetUpdateDefinition() == null
when targetEndpointDefinition() == null
to RagConnect.errors();
}
......
......@@ -2,9 +2,9 @@
//rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRagConnect ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MUpdateDefinition;
MWriteDefinition : MUpdateDefinition;
abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MEndpointDefinition;
MWriteDefinition : MEndpointDefinition;
MMappingDefinition;
MInnerMappingDefinition;
MDependencyDefinition;
......
aspect NameResolution {
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) {
refine RefResolverStubs eq EndpointDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition
for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) {
......
......@@ -16,33 +16,33 @@ aspect Navigation {
eq RagConnect.getChild().containedFileName() = getFileName();
eq MRagConnect.getChild().containedFileName() = null;
// --- isTokenUpdateDefinition ---
syn boolean UpdateDefinition.isTokenUpdateDefinition() = false;
eq TokenUpdateDefinition.isTokenUpdateDefinition() = true;
// --- isTokenEndpointDefinition ---
syn boolean EndpointDefinition.isTokenEndpointDefinition() = false;
eq TokenEndpointDefinition.isTokenEndpointDefinition() = true;
// --- asTokenUpdateDefinition ---
syn TokenUpdateDefinition UpdateDefinition.asTokenUpdateDefinition() = null;
eq TokenUpdateDefinition.asTokenUpdateDefinition() = this;
// --- asTokenEndpointDefinition ---
syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null;
eq TokenEndpointDefinition.asTokenEndpointDefinition() = this;
// --- isWriteToMqttDefinition ---
syn boolean UpdateDefinition.isWriteToMqttDefinition() = false;
syn boolean EndpointDefinition.isWriteToMqttDefinition() = false;
eq WriteToMqttDefinition.isWriteToMqttDefinition() = true;
// --- asWriteToMqttDefinition ---
syn WriteToMqttDefinition UpdateDefinition.asWriteToMqttDefinition() = null;
syn WriteToMqttDefinition EndpointDefinition.asWriteToMqttDefinition() = null;
eq WriteToMqttDefinition.asWriteToMqttDefinition() = this;
// --- asReadFromMqttDefinition ---
syn ReadFromMqttDefinition UpdateDefinition.asReadFromMqttDefinition() = null;
syn ReadFromMqttDefinition EndpointDefinition.asReadFromMqttDefinition() = null;
eq ReadFromMqttDefinition.asReadFromMqttDefinition() = this;
// --- targetUpdateDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetUpdateDefinition() {
// --- targetEndpointDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetEndpointDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (UpdateDefinition updateDefinition : ragconnect().getUpdateDefinitionList()) {
if (updateDefinition.isWriteToMqttDefinition() &&
updateDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) {
return updateDefinition.asWriteToMqttDefinition();
for (EndpointDefinition endpointDefinition : ragconnect().getEndpointDefinitionList()) {
if (endpointDefinition.isWriteToMqttDefinition() &&
endpointDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) {
return endpointDefinition.asWriteToMqttDefinition();
}
}
return null;
......
RagConnect ::= 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;
rel TokenUpdateDefinition.Token -> TokenComponent;
abstract TokenEndpointDefinition : EndpointDefinition;
rel TokenEndpointDefinition.Token -> TokenComponent;
ReadFromMqttDefinition : TokenUpdateDefinition;
WriteToMqttDefinition : TokenUpdateDefinition;
ReadFromMqttDefinition : TokenEndpointDefinition;
WriteToMqttDefinition : TokenEndpointDefinition;
DependencyDefinition ::= <ID>;
rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*;
......
......@@ -37,29 +37,29 @@ aspect AttributesForMustache {
syn String MRagConnect.mqttWaitUntilReadyMethod() = getRagConnect().mqttWaitUntilReadyMethod();
syn String MRagConnect.mqttCloseMethod() = getRagConnect().mqttCloseMethod();
// --- MUpdateDefinition ---
syn String MUpdateDefinition.preemptiveExpectedValue();
syn String MUpdateDefinition.preemptiveReturn();
syn TokenUpdateDefinition MUpdateDefinition.updateDef();
syn String MUpdateDefinition.firstInputVarName();
// --- MEndpointDefinition ---
syn String MEndpointDefinition.preemptiveExpectedValue();
syn String MEndpointDefinition.preemptiveReturn();
syn TokenEndpointDefinition MEndpointDefinition.endpointDef();
syn String MEndpointDefinition.firstInputVarName();
eq MUpdateDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
eq MUpdateDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix();
eq MUpdateDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName();
eq MEndpointDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
eq MEndpointDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix();
eq MEndpointDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName();
inh String MUpdateDefinition.mqttHandlerAttribute();
inh String MEndpointDefinition.mqttHandlerAttribute();
syn String MUpdateDefinition.connectMethod() = updateDef().connectMethod();
syn TokenComponent MUpdateDefinition.token() = updateDef().getToken();
syn boolean MUpdateDefinition.alwaysApply() = updateDef().getAlwaysApply();
syn String MUpdateDefinition.resultVarPrefix() = "result"; // we do not need "_" here, because methodName begins with one
syn String MUpdateDefinition.parentTypeName() = token().containingTypeDecl().getName();
syn String MUpdateDefinition.tokenName() = token().getName();
syn MInnerMappingDefinition MUpdateDefinition.lastDefinition() = getInnerMappingDefinition(getNumInnerMappingDefinition() - 1);
syn String MUpdateDefinition.lastDefinitionToType() = lastDefinition().ToType();
syn String MUpdateDefinition.lastDefinitionName() = lastDefinition().methodName();
syn String MUpdateDefinition.lastResult() = resultVarPrefix() + lastDefinitionName();
syn String MUpdateDefinition.condition() {
syn String MEndpointDefinition.connectMethod() = endpointDef().connectMethod();
syn TokenComponent MEndpointDefinition.token() = endpointDef().getToken();
syn boolean MEndpointDefinition.alwaysApply() = endpointDef().getAlwaysApply();
syn String MEndpointDefinition.resultVarPrefix() = "result"; // we do not need "_" here, because methodName begins with one
syn String MEndpointDefinition.parentTypeName() = token().containingTypeDecl().getName();
syn String MEndpointDefinition.tokenName() = token().getName();
syn MInnerMappingDefinition MEndpointDefinition.lastDefinition() = getInnerMappingDefinition(getNumInnerMappingDefinition() - 1);
syn String MEndpointDefinition.lastDefinitionToType() = lastDefinition().ToType();
syn String MEndpointDefinition.lastDefinitionName() = lastDefinition().methodName();
syn String MEndpointDefinition.lastResult() = resultVarPrefix() + lastDefinitionName();
syn String MEndpointDefinition.condition() {
if (lastDefinition().getMappingDefinition().getToType().isArray()) {
return "java.util.Arrays.equals(" + preemptiveExpectedValue() + ", " + lastResult() + ")";
}
......@@ -82,13 +82,13 @@ aspect AttributesForMustache {
// --- MReadDefinition ---
eq MReadDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()";
eq MReadDefinition.preemptiveReturn() = "return;";
eq MReadDefinition.updateDef() = getReadFromMqttDefinition();
eq MReadDefinition.endpointDef() = getReadFromMqttDefinition();
eq MReadDefinition.firstInputVarName() = "message";
// --- MWriteDefinition ---
eq MWriteDefinition.preemptiveExpectedValue() = lastValue();
eq MWriteDefinition.preemptiveReturn() = "return false;";
eq MWriteDefinition.updateDef() = getWriteToMqttDefinition();
eq MWriteDefinition.endpointDef() = getWriteToMqttDefinition();
eq MWriteDefinition.firstInputVarName() = "get" + tokenName() + "()";
syn String MWriteDefinition.writeTopic() = getWriteToMqttDefinition().writeTopic();
......@@ -109,8 +109,8 @@ aspect AttributesForMustache {
syn String MDependencyDefinition.dependencyMethod() = getDependencyDefinition().dependencyMethod();
syn String MDependencyDefinition.sourceParentTypeName() = getDependencyDefinition().getSource().containingTypeDecl().getName();
syn String MDependencyDefinition.internalRelationPrefix() = getDependencyDefinition().internalRelationPrefix();
syn nta MUpdateDefinition MDependencyDefinition.targetUpdateDefinition() {
return getDependencyDefinition().targetUpdateDefinition().toMustache();
syn nta MEndpointDefinition MDependencyDefinition.targetEndpointDefinition() {
return getDependencyDefinition().targetEndpointDefinition().toMustache();
}
// --- MTypeComponent ---
......@@ -129,7 +129,7 @@ aspect AttributesForMustache {
syn lazy MRagConnect RagConnect.toMustache() {
MRagConnect result = new MRagConnect();
result.setRagConnect(this);
for (UpdateDefinition def : getUpdateDefinitionList()) {
for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isWriteToMqttDefinition()) {
result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache());
} else {
......@@ -156,8 +156,8 @@ aspect AttributesForMustache {
}
//MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
protected void MUpdateDefinition.addInnerMappings() {
for (MappingDefinition def : updateDef().effectiveMappings()) {
protected void MEndpointDefinition.addInnerMappings() {
for (MappingDefinition def : endpointDef().effectiveMappings()) {
MInnerMappingDefinition inner = new MInnerMappingDefinition();
inner.setMappingDefinition(def);
addInnerMappingDefinition(inner);
......@@ -205,7 +205,7 @@ aspect AspectGeneration {
syn String TokenComponent.internalName() = getDependencySourceDefinitionList().isEmpty() ? externalName() : "_internal_" + getName();
syn String TokenComponent.externalName() = getName();
syn String TokenUpdateDefinition.connectMethod() = "connect" + getToken().getName();
syn String TokenEndpointDefinition.connectMethod() = "connect" + getToken().getName();
syn String WriteToMqttDefinition.writeTopic() = "_topic_" + getToken().getName();
syn String WriteToMqttDefinition.lastValue() = "_lastValue" + getToken().getName();
syn String WriteToMqttDefinition.updateMethod() = "_update_" + getToken().getName();
......@@ -227,7 +227,7 @@ aspect AspectGeneration {
// naming copy attributes
// --- mqttHandlerAttribute ---
inh String UpdateDefinition.mqttHandlerAttribute();
inh String EndpointDefinition.mqttHandlerAttribute();
inh String MappingDefinition.mqttHandlerAttribute();
inh String DependencyDefinition.mqttHandlerAttribute();
eq RagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
......
......@@ -105,7 +105,7 @@ aspect DefaultMappings {
aspect Mappings {
// --- effectiveMappings ---
syn java.util.List<MappingDefinition> UpdateDefinition.effectiveMappings();
syn java.util.List<MappingDefinition> EndpointDefinition.effectiveMappings();
eq ReadFromMqttDefinition.effectiveMappings() {
// if there is a first mapping, check if its input type is byte[].
// or if no mappings are specified.
......@@ -159,7 +159,7 @@ aspect Mappings {
eq JavaArrayMappingDefinitionType.isArray() = true;
// --- suitableDefaultMapping ---
syn DefaultMappingDefinition UpdateDefinition.suitableDefaultMapping();
syn DefaultMappingDefinition EndpointDefinition.suitableDefaultMapping();
eq ReadFromMqttDefinition.suitableDefaultMapping() {
String typeName = getMappingList().isEmpty() ?
getToken().getJavaTypeUse().getName() :
......
RagConnect ragconnect
= update_definition.d ragconnect.r {: r.getUpdateDefinitionList().insertChild(d, 0); return r; :}
= endpoint_definition.d ragconnect.r {: r.getEndpointDefinitionList().insertChild(d, 0); return r; :}
| dependency_definition.d ragconnect.r {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
| mapping_definition.d ragconnect.r {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
| comment ragconnect.r {: return r; :}
......@@ -12,7 +12,7 @@ RagConnect ragconnect
}
:} ;
UpdateDefinition update_definition
EndpointDefinition endpoint_definition
= READ ID.type_name DOT ID.token_name SCOL
{:
ReadFromMqttDefinition result = new ReadFromMqttDefinition();
......
......@@ -216,8 +216,8 @@ public class Compiler extends AbstractCompiler {
}
private void mergeRagConnectDefinitions(RagConnect ragConnect, RagConnect ragConnectToIntegrate) {
for (UpdateDefinition updateDefinition : ragConnectToIntegrate.getUpdateDefinitionList()) {
ragConnect.addUpdateDefinition(updateDefinition);
for (EndpointDefinition endpointDefinition : ragConnectToIntegrate.getEndpointDefinitionList()) {
ragConnect.addEndpointDefinition(endpointDefinition);
}
for (MappingDefinition mappingDefinition : ragConnectToIntegrate.getMappingDefinitionList()) {
ragConnect.addMappingDefinition(mappingDefinition);
......
......@@ -127,7 +127,7 @@ public class SimpleMain {
readFromMqttDefinition.setAlwaysApply(false);
readFromMqttDefinition.setToken(TokenComponent.createRef("Link.CurrentPosition"));
readFromMqttDefinition.addMapping(mappingDefinition);
model.addUpdateDefinition(readFromMqttDefinition);
model.addEndpointDefinition(readFromMqttDefinition);
model.treeResolveAll();
for (ErrorMessage error : model.errors()) {
......
......@@ -2,11 +2,11 @@
set{{internalName}}(value);
{{#DependencyDefinitions}}
for ({{targetParentTypeName}} target : get{{internalRelationPrefix}}TargetList()) {
{{#targetUpdateDefinition}}
{{#targetEndpointDefinition}}
if (target.{{updateMethod}}()) {
target.{{writeMethod}}();
}
{{/targetUpdateDefinition}}
{{/targetEndpointDefinition}}
}
{{/DependencyDefinitions}}
return this;
......
Markdown is supported
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