Commit 11db4207 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Fix: EMAComponentInstanceBuilder::clone was missing some fields

parent 0e5a2db4
Pipeline #98277 passed with stage
in 4 minutes and 23 seconds
......@@ -30,7 +30,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc</artifactId>
<version>0.1.8-SNAPSHOT</version>
<version>0.1.9-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -69,14 +69,27 @@ public class EMAComponentInstanceBuilder {
}
public static EMAComponentInstanceSymbol clone(EMAComponentInstanceSymbol inst) {
return new EMAComponentInstanceBuilder().setName(inst.getName())
Collection<EMAComponentInstanceSymbol> subcomps = inst.getSubComponents().stream().map(EMAComponentInstanceBuilder::clone).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());
res
.setName(inst.getName())
.setSymbolReference(inst.getComponentType())
//.addPorts(inst.getPortInstanceList().stream().map(p -> EMAPortBuilder.clone(p)).collect(Collectors.toList()))
//.addPorts(inst.getPortInstanceList()) // is cloned in build method
.addConnectors(inst.getConnectorInstances().stream().map(c -> EMAConnectorBuilder.clone(c)).collect(Collectors.toList()))
.addSubComponents(inst.getSubComponents().stream().map(s -> EMAComponentInstanceBuilder.clone(s)).collect(Collectors.toList()))
.addPorts(ports)
.addSubComponents(subcomps)
.addConnectors(connectors)
.addResolvingFilters(inst.getSpannedScope().getResolvingFilters())
.addActualTypeArguments(inst.getComponentType().getFormalTypeParameters(), inst.getActualTypeArguments())
.addResolutionDeclarationSymbols(inst.getResolutionDeclarationSymbols())
.build();
.addParameters(inst.getParameters())
.addArguments(inst.getArguments())
.setPackageName(inst.getPackageName());
return res.build();
}
public EMAComponentInstanceBuilder addResolvingFilter(ResolvingFilter filter) {
......
......@@ -23,6 +23,7 @@ package de.monticore.lang.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.expressionsbasis._ast.ASTExpression;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceBuilder;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAConnectorInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.InstanceInformation;
......@@ -52,6 +53,17 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
Log.enableFailQuick(false);
}
@Test
public void testClone(){
Scope symTab = createSymTab("src/test/resources");
EMAComponentInstanceSymbol inst = symTab.<EMAComponentInstanceSymbol>resolve("testing.subComponentConnector2", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(inst);
EMAComponentInstanceSymbol inst2 = EMAComponentInstanceBuilder.clone(inst);
assertEquals(inst.toString().trim(),inst2.toString().trim());
}
@Test
public void testFAS() throws Exception {
Scope symTab = createSymTab("src/test/resources");
......
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