Skip to content
Snippets Groups Projects
Commit 2ea8709a authored by René Schöne's avatar René Schöne
Browse files

Fix bugs with TokenComponents not handled correctly after introduction of inheritance.

- needProxyToken and normalTokenSendDef check self and ownedByOther components
- temporary fix in mustache if value of KeyValuePair is null
- fix for RagConnectObserver in case value of entry is null
parent c3f5b702
No related branches found
No related tags found
1 merge request!37Resolve "Inherited components of a type can not be chosen as port targets"
Pipeline #15549 passed
...@@ -101,14 +101,18 @@ aspect Analysis { ...@@ -101,14 +101,18 @@ aspect Analysis {
syn boolean TokenComponent.needProxyToken() { syn boolean TokenComponent.needProxyToken() {
for (Component comp : meOwnedByOthers()) { for (Component comp : meOwnedByOthers()) {
TokenComponent tokenComp = comp.asTokenComponent(); TokenComponent tokenComp = comp.asTokenComponent();
if (!tokenComp.getDependencySourceDefinitionList().isEmpty() || if (tokenComp.directNeedProxyToken()) {
tokenComp.getTokenPortTargetList().stream()
.map(PortTarget::containingPortDefinition)
.anyMatch(PortDefinition::shouldNotResetValue)) {
return true; return true;
} }
} }
return false; return directNeedProxyToken();
}
syn boolean TokenComponent.directNeedProxyToken() {
return !getDependencySourceDefinitionList().isEmpty() ||
getTokenPortTargetList().stream()
.map(PortTarget::containingPortDefinition)
.anyMatch(PortDefinition::shouldNotResetValue);
} }
// --- effectiveUsedAt --- // --- effectiveUsedAt ---
......
...@@ -632,20 +632,27 @@ containingPortDefinition().getIndexBasedListAccess()); ...@@ -632,20 +632,27 @@ containingPortDefinition().getIndexBasedListAccess());
aspect MustacheTokenComponent { aspect MustacheTokenComponent {
// === TokenComponent === // === TokenComponent ===
syn java.util.List<DependencyDefinition> TokenComponent.dependencySourceDefinitionsOwnedByMe() {
java.util.List<DependencyDefinition> result = new java.util.ArrayList<>();
result.addAll(getDependencySourceDefinitions());
for (Component comp : meOwnedByOthers()) {
result.addAll(comp.asTokenComponent().getDependencySourceDefinitions());
}
return result;
}
syn String TokenComponent.internalName() = needProxyToken() ? ragconnect().internalRagConnectPrefix() + getName() : getName(); syn String TokenComponent.internalName() = needProxyToken() ? ragconnect().internalRagConnectPrefix() + getName() : getName();
syn String TokenComponent.javaType() = effectiveJavaTypeUse().prettyPrint(); syn String TokenComponent.javaType() = effectiveJavaTypeUse().prettyPrint();
syn PortDefinition TokenComponent.normalTokenSendDef() { syn PortDefinition TokenComponent.normalTokenSendDef() {
for (Component comp : meOwnedByOthers()) { for (Component comp : meOwnedByOthers()) {
TokenComponent tokenComp = comp.asTokenComponent(); PortDefinition maybeResult = comp.asTokenComponent().directNormalTokenSendDef();
for (PortTarget target : tokenComp.getTokenPortTargetList()) { if (maybeResult != null) {
if (target.isTokenPortTarget() && target.containingPortDefinition().shouldNotResetValue()) { return maybeResult;
return target.containingPortDefinition();
}
} }
} }
return null; return directNormalTokenSendDef();
} }
syn String TokenComponent.parentTypeName() = containingTypeDecl().getName(); syn String TokenComponent.parentTypeName() = containingTypeDecl().getName();
...@@ -673,6 +680,16 @@ aspect MustacheTokenComponent { ...@@ -673,6 +680,16 @@ aspect MustacheTokenComponent {
} }
// > see MustacheSend for updateMethodName, writeMethodName // > see MustacheSend for updateMethodName, writeMethodName
// === attributes needed for computing above ones ===
syn PortDefinition TokenComponent.directNormalTokenSendDef() {
for (PortTarget target : getTokenPortTargetList()) {
if (target.isTokenPortTarget() && target.containingPortDefinition().shouldNotResetValue()) {
return target.containingPortDefinition();
}
}
return null;
}
} }
aspect MustacheTypeDecl { aspect MustacheTypeDecl {
......
...@@ -181,7 +181,8 @@ aspect IntermediateToYAML { ...@@ -181,7 +181,8 @@ aspect IntermediateToYAML {
result.put("DependencySourceDefinitions" , dependencySourceDefinitions); result.put("DependencySourceDefinitions" , dependencySourceDefinitions);
result.put("javaType" , javaType()); result.put("javaType" , javaType());
result.put("normalTokenSendDef" , normalTokenSendDef().toYAML()); result.put("normalTokenSendDef" , ASTNode.<PortDefinition,MappingElement>safeCall(
normalTokenSendDef(), def -> def.toYAML()));
result.put("parentTypeName" , parentTypeName()); result.put("parentTypeName" , parentTypeName());
return result; return result;
} }
...@@ -209,6 +210,29 @@ aspect IntermediateToYAML { ...@@ -209,6 +210,29 @@ aspect IntermediateToYAML {
protected StringElement ASTNode.sanitizeValueForYAML(String value) { protected StringElement ASTNode.sanitizeValueForYAML(String value) {
return StringElement.of(value.replace("\"" , "\\\"").replace("\n" , "\\n")); return StringElement.of(value.replace("\"" , "\\\"").replace("\n" , "\\n"));
} }
// FIXME: remove refine once fixed in upstream mustache
refine Printing protected StringBuilder KeyValuePair.prettyPrint(StringBuilder sb, boolean printIndent, String indent) {
if (printIndent) sb.append(indent);
if (isCollapsed()) {
sb.append("\"");
}
sb.append(getKey());
if (isCollapsed()) {
sb.append("\"");
}
sb.append(":");
if (getValue() == null) {
sb.append(" null");
} else if (getValue().isComplexElement() && !getValue().isEmpty() && !getValue().isCollapsed()) {
sb.append("\n");
getValue().prettyPrint(sb, true, indent + PRINT_INDENT);
} else {
sb.append(" ");
getValue().prettyPrint(sb, false, indent);
}
return sb;
}
} }
aspect Navigation { aspect Navigation {
......
...@@ -4,6 +4,9 @@ aspect Util { ...@@ -4,6 +4,9 @@ aspect Util {
if (s.isEmpty()) return ""; if (s.isEmpty()) return "";
return Character.toUpperCase(s.charAt(0)) + s.substring(1); return Character.toUpperCase(s.charAt(0)) + s.substring(1);
} }
static <Input,Result> Result ASTNode.safeCall(Input input, java.util.function.Function<Input, Result> function) {
return input == null ? null : function.apply(input);
}
protected T JastAddList.firstChild() { return getChild(0); } protected T JastAddList.firstChild() { return getChild(0); }
protected T JastAddList.lastChild() { return getChild(getNumChild() - 1); } protected T JastAddList.lastChild() { return getChild(getNumChild() - 1); }
......
...@@ -119,8 +119,8 @@ aspect RagConnectObserver { ...@@ -119,8 +119,8 @@ aspect RagConnectObserver {
} }
RagConnectObserverStartEntry startEntry = startEntries.peekFirst(); RagConnectObserverStartEntry startEntry = startEntries.peekFirst();
if (node == startEntry.node && if (node == startEntry.node &&
attribute.equals(startEntry.attributeString) && java.util.Objects.equals(attribute, startEntry.attributeString) &&
value.equals(startEntry.flushIncToken)) { java.util.Objects.equals(value, startEntry.flushIncToken)) {
// create a copy of the queue to avoid entering this again causing an endless recursion // create a copy of the queue to avoid entering this again causing an endless recursion
RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]); RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]);
entryQueue.clear(); entryQueue.clear();
......
public {{parentTypeName}} {{parentTypeName}}.set{{Name}}({{javaType}} value) { public {{parentTypeName}} {{parentTypeName}}.set{{Name}}({{javaType}} value) {
set{{internalName}}(value); set{{internalName}}(value);
{{#DependencySourceDefinitions}} {{#dependencySourceDefinitionsOwnedByMe}}
for ({{targetParentTypeName}} target : get{{internalRelationPrefix}}TargetList()) { for ({{targetParentTypeName}} target : get{{internalRelationPrefix}}TargetList()) {
{{#targetPortDefinition}} {{#targetPortDefinition}}
if (target.{{updateMethodName}}()) { if (target.{{updateMethodName}}()) {
...@@ -8,7 +8,7 @@ public {{parentTypeName}} {{parentTypeName}}.set{{Name}}({{javaType}} value) { ...@@ -8,7 +8,7 @@ public {{parentTypeName}} {{parentTypeName}}.set{{Name}}({{javaType}} value) {
} }
{{/targetPortDefinition}} {{/targetPortDefinition}}
} }
{{/DependencySourceDefinitions}} {{/dependencySourceDefinitionsOwnedByMe}}
{{#normalTokenSendDef}} {{#normalTokenSendDef}}
if ({{updateMethodName}}()) { if ({{updateMethodName}}()) {
{{writeMethodName}}(); {{writeMethodName}}();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment