Commit 6b5607b0 authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Update instance structure building

parent ed7962be
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure;
import de.monticore.javaclassexpressions._ast.ASTLiteralExpression;
import de.monticore.javaclassexpressions._ast.ASTNameExpression;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.EmbeddedMontiArcMill;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcSymbolMill;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.UnitNumberExpressionSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.types.EMAVariable;
import de.monticore.expressionsbasis._ast.ASTExpression;
import de.monticore.lang.monticar.common2._ast.ASTLiteralValue;
import de.monticore.lang.monticar.common2._ast.ASTParameter;
import de.monticore.lang.monticar.common2._ast.ASTValue;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberExpression;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolutionExpression;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.monticore.lang.monticar.types2._symboltable.UnitNumberResolutionSymbol;
import de.monticore.literals.literals._ast.*;
import de.monticore.numberunit._ast.ASTNumberWithInf;
import de.monticore.numberunit._ast.ASTNumberWithUnit;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.Symbol;
import de.monticore.symboltable.resolving.ResolvingFilter;
import de.monticore.symboltable.types.references.ActualTypeArgument;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -41,7 +49,8 @@ public class EMAComponentInstanceBuilder {
protected List<ASTExpression> arguments = new ArrayList<>();
protected String packageName = "";
protected static Map<MCTypeSymbol, ActualTypeArgument> createMap(List<MCTypeSymbol> keys, List<ActualTypeArgument> values) {
protected static Map<MCTypeSymbol, ActualTypeArgument> createMap(List<MCTypeSymbol> keys,
List<ActualTypeArgument> values) {
Map<MCTypeSymbol, ActualTypeArgument> ret = new LinkedHashMap<>();
for (int i = 0; i < keys.size(); i++) {
ret.put(keys.get(i), values.get(i));
......@@ -50,9 +59,12 @@ public class EMAComponentInstanceBuilder {
}
public static EMAComponentInstanceSymbol clone(EMAComponentInstanceSymbol inst) {
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());
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());
......@@ -64,7 +76,8 @@ public class EMAComponentInstanceBuilder {
.addSubComponents(subcomps)
.addConnectors(connectors)
.addResolvingFilters(inst.getSpannedScope().getResolvingFilters())
.addActualTypeArguments(inst.getComponentType().getFormalTypeParameters(), inst.getActualTypeArguments())
.addActualTypeArguments(inst.getComponentType().getFormalTypeParameters(),
inst.getActualTypeArguments())
.addResolutionDeclarationSymbols(inst.getResolutionDeclarationSymbols())
.addParameters(inst.getParameters())
.addArguments(inst.getArguments())
......@@ -112,16 +125,19 @@ public class EMAComponentInstanceBuilder {
return this;
}
public EMAComponentInstanceBuilder addActualTypeArgument(MCTypeSymbol formalTypeParameter, ActualTypeArgument typeArgument) {
public EMAComponentInstanceBuilder addActualTypeArgument(MCTypeSymbol formalTypeParameter,
ActualTypeArgument typeArgument) {
this.actualTypeArguments.put(formalTypeParameter, typeArgument);
return this;
}
public EMAComponentInstanceBuilder addActualTypeArguments(List<MCTypeSymbol> formalTypeParameters, List<ActualTypeArgument> actualTypeArguments) {
public EMAComponentInstanceBuilder addActualTypeArguments(List<MCTypeSymbol> formalTypeParameters,
List<ActualTypeArgument> actualTypeArguments) {
if (formalTypeParameters.size() != actualTypeArguments.size()) {
Log.debug(formalTypeParameters.toString(), "FormalTypeParameters");
Log.debug(actualTypeArguments.toString(), "ActualTypeArguments");
Log.debug("instance has not as many actual type arguments as component definition has formal type parameters. No mapping is possible. Function does nothing.",
Log.debug(
"instance has not as many actual type arguments as component definition has formal type parameters. No mapping is possible. Function does nothing.",
EMAComponentInstanceBuilder.class.toString());
} else {
for (int i = 0; i < formalTypeParameters.size(); i++) {
......@@ -143,7 +159,8 @@ public class EMAComponentInstanceBuilder {
/**
* adds ports if they do not exist and replace generics of ports
*/
public EMAComponentInstanceBuilder addPortsIfNameDoesNotExists(Collection<EMAPortSymbol> ports, List<MCTypeSymbol> formalTypeParameters, List<ActualTypeArgument> actualTypeArguments) {
public EMAComponentInstanceBuilder addPortsIfNameDoesNotExists(Collection<EMAPortSymbol> ports,
List<MCTypeSymbol> formalTypeParameters, List<ActualTypeArgument> actualTypeArguments) {
List<EMAPortSymbol> pList = ports.stream().collect(Collectors.toList());
createMap(formalTypeParameters, actualTypeArguments).forEach((k, v) ->
ports.stream().filter(p -> p.getTypeReference().getReferencedSymbol().getName().equals(k.getName()))
......@@ -183,7 +200,8 @@ public class EMAComponentInstanceBuilder {
return this;
}
public EMAComponentInstanceBuilder addSubComponentsIfNameDoesNotExists(Collection<EMAComponentInstanceSymbol> subCmps) {
public EMAComponentInstanceBuilder addSubComponentsIfNameDoesNotExists(
Collection<EMAComponentInstanceSymbol> subCmps) {
List<String> existingSubComponentNames = this.subComponents.stream().map(s -> s.getName())
.collect(Collectors.toList());
this.addSubComponents(subCmps.stream().filter(s ->
......@@ -210,7 +228,7 @@ public class EMAComponentInstanceBuilder {
}
protected void exchangeGenerics(EMAComponentInstanceSymbol inst,
Map<MCTypeSymbol, ActualTypeArgument> mapTypeArguments) {
Map<MCTypeSymbol, ActualTypeArgument> mapTypeArguments) {
Log.debug(inst.toString(), "exchangeGenerics inst");
// TODO work with full names, but then you got the problem with generics.GenericInstance.Generic.T != generics.SuperGenericComparableComp2.T
// because when delegating the name of the referenced type must be created
......@@ -219,17 +237,22 @@ public class EMAComponentInstanceBuilder {
// 1) replace port generics
inst.getPortInstanceList().stream()
// .filter(p -> p.getTypeReference().getReferencedSymbol().getFullName().equals(k.getFullName()))
.filter( p -> p.getTypeReference().existsReferencedSymbol() ? p.getTypeReference().getReferencedSymbol().getName().equals(k.getName()) : false)
.filter(p -> p.getTypeReference().existsReferencedSymbol() ? p.getTypeReference()
.getReferencedSymbol()
.getName().equals(k.getName()) : false)
.forEachOrdered(p -> p.setTypeReference((MCTypeReference<? extends MCTypeSymbol>) v.getType()));
// 2) propagate component instance definition generics
inst.getSubComponents().stream()
// now update the actual type reference definitions by replacing them according to the hash map
.forEachOrdered(s -> s.setActualTypeArguments(
.forEachOrdered(
s -> s.setActualTypeArguments(
s.getActualTypeArguments().stream()
// replace this filtered type arguments with the value we want to replace
// .map(a -> a.getType().getReferencedSymbol().getFullName().equals(k.getFullName()) ? v : a)
.map(a -> (a.getType().existsReferencedSymbol() ? (a.getType().getReferencedSymbol().getName().equals(k.getName()) ? v : a) : a))
.map(a -> (a.getType().existsReferencedSymbol() ? (
a.getType().getReferencedSymbol().getName().equals(k.getName()) ? v : a)
: a))
.collect(Collectors.toList())
));
......@@ -246,21 +269,89 @@ public class EMAComponentInstanceBuilder {
} else {
Log.debug(s.getComponentType().toString(), "ComponentType");
Log.debug(s.getComponentType().getFormalTypeParameters().toString(), "FormalTypeParameters");
exchangeGenerics(s, createMap(s.getComponentType().getFormalTypeParameters(),
s.getActualTypeArguments()));
//Hack to pass through replaced type symbols
Map<MCTypeSymbol, ActualTypeArgument> map =
createMap(s.getComponentType().getFormalTypeParameters(), s.getActualTypeArguments());
map.putAll(mapTypeArguments);
exchangeGenerics(s, map);
}
});
Log.debug("See next lines", "Fixing Wrong Ports");
}
protected void exchangeParameters(EMAComponentInstanceSymbol sym) {
Map<String, ASTExpression> argumentsMap = new HashMap<>();
for (int i = 0; i < parameters.size(); i++) {
argumentsMap.put(parameters.get(i).getName(), arguments.get(i));
}
exchangeParameters(sym, argumentsMap);
}
protected void exchangeParameters(EMAComponentInstanceSymbol inst, Map<String, ASTExpression> arguments) {
for (EMAComponentInstanceSymbol subComponent : inst.getSubComponents()) {
for (int i = 0; i < subComponent.getArguments().size(); i++) {
ASTExpression argument = subComponent.getArguments().get(i);
ASTExpression exchange = calculateExchange(argument, arguments);
if (exchange != null) {
subComponent.getArguments().set(i, exchange);
}
}
if (subComponent.getParameters().size() == subComponent.getArguments().size()) {
for (int i = 0; i < subComponent.getParameters().size(); i++) {
arguments.put(subComponent.getParameters().get(i).getName(), subComponent.getArguments().get(i));
}
exchangeParameters(subComponent, arguments);
} else if (!subComponent.getArguments().isEmpty() &&
subComponent.getArguments().size() != subComponent.getParameters().size()) {
Log.error("TODO");
}
}
}
protected ASTExpression calculateExchange(ASTExpression argument, Map<String, ASTExpression> arguments) {
if (argument instanceof ASTUnitNumberResolutionExpression) {
if (((ASTUnitNumberResolutionExpression) argument).getUnitNumberResolution().isPresentName()) {
String argumentName =
((ASTUnitNumberResolutionExpression) argument).getUnitNumberResolution().getName();
return arguments.get(argumentName);
} else {
// TODO Fall untersuchen
}
}
// TODO Fall untersuchen
return null;
}
public void addPortArraySymbolsToInstance(EMAComponentInstanceSymbol instance){
Map<String, List<EMAPortInstanceSymbol>> nameToPortList = new HashMap<>();
for (EMAPortInstanceSymbol port : instance.getPortInstanceList()){
List<EMAPortInstanceSymbol> list = nameToPortList
.computeIfAbsent(port.getNameWithoutArrayBracketPart(), k -> new ArrayList<>());
list.add(port);
if (list.size() > 1) {
list.toString();
}
}
for (String name : nameToPortList.keySet()){
if (!instance.getSpannedScope().resolveLocally(name, EMAPortArraySymbol.KIND).isPresent()) {
List<EMAPortInstanceSymbol> ports = nameToPortList.get(name);
EMAPortArraySymbol portArray = new EMAPortArraySymbol(name, null);
portArray.setDimension(ports.size());
portArray.setDirection(ports.get(0).isIncoming());
portArray.setTypeReference(ports.get(0).getTypeReference());
instance.getSpannedScope().getAsMutableScope().add(portArray);
}
}
}
public EMAComponentInstanceSymbol build() {
if (name.isPresent() && symbolReference.isPresent()) {
EMAComponentInstanceSymbol sym =
new EMAComponentInstanceSymbol(this.name.get(),
this.symbolReference.get());
EMAComponentInstanceSymbol sym = instantiateComponentSymbol();
//TODO add checks that port names and subcomponent names are unique
if(!getPackageName().equals("")) {
if (!getPackageName().equals("")) {
sym.setPackageName(getPackageName());
sym.setFullName(getPackageName() + "." + this.name.get());
}
......@@ -268,17 +359,31 @@ public class EMAComponentInstanceBuilder {
final MutableScope scope = (MutableScope) sym.getSpannedScope();
resolvingFilters.stream().forEachOrdered(f -> scope.addResolver(f));
ports.stream().forEachOrdered(p -> scope.add(EMAPortBuilder.instantiate(p, sym.getFullName()))); // must be cloned since we change it if it has generics
connectors.stream().forEachOrdered(c -> scope.add(EMAConnectorBuilder.instantiate(c, sym.getFullName())));
ports.stream().forEachOrdered(p ->
instantiatePortSymbol(p, sym.getFullName(), scope)); // must be cloned since we change it if it has
addPortArraySymbolsToInstance(sym);
// generics
connectors.stream().forEachOrdered(c -> instantiateConnectorSymbol(c, sym.getFullName(), scope));
subComponents.stream().forEachOrdered(s -> scope.add(s));
sym.setActualTypeArguments(actualTypeArguments.values().stream().collect(Collectors.toList()));
sym.setResolutionDeclarationSymbols(resolutionDeclarationSymbols);
sym.setParameters(parameters);
addOtherToComponentInstance(sym);
// set arguments
// there are either no arguments or the equal number to parameters
if (!arguments.isEmpty() && arguments.size() != parameters.size()) {
Log.error("TODO Wrong number of arguments: " + sym.getFullName());
}
setDefaultValuesToArguments(sym);
sym.setArguments(arguments);
exchangeGenerics(sym, actualTypeArguments);
if (parameters.size() == arguments.size()) {
exchangeParameters(sym);
}
Log.debug(sym.toString(), "build end sym");
return sym;
......@@ -287,12 +392,123 @@ public class EMAComponentInstanceBuilder {
throw new Error("not all parameters have been set before to build the expanded component instance symbol");
}
private void setDefaultValuesToArguments(EMAComponentInstanceSymbol sym) {
if (arguments.isEmpty() && !parameters.isEmpty()) {
// set default values
for (ASTParameter astParameter :
((ASTComponent) sym.getComponentType().getReferencedComponent().get().getAstNode().get())
.getParameterList()) {
if (astParameter.isPresentDefaultValue()) {
ASTExpression argument = createArgumentFromDefaultValue(astParameter);
arguments.add(argument);
} else {
// TODO Do nothing for default instances else log error
// Log.error("TODO No default value given for parameter with missing argument: "
// + sym.getFullName() + "." + astParameter.getNameWithArray().getName());
}
}
}
}
protected EMAComponentInstanceSymbol instantiateComponentSymbol() {
return new EMAComponentInstanceSymbol(this.name.get(),
this.symbolReference.get());
}
protected void instantiateConnectorSymbol(EMAConnectorSymbol c, String fullName,
MutableScope scope) {
scope.add(EMAConnectorBuilder.instantiate(c, fullName));
}
protected void instantiatePortSymbol(EMAPortSymbol port, String packageName, MutableScope scope) {
EMAPortInstanceSymbol symbol = EMAPortBuilder.instantiate(port, packageName);
scope.add(symbol);
}
protected void addOtherToComponentInstance(EMAComponentInstanceSymbol sym) {
// can be overriden
}
protected ASTExpression createArgumentFromDefaultValue(ASTParameter astParameter) {
ASTValue defaultValue = astParameter.getDefaultValue();
if (defaultValue instanceof ASTLiteralValue) {
if (((ASTLiteralValue) defaultValue).getValue() instanceof ASTSignedNumericLiteral) {
ASTNumberWithInf numberWithInf =
createNumberWithInfFromLiteralValue(
(ASTSignedNumericLiteral) ((ASTLiteralValue) defaultValue).getValue());
ASTNumberWithUnit numberWithUnit =
EmbeddedMontiArcMill
.numberWithUnitBuilder()
.setNum(numberWithInf)
.build();
ASTUnitNumberExpression expression =
EmbeddedMontiArcMill
.unitNumberExpressionBuilder()
.setNumberWithUnit(numberWithUnit)
.build();
UnitNumberExpressionSymbol symbol = new UnitNumberExpressionSymbol(expression);
expression.setSymbol(symbol);
return expression;
} else if (((ASTLiteralValue) defaultValue).getValue() instanceof ASTBooleanLiteral) {
return EmbeddedMontiArcMill
.booleanExpressionBuilder()
.setBooleanLiteral((ASTBooleanLiteral) ((ASTLiteralValue) defaultValue).getValue())
.build();
} else {
Log.error("not supported parameter ASTCharLiteral, ASTStringLiteral, ASTNullLIteral");
}
} else {
Log.error("not supported ASTValue implementation");
}
return null;
}
protected ASTNumberWithInf createNumberWithInfFromLiteralValue(ASTSignedNumericLiteral defaultValue) {
ASTNumericLiteral literal = null;
String negNumber = null;
if (defaultValue instanceof ASTSignedDoubleLiteral) {
if (((ASTSignedDoubleLiteral) defaultValue).isNegative())
negNumber = "-";
literal = EmbeddedMontiArcMill
.intLiteralBuilder()
.setSource(((ASTSignedDoubleLiteral) defaultValue).getSource())
.build();
} else if (defaultValue instanceof ASTSignedFloatLiteral) {
if (((ASTSignedFloatLiteral) defaultValue).isNegative())
negNumber = "-";
literal = EmbeddedMontiArcMill
.intLiteralBuilder()
.setSource(((ASTSignedFloatLiteral) defaultValue).getSource())
.build();
} else if (defaultValue instanceof ASTSignedIntLiteral) {
if (((ASTSignedIntLiteral) defaultValue).isNegative())
negNumber = "-";
literal = EmbeddedMontiArcMill
.intLiteralBuilder()
.setSource(((ASTSignedIntLiteral) defaultValue).getSource())
.build();
} else if (defaultValue instanceof ASTSignedLongLiteral) {
if (((ASTSignedLongLiteral) defaultValue).isNegative())
negNumber = "-";
literal = EmbeddedMontiArcMill
.intLiteralBuilder()
.setSource(((ASTSignedLongLiteral) defaultValue).getSource())
.build();
}
return EmbeddedMontiArcMill
.numberWithInfBuilder()
.setNegNumber(negNumber)
.setNumber(literal)
.build();
}
public EMAComponentInstanceBuilder addConnectorIfNameDoesNotExists(EMAConnectorSymbol connector) {
List<String> existingConnectorSources = this.connectors.stream().map(c -> c.getSource())
.collect(Collectors.toList());
List<String> existingConnectorTargets = this.connectors.stream().map(c -> c.getTarget())
.collect(Collectors.toList());
if (!existingConnectorSources.contains(connector.getSource()) && !existingConnectorTargets.contains(connector.getTarget())) {
if (!existingConnectorSources.contains(connector.getSource()) &&
!existingConnectorTargets.contains(connector.getTarget())) {
this.addConnector(connector);
}
return this;
......@@ -303,10 +519,13 @@ public class EMAComponentInstanceBuilder {
return this;
}
public EMAComponentInstanceBuilder addResolutionDeclarationSymbols(List<ResolutionDeclarationSymbol> resolutionDeclarationSymbols) {
public EMAComponentInstanceBuilder addResolutionDeclarationSymbols(
List<ResolutionDeclarationSymbol> resolutionDeclarationSymbols) {
for (ResolutionDeclarationSymbol symbol : resolutionDeclarationSymbols) {
if (!this.resolutionDeclarationSymbols.contains(symbol)) {
Log.info("name: "+symbol.getNameToResolve() +" astResolution: "+symbol.getASTResolution().toString(),"Added ResolutionDeclarationSymbol To EMAComponentInstanceBuilder");
Log.info("name: " + symbol.getNameToResolve() + " astResolution: " +
symbol.getASTResolution().toString(),
"Added ResolutionDeclarationSymbol To EMAComponentInstanceBuilder");
this.resolutionDeclarationSymbols.add(symbol);
}
}
......
......@@ -91,7 +91,11 @@ public class EMAComponentInstanceSymbolCreator {
createInstance(inst.getComponentType(), filters, inst.getComponentType().getReferencedSymbol().getResolutionDeclarationSymbols(), packageName + "." + inst.getName())
.setName(inst.getName()).setPackageName(packageName)
.addActualTypeArguments(inst.getComponentType().getFormalTypeParameters(),
inst.getComponentType().getActualTypeArguments()).addResolvingFilters(filters).addResolutionDeclarationSymbols(inst.getComponentType().getResolutionDeclarationSymbols()).addParameters(inst.getComponentType().getReferencedSymbol().getParameters()).addArguments(inst.getComponentType().getReferencedSymbol().getArguments()).build());
inst.getComponentType().getActualTypeArguments())
.addResolvingFilters(filters)
.addResolutionDeclarationSymbols(inst.getComponentType().getResolutionDeclarationSymbols())
.addParameters(inst.getComponentType().getReferencedSymbol().getParameters())
.addArguments(inst.getComponentType().getReferencedSymbol().getArguments()).build());
Log.debug(inst.getInstanceInformation().get().getInstanceNumberForArgumentIndex(0) + "", "InstanceInformation:");
Log.debug(inst.toString(), "ComponentInstance CreateInstance PostSub");
......
......@@ -249,7 +249,7 @@ public class EMATypeHelper {
// typeArgumentSymbolReference.setStringRepresentation(TypesPrinter
// .printType(astTypeNoBound));
addTypeArgumentsToTypeSymbol(typeArgumentSymbolReference, astTypeNoBound, symbolTableCreator);
typeArgumentSymbolReference = addTypeArgumentsToTypeSymbol(typeArgumentSymbolReference, astTypeNoBound, symbolTableCreator);
actualTypeArguments.add(new ActualTypeArgument(typeArgumentSymbolReference));
} else {
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt;
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt;
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.tagging.middleware.someip;
......
......@@ -195,6 +195,47 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
assertEquals("1", symbol2.getTextualRepresentation());
}
@Test
public void testExpandedParameterInstance() {
Scope symTab = createSymTab("src/test/resources");
EMAComponentInstanceSymbol inst = symTab.<EMAComponentInstanceSymbol>resolve(
"testing.expandedParameterInstanceInstance", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(inst);
assertEquals(2, inst.getSubComponents().size());
assertEquals(1, inst.getSubComponents().iterator().next().getParameters().size());
for (ASTExpression astExpression : inst.getSubComponents().iterator().next().getArguments()) {
Log.info(astExpression.toString(), "info:");
}
Iterator<EMAComponentInstanceSymbol> iterator = inst.getSubComponents().iterator();
EMAComponentInstanceSymbol sub1 = iterator.next();
EMAComponentInstanceSymbol sub2 = iterator.next();
Iterator<EMAComponentInstanceSymbol> iterator1 = sub1.getSubComponents().iterator();
EMAComponentInstanceSymbol sub11 = iterator1.next();
EMAComponentInstanceSymbol sub12 = iterator1.next();
Iterator<EMAComponentInstanceSymbol> iterator2 = sub2.getSubComponents().iterator();
EMAComponentInstanceSymbol sub21 = iterator2.next();
EMAComponentInstanceSymbol sub22 = iterator2.next();
UnitNumberExpressionSymbol symbol1 = (UnitNumberExpressionSymbol) sub1.getArguments().get(0).getSymbolOpt().get();
UnitNumberExpressionSymbol symbol2 = (UnitNumberExpressionSymbol) sub2.getArguments().get(0).getSymbolOpt().get();
UnitNumberExpressionSymbol symbol11 =
(UnitNumberExpressionSymbol) sub11.getArguments().get(0).getSymbolOpt().get();
UnitNumberExpressionSymbol symbol12 =
(UnitNumberExpressionSymbol) sub12.getArguments().get(0).getSymbolOpt().get();
UnitNumberExpressionSymbol symbol21 =
(UnitNumberExpressionSymbol) sub21.getArguments().get(0).getSymbolOpt().get();
UnitNumberExpressionSymbol symbol22 =
(UnitNumberExpressionSymbol) sub22.getArguments().get(0).getSymbolOpt().get();
assertEquals("2", symbol1.getTextualRepresentation());
assertEquals("9", symbol2.getTextualRepresentation());
assertEquals("2", symbol11.getTextualRepresentation());
assertEquals("2", symbol12.getTextualRepresentation());