diff options
author | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-19 17:39:44 +0100 |
---|---|---|
committer | Philip Rauwolf <rauwolf@itestra.de> | 2013-02-19 17:39:44 +0100 |
commit | 94181774594725a5d02f0582115e41f74355569b (patch) | |
tree | 395a86815c703ac2c7336e529dbafdbaf7e5e3d3 | |
parent | 0e58661c9f80848bedf7f7156710a2e1fdbe1923 (diff) | |
download | genivi-common-api-runtime-94181774594725a5d02f0582115e41f74355569b.tar.gz |
streamlined base generator code
-rw-r--r-- | org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend | 58 |
1 files changed, 19 insertions, 39 deletions
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 12dbe0a..52d8b2a 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 @@ -33,6 +33,10 @@ import org.genivi.commonapi.core.deployment.DeploymentInterfacePropertyAccessor import static com.google.common.base.Preconditions.* import org.franca.deploymodel.core.FDeployedInterface +import org.franca.deploymodel.dsl.fDeploy.FDInterface +import java.util.List +import java.util.LinkedList +import java.util.Set class FrancaGenerator implements IGenerator { @Inject private extension FTypeCollectionGenerator @@ -46,14 +50,26 @@ class FrancaGenerator implements IGenerator { override doGenerate(Resource input, IFileSystemAccess fileSystemAccess) { + var FModel fModel + var List<FDInterface> deployedInterfaces + if(input.URI.fileExtension.equals(francaPersistenceManager.fileExtension)) { - doGenerateStandardFrancaComponents(input, fileSystemAccess) + fModel = francaPersistenceManager.loadModel(input.filePath) + deployedInterfaces = new LinkedList<FDInterface>() + } else if (input.URI.fileExtension.equals("fdepl" /* fDeployPersistenceManager.fileExtension */)) { - doGenerateDeployedFrancaComponents(input, fileSystemAccess) + var fDeployedModel = fDeployPersistenceManager.loadModel(input.filePathUrl); + val fModelExtender = new FDModelExtender(fDeployedModel); + + checkArgument(fModelExtender.getFDInterfaces().size > 0, "No Interfaces were deployed, nothing to generate.") + fModel = fModelExtender.getFDInterfaces().get(0).target.model + deployedInterfaces = fModelExtender.getFDInterfaces() + } else { checkArgument(false, "Unknown input: " + input) } + doGenerateComponents(fModel, deployedInterfaces, fileSystemAccess) // mainStubGenerator.generate(basicModel.interfaces, null, fileSystemAccess, outputLocation, skeletonFolderPath) // automakeGenerator.generate(basicModel.interfaces, null, fileSystemAccess, outputLocation, skeletonFolderPath) @@ -63,44 +79,9 @@ class FrancaGenerator implements IGenerator { // } // finalizeTypeGeneration(fileSystemAccess, outputLocation) } - - - def private doGenerateStandardFrancaComponents(Resource input, IFileSystemAccess fileSystemAccess) { - val fModel = francaPersistenceManager.loadModel(input.filePath) - - val deploymentAccessor = new DeploymentInterfacePropertyAccessorWrapper(null) as DeploymentInterfacePropertyAccessor - - - 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 generateTypeCollections = fModel.typeCollections.toSet - generateTypeCollections.addAll(allFTypeTypeCollections) - - val generateInterfaces = fModel.allReferencedFInterfaces.toSet - generateInterfaces.addAll(allFTypeFInterfaces) - - - - generateTypeCollections.forEach[generate(it, fileSystemAccess, deploymentAccessor)] - generateInterfaces.forEach[ - generate(it, fileSystemAccess, deploymentAccessor) - ] - fModel.interfaces.forEach[ - it.generateProxy(fileSystemAccess, deploymentAccessor) - it.generateStub(fileSystemAccess) - ] - } - def private doGenerateDeployedFrancaComponents(Resource input, IFileSystemAccess access) { - var fDeployedModel = fDeployPersistenceManager.loadModel(input.filePathUrl); - val fModelExtender = new FDModelExtender(fDeployedModel); - - checkArgument(fModelExtender.getFDInterfaces().size > 0, "No Interfaces were deployed, nothing to generate.") - val fModel = fModelExtender.getFDInterfaces().get(0).target.model - + def private doGenerateComponents(FModel fModel, List<FDInterface> deployedInterfaces, IFileSystemAccess access) { 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] @@ -111,7 +92,6 @@ class FrancaGenerator implements IGenerator { val generateInterfaces = fModel.allReferencedFInterfaces.toSet generateInterfaces.addAll(allFTypeFInterfaces) - val deployedInterfaces = fModelExtender.getFDInterfaces() val defaultDeploymentAccessor = new DeploymentInterfacePropertyAccessorWrapper(null) as DeploymentInterfacePropertyAccessor generateTypeCollections.forEach[generate(it, access, defaultDeploymentAccessor)] |