Fixed: generated files for instance arrays had [ and ] in name

parent 2046703d
......@@ -2,10 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.ClusterHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.RosHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.*;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.apache.commons.io.FileUtils;
......@@ -35,10 +32,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
List<ExpandedComponentInstanceSymbol> clusterSubcomponents = ClusterHelper.getClusterSubcomponents(componentInstanceSymbol);
if (clusterSubcomponents.size() > 0) {
clusterSubcomponents.forEach(clusterECIS -> {
generatorMap.put(clusterECIS, createFullGenerator(clusterECIS.getFullName().replace(".", "_")));
String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName());
generatorMap.put(clusterECIS, createFullGenerator(nameTargetLanguage));
});
} else {
generatorMap.put(componentInstanceSymbol, createFullGenerator(componentInstanceSymbol.getFullName().replace(".", "_")));
String nameTargetLanguage = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
generatorMap.put(componentInstanceSymbol, createFullGenerator(nameTargetLanguage));
}
List<File> files = new ArrayList<>();
......@@ -46,7 +45,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
for (ExpandedComponentInstanceSymbol comp : generatorMap.keySet()) {
files.addAll(generatorMap.get(comp).generate(comp, taggingResolver));
//add empty generator to subDirs so that CMakeLists.txt will be generated correctly
subDirs.add(comp.getFullName().replace(".", "_"));
subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName()));
}
subDirs.add("rosMsg");
......
......@@ -3,9 +3,9 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import java.io.File;
......@@ -31,7 +31,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
private FileContent generateIAdapter(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".h");
res.setFileContent(TemplateHelper.getIAdapterTemplate().replace("${compName}", name));
return res;
......@@ -41,7 +41,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
private FileContent generateCoordinator(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<File> files) {
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
List<String> filesNames = files.stream()
.map(File::getName)
.collect(Collectors.toList());
......@@ -74,7 +74,7 @@ public class MiddlewareGenerator extends CMakeGenerator {
private FileContent generateCoordinatorCMakeList(ExpandedComponentInstanceSymbol componentInstanceSymbol, List<File> files) {
FileContent res = new FileContent();
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String targets = files.stream()
.map(File::getName)
......
package de.monticore.lang.monticar.generator.middleware.helpers;
public class NameHelper {
private NameHelper(){
}
public static String getNameTargetLanguage(String name){
return name
.replace('.','_')
.replace('[','_')
.replace(']','_');
}
}
......@@ -53,7 +53,7 @@ public class RosHelper {
}
//target port name is unique: each in port can only have one connection!
String topicName = connectorSymbol.getTargetPort().getFullName().replace(".", "_").replace("[","_").replace("]","_");
String topicName = NameHelper.getNameTargetLanguage(connectorSymbol.getTargetPort().getFullName());
RosMsg rosTypeA = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getTargetPort().getTypeReference());
RosMsg rosTypeB = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getSourcePort().getTypeReference());
if (!rosTypeA.equals(rosTypeB)) {
......
......@@ -3,8 +3,8 @@ package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import java.io.File;
......@@ -38,7 +38,7 @@ public class CPPGenImpl implements GeneratorImpl {
private FileContent generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
FileContent cmake = new FileContent();
cmake.setFileName("CMakeLists.txt");
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
cmake.setFileContent(TemplateHelper.getCmakeCppTemplate().replace("${compName}", name));
return cmake;
}
......
......@@ -4,8 +4,8 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.Expanded
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.NameHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import java.io.File;
......@@ -29,7 +29,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
private FileContent generateAdapter(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyAdapterTemplate()
.replace("${compName}", name);
......@@ -56,7 +56,7 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
private FileContent generateCMake(ExpandedComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getComponentNameTargetLanguage(componentInstanceSymbol.getFullName());
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyCmakeTemplate()
.replace("${compName}", name);
......
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