Workaround: EMAComponentInstanceBuider::clone does not clone ports and package name

parent 6588a325
Pipeline #97522 passed with stages
in 8 minutes
......@@ -135,10 +135,11 @@ public class ClusterHelper {
.collect(Collectors.toList());
Set<ResolvingFilter<? extends Symbol>> resolvingFilters = inst.getSpannedScope().getResolvingFilters();
List<EMAComponentInstanceSymbol> tmpSubcomps = cluster.stream().map(EMAComponentInstanceBuilder::clone).collect(Collectors.toList());
List<EMAComponentInstanceSymbol> tmpSubcomps = cluster.stream().map(ClusterHelper::realClone).collect(Collectors.toList());
tmpSubcomps.forEach(sc -> ((CommonScope) sc.getSpannedScope()).setResolvingFilters(resolvingFilters));
EMAComponentInstanceSymbol res = new EMAComponentInstanceBuilder()
.setName(clusterName)
.setPackageName(inst.getPackageName())
.setSymbolReference(inst.getComponentType())
.addPorts(tmpPorts)
.addConnectors(tmpConnectiors)
......@@ -151,5 +152,24 @@ public class ClusterHelper {
return res;
}
//TODO: ports, package name are not cloned in EMAComponentInstanceBuilder::clone
private static EMAComponentInstanceSymbol realClone(EMAComponentInstanceSymbol inst) {
Collection<EMAComponentInstanceSymbol> subcomps = inst.getSubComponents().stream().map(ClusterHelper::realClone).collect(Collectors.toList());
Collection<EMAConnectorSymbol> connectors = inst.getConnectorInstances().stream().map(EMAConnectorBuilder::clone).collect(Collectors.toList());
Collection<EMAPortSymbol> ports = inst.getPortInstanceList().stream().map(EMAPortBuilder::clone).collect(Collectors.toList());
EMAComponentInstanceBuilder res = (new EMAComponentInstanceBuilder());
ports.forEach(res::addPort);
res.setName(inst.getName())
.setPackageName(inst.getPackageName())
.setSymbolReference(inst.getComponentType())
.addConnectors(connectors)
.addSubComponents(subcomps)
.addResolutionDeclarationSymbols(inst.getResolutionDeclarationSymbols());
return res.build();
}
}
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