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

Cleanup

parent 1e30ed27
......@@ -27,35 +27,6 @@ aspect Analysis {
syn boolean TokenEndpointDefinition.isAlreadyDefined() = lookupTokenEndpointDefinitions(getToken()).size() > 1;
syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this;
// // --- protocol ---
// syn String TokenEndpointDefinition.protocol();
// eq ReceiveFromMqttDefinition.protocol() = "mqtt";
// eq SendToMqttDefinition.protocol() = "mqtt";
// eq ReceiveFromRestDefinition.protocol() = "rest";
// eq SendToRestDefinition.protocol() = "rest";
// // --- usesPROTOCOL ---
// syn boolean RagConnect.usesMqtt() = !mqttEndpointDefinitions().isEmpty();
// syn boolean RagConnect.usesRest() = !restEndpointDefinitions().isEmpty();
// // --- mqttEndpointDefinitions ---
// coll java.util.List<TokenEndpointDefinition> RagConnect.mqttEndpointDefinitions() [new java.util.ArrayList<>()] root RagConnect;
// ReceiveFromMqttDefinition contributes this
// to RagConnect.mqttEndpointDefinitions()
// for ragconnect();
// SendToMqttDefinition contributes this
// to RagConnect.mqttEndpointDefinitions()
// for ragconnect();
//
// // --- restEndpointDefinitions ---
// coll java.util.List<TokenEndpointDefinition> RagConnect.restEndpointDefinitions() [new java.util.ArrayList<>()] root RagConnect;
// ReceiveFromRestDefinition contributes this
// to RagConnect.restEndpointDefinitions()
// for ragconnect();
// SendToRestDefinition contributes this
// to RagConnect.restEndpointDefinitions()
// for ragconnect();
syn boolean MappingDefinitionType.assignableTo(JavaTypeUse target);
eq JavaMappingDefinitionType.assignableTo(JavaTypeUse target) = getType().assignableTo(target);
eq JavaArrayMappingDefinitionType.assignableTo(JavaTypeUse target) {
......
//TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRagConnect ::= ReceiveDefinition:MReceiveDefinition* SendDefinition:MSendDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReceiveDefinition : MEndpointDefinition;
......@@ -12,7 +9,6 @@ MTypeComponent;
MTokenComponent;
rel MRagConnect.RagConnect -> RagConnect;
// useless comment
rel MInnerMappingDefinition.MMappingDefinition -> MMappingDefinition;
rel MReceiveDefinition.ReceiveTokenEndpointDefinition -> ReceiveTokenEndpointDefinition;
rel MSendDefinition.SendTokenEndpointDefinition -> SendTokenEndpointDefinition;
......
aspect Printing {
String ASTNode.PRINT_INDENT = " ";
syn String MappingDefinitionType.prettyPrint();
eq JavaMappingDefinitionType.prettyPrint() = getType().getName();
eq JavaArrayMappingDefinitionType.prettyPrint() = getType().getName() + "[]";
syn String JavaTypeUse.prettyPrint() {
StringBuilder sb = new StringBuilder();
generateAbstractGrammar(sb);
return sb.toString();
}
syn String Document.prettyPrint() {
StringBuilder sb = new StringBuilder();
sb.append("# RagConnect created at ").append(java.time.Instant.now()).append("\n");
......
aspect GenerationUtils {
public static final String ASTNode.aspectIndent = " ";
public String ASTNode.ind(int n) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < n; i++) {
s.append(aspectIndent);
}
return s.toString();
}
// --- prettyPrint ---
syn String MappingDefinitionType.prettyPrint();
eq JavaMappingDefinitionType.prettyPrint() = getType().getName();
eq JavaArrayMappingDefinitionType.prettyPrint() = getType().getName() + "[]";
syn String JavaTypeUse.prettyPrint() {
StringBuilder sb = new StringBuilder();
generateAbstractGrammar(sb);
return sb.toString();
}
}
/* Open questions
- Should all string constants be defined on the normal AST, or on the special mustache AST?
/*
Design considerations
- InnerMappingDefinition needed for iteration attribute (first, last) - not easily possible with list-relation
*/
......@@ -35,45 +11,24 @@ aspect AttributesForMustache {
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRagConnect.closeMethod() = "ragconnectCloseConnections";
// syn boolean MRagConnect.usesMqtt() = getRagConnect().usesMqtt();
syn String MRagConnect.mqttHandlerAttribute() = "_mqttHandler";
syn String MRagConnect.mqttHandlerField() = "_mqttHandler";
// syn String MRagConnect.mqttSetHostMethod() = "MqttSetHost";
syn String MRagConnect.mqttSetupWaitUntilReadyMethod() = "ragconnectSetupMqttWaitUntilReady";
// syn boolean MRagConnect.usesRest() = getRagConnect().usesRest();
syn String MRagConnect.restHandlerAttribute() = "_restHandler";
syn String MRagConnect.restHandlerField() = "_restHandler";
// syn String MRagConnect.restSetPortMethod() = "RestSetPort";
// --- MEndpointDefinition ---
syn String MEndpointDefinition.preemptiveExpectedValue();
syn String MEndpointDefinition.preemptiveReturn();
syn TokenEndpointDefinition MEndpointDefinition.endpointDef();
syn String MEndpointDefinition.firstInputVarName();
// syn String MEndpointDefinition.newConnectionMethod();
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).methodName();
inh String MEndpointDefinition.mqttHandlerAttribute();
inh String MEndpointDefinition.restHandlerAttribute();
syn String MEndpointDefinition.connectParameterName() = "uriString";
// switch (endpointDef().protocol()) {
// case "mqtt": return "topic";
// case "rest": return "path";
// default: return null;
// }
// }
// syn String MEndpointDefinition.handlerAttribute() {
// switch (endpointDef().protocol()) {
// case "mqtt": return mqttHandlerAttribute();
// case "rest": return restHandlerAttribute();
// default: return null;
// }
// }
syn String MEndpointDefinition.connectMethod() = "connect" + tokenName();
syn TokenComponent MEndpointDefinition.token() = endpointDef().getToken();
syn boolean MEndpointDefinition.alwaysApply() = endpointDef().getAlwaysApply();
......@@ -111,23 +66,9 @@ aspect AttributesForMustache {
eq MReceiveDefinition.endpointDef() = getReceiveTokenEndpointDefinition();
eq MReceiveDefinition.firstInputVarName() = "message";
// syn String MReceiveDefinition.newConnectionMethod() {
// switch (endpointDef().protocol()) {
// case "mqtt": return "newConnection";
// case "rest": return "newPUTConnection";
// default: return null;
// }
// }
// --- MSendDefinition ---
eq MSendDefinition.preemptiveExpectedValue() = lastValue();
eq MSendDefinition.preemptiveReturn() = "return false;";
// switch (endpointDef().protocol()) {
// case "mqtt": return "return false;";
// case "rest": return "throw e;"; // e is Exception variable
// default: return null;
// }
// }
eq MSendDefinition.endpointDef() = getSendTokenEndpointDefinition();
eq MSendDefinition.firstInputVarName() = "get" + tokenName() + "()";
......@@ -136,14 +77,6 @@ aspect AttributesForMustache {
syn String MSendDefinition.updateMethod() = "_update_" + tokenName();
syn String MSendDefinition.writeMethod() = "_writeLastValue_" + tokenName();
syn String MSendDefinition.tokenResetMethod() = "get" + tokenName() + "_reset";
// syn boolean MSendDefinition.isPush() = getSendTokenEndpointDefinition().isPush();
// syn String MSendDefinition.newConnectionMethod() {
// switch (endpointDef().protocol()) {
// case "mqtt": return null;
// case "rest": return "newGETConnection";
// default: return null;
// }
// }
// --- MMappingDefinition ---
syn String MMappingDefinition.toType() = getMappingDefinition().getToType().prettyPrint();
......@@ -252,10 +185,6 @@ aspect AttributesForMustache {
aspect AspectGeneration {
// syn boolean SendTokenEndpointDefinition.isPush();
// eq SendToMqttDefinition.isPush() = true;
// eq SendToRestDefinition.isPush() = false;
// --- rootNodeName ---
syn String ASTNode.rootNodeName() = rootNode.getName();
......
......@@ -100,8 +100,7 @@ aspect Mappings {
// then append the suitable default mapping
java.util.List<MappingDefinition> result;
if (getMappingList().isEmpty() || !hasSuitableEdgeMapping()) {
result = new java.util.ArrayList();
result.addAll(getMappingList());
result = new java.util.ArrayList(getMappingList());
result.add(suitableDefaultMapping());
} else {
result = getMappingList();
......
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