diff options
author | Markus Freutsmiedl <Markus.Freutsmiedl@berner-mattner.com> | 2015-10-07 12:21:31 +0200 |
---|---|---|
committer | Markus Freutsmiedl <Markus.Freutsmiedl@berner-mattner.com> | 2015-10-07 12:21:31 +0200 |
commit | 23a8adf5723d79f5ad75de4929129411340417c0 (patch) | |
tree | 7a2ffafa24252c45af31949fa1deab4f85a9fcb0 | |
parent | 336db577dc057b7a13aeaf8eb2c777a26a7b607a (diff) | |
download | genivi-common-api-runtime-3.1.3p3.tar.gz |
CommonAPI-Tools 3.1.3p33.1.3p3
7 files changed, 260 insertions, 156 deletions
diff --git a/org.genivi.commonapi.console/about.mappings b/org.genivi.commonapi.console/about.mappings index 7a6e954..b80ace9 100644 --- a/org.genivi.commonapi.console/about.mappings +++ b/org.genivi.commonapi.console/about.mappings @@ -1,3 +1,3 @@ -0=3.1.3 -1=20150728 +0=3.1.3-p3 +1=20151001 2=$sun.arch.data.model$ diff --git a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java index 54f1c26..0d2c49d 100644 --- a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java +++ b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java @@ -66,6 +66,7 @@ public class CommandlineToolMain protected String SCOPE = "Core validation: "; private boolean isValidation = true; public static final int ERROR_STATE = 1; + public static final int NO_ERROR_STATE = 0; private ValidationMessageAcceptor cliMessageAcceptor = new AbstractValidationMessageAcceptor() { @@ -198,10 +199,18 @@ public class CommandlineToolMain ConsoleLogger.printLog("Using Franca Version " + francaversion); ConsoleLogger.printLog("and CommonAPI Version " + coreversion); + int error_state = NO_ERROR_STATE; for (String file : tempfilelist) { URI uri = URI.createFileURI(file); - Resource resource = rsset.createResource(uri); + Resource resource = null; + try { + resource = rsset.createResource(uri); + } catch (IllegalStateException ise) { + // In case we have a search path with several fidl and fdepl files that have includes to each other: + // This resource may have been already registered. Don't worry, continue. + continue; + } validationErrorCount = 0; if(isValidation) { validate(resource); @@ -212,15 +221,16 @@ public class CommandlineToolMain francaGenerator.doGenerate(resource, fsa); } catch (Exception e) { - System.err.println("Failed to generate code for " + file ); - System.exit(ERROR_STATE); + System.err.println("Failed to generate code for " + file + " due to " + e.getMessage()); + error_state = ERROR_STATE; } } else { ConsoleLogger.printErrorLog(file + " contains validation errors !"); - System.exit(ERROR_STATE); + error_state = ERROR_STATE; } } + System.exit(error_state); } private void validate(Resource resource) { diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java index d23896f..5324063 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java @@ -4,7 +4,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; @@ -18,96 +17,119 @@ import org.franca.deploymodel.dsl.fDeploy.FDModel; import org.franca.deploymodel.dsl.fDeploy.Import; /** - * The FDeployManager loads models from fdepl files and from fidl files that are imported in a fdepl file. - * It continues to import files even it could not find all of them (e.g an unknown deployment specification). + * The FDeployManager loads models from fdepl files and from fidl files that are + * imported in a fdepl file. It continues to import files even it could not find + * all of them (e.g an unknown deployment specification). * * @author gutknecht * */ public class FDeployManager { - private final static String fileExtension = "fdepl"; + private final static String fdeplExtension = "fdepl"; private ResourceSet resourceSet; - + /** - * Map used to handle generically different model files. + * Map used to handle generically different model files. */ private static Map<String, ImportsProvider> fileHandlerRegistry = new HashMap<String, ImportsProvider>(); + private Map<String, FDModel> deploymentModels = new HashMap<String, FDModel>(); + private Map<String, FModel> fidlModels = new HashMap<String, FModel>(); + public FDeployManager() { - + resourceSet = new ResourceSetImpl(); - + // we expect fdepl files - fileHandlerRegistry.put(fileExtension, new FDeployImportsProvider()); + fileHandlerRegistry.put(fdeplExtension, new FDeployImportsProvider()); // allow for fidl file imports fileHandlerRegistry.put("fidl", new FrancaImportsProvider()); - } - + } + /** * - * Load the model found in the fileName. Its dependencies (imports) can be loaded subsequently. - * @param uri the URI to be loaded - * @param root the root of the model (needed for loading multiple file models) - * This has to be an absolute, hierarchical URI. + * Load the model found in the fileName. Its dependencies (imports) can be + * loaded subsequently. + * + * @param uri + * the URI to be loaded + * @param root + * the root of the model (needed for loading multiple file + * models) This has to be an absolute, hierarchical URI. * @return the root model or null in case of an error. */ public EObject loadModel(URI uri, URI root) { // resolve the input uri, in case it is a relative path URI absURI = uri.resolve(root); - if (! uri.equals(absURI)) { - // add this pair to URI converter so that others can get the URI by its relative path + if (!uri.equals(absURI)) { + // add this pair to URI converter so that others can get the URI by + // its relative path resourceSet.getURIConverter().getURIMap().put(uri, absURI); } // load root model Resource resource = null; try { resource = resourceSet.getResource(absURI, true); - // Set the isLoaded flag to false in order to force reloading of fdepl or imported fidl files + // Set the isLoaded flag to false in order to force reloading of + // fdepl/fidl files resource.unload(); resource.load(Collections.EMPTY_MAP); + //System.out.println("Load resource: " + resource.toString()); } catch (Exception e) { - // Don't show an error message here, because code may be generated from an included fidl file. + // Don't show an error message here, because code may be generated + // from an included fidl file. //System.err.println("Failed to load model from : " + absURI); return null; } EObject model = resource.getContents().get(0); - + // load all its imports recursively - for (Iterator<String> it = fileHandlerRegistry.get(absURI.fileExtension()).importsIterator(model); it.hasNext();) { + for (Iterator<String> it = fileHandlerRegistry.get( + absURI.fileExtension()).importsIterator(model); it.hasNext();) { String importURIStr = it.next(); - if(importURIStr != null) { + if (importURIStr != null) { URI importURI = URI.createURI(importURIStr); URI resolvedURI = importURI.resolve(absURI); - // add this pair to URI converter so that others can get the URI by its relative path - resourceSet.getURIConverter().getURIMap().put(importURI, resolvedURI); - //System.out.println("trying to load model " + resolvedURI); - EObject localModel = loadModel(resolvedURI, root); - if(localModel == null) { - // something went wrong with this import, go on with the next one - continue; + // add this pair to URI converter so that others can get the URI + // by its relative path + resourceSet.getURIConverter().getURIMap() + .put(importURI, resolvedURI); + String uriName = resolvedURI.lastSegment(); + //System.out.println("Load model from import " + uriName); + EObject importModel = loadModel(resolvedURI, root); + if (importModel != null) { + if(importModel instanceof FDModel && !(uriName.contains("_spec"))) { + deploymentModels.put(uriName, (FDModel) importModel); + } + else if(importModel instanceof FModel) { + fidlModels.put(uriName, (FModel) importModel); + } } } } - return model; + return model; } /** * @return the file extension this class will deal with (.fdepl) */ public static String fileExtension() { - return fileExtension; - } - + return fdeplExtension; + } + /** * Load the model from fdepl that has an fidl file import - * @param fdmodel - the deployment model from fdepl - * @param input - the fdepl uri + * + * @param fdmodel + * - the deployment model from fdepl + * @param input + * - the fdepl uri * @return the model defined in the fidl file import */ public FModel getModelFromFdepl(FDModel fdmodel, URI input) { - for(Import fdimport : fdmodel.getImports()) { + for (Import fdimport : fdmodel.getImports()) { String uriString = fdimport.getImportURI(); if (uriString.endsWith("fidl")) { URI newUri = URI.createURI(uriString); @@ -118,14 +140,28 @@ public class FDeployManager { resource = resourceSet.getResource(fidlUri, true); resource.load(Collections.EMPTY_MAP); } catch (Exception e) { - // failed to load model from fidl + // failed to load model from fidl return null; } return (FModel) resource.getContents().get(0); } } return null; - } - - + } + + public Map<String, FDModel> getDeploymentModels() { + return deploymentModels; + } + + public void clearDeploymentModels() { + deploymentModels.clear(); + } + + public Map<String, FModel> getFidlModels() { + return fidlModels; + } + + public void clearFidlModels() { + fidlModels.clear(); + } } diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend index 9c9eec5..041e64e 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend @@ -270,7 +270,7 @@ class FInterfaceProxyGenerator { template <typename ... _AttributeExtensions> «fInterface.proxyClassName»<_AttributeExtensions...>::«fInterface.proxyClassName»(std::shared_ptr<CommonAPI::Proxy> delegate): «IF fInterface.base != null» - «fInterface.base.proxyClassName»<_AttributeExtensions...>(delegate), + «fInterface.base.getFullName()»Proxy<_AttributeExtensions...>(delegate), «ENDIF» _AttributeExtensions(*(std::dynamic_pointer_cast<«fInterface.proxyBaseClassName»>(delegate)))..., delegate_(std::dynamic_pointer_cast<«fInterface.proxyBaseClassName»>(delegate)) { diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend index 4ca7c01..7bf06ed 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend @@ -308,7 +308,7 @@ class FInterfaceStubGenerator { «ENDFOR» «FOR managed : fInterface.managedInterfaces» - bool «managed.stubRegisterManagedAutoName»(std::shared_ptr<«managed.stubClassName»>); + bool «managed.stubRegisterManagedAutoName»(std::shared_ptr<«managed.getStubFullClassName»>); «managed.stubRegisterManagedMethod»; bool «managed.stubDeregisterManagedName»(const std::string&); std::set<std::string>& «managed.stubManagedSetGetterName»(); @@ -485,7 +485,7 @@ class FInterfaceStubGenerator { «ENDFOR» «FOR managed : fInterface.managedInterfaces» - bool «fInterface.stubDefaultClassName»::«managed.stubRegisterManagedAutoName»(std::shared_ptr<«managed.stubClassName»> _stub) { + bool «fInterface.stubDefaultClassName»::«managed.stubRegisterManagedAutoName»(std::shared_ptr<«managed.stubFullClassName»> _stub) { autoInstanceCounter_++; std::stringstream ss; ss << «fInterface.stubCommonAPIClassName»::stubAdapter_->getAddress().getInstance() << ".i" << autoInstanceCounter_; diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend index 5d48902..346f5a5 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend @@ -32,6 +32,7 @@ import org.franca.core.franca.FUnionType import org.franca.deploymodel.core.FDeployedInterface import org.franca.deploymodel.core.FDeployedTypeCollection import org.franca.deploymodel.dsl.fDeploy.FDInterface +import org.franca.deploymodel.dsl.fDeploy.FDModel import org.franca.deploymodel.dsl.fDeploy.FDProvider import org.franca.deploymodel.dsl.fDeploy.FDTypes import org.genivi.commonapi.core.deployment.PropertyAccessor @@ -39,102 +40,71 @@ import org.genivi.commonapi.core.preferences.FPreferences import org.genivi.commonapi.core.preferences.PreferenceConstants import static com.google.common.base.Preconditions.* -import org.franca.deploymodel.dsl.fDeploy.FDModel -import org.franca.deploymodel.core.FDModelExtender -class FrancaGenerator implements IGenerator -{ +class FrancaGenerator implements IGenerator { @Inject private extension FTypeCollectionGenerator @Inject private extension FInterfaceGenerator @Inject private extension FInterfaceProxyGenerator @Inject private extension FInterfaceStubGenerator @Inject private extension FrancaGeneratorExtensions - + @Inject private FrancaPersistenceManager francaPersistenceManager @Inject private FDeployManager fDeployManager - override doGenerate(Resource input, IFileSystemAccess fileSystemAccess) - { - var FModel fModel - var List<FDInterface> deployedInterfaces - var List<FDTypes> deployedTypeCollections - var List<FDProvider> deployedProviders + override doGenerate(Resource input, IFileSystemAccess fileSystemAccess) { + var List<FDInterface> deployedInterfaces = new LinkedList<FDInterface>() + var List<FDTypes> deployedTypeCollections = new LinkedList<FDTypes>() + var List<FDProvider> deployedProviders = new LinkedList<FDProvider>() var IResource res = null val String CORE_SPECIFICATION_TYPE = "core.deployment" - // load the model from a fidl file - if(input.URI.fileExtension.equals(francaPersistenceManager.fileExtension)) - { - fModel = francaPersistenceManager.loadModel(input.URI, input.URI) - deployedInterfaces = new LinkedList<FDInterface>() - - } - // load the model from deployment file - else if(input.URI.fileExtension.equals(FDeployManager.fileExtension)) - { - var model = fDeployManager.loadModel(input.URI, input.URI); - if(model instanceof FDModel) { - val fModelExtender = new FDModelExtender(model); - var fdinterfaces = fModelExtender.getFDInterfaces() - // we need at least one FDInterface to access the model ! - if(fdinterfaces.size > 0) { - fModel = fdinterfaces.get(0).target.model - } else { - // empty deployment ! - // try to load the fidl file from the imports of the fdpl - fModel = fDeployManager.getModelFromFdepl(model, input.URI) - } - checkArgument(fModel != null, "\nFailed to load the model from fdepl file,\ncannot generate code.") - // read deployment information - deployedInterfaces = getFDInterfaces(model, CORE_SPECIFICATION_TYPE) - deployedTypeCollections = getFDTypesList(model, CORE_SPECIFICATION_TYPE) - deployedProviders = getFDProviders(model, CORE_SPECIFICATION_TYPE) - } else if(model instanceof FModel) { - fModel = model - deployedInterfaces = new LinkedList<FDInterface>() + // generate code from the fidl or fdepl file + if (input.URI.fileExtension.equals(francaPersistenceManager.fileExtension) || + input.URI.fileExtension.equals(FDeployManager.fileExtension)) { + + var model = fDeployManager.loadModel(input.URI, input.URI); + + // fModels is the map of all models from imported fidl files + var fModels = fDeployManager.fidlModels + + if (model instanceof FDModel) { + // read deployment information + deployedInterfaces = getFDInterfaces(model, CORE_SPECIFICATION_TYPE) + deployedTypeCollections = getFDTypesList(model, CORE_SPECIFICATION_TYPE) + deployedProviders = getFDProviders(model, CORE_SPECIFICATION_TYPE) } - } - else - { - checkArgument(false, "Unknown input: " + input) - } - - try - { - var pathfile = input.URI.toPlatformString(false); - if(pathfile == null) - { - pathfile = FPreferences::instance.getModelPath(fModel) - } - if(pathfile.startsWith("platform:/")) - { - pathfile = pathfile.substring(pathfile.indexOf("platform") + 10) - pathfile = pathfile.substring(pathfile.indexOf(System.getProperty("file.separator"))) + // add the model from the given fidl file + else if(model instanceof FModel) { + fModels.put(input.URI.lastSegment, model); } - res = ResourcesPlugin.workspace.root.findMember(pathfile) + for (fModelEntry : fModels.entrySet) { + //System.out.println("Generation code for: " + fModelEntry.key) + var fModel = fModelEntry.value - doGenerateComponents(fModel, deployedInterfaces, deployedTypeCollections, deployedProviders, fileSystemAccess, res) - } - catch(IllegalStateException e) - { - //happens only when the cli calls the francagenerator + if (fModel != null) { + + // actually generate code + doGenerateComponents(fModel, deployedInterfaces, deployedTypeCollections, deployedProviders, + fileSystemAccess, res) + } + } + fDeployManager.clearFidlModels + } else { + // input has not *.fidl or *.fdepl + checkArgument(false, "Unknown input: " + input) } - doGenerateComponents(fModel, deployedInterfaces, deployedTypeCollections, deployedProviders, fileSystemAccess, res) } - def private doGenerateComponents(FModel fModel, - List<FDInterface> deployedInterfaces, - List<FDTypes> deployedTypeCollections, - List<FDProvider> deployedProviders, - IFileSystemAccess fileSystemAccess, - IResource res) - { + def private doGenerateComponents(FModel fModel, List<FDInterface> deployedInterfaces, + List<FDTypes> deployedTypeCollections, List<FDProvider> deployedProviders, + IFileSystemAccess fileSystemAccess, IResource res) { val allReferencedFTypes = fModel.allReferencedFTypes val allFTypeTypeCollections = allReferencedFTypes.filter[eContainer instanceof FTypeCollection].map[ eContainer as FTypeCollection] - val allFTypeFInterfaces = allReferencedFTypes.filter[eContainer instanceof FInterface].map[eContainer as FInterface] + val allFTypeFInterfaces = allReferencedFTypes.filter[eContainer instanceof FInterface].map[ + eContainer as FInterface] val generateTypeCollections = fModel.typeCollections.toSet generateTypeCollections.addAll(allFTypeTypeCollections) @@ -142,17 +112,14 @@ class FrancaGenerator implements IGenerator val interfacesToGenerate = fModel.allReferencedFInterfaces.toSet interfacesToGenerate.addAll(allFTypeFInterfaces) - val defaultDeploymentAccessor = new PropertyAccessor() - interfacesToGenerate.forEach [ + val defaultDeploymentAccessor = new PropertyAccessor() + interfacesToGenerate.forEach [ val currentInterface = it var PropertyAccessor deploymentAccessor - if (deployedInterfaces != null && deployedInterfaces.exists[it.target == currentInterface]) - { + if (deployedInterfaces != null && deployedInterfaces.exists[it.target == currentInterface]) { deploymentAccessor = new PropertyAccessor( - new FDeployedInterface(deployedInterfaces.filter[it.target == currentInterface].last)) - } - else - { + new FDeployedInterface(deployedInterfaces.filter[it.target == currentInterface].last)) + } else { deploymentAccessor = defaultDeploymentAccessor } generateInterface(it, fileSystemAccess, deploymentAccessor, res) @@ -162,39 +129,31 @@ class FrancaGenerator implements IGenerator val currentTypeCollection = it if (!(currentTypeCollection instanceof FInterface)) { var PropertyAccessor deploymentAccessor - if (deployedTypeCollections != null && deployedTypeCollections.exists[it.target == currentTypeCollection]) { - deploymentAccessor = new PropertyAccessor( - new FDeployedTypeCollection(deployedTypeCollections.filter[it.target == currentTypeCollection].last)) - } else { - deploymentAccessor = defaultDeploymentAccessor - } - generate(it, fileSystemAccess, deploymentAccessor, res) + if (deployedTypeCollections != null && + deployedTypeCollections.exists[it.target == currentTypeCollection]) { + deploymentAccessor = new PropertyAccessor( + new FDeployedTypeCollection( + deployedTypeCollections.filter[it.target == currentTypeCollection].last)) + } else { + deploymentAccessor = defaultDeploymentAccessor + } + generate(it, fileSystemAccess, deploymentAccessor, res) } - ] + ] fModel.interfaces.forEach [ val currentInterface = it var PropertyAccessor deploymentAccessor - if(deployedInterfaces.exists[it.target == currentInterface]) - { + if (deployedInterfaces.exists[it.target == currentInterface]) { deploymentAccessor = new PropertyAccessor( new FDeployedInterface(deployedInterfaces.filter[it.target == currentInterface].last)) - } - else - { + } else { deploymentAccessor = defaultDeploymentAccessor } - val booleanTrue = Boolean.toString(true) - var String finalValue = booleanTrue - finalValue = FPreferences::instance.getPreference(PreferenceConstants::P_GENERATEPROXY, finalValue) - if(finalValue.equals(booleanTrue)) - { + if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATEPROXY, "true").equals("true")) { it.generateProxy(fileSystemAccess, deploymentAccessor, res) } - finalValue = booleanTrue - finalValue = FPreferences::instance.getPreference(PreferenceConstants::P_GENERATESTUB, finalValue) - if(finalValue.equals(booleanTrue)) - { + if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATESTUB, "true").equals("true")) { it.generateStub(fileSystemAccess, res) } ] diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend index 3eb9d6e..e567e39 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend @@ -1435,11 +1435,11 @@ class FrancaGeneratorExtensions { } def stubRegisterManagedMethod(FInterface fInterface) { - 'bool ' + fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.stubClassName + '>, const std::string&)' + 'bool ' + fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.getStubFullClassName + '>, const std::string&)' } def stubRegisterManagedMethodImpl(FInterface fInterface) { - fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.stubClassName + '> _stub, const std::string &_instance)' + fInterface.stubRegisterManagedName + '(std::shared_ptr<' + fInterface.getStubFullClassName + '> _stub, const std::string &_instance)' } def stubDeregisterManagedName(FInterface fInterface) { @@ -1763,7 +1763,7 @@ class FrancaGeneratorExtensions { for(depl : fdmodel.getDeployments()) { if (depl instanceof FDInterface) { var specname = depl.spec.name - if(specname.contains(selector)) { + if(specname != null && specname.contains(selector)) { fdinterfaces.add(depl); } } @@ -1782,7 +1782,7 @@ class FrancaGeneratorExtensions { for(depl : fdmodel.getDeployments()) { if (depl instanceof FDTypes) { var specname = depl.spec?.name - if(specname.contains(selector)) { + if(specname != null && specname.contains(selector)) { fdTypes.add(depl); } } @@ -1837,4 +1837,103 @@ class FrancaGeneratorExtensions { } } + def public getAllReferencedFInterfaces(FModel fModel) + { + val referencedFInterfaces = fModel.interfaces.toSet + fModel.interfaces.forEach[base?.addFInterfaceTree(referencedFInterfaces)] + fModel.interfaces.forEach[managedInterfaces.forEach[addFInterfaceTree(referencedFInterfaces)]] + return referencedFInterfaces + } + + def public void addFInterfaceTree(FInterface fInterface, Collection<FInterface> fInterfaceReferences) + { + if(!fInterfaceReferences.contains(fInterface)) + { + fInterfaceReferences.add(fInterface) + fInterface.base?.addFInterfaceTree(fInterfaceReferences) + } + } + + def public getAllReferencedFTypes(FModel fModel) + { + val referencedFTypes = new HashSet<FType> + + fModel.typeCollections.forEach[types.forEach[addFTypeDerivedTree(referencedFTypes)]] + + fModel.interfaces.forEach [ + attributes.forEach[type.addDerivedFTypeTree(referencedFTypes)] + types.forEach[addFTypeDerivedTree(referencedFTypes)] + methods.forEach [ + inArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)] + outArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)] + ] + broadcasts.forEach [ + outArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)] + ] + ] + + return referencedFTypes + } + + def public void addDerivedFTypeTree(FTypeRef fTypeRef, Collection<FType> fTypeReferences) + { + fTypeRef.derived?.addFTypeDerivedTree(fTypeReferences) + } + + def public dispatch void addFTypeDerivedTree(FTypeDef fTypeDef, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fTypeDef)) + { + fTypeReferences.add(fTypeDef) + fTypeDef.actualType.addDerivedFTypeTree(fTypeReferences) + } + } + + def public dispatch void addFTypeDerivedTree(FArrayType fArrayType, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fArrayType)) + { + fTypeReferences.add(fArrayType) + fArrayType.elementType?.addDerivedFTypeTree(fTypeReferences) + } + } + + def public dispatch void addFTypeDerivedTree(FMapType fMapType, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fMapType)) + { + fTypeReferences.add(fMapType) + fMapType.keyType.addDerivedFTypeTree(fTypeReferences) + fMapType.valueType.addDerivedFTypeTree(fTypeReferences) + } + } + + def public dispatch void addFTypeDerivedTree(FStructType fStructType, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fStructType)) + { + fTypeReferences.add(fStructType) + fStructType.base?.addFTypeDerivedTree(fTypeReferences) + fStructType.elements.forEach[type.addDerivedFTypeTree(fTypeReferences)] + } + } + + def public dispatch void addFTypeDerivedTree(FEnumerationType fEnumerationType, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fEnumerationType)) + { + fTypeReferences.add(fEnumerationType) + fEnumerationType.base?.addFTypeDerivedTree(fTypeReferences) + } + } + + def public dispatch void addFTypeDerivedTree(FUnionType fUnionType, Collection<FType> fTypeReferences) + { + if(!fTypeReferences.contains(fUnionType)) + { + fTypeReferences.add(fUnionType) + fUnionType.base?.addFTypeDerivedTree(fTypeReferences) + fUnionType.elements.forEach[type.addDerivedFTypeTree(fTypeReferences)] + } + } } |