Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-10-06 09:31:21 +0000
committerHenrik Rentz-Reichert2011-10-06 09:31:21 +0000
commit26bb4e9daf8b11e8ea7866f0e06d06750d9d5d3f (patch)
tree10b8abe41aa2f35dabdea1ff212e3e5713916866
parent77597cd1f117794512309c1199fd8c13062d01c5 (diff)
downloadorg.eclipse.etrice-26bb4e9daf8b11e8ea7866f0e06d06750d9d5d3f.tar.gz
org.eclipse.etrice-26bb4e9daf8b11e8ea7866f0e06d06750d9d5d3f.tar.xz
org.eclipse.etrice-26bb4e9daf8b11e8ea7866f0e06d06750d9d5d3f.zip
[generator] added more helpers for code generation
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomModelValidator.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java13
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator/model/etricegen.ecore3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java12
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DependencyManager.java99
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/FileSystemHelpers.java68
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/builder/GeneratorModelBuilder.java3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java13
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/ETriceGenPackageImpl.java2
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java52
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java1
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java28
-rw-r--r--tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/TestInstanceModelBuilderBase.java2
14 files changed, 257 insertions, 45 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomModelValidator.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomModelValidator.java
index 9e1df1031..70ffc3ca5 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomModelValidator.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/RoomModelValidator.java
@@ -67,7 +67,7 @@ public class RoomModelValidator extends RoomJavaValidator implements ILogger {
LinkedList<RoomModel> models = new LinkedList<RoomModel>();
models.add(model);
- builder.createGeneratorModel(models);
+ builder.createGeneratorModel(models, false);
System.out.println("done checking model "+model.getName()+" with result: "+(diagnostician.isFailed()?"failed":"ok"));
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
index bb37b2aa0..3de860418 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
@@ -30,11 +30,12 @@ public class Main extends AbstractGenerator {
* print usage message to stderr
*/
private static void printUsage() {
- output.println(Main.class.getName()+" [-saveGenModel <genmodel path>] [-genInstDiag] <list of model file paths>");
+ output.println(Main.class.getName()+" [-saveGenModel <genmodel path>] [-genInstDiag] [-lib] <list of model file paths>");
output.println(" <list of model file paths> # model file paths may be specified as");
output.println(" # e.g. C:\\path\\to\\model\\mymodel.room");
output.println(" -saveGenModel <genmodel path> # if specified the generator model will be saved to this location");
output.println(" -genInstDiag # if specified an instance diagram is created for each subsystem");
+ output.println(" -lib # if specified all classes are generated and no instances");
}
public static void main(String[] args) {
@@ -58,6 +59,7 @@ public class Main extends AbstractGenerator {
String genModelPath = null;
List<String> uriList = new ArrayList<String>();
boolean genInstDiag = false;
+ boolean asLibrary = false;
for (int i=0; i<args.length; ++i) {
if (args[i].equals("-saveGenModel")) {
if (++i<args.length) {
@@ -67,6 +69,9 @@ public class Main extends AbstractGenerator {
else if (args[i].equals("-genInstDiag")) {
genInstDiag = true;
}
+ else if (args[i].equals("-lib")) {
+ asLibrary = true;
+ }
else {
uriList.add(convertToURI(args[i]));
}
@@ -74,10 +79,10 @@ public class Main extends AbstractGenerator {
setupRoomModel();
- runGenerator(uriList, genModelPath, genInstDiag);
+ runGenerator(uriList, genModelPath, genInstDiag, asLibrary);
}
- protected boolean runGenerator(List<String> uriList, String genModelPath, boolean genInstDiag) {
+ protected boolean runGenerator(List<String> uriList, String genModelPath, boolean genInstDiag, boolean asLibrary) {
ResourceSet rs = resourceSetProvider.get();
loadModels(uriList, rs);
@@ -85,7 +90,7 @@ public class Main extends AbstractGenerator {
if (!validateModels(rs))
return false;
- Root genModel = createGeneratorModel(rs, genModelPath);
+ Root genModel = createGeneratorModel(rs, asLibrary, genModelPath);
if (genModel==null)
return false;
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
index 49b8fa35d..d6c9734c6 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/MainGen.xtend
@@ -46,6 +46,8 @@ class MainGen implements IGenerator {
actorClassGen.doGenerate(e);
subsystemClassGen.doGenerate(e);
- subsystemRunnerGen.doGenerate(e);
+ if (!e.library) {
+ subsystemRunnerGen.doGenerate(e);
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator/model/etricegen.ecore b/plugins/org.eclipse.etrice.generator/model/etricegen.ecore
index 95c46f673..d2c5486b3 100644
--- a/plugins/org.eclipse.etrice.generator/model/etricegen.ecore
+++ b/plugins/org.eclipse.etrice.generator/model/etricegen.ecore
@@ -10,8 +10,7 @@
<eOperations name="getReferencedProtocols" upperBound="-1" eType="ecore:EClass ../../org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore#//ProtocolClass">
<eParameters name="cls" eType="ecore:EClass ../../org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore#//ActorClass"/>
</eOperations>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="library" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
- changeable="false" volatile="true" transient="true" derived="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="library" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="subSystemInstances" upperBound="-1"
eType="#//SubSystemInstance" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="models" upperBound="-1"
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index decfcb377..5e2b9b65e 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -101,7 +101,7 @@ public abstract class AbstractGenerator {
*
* @return the {@link Root} object of the generator model (is added to a new Resource also)
*/
- protected Root createGeneratorModel(ResourceSet rs, String genModelPath) {
+ protected Root createGeneratorModel(ResourceSet rs, boolean asLibrary, String genModelPath) {
// create a list of ROOM models
List<RoomModel> rml = new ArrayList<RoomModel>();
for (Resource resource : rs.getResources()) {
@@ -118,7 +118,7 @@ public abstract class AbstractGenerator {
else {
logger.logInfo("-- creating generator model");
GeneratorModelBuilder gmb = new GeneratorModelBuilder(logger, diagnostician);
- Root gmRoot = gmb.createGeneratorModel(rml);
+ Root gmRoot = gmb.createGeneratorModel(rml, asLibrary);
if (diagnostician.isFailed()) {
logger.logInfo("validation failed during build of generator model");
logger.logError("-- terminating", null);
@@ -182,19 +182,23 @@ public abstract class AbstractGenerator {
* @param uriList a list of {@link URI}s as Strings
* @param rs the {@link ResourceSet}
*/
- protected void loadModels(List<String> uriList, ResourceSet rs) {
+ protected boolean loadModels(List<String> uriList, ResourceSet rs) {
logger.logInfo("-- reading models");
+ boolean ok = true;
for (String uriString : uriList) {
logger.logInfo("Loading " + uriString);
try {
rs.getResource(URI.createURI(uriString), true);
}
catch (RuntimeException e) {
- logger.logError("couldn't load", null);
+ ok = false;
+ logger.logError("couldn't load '"+uriString+"'", null);
}
}
EcoreUtil.resolveAll(rs);
+
+ return ok;
}
/**
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DependencyManager.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DependencyManager.java
new file mode 100644
index 000000000..27e1ea6f2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/DependencyManager.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.etrice.core.room.RoomModel;
+
+/**
+ * a class that computes dependencies of ROOM models.
+ *
+ * All models contained in the generator model are looked at.
+ * Then the paths of the associated eResource are searched upward
+ * for a marker file (in the case of an Eclipse project this would
+ * be <code>.project</code>).</br></br>
+ *
+ * If this path differs from the supplied main path then the
+ * model is mapped as referenced model to a relative path from
+ * the main path to the referenced project.
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DependencyManager {
+
+ private HashMap<String, String> refmodel2relpath = new HashMap<String, String>();
+
+ /**
+ * calls {@link #computeDependencies(List, URI, String)} with '.project' as
+ * project marker file.
+ *
+ * @param models a list of all ROOM models
+ * @param main
+ */
+ public void computeProjectDependencies(List<RoomModel> models, URI main) {
+ computeDependencies(models, main, ".project");
+ }
+
+ /**
+ * see the description of the {@link DependencyManager} class
+ *
+ * @param models a list of all ROOM models
+ * @param main
+ * @param projectMarker
+ */
+ public void computeDependencies(List<RoomModel> models, URI main, String projectMarker) {
+ for (RoomModel model : models) {
+ URI uri = FileSystemHelpers.getMarkerFileURI(model, projectMarker);
+ if (!uri.equals(main)) {
+ String relativePath = FileSystemHelpers.getRelativePath(main, uri, true);
+ refmodel2relpath.put(model.getName(), relativePath);
+ }
+ }
+ }
+
+ /**
+ * @return the map of referenced models to relative paths
+ */
+ public Map<String, String> getReferencedModelToRelPath() {
+ return refmodel2relpath;
+ }
+
+ /**
+ * @return all referenced model names
+ */
+ public Set<String> getReferencedModels() {
+ return refmodel2relpath.keySet();
+ }
+
+ /**
+ * @return all relative paths of referenced models
+ */
+ public Collection<String> getReferencedModelRelativePaths() {
+ return refmodel2relpath.values();
+ }
+
+ /**
+ * @param refmodel the name of a referenced model
+ * @return the relative path of the referenced model' project
+ */
+ public String getRelativePath(String refmodel) {
+ return refmodel2relpath.get(refmodel);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/FileSystemHelpers.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/FileSystemHelpers.java
index 8e36981e6..99e463cb2 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/FileSystemHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/FileSystemHelpers.java
@@ -99,14 +99,39 @@ public class FileSystemHelpers {
/**
* the given paths are converted to file URIs (using {@link URI#createFileURI(String)}
- * and then {@link #getRelativePath(URI, URI)} is called.
+ * and then {@link #getRelativePath(URI, URI, boolean)} is called with <code>goUpIfNeeded=false</code>.
*
* @param base the base path
* @param path the path for which the relative path is computed
* @return relative path (<code>null</code>if there is none)
*/
public static String getRelativePath(String base, String path) {
- return getRelativePath(URI.createFileURI(base), URI.createFileURI(path));
+ return getRelativePath(URI.createFileURI(base), URI.createFileURI(path), false);
+ }
+
+ /**
+ * the given paths are converted to file URIs (using {@link URI#createFileURI(String)}
+ * and then {@link #getRelativePath(URI, URI, boolean)} is called.
+ *
+ * @param base the base path
+ * @param path the path for which the relative path is computed
+ * @param goUpIfNeeded allow also ascending to parent directories
+ * @return relative path (<code>null</code>if there is none)
+ */
+ public static String getRelativePath(String base, String path, boolean goUpIfNeeded) {
+ return getRelativePath(URI.createFileURI(base), URI.createFileURI(path), goUpIfNeeded);
+ }
+
+ /**
+ * {@link #getRelativePath(URI, URI, boolean)} is called with
+ * <code>goUpIfNeeded=false</code>
+ *
+ * @param base the base path
+ * @param path the path for which the relative path is computed
+ * @return relative path (<code>null</code>if there is none)
+ */
+ public static String getRelativePath(URI base, URI path) {
+ return getRelativePath(base, path, false);
}
/**
@@ -118,9 +143,10 @@ public class FileSystemHelpers {
*
* @param base the base path
* @param path the path for which the relative path is computed
+ * @param goUpIfNeeded allow also ascending to parent directories
* @return relative path (<code>null</code>if there is none)
*/
- public static String getRelativePath(URI base, URI path) {
+ public static String getRelativePath(URI base, URI path, boolean goUpIfNeeded) {
if (base==null || path==null)
return null;
@@ -136,16 +162,34 @@ public class FileSystemHelpers {
if (path.segmentCount()<base.segmentCount())
return null;
- for (int i=0; i<base.segmentCount(); ++i) {
- if (!base.segment(i).equals(path.segment(i)))
- return null;
- }
-
StringBuffer result = new StringBuffer();
- for (int i=base.segmentCount(); i<path.segmentCount(); ++i) {
- result.append(path.segment(i)+"/");
+ if (goUpIfNeeded) {
+ int max = base.segmentCount()<path.segmentCount()? base.segmentCount():path.segmentCount();
+ int common;
+ for (common=0; common<max; ++common) {
+ if (!base.segment(common).equals(path.segment(common)))
+ break;
+ }
+ for (int i=common; i<base.segmentCount(); ++i) {
+ result.append("../");
+ }
+ for (int i=common; i<path.segmentCount(); ++i) {
+ result.append(path.segment(i)+"/");
+ }
+
+ return result.substring(0, result.length()-1);
+ }
+ else {
+ for (int i=0; i<base.segmentCount(); ++i) {
+ if (!base.segment(i).equals(path.segment(i)))
+ return null;
+ }
+
+ for (int i=base.segmentCount(); i<path.segmentCount(); ++i) {
+ result.append(path.segment(i)+"/");
+ }
+
+ return result.substring(0, result.length()-1);
}
-
- return result.substring(0, result.length()-1);
}
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/builder/GeneratorModelBuilder.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/builder/GeneratorModelBuilder.java
index 1e5a75e81..e90a1113d 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/builder/GeneratorModelBuilder.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/builder/GeneratorModelBuilder.java
@@ -118,9 +118,10 @@ public class GeneratorModelBuilder {
* @param models
* @return the root of the newly created instance model
*/
- public Root createGeneratorModel(List<RoomModel> models) {
+ public Root createGeneratorModel(List<RoomModel> models, boolean asLibrary) {
Root root = ETriceGenFactory.eINSTANCE.createRoot();
root.getModels().addAll(models);
+ root.setLibrary(asLibrary);
if (!root.isLibrary()) {
// create instance model
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
index f10420e65..2f64d2304 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/Root.java
@@ -179,13 +179,24 @@ public interface Root extends EObject {
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Library</em>' attribute.
+ * @see #setLibrary(boolean)
* @see org.eclipse.etrice.generator.etricegen.ETriceGenPackage#getRoot_Library()
- * @model transient="true" changeable="false" volatile="true" derived="true"
+ * @model
* @generated
*/
boolean isLibrary();
/**
+ * Sets the value of the '{@link org.eclipse.etrice.generator.etricegen.Root#isLibrary <em>Library</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Library</em>' attribute.
+ * @see #isLibrary()
+ * @generated
+ */
+ void setLibrary(boolean value);
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/ETriceGenPackageImpl.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/ETriceGenPackageImpl.java
index 09b66b923..ea936dc3d 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/ETriceGenPackageImpl.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/ETriceGenPackageImpl.java
@@ -993,7 +993,7 @@ public class ETriceGenPackageImpl extends EPackageImpl implements ETriceGenPacka
// Initialize classes and features; add operations and parameters
initEClass(rootEClass, Root.class, "Root", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getRoot_Library(), ecorePackage.getEBoolean(), "library", null, 0, 1, Root.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ initEAttribute(getRoot_Library(), ecorePackage.getEBoolean(), "library", null, 0, 1, Root.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getRoot_SubSystemInstances(), this.getSubSystemInstance(), null, "subSystemInstances", null, 0, -1, Root.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getRoot_Models(), theRoomPackage.getRoomModel(), null, "models", null, 0, -1, Root.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getRoot_XpActorClasses(), this.getExpandedActorClass(), null, "xpActorClasses", null, 0, -1, Root.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
index 152eca026..44218d69f 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/impl/RootImpl.java
@@ -7,6 +7,7 @@
package org.eclipse.etrice.generator.etricegen.impl;
import java.util.Collection;
+import org.eclipse.emf.common.notify.Notification;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -21,6 +22,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
@@ -98,6 +100,16 @@ public class RootImpl extends EObjectImpl implements Root {
protected static final boolean LIBRARY_EDEFAULT = false;
/**
+ * The cached value of the '{@link #isLibrary() <em>Library</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isLibrary()
+ * @generated
+ * @ordered
+ */
+ protected boolean library = LIBRARY_EDEFAULT;
+
+ /**
* The cached value of the '{@link #getSubSystemInstances() <em>Sub System Instances</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -278,10 +290,22 @@ public class RootImpl extends EObjectImpl implements Root {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated NOT
+ * @generated
*/
public boolean isLibrary() {
- return getMainPathSubSystemClasses().isEmpty();
+ return library;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setLibrary(boolean newLibrary) {
+ boolean oldLibrary = library;
+ library = newLibrary;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, ETriceGenPackage.ROOT__LIBRARY, oldLibrary, library));
}
/**
@@ -416,6 +440,9 @@ public class RootImpl extends EObjectImpl implements Root {
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
+ case ETriceGenPackage.ROOT__LIBRARY:
+ setLibrary((Boolean)newValue);
+ return;
case ETriceGenPackage.ROOT__SUB_SYSTEM_INSTANCES:
getSubSystemInstances().clear();
getSubSystemInstances().addAll((Collection<? extends SubSystemInstance>)newValue);
@@ -460,6 +487,9 @@ public class RootImpl extends EObjectImpl implements Root {
@Override
public void eUnset(int featureID) {
switch (featureID) {
+ case ETriceGenPackage.ROOT__LIBRARY:
+ setLibrary(LIBRARY_EDEFAULT);
+ return;
case ETriceGenPackage.ROOT__SUB_SYSTEM_INSTANCES:
getSubSystemInstances().clear();
return;
@@ -497,7 +527,7 @@ public class RootImpl extends EObjectImpl implements Root {
public boolean eIsSet(int featureID) {
switch (featureID) {
case ETriceGenPackage.ROOT__LIBRARY:
- return isLibrary() != LIBRARY_EDEFAULT;
+ return library != LIBRARY_EDEFAULT;
case ETriceGenPackage.ROOT__SUB_SYSTEM_INSTANCES:
return subSystemInstances != null && !subSystemInstances.isEmpty();
case ETriceGenPackage.ROOT__MODELS:
@@ -518,6 +548,22 @@ public class RootImpl extends EObjectImpl implements Root {
return super.eIsSet(featureID);
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (library: ");
+ result.append(library);
+ result.append(')');
+ return result.toString();
+ }
+
private HashMap<String, DataClass> name2dc = new HashMap<String, DataClass>();
private BasicEList<DataClass> usedDataClasses = null;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
index e71308fa0..b38ea5a4a 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/etricegen/util/ETriceGenSwitch.java
@@ -13,6 +13,7 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.StructureClass;
+import org.eclipse.etrice.generator.etricegen.*;
import org.eclipse.etrice.generator.etricegen.ActiveTrigger;
import org.eclipse.etrice.generator.etricegen.ActorInstance;
import org.eclipse.etrice.generator.etricegen.BindingInstance;
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
index d3e141a2e..600f7c6cf 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/extensions/RoomExtensions.java
@@ -61,7 +61,7 @@ public class RoomExtensions {
{
ArrayList<Port> _arrayList = new ArrayList<Port>();
ArrayList<Port> ret = _arrayList;
- for (ExternalPort ele : in2) {
+ for (final ExternalPort ele : in2) {
Port _ifport = ele.getIfport();
ret.add(_ifport);
}
@@ -117,7 +117,7 @@ public class RoomExtensions {
tmpf = _parentFile;
String[] _list = tmpf.list();
String[] contents = _list;
- for (String f : contents) {
+ for (final String f : contents) {
boolean _equals = f.equals(".project");
if (_equals) {
isProject = true;
@@ -283,7 +283,7 @@ public class RoomExtensions {
} else {
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (MessageHandler hdlr : _msgHandlers) {
+ for (final MessageHandler hdlr : _msgHandlers) {
List<Message> _outgoing = this.getOutgoing(pc, conj);
Message _msg = hdlr.getMsg();
boolean _contains = _outgoing.contains(_msg);
@@ -305,7 +305,7 @@ public class RoomExtensions {
} else {
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (MessageHandler hdlr : _msgHandlers) {
+ for (final MessageHandler hdlr : _msgHandlers) {
List<Message> _incoming = this.getIncoming(pc, conj);
Message _msg = hdlr.getMsg();
boolean _contains = _incoming.contains(_msg);
@@ -330,7 +330,7 @@ public class RoomExtensions {
ArrayList<MessageHandler> res = _arrayList_1;
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (MessageHandler hdlr : _msgHandlers) {
+ for (final MessageHandler hdlr : _msgHandlers) {
List<Message> _incoming = this.getIncoming(pc, conj);
Message _msg = hdlr.getMsg();
boolean _contains = _incoming.contains(_msg);
@@ -355,7 +355,7 @@ public class RoomExtensions {
ArrayList<MessageHandler> res = _arrayList_1;
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (MessageHandler hdlr : _msgHandlers) {
+ for (final MessageHandler hdlr : _msgHandlers) {
List<Message> _outgoing = this.getOutgoing(pc, conj);
Message _msg = hdlr.getMsg();
boolean _contains = _outgoing.contains(_msg);
@@ -413,7 +413,7 @@ public class RoomExtensions {
ArrayList<State> _arrayList = new ArrayList<State>();
ArrayList<State> res = _arrayList;
EList<State> _states = sg.getStates();
- for (State s : _states) {
+ for (final State s : _states) {
List<State> _leafStateList = this.getLeafStateList(s);
res.addAll(_leafStateList);
}
@@ -442,7 +442,7 @@ public class RoomExtensions {
ArrayList<State> _arrayList = new ArrayList<State>();
ArrayList<State> ret = _arrayList;
EList<State> _states = sg.getStates();
- for (State e : _states) {
+ for (final State e : _states) {
{
ret.add(e);
StateGraph _subgraph = e.getSubgraph();
@@ -464,7 +464,7 @@ public class RoomExtensions {
ArrayList<State> _arrayList = new ArrayList<State>();
ArrayList<State> ret = _arrayList;
List<State> _stateList = this.getStateList(sg);
- for (State e : _stateList) {
+ for (final State e : _stateList) {
if ((e instanceof org.eclipse.etrice.core.room.BaseState)) {
ret.add(e);
}
@@ -616,7 +616,7 @@ public class RoomExtensions {
{
boolean hasGuard = false;
EList<TriggeredTransition> _transitions = at.getTransitions();
- for (TriggeredTransition t : _transitions) {
+ for (final TriggeredTransition t : _transitions) {
EList<Trigger> _triggers = t.getTriggers();
final Function1<Trigger,Boolean> _function = new Function1<Trigger,Boolean>() {
public Boolean apply(final Trigger e) {
@@ -731,14 +731,14 @@ public class RoomExtensions {
public String getContextId(final TransitionChain tc) {
State _stateContext = tc.getStateContext();
- String _stateId = this.nameProvider.getStateId(_stateContext);
+ String _stateId = this.getStateId(_stateContext);
return _stateId;
}
public Transition getInitTransition(final StateGraph sg) {
{
EList<Transition> _transitions = sg.getTransitions();
- for (Transition tr : _transitions) {
+ for (final Transition tr : _transitions) {
if ((tr instanceof org.eclipse.etrice.core.room.InitialTransition)) {
return tr;
}
@@ -750,7 +750,7 @@ public class RoomExtensions {
public boolean hasInitTransition(final StateGraph sg) {
{
EList<Transition> _transitions = sg.getTransitions();
- for (Transition tr : _transitions) {
+ for (final Transition tr : _transitions) {
if ((tr instanceof org.eclipse.etrice.core.room.InitialTransition)) {
return true;
}
@@ -777,7 +777,7 @@ public class RoomExtensions {
ArrayList<Transition> _arrayList = new ArrayList<Transition>(_transitions);
ArrayList<Transition> res = _arrayList;
EList<State> _states = sg.getStates();
- for (State s : _states) {
+ for (final State s : _states) {
List<Transition> _transitionList = this.getTransitionList(s);
res.addAll(_transitionList);
}
diff --git a/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/TestInstanceModelBuilderBase.java b/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/TestInstanceModelBuilderBase.java
index 8bcf75b69..df4b9257a 100644
--- a/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/TestInstanceModelBuilderBase.java
+++ b/tests/org.eclipse.etrice.generator.tests/src/org/eclipse/etrice/generator/TestInstanceModelBuilderBase.java
@@ -112,7 +112,7 @@ public class TestInstanceModelBuilderBase {
protected Root buildInstanceModel(String modelName) {
GeneratorModelBuilder builder = new GeneratorModelBuilder(new Logger(), new Diagnostician());
LinkedList<RoomModel> models = getModels(modelName);
- Root root = builder.createGeneratorModel(models);
+ Root root = builder.createGeneratorModel(models, false);
return root;
}

Back to the top