Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-03-15 11:51:35 +0000
committerHenrik Rentz-Reichert2013-03-15 11:51:35 +0000
commit08425187808562c83d98bdaf77d4ed3c8a59aae7 (patch)
tree5e50aa1307c58dc35448a64b9bc3e0b3025bc4ad /plugins
parent0052cd77a4b786b1d0fde877f27a505c53087c16 (diff)
downloadorg.eclipse.etrice-08425187808562c83d98bdaf77d4ed3c8a59aae7.tar.gz
org.eclipse.etrice-08425187808562c83d98bdaf77d4ed3c8a59aae7.tar.xz
org.eclipse.etrice-08425187808562c83d98bdaf77d4ed3c8a59aae7.zip
[core.room] bug 403441: DataClass: attribute with ref to self does not work
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403441 ...and added some model documentation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java11
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore46
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/DataClass.java30
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/Import.java31
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomClass.java8
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomModel.java18
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend89
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend4
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java12
-rw-r--r--plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java108
-rw-r--r--plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java14
11 files changed, 320 insertions, 51 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java
index cbb1a07e3..69ed6a43d 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/quickfix/RoomQuickfixProvider.java
@@ -79,4 +79,15 @@ public class RoomQuickfixProvider extends DefaultQuickfixProvider {
}
});
}
+
+ @Fix(RoomJavaValidator.CIRCULAR_CONTAINMENT)
+ public void fixCircularContainment(final Issue issue, IssueResolutionAcceptor acceptor) {
+ acceptor.accept(issue, "Make attribute a reference", "add 'ref' keyword", "add.gif", new IModification() {
+ public void apply(IModificationContext context) throws BadLocationException {
+ IXtextDocument xtextDocument = context.getXtextDocument();
+ int offset = Integer.parseInt(issue.getData()[0]);
+ xtextDocument.replace(issue.getOffset()+offset, 0, " ref");
+ }
+ });
+ }
}
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore
index f8133ff69..dfd13dcba 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore
@@ -3,11 +3,11 @@
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="room" nsURI="http://www.eclipse.org/etrice/Room" nsPrefix="room">
<eClassifiers xsi:type="ecore:EClass" name="RoomModel">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
- <details key="documentation" value="&lt;br>&#xD;&#xA;"/>
+ <details key="documentation" value="The root object for the ROOM model. It gives access to {@link Import imports} and&#xD;&#xA;the {@link SubSystemClass sub system},&#xD;&#xA;{@link ActorClass actor}, {@link ProtocolClass protocol} and&#xD;&#xA;{@link DataClass data} classes defined.&#xD;&#xA;"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
- <details key="documentation" value="&lt;br>&#xD;&#xA;"/>
+ <details key="documentation" value="The model name is a dot separated fully qualified name and is&#xD;&#xA;used to provide a name space. The generators may use that also&#xD;&#xA;to place the generated code into separate directories.&#xD;&#xA;"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="docu" eType="#//Documentation"
@@ -30,7 +30,11 @@
eType="#//LogicalSystem" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RoomClass">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The name of the data class by which it is referred to in the model.&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="docu" eType="#//Documentation"
containment="true"/>
</eClassifiers>
@@ -82,7 +86,14 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultValueLiteral" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DataClass" eSuperTypes="#//ComplexType">
- <eStructuralFeatures xsi:type="ecore:EReference" name="base" eType="#//DataClass"/>
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The data class in ROOM is a {@link ComplexType} which has {@link Attribute} members.&#xD;&#xA;It can be derived from a single base data class. &#xD;&#xA;"/>
+ </eAnnotations>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="base" eType="#//DataClass">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The base class from which all attributes and operations are inherited.&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="annotations" upperBound="-1"
eType="#//Annotation" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="userCode1" eType="#//DetailCode"
@@ -92,9 +103,17 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="userCode3" eType="#//DetailCode"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="attributes" upperBound="-1"
- eType="#//Attribute" containment="true"/>
+ eType="#//Attribute" containment="true">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Attributes are the data members of the data class.&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="operations" upperBound="-1"
- eType="#//StandardOperation" containment="true"/>
+ eType="#//StandardOperation" containment="true">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Operations are the methods of the data class.&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Attribute">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
@@ -465,7 +484,18 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Import">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="importedNamespace" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="importURI" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The import references another ROOM model. Optionally it may import also&#xD;&#xA;the name space of the imported model.&#xD;&#xA;"/>
+ </eAnnotations>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="importedNamespace" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The imported name space has to be a dot separated qualified name followed by .*.&#xD;&#xA;Example: my.namespace.*&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="importURI" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The import URI can be a relative or absolute file system path.&#xD;&#xA;It may contain environment variables in ${} which will be expanded.&#xD;&#xA;&lt;p>&#xD;&#xA;Examples:&#xD;&#xA;&lt;ul>&#xD;&#xA; &lt;li>import model &quot;AnotherModel.room&quot;&lt;/li>&#xD;&#xA; &lt;li>import my.namespace.* from &quot;AnotherModel.room&quot;&lt;/li>&#xD;&#xA; &lt;li>import my.namespace.* from &quot;../../AnotherProject/models/AnotherModel.room&quot;&lt;/li>&#xD;&#xA; &lt;li>import my.namespace.* from &quot;/${ROOM_MODELS}/SomeModel.room&quot;&lt;/li>&#xD;&#xA;&lt;/ul>&#xD;&#xA;&lt;/p>&#xD;&#xA;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/DataClass.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/DataClass.java
index 0a009f532..f38e075a1 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/DataClass.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/DataClass.java
@@ -9,6 +9,12 @@ import org.eclipse.emf.common.util.EList;
* A representation of the model object '<em><b>Data Class</b></em>'.
* <!-- end-user-doc -->
*
+ * <!-- begin-model-doc -->
+ * The data class in ROOM is a {@link ComplexType} which has {@link Attribute} members.
+ * It can be derived from a single base data class.
+ *
+ * <!-- end-model-doc -->
+ *
* <p>
* The following features are supported:
* <ul>
@@ -31,11 +37,11 @@ public interface DataClass extends ComplexType
/**
* Returns the value of the '<em><b>Base</b></em>' reference.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Base</em>' reference isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * The base class from which all attributes and operations are inherited.
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Base</em>' reference.
* @see #setBase(DataClass)
* @see org.eclipse.etrice.core.room.RoomPackage#getDataClass_Base()
@@ -152,11 +158,11 @@ public interface DataClass extends ComplexType
* Returns the value of the '<em><b>Attributes</b></em>' containment reference list.
* The list contents are of type {@link org.eclipse.etrice.core.room.Attribute}.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Attributes</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * Attributes are the data members of the data class.
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Attributes</em>' containment reference list.
* @see org.eclipse.etrice.core.room.RoomPackage#getDataClass_Attributes()
* @model containment="true"
@@ -168,11 +174,11 @@ public interface DataClass extends ComplexType
* Returns the value of the '<em><b>Operations</b></em>' containment reference list.
* The list contents are of type {@link org.eclipse.etrice.core.room.StandardOperation}.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Operations</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * Operations are the methods of the data class.
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Operations</em>' containment reference list.
* @see org.eclipse.etrice.core.room.RoomPackage#getDataClass_Operations()
* @model containment="true"
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/Import.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/Import.java
index 8e057e5ab..647084e31 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/Import.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/Import.java
@@ -9,6 +9,12 @@ import org.eclipse.emf.ecore.EObject;
* A representation of the model object '<em><b>Import</b></em>'.
* <!-- end-user-doc -->
*
+ * <!-- begin-model-doc -->
+ * The import references another ROOM model. Optionally it may import also
+ * the name space of the imported model.
+ *
+ * <!-- end-model-doc -->
+ *
* <p>
* The following features are supported:
* <ul>
@@ -26,11 +32,12 @@ public interface Import extends EObject
/**
* Returns the value of the '<em><b>Imported Namespace</b></em>' attribute.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Imported Namespace</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * The imported name space has to be a dot separated qualified name followed by .*.
+ * Example: my.namespace.*
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Imported Namespace</em>' attribute.
* @see #setImportedNamespace(String)
* @see org.eclipse.etrice.core.room.RoomPackage#getImport_ImportedNamespace()
@@ -52,11 +59,21 @@ public interface Import extends EObject
/**
* Returns the value of the '<em><b>Import URI</b></em>' attribute.
* <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * The import URI can be a relative or absolute file system path.
+ * It may contain environment variables in ${} which will be expanded.
* <p>
- * If the meaning of the '<em>Import URI</em>' attribute isn't clear,
- * there really should be more of a description here...
+ * Examples:
+ * <ul>
+ * <li>import model "AnotherModel.room"</li>
+ * <li>import my.namespace.* from "AnotherModel.room"</li>
+ * <li>import my.namespace.* from "../../AnotherProject/models/AnotherModel.room"</li>
+ * <li>import my.namespace.* from "/${ROOM_MODELS}/SomeModel.room"</li>
+ * </ul>
* </p>
- * <!-- end-user-doc -->
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Import URI</em>' attribute.
* @see #setImportURI(String)
* @see org.eclipse.etrice.core.room.RoomPackage#getImport_ImportURI()
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomClass.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomClass.java
index 96ab6f7b8..3ffcf204a 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomClass.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomClass.java
@@ -26,11 +26,11 @@ public interface RoomClass extends EObject
/**
* Returns the value of the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Name</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * The name of the data class by which it is referred to in the model.
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see org.eclipse.etrice.core.room.RoomPackage#getRoomClass_Name()
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomModel.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomModel.java
index b2b780a09..3c6e1bb0d 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomModel.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/RoomModel.java
@@ -11,6 +11,14 @@ import org.eclipse.emf.ecore.EObject;
* A representation of the model object '<em><b>Model</b></em>'.
* <!-- end-user-doc -->
*
+ * <!-- begin-model-doc -->
+ * The root object for the ROOM model. It gives access to {@link Import imports} and
+ * the {@link SubSystemClass sub system},
+ * {@link ActorClass actor}, {@link ProtocolClass protocol} and
+ * {@link DataClass data} classes defined.
+ *
+ * <!-- end-model-doc -->
+ *
* <p>
* The following features are supported:
* <ul>
@@ -36,11 +44,13 @@ public interface RoomModel extends EObject
/**
* Returns the value of the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Name</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * The model name is a dot separated fully qualified name and is
+ * used to provide a name space. The generators may use that also
+ * to place the generated code into separate directories.
+ *
+ * <!-- end-model-doc -->
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see org.eclipse.etrice.core.room.RoomPackage#getRoomModel_Name()
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend
index 1a56f5e44..6869d7812 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend
@@ -17,21 +17,86 @@ import org.eclipse.xtext.GeneratedMetamodel
import static extension org.eclipse.emf.ecore.util.EcoreUtil.*
import static extension org.eclipse.etrice.core.postprocessing.PostprocessingHelpers.*
+/**
+ * This post processor adds documentation to the generated EMF model.
+ * By intention no {@code null} checks are performed. This way developers
+ * find easier if the referenced class, attribute or reference isn't found.
+ */
class DocuPostprocessor {
def process(GeneratedMetamodel metamodel) {
-// var pckg = metamodel.EPackage
-//
-// var mdl = pckg.getClass("RoomModel")
-// mdl.setDocumentation(
-// '''
-// <br>
-// ''')
-//
-// mdl.getAttribute("name").setDocumentation(
-// '''
-// <br>
-// ''')
+ val pckg = metamodel.EPackage
+
+ var cls = pckg.getClass("RoomModel")
+ cls.setDocumentation(
+ '''
+ The root object for the ROOM model. It gives access to {@link Import imports} and
+ the {@link SubSystemClass sub system},
+ {@link ActorClass actor}, {@link ProtocolClass protocol} and
+ {@link DataClass data} classes defined.
+ ''')
+
+ cls.getAttribute("name").setDocumentation(
+ '''
+ The model name is a dot separated fully qualified name and is
+ used to provide a name space. The generators may use that also
+ to place the generated code into separate directories.
+ ''')
+
+ cls = pckg.getClass("Import")
+ cls.setDocumentation(
+ '''
+ The import references another ROOM model. Optionally it may import also
+ the name space of the imported model.
+ ''')
+
+ cls.getAttribute("importedNamespace").setDocumentation(
+ '''
+ The imported name space has to be a dot separated qualified name followed by .*.
+ Example: my.namespace.*
+ ''')
+
+ cls.getAttribute("importURI").setDocumentation(
+ '''
+ The import URI can be a relative or absolute file system path.
+ It may contain environment variables in ${} which will be expanded.
+ <p>
+ Examples:
+ <ul>
+ <li>import model "AnotherModel.room"</li>
+ <li>import my.namespace.* from "AnotherModel.room"</li>
+ <li>import my.namespace.* from "../../AnotherProject/models/AnotherModel.room"</li>
+ <li>import my.namespace.* from "/${ROOM_MODELS}/SomeModel.room"</li>
+ </ul>
+ </p>
+ ''')
+
+ cls = pckg.getClass("DataClass")
+ cls.setDocumentation(
+ '''
+ The data class in ROOM is a {@link ComplexType} which has {@link Attribute} members.
+ It can be derived from a single base data class.
+ ''')
+
+ cls.getAttribute("name").setDocumentation(
+ '''
+ The name of the data class by which it is referred to in the model.
+ ''')
+
+ cls.getReference("base").setDocumentation(
+ '''
+ The base class from which all attributes and operations are inherited.
+ ''')
+
+ cls.getReference("attributes").setDocumentation(
+ '''
+ Attributes are the data members of the data class.
+ ''')
+
+ cls.getReference("operations").setDocumentation(
+ '''
+ Operations are the methods of the data class.
+ ''')
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend
index 98a6f3d22..6fe039f93 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend
@@ -30,6 +30,10 @@ class PostprocessingHelpers {
cls.EAllAttributes.findFirst(a | a.name.equals(name))
}
+ def static getReference(EClass cls, String name) {
+ cls.EAllReferences.findFirst(a | a.name.equals(name))
+ }
+
def static addOperation(EClass owner, String name, EClassifier type, String body) {
addOperation(owner, name, type, 1, body)
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index 4f6eb5869..12f31222b 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -70,6 +70,7 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
public static final String THREAD_MISSING = "RoomJavaValidator.ThreadMissing";
public static final String DUPLICATE_ACTOR_INSTANCE_MAPPING = "RoomJavaValidator.DuplicateActorInstanceMapping";
public static final String WRONG_NAMESPACE = "RoomJavaValidator.WrongNamespace";
+ public static final String CIRCULAR_CONTAINMENT = "RoomJavaValidator.CircularContainment";
@Inject ImportUriResolver importUriResolver;
@@ -179,8 +180,15 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
return;
while (dc!=null) {
- if (att.getRefType().getType()==dc)
- error("Attribute type must not refer to own class or a super class", RoomPackage.Literals.ATTRIBUTE__REF_TYPE);
+ if (att.getRefType().getType()==dc && !att.getRefType().isRef()) {
+ error(
+ "Attribute type must not refer to own class or a super class",
+ RoomPackage.Literals.ATTRIBUTE__REF_TYPE,
+ CIRCULAR_CONTAINMENT,
+ ""+att.getRefType().getType().getName().length()
+ );
+ break;
+ }
dc = dc.getBase();
}
diff --git a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java
index 9c18df4e3..d8412545e 100644
--- a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java
@@ -1,10 +1,114 @@
package org.eclipse.etrice.core.postprocessing;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.postprocessing.PostprocessingHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.GeneratedMetamodel;
+/**
+ * This post processor adds documentation to the generated EMF model.
+ * By intention no {@code null} checks are performed. This way developers
+ * find easier if the referenced class, attribute or reference isn't found.
+ */
@SuppressWarnings("all")
public class DocuPostprocessor {
- public Object process(final GeneratedMetamodel metamodel) {
- return null;
+ public void process(final GeneratedMetamodel metamodel) {
+ final EPackage pckg = metamodel.getEPackage();
+ EClass cls = PostprocessingHelpers.getClass(pckg, "RoomModel");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("The root object for the ROOM model. It gives access to {@link Import imports} and");
+ _builder.newLine();
+ _builder.append("the {@link SubSystemClass sub system},");
+ _builder.newLine();
+ _builder.append("{@link ActorClass actor}, {@link ProtocolClass protocol} and");
+ _builder.newLine();
+ _builder.append("{@link DataClass data} classes defined.");
+ _builder.newLine();
+ EcoreUtil.setDocumentation(cls, _builder.toString());
+ EAttribute _attribute = PostprocessingHelpers.getAttribute(cls, "name");
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("The model name is a dot separated fully qualified name and is");
+ _builder_1.newLine();
+ _builder_1.append("used to provide a name space. The generators may use that also");
+ _builder_1.newLine();
+ _builder_1.append("to place the generated code into separate directories.");
+ _builder_1.newLine();
+ EcoreUtil.setDocumentation(_attribute, _builder_1.toString());
+ EClass _class = PostprocessingHelpers.getClass(pckg, "Import");
+ cls = _class;
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("The import references another ROOM model. Optionally it may import also");
+ _builder_2.newLine();
+ _builder_2.append("the name space of the imported model.");
+ _builder_2.newLine();
+ EcoreUtil.setDocumentation(cls, _builder_2.toString());
+ EAttribute _attribute_1 = PostprocessingHelpers.getAttribute(cls, "importedNamespace");
+ StringConcatenation _builder_3 = new StringConcatenation();
+ _builder_3.append("The imported name space has to be a dot separated qualified name followed by .*.");
+ _builder_3.newLine();
+ _builder_3.append("Example: my.namespace.*");
+ _builder_3.newLine();
+ EcoreUtil.setDocumentation(_attribute_1, _builder_3.toString());
+ EAttribute _attribute_2 = PostprocessingHelpers.getAttribute(cls, "importURI");
+ StringConcatenation _builder_4 = new StringConcatenation();
+ _builder_4.append("The import URI can be a relative or absolute file system path.");
+ _builder_4.newLine();
+ _builder_4.append("It may contain environment variables in ${} which will be expanded.");
+ _builder_4.newLine();
+ _builder_4.append("<p>");
+ _builder_4.newLine();
+ _builder_4.append("Examples:");
+ _builder_4.newLine();
+ _builder_4.append("<ul>");
+ _builder_4.newLine();
+ _builder_4.append(" ");
+ _builder_4.append("<li>import model \"AnotherModel.room\"</li>");
+ _builder_4.newLine();
+ _builder_4.append(" ");
+ _builder_4.append("<li>import my.namespace.* from \"AnotherModel.room\"</li>");
+ _builder_4.newLine();
+ _builder_4.append(" ");
+ _builder_4.append("<li>import my.namespace.* from \"../../AnotherProject/models/AnotherModel.room\"</li>");
+ _builder_4.newLine();
+ _builder_4.append(" ");
+ _builder_4.append("<li>import my.namespace.* from \"/${ROOM_MODELS}/SomeModel.room\"</li>");
+ _builder_4.newLine();
+ _builder_4.append("</ul>");
+ _builder_4.newLine();
+ _builder_4.append("</p>");
+ _builder_4.newLine();
+ EcoreUtil.setDocumentation(_attribute_2, _builder_4.toString());
+ EClass _class_1 = PostprocessingHelpers.getClass(pckg, "DataClass");
+ cls = _class_1;
+ StringConcatenation _builder_5 = new StringConcatenation();
+ _builder_5.append("The data class in ROOM is a {@link ComplexType} which has {@link Attribute} members.");
+ _builder_5.newLine();
+ _builder_5.append("It can be derived from a single base data class. ");
+ _builder_5.newLine();
+ EcoreUtil.setDocumentation(cls, _builder_5.toString());
+ EAttribute _attribute_3 = PostprocessingHelpers.getAttribute(cls, "name");
+ StringConcatenation _builder_6 = new StringConcatenation();
+ _builder_6.append("The name of the data class by which it is referred to in the model.");
+ _builder_6.newLine();
+ EcoreUtil.setDocumentation(_attribute_3, _builder_6.toString());
+ EReference _reference = PostprocessingHelpers.getReference(cls, "base");
+ StringConcatenation _builder_7 = new StringConcatenation();
+ _builder_7.append("The base class from which all attributes and operations are inherited.");
+ _builder_7.newLine();
+ EcoreUtil.setDocumentation(_reference, _builder_7.toString());
+ EReference _reference_1 = PostprocessingHelpers.getReference(cls, "attributes");
+ StringConcatenation _builder_8 = new StringConcatenation();
+ _builder_8.append("Attributes are the data members of the data class.");
+ _builder_8.newLine();
+ EcoreUtil.setDocumentation(_reference_1, _builder_8.toString());
+ EReference _reference_2 = PostprocessingHelpers.getReference(cls, "operations");
+ StringConcatenation _builder_9 = new StringConcatenation();
+ _builder_9.append("Operations are the methods of the data class.");
+ _builder_9.newLine();
+ EcoreUtil.setDocumentation(_reference_2, _builder_9.toString());
}
}
diff --git a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java
index e8d7b96e0..c9983fc7b 100644
--- a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java
@@ -8,6 +8,7 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
@@ -35,6 +36,19 @@ public class PostprocessingHelpers {
return _findFirst;
}
+ public static EReference getReference(final EClass cls, final String name) {
+ EList<EReference> _eAllReferences = cls.getEAllReferences();
+ final Function1<EReference,Boolean> _function = new Function1<EReference,Boolean>() {
+ public Boolean apply(final EReference a) {
+ String _name = a.getName();
+ boolean _equals = _name.equals(name);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ EReference _findFirst = IterableExtensions.<EReference>findFirst(_eAllReferences, _function);
+ return _findFirst;
+ }
+
public static boolean addOperation(final EClass owner, final String name, final EClassifier type, final String body) {
boolean _addOperation = PostprocessingHelpers.addOperation(owner, name, type, Integer.valueOf(1), body);
return _addOperation;

Back to the top