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

Update to version 0.2.2

- allow normal tokens to be sent
parent abe8a70b
Pipeline #7613 passed with stage
in 1 minute and 16 seconds
......@@ -51,9 +51,9 @@ task newVersion() {
}
}
sourceSets.main.java {
srcDir "src/gen/java"
}
File genSrc = file("src/gen/java");
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
jar {
manifest {
......
......@@ -24,9 +24,17 @@ aspect Analysis {
}
// --- isAlreadyDefined ---
syn boolean TokenEndpointDefinition.isAlreadyDefined() = lookupTokenEndpointDefinitions(getToken()).size() > 1;
syn boolean TokenEndpointDefinition.isAlreadyDefined() {
return lookupTokenEndpointDefinitions(getToken()).stream()
.filter(this::matchesType)
.count() > 1;
}
syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this;
syn boolean TokenEndpointDefinition.matchesType(TokenEndpointDefinition other);
eq ReceiveTokenEndpointDefinition.matchesType(TokenEndpointDefinition other) = other.isReceiveTokenEndpointDefinition();
eq SendTokenEndpointDefinition.matchesType(TokenEndpointDefinition other) = other.isSendTokenEndpointDefinition();
syn boolean MappingDefinitionType.assignableTo(JavaTypeUse target);
eq JavaMappingDefinitionType.assignableTo(JavaTypeUse target) = getType().assignableTo(target);
eq JavaArrayMappingDefinitionType.assignableTo(JavaTypeUse target) {
......@@ -54,4 +62,10 @@ aspect Analysis {
default: return getName();
}
}
// --- shouldSendValue ---
syn boolean TokenEndpointDefinition.shouldSendValue() = isSendTokenEndpointDefinition() && !getToken().getNTA();
// --- needProxyToken ---
syn boolean TokenComponent.needProxyToken() = !getDependencySourceDefinitionList().isEmpty() || getTokenEndpointDefinitionList().stream().anyMatch(TokenEndpointDefinition::shouldSendValue);
}
......@@ -28,10 +28,6 @@ aspect Errors {
getToken().effectiveJavaTypeUse())
to RagConnect.errors();
SendTokenEndpointDefinition contributes error("Sending target token must be an NTA token!")
when !getToken().getNTA()
to RagConnect.errors();
SendTokenEndpointDefinition contributes error("Send definition already defined for " + getToken().getName())
when isAlreadyDefined()
to RagConnect.errors();
......
......@@ -35,6 +35,10 @@ aspect Navigation {
syn SendTokenEndpointDefinition EndpointDefinition.asSendTokenEndpointDefinition() = null;
eq SendTokenEndpointDefinition.asSendTokenEndpointDefinition() = this;
// --- isReceiveTokenEndpointDefinition ---
syn boolean EndpointDefinition.isReceiveTokenEndpointDefinition() = false;
eq ReceiveTokenEndpointDefinition.isReceiveTokenEndpointDefinition() = true;
// --- asReceiveTokenEndpointDefinition ---
syn ReceiveTokenEndpointDefinition EndpointDefinition.asReceiveTokenEndpointDefinition() = null;
eq ReceiveTokenEndpointDefinition.asReceiveTokenEndpointDefinition() = this;
......
......@@ -5,7 +5,7 @@ abstract EndpointDefinition ::= <AlwaysApply:boolean> ;
rel EndpointDefinition.Mapping* <-> MappingDefinition.UsedAt*;
abstract TokenEndpointDefinition : EndpointDefinition;
rel TokenEndpointDefinition.Token -> TokenComponent;
rel TokenEndpointDefinition.Token <-> TokenComponent.TokenEndpointDefinition*;
ReceiveTokenEndpointDefinition : TokenEndpointDefinition;
SendTokenEndpointDefinition : TokenEndpointDefinition;
......
......@@ -71,6 +71,7 @@ aspect AttributesForMustache {
syn String MSendDefinition.updateMethod() = "_update_" + tokenName();
syn String MSendDefinition.writeMethod() = "_writeLastValue_" + tokenName();
syn String MSendDefinition.tokenResetMethod() = "get" + tokenName() + "_reset";
syn boolean MSendDefinition.shouldSendValue() = endpointDef().shouldSendValue();
// --- MMappingDefinition ---
syn String MMappingDefinition.toType() = getMappingDefinition().getToType().prettyPrint();
......@@ -96,8 +97,16 @@ aspect AttributesForMustache {
syn String MTokenComponent.parentTypeName() = getTokenComponent().containingTypeDecl().getName();
syn String MTokenComponent.name() = getTokenComponent().getName();
syn String MTokenComponent.javaType() = getTokenComponent().effectiveJavaTypeUse().prettyPrint();
syn String MTokenComponent.internalName() = getTokenComponent().getDependencySourceDefinitionList().isEmpty() ? externalName() : "_internal_" + name();
syn String MTokenComponent.internalName() = getTokenComponent().needProxyToken() ? "_internal_" + name() : externalName();
syn String MTokenComponent.externalName() = name();
syn MSendDefinition MTokenComponent.normalTokenSendDef() {
for (TokenEndpointDefinition endpointDef : getTokenComponent().getTokenEndpointDefinitionList()) {
if (endpointDef.shouldSendValue()) {
return endpointDef.asSendTokenEndpointDefinition().toMustache();
}
}
return null;
}
// --- toMustache ---
syn lazy MRagConnect RagConnect.toMustache() {
......@@ -118,7 +127,7 @@ aspect AttributesForMustache {
result.addDependencyDefinition(def.toMustache());
}
for (TokenComponent token : getProgram().allTokenComponents()) {
if (!token.getDependencySourceDefinitionList().isEmpty()) {
if (token.needProxyToken()) {
result.addTokenComponent(token.toMustache());
}
}
......
......@@ -216,6 +216,7 @@ public class Compiler extends AbstractCompiler {
if (!atLeastOneGrammar && !atLeastOneRagConnect) {
System.exit(1);
}
ragConnect.flushTreeCache();
ragConnect.treeResolveAll();
ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration);
ASTNode.loggingEnabledForReads = optionLogReads.value();
......@@ -264,15 +265,9 @@ public class Compiler extends AbstractCompiler {
}
private void mergeRagConnectDefinitions(RagConnect ragConnect, RagConnect ragConnectToIntegrate) {
for (EndpointDefinition endpointDefinition : ragConnectToIntegrate.getEndpointDefinitionList()) {
ragConnect.addEndpointDefinition(endpointDefinition);
}
for (MappingDefinition mappingDefinition : ragConnectToIntegrate.getMappingDefinitionList()) {
ragConnect.addMappingDefinition(mappingDefinition);
}
for (DependencyDefinition dependencyDefinition : ragConnectToIntegrate.getDependencyDefinitionList()) {
ragConnect.addDependencyDefinition(dependencyDefinition);
}
ragConnect.setEndpointDefinitionList(ragConnectToIntegrate.getEndpointDefinitionList());
ragConnect.setMappingDefinitionList(ragConnectToIntegrate.getMappingDefinitionList());
ragConnect.setDependencyDefinitionList(ragConnectToIntegrate.getDependencyDefinitionList());
}
// protected void printUsage() {
......
#Fri Aug 14 13:28:32 CEST 2020
version=0.2.1
#Fri Aug 14 19:22:30 CEST 2020
version=0.2.2
......@@ -36,7 +36,9 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
}
protected boolean {{parentTypeName}}.{{updateMethod}}() {
{{^shouldSendValue}}
{{tokenResetMethod}}();
{{/shouldSendValue}}
{{> mappingApplication}}
{{lastValue}} = {{lastResult}};
// normally we would return true here. unless no connect method was called so far to initialize {{sender}} yet
......
......@@ -9,6 +9,11 @@ public {{parentTypeName}} {{parentTypeName}}.set{{name}}({{javaType}} value) {
{{/targetEndpointDefinition}}
}
{{/DependencyDefinitions}}
{{#normalTokenSendDef}}
if ({{updateMethod}}()) {
{{writeMethod}}();
}
{{/normalTokenSendDef}}
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