Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-03-07 15:19:20 +0000
committerGerrit Code Review @ Eclipse.org2013-03-07 15:19:20 +0000
commit9b93699fb7ada62ffdab52a4c29b66cf0bf2334b (patch)
tree306d87f36b9665d57ba83f4c52c5e8bf1ffd4cf3 /plugins/org.eclipse.etrice.core.room
parentda88ce67bc717d01f083db8d9e461c2e17fa6544 (diff)
parent42bb0d6e52a14fd586bac0cf85ad8c611e6e3f23 (diff)
downloadorg.eclipse.etrice-9b93699fb7ada62ffdab52a4c29b66cf0bf2334b.tar.gz
org.eclipse.etrice-9b93699fb7ada62ffdab52a4c29b66cf0bf2334b.tar.xz
org.eclipse.etrice-9b93699fb7ada62ffdab52a4c29b66cf0bf2334b.zip
Merge "[core] (Bug 398876) add documentation to Xtext generated meta models activated xtend2 support"
Diffstat (limited to 'plugins/org.eclipse.etrice.core.room')
-rw-r--r--plugins/org.eclipse.etrice.core.room/.classpath1
-rw-r--r--plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore13
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java2
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/StateGraphItem.java2
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java8
-rw-r--r--plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/StateGraphItemImpl.java13
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomPostprocessor.ext77
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend37
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend66
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend44
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessorController.java23
-rw-r--r--plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java10
-rw-r--r--plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java84
-rw-r--r--plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java54
15 files changed, 351 insertions, 88 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/.classpath b/plugins/org.eclipse.etrice.core.room/.classpath
index 42c365c0b..67148645d 100644
--- a/plugins/org.eclipse.etrice.core.room/.classpath
+++ b/plugins/org.eclipse.etrice.core.room/.classpath
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
diff --git a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
index 331c13fde..55dc74d3b 100644
--- a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
@@ -22,15 +22,16 @@ Import-Package: org.apache.log4j,
org.eclipse.etrice.core.room
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.etrice.core,
+ org.eclipse.etrice.core.formatting,
org.eclipse.etrice.core.naming,
org.eclipse.etrice.core.parseTreeConstruction,
org.eclipse.etrice.core.parser.antlr,
org.eclipse.etrice.core.parser.antlr.internal,
+ org.eclipse.etrice.core.postprocessing,
org.eclipse.etrice.core.room,
org.eclipse.etrice.core.room.impl,
org.eclipse.etrice.core.room.util,
org.eclipse.etrice.core.scoping,
org.eclipse.etrice.core.services,
- org.eclipse.etrice.core.validation,
- org.eclipse.etrice.core.formatting
+ org.eclipse.etrice.core.validation
Bundle-Activator: org.eclipse.etrice.core.RoomActivator
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 cb51d2c53..f8133ff69 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
@@ -2,7 +2,14 @@
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
- <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;"/>
+ </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;"/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="docu" eType="#//Documentation"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="imports" upperBound="-1"
@@ -224,7 +231,7 @@
<eClassifiers xsi:type="ecore:EClass" name="InterfaceItem">
<eOperations name="getGeneralProtocol" eType="#//GeneralProtocolClass">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
- <details key="body" value="if (this instanceof org.eclipse.etrice.core.room.Port)&#xA;return ((org.eclipse.etrice.core.room.Port) this).getProtocol();&#xA;else if (this instanceof org.eclipse.etrice.core.room.SAPRef)&#xA;return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();&#xA;else if (this instanceof org.eclipse.etrice.core.room.SPPRef)&#xA;return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();return null;"/>
+ <details key="body" value="if (this instanceof org.eclipse.etrice.core.room.Port)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.Port) this).getProtocol();&#xD;&#xA;else if (this instanceof org.eclipse.etrice.core.room.SAPRef)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();&#xD;&#xA;else if (this instanceof org.eclipse.etrice.core.room.SPPRef)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();&#xD;&#xA;return null;&#xD;&#xA;"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
@@ -325,7 +332,7 @@
<eClassifiers xsi:type="ecore:EClass" name="StateGraphItem">
<eOperations name="getName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
- <details key="body" value="if (this instanceof org.eclipse.etrice.core.room.State) return ((org.eclipse.etrice.core.room.State)this).getName();&#xA;else if (this instanceof org.eclipse.etrice.core.room.TrPoint) return ((org.eclipse.etrice.core.room.TrPoint)this).getName();&#xA;else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint) return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();&#xA;else if (this instanceof org.eclipse.etrice.core.room.Transition) return ((org.eclipse.etrice.core.room.Transition)this).getName();&#xA;return &quot;&quot;;"/>
+ <details key="body" value="if (this instanceof org.eclipse.etrice.core.room.State) &#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.State)this).getName();&#xD;&#xA;else if (this instanceof org.eclipse.etrice.core.room.TrPoint)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.TrPoint)this).getName();&#xD;&#xA;else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();&#xD;&#xA;else if (this instanceof org.eclipse.etrice.core.room.Transition)&#xD;&#xA;&#x9;return ((org.eclipse.etrice.core.room.Transition)this).getName();&#xD;&#xA;return &quot;&quot;;&#xD;&#xA;"/>
</eAnnotations>
</eOperations>
</eClassifiers>
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
index 409630d49..aa9c0019d 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/InterfaceItem.java
@@ -52,7 +52,7 @@ public interface InterfaceItem extends EObject
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model kind="operation"
- * annotation="http://www.eclipse.org/emf/2002/GenModel body='if (this instanceof org.eclipse.etrice.core.room.Port)\nreturn ((org.eclipse.etrice.core.room.Port) this).getProtocol();\nelse if (this instanceof org.eclipse.etrice.core.room.SAPRef)\nreturn ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();\nelse if (this instanceof org.eclipse.etrice.core.room.SPPRef)\nreturn ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();return null;'"
+ * annotation="http://www.eclipse.org/emf/2002/GenModel body='if (this instanceof org.eclipse.etrice.core.room.Port)\r\n\treturn ((org.eclipse.etrice.core.room.Port) this).getProtocol();\r\nelse if (this instanceof org.eclipse.etrice.core.room.SAPRef)\r\n\treturn ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();\r\nelse if (this instanceof org.eclipse.etrice.core.room.SPPRef)\r\n\treturn ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();\r\nreturn null;\r\n'"
* @generated
*/
GeneralProtocolClass getGeneralProtocol();
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/StateGraphItem.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/StateGraphItem.java
index e1d9adbef..5ee917744 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/StateGraphItem.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/StateGraphItem.java
@@ -20,7 +20,7 @@ public interface StateGraphItem extends EObject
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model kind="operation"
- * annotation="http://www.eclipse.org/emf/2002/GenModel body='if (this instanceof org.eclipse.etrice.core.room.State) return ((org.eclipse.etrice.core.room.State)this).getName();\nelse if (this instanceof org.eclipse.etrice.core.room.TrPoint) return ((org.eclipse.etrice.core.room.TrPoint)this).getName();\nelse if (this instanceof org.eclipse.etrice.core.room.ChoicePoint) return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();\nelse if (this instanceof org.eclipse.etrice.core.room.Transition) return ((org.eclipse.etrice.core.room.Transition)this).getName();\nreturn \"\";'"
+ * annotation="http://www.eclipse.org/emf/2002/GenModel body='if (this instanceof org.eclipse.etrice.core.room.State) \r\n\treturn ((org.eclipse.etrice.core.room.State)this).getName();\r\nelse if (this instanceof org.eclipse.etrice.core.room.TrPoint)\r\n\treturn ((org.eclipse.etrice.core.room.TrPoint)this).getName();\r\nelse if (this instanceof org.eclipse.etrice.core.room.ChoicePoint)\r\n\treturn ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();\r\nelse if (this instanceof org.eclipse.etrice.core.room.Transition)\r\n\treturn ((org.eclipse.etrice.core.room.Transition)this).getName();\r\nreturn \"\";\r\n'"
* @generated
*/
String getName();
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
index 0533c2c66..d8ba3997d 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/InterfaceItemImpl.java
@@ -100,11 +100,13 @@ public class InterfaceItemImpl extends MinimalEObjectImpl.Container implements I
public GeneralProtocolClass getGeneralProtocol()
{
if (this instanceof org.eclipse.etrice.core.room.Port)
- return ((org.eclipse.etrice.core.room.Port) this).getProtocol();
+ return ((org.eclipse.etrice.core.room.Port) this).getProtocol();
else if (this instanceof org.eclipse.etrice.core.room.SAPRef)
- return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();
+ return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();
else if (this instanceof org.eclipse.etrice.core.room.SPPRef)
- return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();return null;
+ return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();
+ return null;
+
}
/**
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/StateGraphItemImpl.java b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/StateGraphItemImpl.java
index 522936dc7..5a0b745fb 100644
--- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/StateGraphItemImpl.java
+++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/room/impl/StateGraphItemImpl.java
@@ -48,11 +48,16 @@ public class StateGraphItemImpl extends MinimalEObjectImpl.Container implements
*/
public String getName()
{
- if (this instanceof org.eclipse.etrice.core.room.State) return ((org.eclipse.etrice.core.room.State)this).getName();
- else if (this instanceof org.eclipse.etrice.core.room.TrPoint) return ((org.eclipse.etrice.core.room.TrPoint)this).getName();
- else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint) return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();
- else if (this instanceof org.eclipse.etrice.core.room.Transition) return ((org.eclipse.etrice.core.room.Transition)this).getName();
+ if (this instanceof org.eclipse.etrice.core.room.State)
+ return ((org.eclipse.etrice.core.room.State)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.TrPoint)
+ return ((org.eclipse.etrice.core.room.TrPoint)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint)
+ return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.Transition)
+ return ((org.eclipse.etrice.core.room.Transition)this).getName();
return "";
+
}
} //StateGraphItemImpl
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomPostprocessor.ext b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomPostprocessor.ext
index 261dfcd84..a48592232 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomPostprocessor.ext
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomPostprocessor.ext
@@ -10,79 +10,8 @@
*
*******************************************************************************/
-// possible improvement: http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/
-
-import ecore;
import xtext;
-process(xtext::GeneratedMetamodel this) :
- process(ePackage)
-;
-
-// the multiplicity is an optional attribute with a default of 1
-process(ecore::EPackage this) :
- this.eClassifiers.typeSelect(ecore::EClass).process()
-;
-
-process(EClass this) :
- switch (name) {
- case "Port": (eAllAttributes.select(e|e.name=="multiplicity").first().setDefaultValueLiteral("1")
- -> addOperation("isReplicated", getEcoreDataType("EBoolean")))
- case "ActorRef": (eAllAttributes.select(e|e.name=="size").first().setDefaultValueLiteral("1"))
- case "State": (addOperation("getName", getEcoreDataType("EString")))
- case "StateGraphItem": (addOperation("getName", getEcoreDataType("EString")))
- case "InterfaceItem": (addOperation("getGeneralProtocol", ePackage.getEClassifier("GeneralProtocolClass")))
- default: null
- }
-;
-
-EDataType getEcoreDataType(String name) :
- org::eclipse::emf::ecore::EcorePackage::eINSTANCE.getEClassifier(name)
-;
-
-addOperation(EClass this, String name, EClassifier type) :
- let op = newOperation(name, type) :
- newDelegatingBodyAnnotation(this, op)
-;
-
-create EOperation newOperation(EClass owner, String name, EClassifier type) :
- setName(name) -> setEType(type) -> owner.eOperations.add(this)
-;
-
-create EAnnotation newDelegatingBodyAnnotation(EClass cls, EOperation op) :
- let d = new EStringToStringMapEntry :
- setSource("http://www.eclipse.org/emf/2002/GenModel") ->
- d.setKey("body") ->
- switch (op.name) {
- case "getName":
- (switch (cls.name) {
- case "State":
- (d.setValue("return (this instanceof org.eclipse.etrice.core.room.SimpleState)? "
- +"((org.eclipse.etrice.core.room.SimpleState)this).getName() :"
- +"(this instanceof org.eclipse.etrice.core.room.RefinedState)? "
- +"(((org.eclipse.etrice.core.room.RefinedState)this).getTarget()==null?"
- +" \"\":((org.eclipse.etrice.core.room.RefinedState)this).getTarget().getName()) :"
- +"\"\";"))
- case "StateGraphItem":
- (d.setValue("if (this instanceof org.eclipse.etrice.core.room.State) return ((org.eclipse.etrice.core.room.State)this).getName();\n"
- + "else if (this instanceof org.eclipse.etrice.core.room.TrPoint) return ((org.eclipse.etrice.core.room.TrPoint)this).getName();\n"
- + "else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint) return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();\n"
- + "else if (this instanceof org.eclipse.etrice.core.room.Transition) return ((org.eclipse.etrice.core.room.Transition)this).getName();\n"
- + "return \"\";"))
- default: null
- })
- case "isReplicated":
- (d.setValue("return multiplicity>1 || multiplicity==-1;"))
- case "getGeneralProtocol":
- (d.setValue("if (this instanceof org.eclipse.etrice.core.room.Port)\n"
- +"return ((org.eclipse.etrice.core.room.Port) this).getProtocol();\n"
- +"else if (this instanceof org.eclipse.etrice.core.room.SAPRef)\n"
- +"return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();\n"
- +"else if (this instanceof org.eclipse.etrice.core.room.SPPRef)\n"
- +"return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();"
- +"return null;"))
- default: null
- } ->
- details.add(d) ->
- op.eAnnotations.add(this)
-;
+process(GeneratedMetamodel this) :
+ JAVA org.eclipse.etrice.core.postprocessing.PostprocessorController.process(org.eclipse.xtext.GeneratedMetamodel)
+; \ No newline at end of file
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
new file mode 100644
index 000000000..1a56f5e44
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.xtend
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.postprocessing
+
+import org.eclipse.xtext.GeneratedMetamodel
+
+import static extension org.eclipse.emf.ecore.util.EcoreUtil.*
+import static extension org.eclipse.etrice.core.postprocessing.PostprocessingHelpers.*
+
+class DocuPostprocessor {
+
+ def process(GeneratedMetamodel metamodel) {
+// var pckg = metamodel.EPackage
+//
+// var mdl = pckg.getClass("RoomModel")
+// mdl.setDocumentation(
+// '''
+// <br>
+// ''')
+//
+// mdl.getAttribute("name").setDocumentation(
+// '''
+// <br>
+// ''')
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend
new file mode 100644
index 000000000..e7014d299
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.xtend
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.postprocessing
+
+import org.eclipse.xtext.GeneratedMetamodel
+
+import org.eclipse.emf.ecore.EcorePackage
+
+import static extension org.eclipse.emf.ecore.util.EcoreUtil.*
+import static extension org.eclipse.etrice.core.postprocessing.PostprocessingHelpers.*
+
+class ImplPostprocessor {
+
+ def process(GeneratedMetamodel metamodel) {
+ var roomPackage = metamodel.EPackage
+
+ var port = roomPackage.getClass("Port")
+ port.getAttribute("multiplicity").setDefaultValueLiteral("1")
+ port.addOperation("isReplicated", EcorePackage::eINSTANCE.getEClassifier("EBoolean"), 1,
+ '''return multiplicity>1 || multiplicity==-1;''')
+
+ var actorRef = roomPackage.getClass("ActorRef")
+ actorRef.getAttribute("size").setDefaultValueLiteral("1")
+
+ var state = roomPackage.getClass("State")
+ state.addOperation("getName", EcorePackage::eINSTANCE.getEClassifier("EString"), 1,
+ '''return (this instanceof org.eclipse.etrice.core.room.SimpleState)? ((org.eclipse.etrice.core.room.SimpleState)this).getName() :(this instanceof org.eclipse.etrice.core.room.RefinedState)? (((org.eclipse.etrice.core.room.RefinedState)this).getTarget()==null? "":((org.eclipse.etrice.core.room.RefinedState)this).getTarget().getName()) :"";''')
+
+ var stateGraphItem = roomPackage.getClass("StateGraphItem")
+ stateGraphItem.addOperation("getName", EcorePackage::eINSTANCE.getEClassifier("EString"), 1,
+ '''
+ if (this instanceof org.eclipse.etrice.core.room.State)
+ return ((org.eclipse.etrice.core.room.State)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.TrPoint)
+ return ((org.eclipse.etrice.core.room.TrPoint)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint)
+ return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();
+ else if (this instanceof org.eclipse.etrice.core.room.Transition)
+ return ((org.eclipse.etrice.core.room.Transition)this).getName();
+ return "";
+ ''')
+
+ var interfaceItem = roomPackage.getClass("InterfaceItem")
+ interfaceItem.addOperation("getGeneralProtocol", roomPackage.getEClassifier("GeneralProtocolClass"), 1,
+ '''
+ if (this instanceof org.eclipse.etrice.core.room.Port)
+ return ((org.eclipse.etrice.core.room.Port) this).getProtocol();
+ else if (this instanceof org.eclipse.etrice.core.room.SAPRef)
+ return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();
+ else if (this instanceof org.eclipse.etrice.core.room.SPPRef)
+ return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();
+ return null;
+ ''')
+ }
+}
+
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
new file mode 100644
index 000000000..15806bbfc
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.xtend
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.postprocessing
+
+import org.eclipse.emf.ecore.EPackage
+import org.eclipse.emf.ecore.EClass
+import org.eclipse.emf.ecore.EClassifier
+import org.eclipse.emf.ecore.EcoreFactory
+
+class PostprocessingHelpers {
+
+ def static getClass(EPackage pckg, String name) {
+ pckg.getEClassifier(name) as EClass
+ }
+
+ def static getAttribute(EClass cls, String name) {
+ cls.EAllAttributes.findFirst(a | a.name.equals(name))
+ }
+
+ def static addOperation(EClass owner, String name, EClassifier type, Integer upperBound, String body){
+ var op = EcoreFactory::eINSTANCE.createEOperation()
+ op.setName(name)
+ op.setEType(type)
+ op.setUpperBound(upperBound)
+
+ var anno = EcoreFactory::eINSTANCE.createEAnnotation
+ anno.setSource("http://www.eclipse.org/emf/2002/GenModel")
+ anno.details.put("body", body)
+ op.EAnnotations.add(anno)
+
+ owner.EOperations.add(op)
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessorController.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessorController.java
new file mode 100644
index 000000000..d319e332f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/postprocessing/PostprocessorController.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.postprocessing;
+
+import org.eclipse.xtext.GeneratedMetamodel;
+
+public class PostprocessorController {
+
+ public static void process(GeneratedMetamodel metamodel){
+ new DocuPostprocessor().process(metamodel);
+ new ImplPostprocessor().process(metamodel);
+ }
+}
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
new file mode 100644
index 000000000..9c18df4e3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/DocuPostprocessor.java
@@ -0,0 +1,10 @@
+package org.eclipse.etrice.core.postprocessing;
+
+import org.eclipse.xtext.GeneratedMetamodel;
+
+@SuppressWarnings("all")
+public class DocuPostprocessor {
+ public Object process(final GeneratedMetamodel metamodel) {
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java
new file mode 100644
index 000000000..aa5085263
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/ImplPostprocessor.java
@@ -0,0 +1,84 @@
+package org.eclipse.etrice.core.postprocessing;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.etrice.core.postprocessing.PostprocessingHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.GeneratedMetamodel;
+
+@SuppressWarnings("all")
+public class ImplPostprocessor {
+ public boolean process(final GeneratedMetamodel metamodel) {
+ boolean _xblockexpression = false;
+ {
+ EPackage roomPackage = metamodel.getEPackage();
+ EClass port = PostprocessingHelpers.getClass(roomPackage, "Port");
+ EAttribute _attribute = PostprocessingHelpers.getAttribute(port, "multiplicity");
+ _attribute.setDefaultValueLiteral("1");
+ EClassifier _eClassifier = EcorePackage.eINSTANCE.getEClassifier("EBoolean");
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("return multiplicity>1 || multiplicity==-1;");
+ PostprocessingHelpers.addOperation(port, "isReplicated", _eClassifier, Integer.valueOf(1), _builder.toString());
+ EClass actorRef = PostprocessingHelpers.getClass(roomPackage, "ActorRef");
+ EAttribute _attribute_1 = PostprocessingHelpers.getAttribute(actorRef, "size");
+ _attribute_1.setDefaultValueLiteral("1");
+ EClass state = PostprocessingHelpers.getClass(roomPackage, "State");
+ EClassifier _eClassifier_1 = EcorePackage.eINSTANCE.getEClassifier("EString");
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("return (this instanceof org.eclipse.etrice.core.room.SimpleState)? ((org.eclipse.etrice.core.room.SimpleState)this).getName() :(this instanceof org.eclipse.etrice.core.room.RefinedState)? (((org.eclipse.etrice.core.room.RefinedState)this).getTarget()==null? \"\":((org.eclipse.etrice.core.room.RefinedState)this).getTarget().getName()) :\"\";");
+ PostprocessingHelpers.addOperation(state, "getName", _eClassifier_1, Integer.valueOf(1), _builder_1.toString());
+ EClass stateGraphItem = PostprocessingHelpers.getClass(roomPackage, "StateGraphItem");
+ EClassifier _eClassifier_2 = EcorePackage.eINSTANCE.getEClassifier("EString");
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("if (this instanceof org.eclipse.etrice.core.room.State) ");
+ _builder_2.newLine();
+ _builder_2.append("\t");
+ _builder_2.append("return ((org.eclipse.etrice.core.room.State)this).getName();");
+ _builder_2.newLine();
+ _builder_2.append("else if (this instanceof org.eclipse.etrice.core.room.TrPoint)");
+ _builder_2.newLine();
+ _builder_2.append("\t");
+ _builder_2.append("return ((org.eclipse.etrice.core.room.TrPoint)this).getName();");
+ _builder_2.newLine();
+ _builder_2.append("else if (this instanceof org.eclipse.etrice.core.room.ChoicePoint)");
+ _builder_2.newLine();
+ _builder_2.append("\t");
+ _builder_2.append("return ((org.eclipse.etrice.core.room.ChoicePoint)this).getName();");
+ _builder_2.newLine();
+ _builder_2.append("else if (this instanceof org.eclipse.etrice.core.room.Transition)");
+ _builder_2.newLine();
+ _builder_2.append("\t");
+ _builder_2.append("return ((org.eclipse.etrice.core.room.Transition)this).getName();");
+ _builder_2.newLine();
+ _builder_2.append("return \"\";");
+ _builder_2.newLine();
+ PostprocessingHelpers.addOperation(stateGraphItem, "getName", _eClassifier_2, Integer.valueOf(1), _builder_2.toString());
+ EClass interfaceItem = PostprocessingHelpers.getClass(roomPackage, "InterfaceItem");
+ EClassifier _eClassifier_3 = roomPackage.getEClassifier("GeneralProtocolClass");
+ StringConcatenation _builder_3 = new StringConcatenation();
+ _builder_3.append("if (this instanceof org.eclipse.etrice.core.room.Port)");
+ _builder_3.newLine();
+ _builder_3.append("\t");
+ _builder_3.append("return ((org.eclipse.etrice.core.room.Port) this).getProtocol();");
+ _builder_3.newLine();
+ _builder_3.append("else if (this instanceof org.eclipse.etrice.core.room.SAPRef)");
+ _builder_3.newLine();
+ _builder_3.append("\t");
+ _builder_3.append("return ((org.eclipse.etrice.core.room.SAPRef) this).getProtocol();");
+ _builder_3.newLine();
+ _builder_3.append("else if (this instanceof org.eclipse.etrice.core.room.SPPRef)");
+ _builder_3.newLine();
+ _builder_3.append("\t");
+ _builder_3.append("return ((org.eclipse.etrice.core.room.SPPRef) this).getProtocol();");
+ _builder_3.newLine();
+ _builder_3.append("return null;");
+ _builder_3.newLine();
+ boolean _addOperation = PostprocessingHelpers.addOperation(interfaceItem, "getGeneralProtocol", _eClassifier_3, Integer.valueOf(1), _builder_3.toString());
+ _xblockexpression = (_addOperation);
+ }
+ return _xblockexpression;
+ }
+}
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
new file mode 100644
index 000000000..24237f320
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.room/xtend-gen/org/eclipse/etrice/core/postprocessing/PostprocessingHelpers.java
@@ -0,0 +1,54 @@
+package org.eclipse.etrice.core.postprocessing;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+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.EcoreFactory;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@SuppressWarnings("all")
+public class PostprocessingHelpers {
+ public static EClass getClass(final EPackage pckg, final String name) {
+ EClassifier _eClassifier = pckg.getEClassifier(name);
+ return ((EClass) _eClassifier);
+ }
+
+ public static EAttribute getAttribute(final EClass cls, final String name) {
+ EList<EAttribute> _eAllAttributes = cls.getEAllAttributes();
+ final Function1<EAttribute,Boolean> _function = new Function1<EAttribute,Boolean>() {
+ public Boolean apply(final EAttribute a) {
+ String _name = a.getName();
+ boolean _equals = _name.equals(name);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ EAttribute _findFirst = IterableExtensions.<EAttribute>findFirst(_eAllAttributes, _function);
+ return _findFirst;
+ }
+
+ public static boolean addOperation(final EClass owner, final String name, final EClassifier type, final Integer upperBound, final String body) {
+ boolean _xblockexpression = false;
+ {
+ EOperation op = EcoreFactory.eINSTANCE.createEOperation();
+ op.setName(name);
+ op.setEType(type);
+ op.setUpperBound((upperBound).intValue());
+ EAnnotation anno = EcoreFactory.eINSTANCE.createEAnnotation();
+ anno.setSource("http://www.eclipse.org/emf/2002/GenModel");
+ EMap<String,String> _details = anno.getDetails();
+ _details.put("body", body);
+ EList<EAnnotation> _eAnnotations = op.getEAnnotations();
+ _eAnnotations.add(anno);
+ EList<EOperation> _eOperations = owner.getEOperations();
+ boolean _add = _eOperations.add(op);
+ _xblockexpression = (_add);
+ }
+ return _xblockexpression;
+ }
+}

Back to the top