Browse Source

decoupled generator. Chain runs canonical generator. Missing tests.

Cláudio Gomes 3 years ago
parent
commit
b2187fb81a
24 changed files with 260 additions and 250 deletions
  1. 5 3
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.canonical/META-INF/MANIFEST.MF
  2. 1 4
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.canonical/pom.xml
  3. 11 24
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationCanonicalGenerator.xtend
  4. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/DirectedGraph.java
  5. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/FMUGraph.java
  6. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/TopologicalSort.java
  7. 11 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/META-INF/MANIFEST.MF
  8. 16 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/build.properties
  9. 12 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/plugin.xml
  10. 35 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/pom.xml
  11. 22 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/src/be/uantwerpen/ansymo/semanticadaptation/cg/chain/SemanticAdaptationChainGenerator.xtend
  12. 8 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/pom.xml
  13. 0 18
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/AbstractSemanticAdaptationGeneratorTest.xtend
  14. 12 10
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/META-INF/MANIFEST.MF
  15. 1 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/plugin.xml
  16. 102 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/schema/generator_extension.exsd
  17. 3 3
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptationRuntimeModule.xtend
  18. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/formatting2/SemanticAdaptationFormatter.xtend
  19. 0 48
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/Log.xtend
  20. 14 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationCustomGenerator.java
  21. 0 25
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationGenerator.xtend
  22. 0 110
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationPythonGenerator.xtend
  23. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/scoping/SemanticAdaptationScopeProvider.xtend
  24. 2 0
      DSL_SemanticAdaptation/pom.xml

+ 5 - 3
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.canonical/META-INF/MANIFEST.MF

@@ -1,9 +1,9 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
-Bundle-Name: be.uantwerpen.ansymo.semanticadaptation.cg.cpp
+Bundle-Name: be.uantwerpen.ansymo.semanticadaptation.cg.canonical
 Bundle-Vendor: University of Antwerp, Ansymo Lab
 Bundle-Version: 1.0.0.qualifier
-Bundle-SymbolicName: be.uantwerpen.ansymo.semanticadaptation.cg.cpp; singleton:=true
+Bundle-SymbolicName: be.uantwerpen.ansymo.semanticadaptation.cg.canonical;singleton:=true
 Bundle-ActivationPolicy: lazy
 Require-Bundle: be.uantwerpen.ansymo.semanticadaptation,
  org.junit;bundle-version="4.7.0",
@@ -15,4 +15,6 @@ Require-Bundle: be.uantwerpen.ansymo.semanticadaptation,
  org.eclipse.xtext.xbase.testing,
  org.eclipse.xtext.util
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: org.apache.log4j
+Import-Package: be.uantwerpen.ansymo.semanticadaptation.log,
+ org.apache.log4j
+Export-Package: be.uantwerpen.ansymo.semanticadaptation.cg.canonical

+ 1 - 4
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.canonical/pom.xml

@@ -12,15 +12,12 @@
 	<artifactId>be.uantwerpen.ansymo.semanticadaptation.cg.canonical</artifactId>
 	<packaging>eclipse-plugin</packaging>
 
-	<name>be.uantwerpen.ansymo.semanticadaptation Code Generation to Canonical</name>
+	<name>be.uantwerpen.ansymo.semanticadaptation Canonical Generator</name>
 
 	<properties>
     <main.basedir>${project.parent.basedir}</main.basedir>
 	</properties>
 
-	<dependencies>
-		
-	</dependencies>
 
 	<build>
 			<plugins>

+ 11 - 24
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationCanonicalGenerator.xtend

@@ -1,11 +1,12 @@
 /*
  * generated by Xtext 2.10.0
  */
-package be.uantwerpen.ansymo.semanticadaptation.generator
+package be.uantwerpen.ansymo.semanticadaptation.cg.canonical
 
-import be.uantwerpen.ansymo.semanticadaptation.generator.graph.DirectedGraph
-import be.uantwerpen.ansymo.semanticadaptation.generator.graph.FMUGraph
-import be.uantwerpen.ansymo.semanticadaptation.generator.graph.TopologicalSort
+import be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph.DirectedGraph
+import be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph.FMUGraph
+import be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph.TopologicalSort
+import be.uantwerpen.ansymo.semanticadaptation.log.Log
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.AtomicUnity
@@ -33,7 +34,6 @@ import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.MultiplyUnity
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ReactiveOrDelayed
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RealLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptationFactory
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleParamDeclaration
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleVarDeclaration
@@ -47,40 +47,27 @@ import java.util.LinkedList
 import java.util.List
 import java.util.Map
 import org.eclipse.emf.common.util.EList
+import org.eclipse.emf.common.util.URI
 import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.Resource
 import org.eclipse.xtext.EcoreUtil2
-import org.eclipse.xtext.generator.AbstractGenerator
 import org.eclipse.xtext.generator.IFileSystemAccess2
-import org.eclipse.xtext.generator.IGeneratorContext
 
 /**
  * Generates code from your model files on save.
  * 
  * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
  */
-class SemanticAdaptationCanonicalGenerator extends AbstractGenerator {
+class SemanticAdaptationCanonicalGenerator {
 	
 	String CANONICAL_SUFIX = "_canonical"
 	
-	override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
-		Log.push("Generating canonical semantic adaptation for file " + resource.URI + "...")
-		
-		Log.println("Resource URI information:")
-		Log.println("\t resource.URI.lastSegment = " + resource.URI.lastSegment())
-		Log.println("\t resource.URI.trimFileExtension = " + resource.URI.trimFileExtension())
-		
-		// Create in memory representation of canonical SA file
-		var adaptations = resource.allContents.toIterable.filter(SemanticAdaptation).last.elements.filter(Adaptation);
-		
-		check(adaptations.size == 1, "Only one semantic adaptation is supported per .sa file")
-		
-		var adaptation = adaptations.head
+	def doGenerate(Adaptation adaptation, IFileSystemAccess2 fsa, URI mainFile) {
+		Log.push("Generating canonical semantic adaptation for file...")
 		
 		Log.println(prettyprint_model(adaptation, "File Read"))
 		
 		// Create file name for the canonical sa file
-		var fileNameWithoutExt = resource.URI.trimFileExtension().lastSegment()
+		var fileNameWithoutExt = mainFile.trimFileExtension().lastSegment()
 		
 		Log.println("Checking if file is already a canonical version...")
 		if (fileNameWithoutExt.indexOf(CANONICAL_SUFIX) == -1){
@@ -102,7 +89,7 @@ class SemanticAdaptationCanonicalGenerator extends AbstractGenerator {
 			Log.println("Nothing to do.")
 		}
 		
-		Log.pop("Generating canonical semantic adaptation for file " + resource.URI + "... DONE.")
+		Log.pop("Generating canonical semantic adaptation for file... DONE")
 	}
 	
 	def prettyprint_model(Adaptation sa, String title){

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/DirectedGraph.java

@@ -1,4 +1,4 @@
-package be.uantwerpen.ansymo.semanticadaptation.generator.graph;
+package be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph;
 
 import java.util.Collections;
 import java.util.HashMap;

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/FMUGraph.java

@@ -1,4 +1,4 @@
-package be.uantwerpen.ansymo.semanticadaptation.generator.graph;
+package be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph;
 
 import java.util.Iterator;
 

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/graph/TopologicalSort.java

@@ -1,4 +1,4 @@
-package be.uantwerpen.ansymo.semanticadaptation.generator.graph;
+package be.uantwerpen.ansymo.semanticadaptation.cg.canonical.graph;
 
 /******************************************************************************
  * File: TopologicalSort.java

+ 11 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/META-INF/MANIFEST.MF

@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: be.uantwerpen.ansymo.semanticadaptation.cg.chain
+Bundle-Vendor: University of Antwerp, Ansymo Lab
+Bundle-Version: 1.0.0.qualifier
+Bundle-SymbolicName: be.uantwerpen.ansymo.semanticadaptation.cg.chain;singleton:=true
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Import-Package: be.uantwerpen.ansymo.semanticadaptation.cg.canonical,
+ be.uantwerpen.ansymo.semanticadaptation.log
+Require-Bundle: be.uantwerpen.ansymo.semanticadaptation;bundle-version="1.0.0"

+ 16 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/build.properties

@@ -0,0 +1,16 @@
+source.. = src/,\
+           src-gen/,\
+           xtend-gen/
+bin.includes = .,\
+               META-INF/,\
+               plugin.xml
+additional.bundles = org.eclipse.xtext.xbase,\
+                     org.eclipse.xtext.common.types,\
+                     org.eclipse.xtext.xtext.generator,\
+                     org.eclipse.emf.codegen.ecore,\
+                     org.eclipse.emf.mwe.utils,\
+                     org.eclipse.emf.mwe2.launch,\
+                     org.eclipse.emf.mwe2.lib,\
+                     org.objectweb.asm,\
+                     org.apache.commons.logging,\
+                     com.ibm.icu

+ 12 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/plugin.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="windows-1252"?>
+<?eclipse version="3.0"?>
+<plugin>
+   <extension
+         id="chain_generator_extension"
+         point="be.uantwerpen.ansymo.semanticadaptation.generator_extension">
+      <generator
+            class="be.uantwerpen.ansymo.semanticadaptation.cg.chain.SemanticAdaptationChainGenerator">
+      </generator>
+   </extension>
+
+</plugin>

+ 35 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/pom.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../pom.xml</relativePath>
+		<groupId>be.uantwerpen.ansymo.semanticadaptation</groupId>
+		<artifactId>parent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>be.uantwerpen.ansymo.semanticadaptation.cg.chain</artifactId>
+	<packaging>eclipse-plugin</packaging>
+
+	<name>be.uantwerpen.ansymo.semanticadaptation Code Generator</name>
+
+	<properties>
+    <main.basedir>${project.parent.basedir}</main.basedir>
+	</properties>
+
+	<dependencies>
+		
+	</dependencies>
+
+	<build>
+			<plugins>
+				<plugin>
+					<groupId>org.eclipse.xtend</groupId>
+					<artifactId>xtend-maven-plugin</artifactId>
+				</plugin>
+	
+			</plugins>
+	</build>
+
+</project>

+ 22 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.chain/src/be/uantwerpen/ansymo/semanticadaptation/cg/chain/SemanticAdaptationChainGenerator.xtend

@@ -0,0 +1,22 @@
+/*
+ * generated by Xtext 2.10.0
+ */
+package be.uantwerpen.ansymo.semanticadaptation.cg.chain
+
+import be.uantwerpen.ansymo.semanticadaptation.cg.canonical.SemanticAdaptationCanonicalGenerator
+import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationCustomGenerator
+import be.uantwerpen.ansymo.semanticadaptation.log.Log
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
+import org.eclipse.emf.common.util.URI
+import org.eclipse.xtext.generator.IFileSystemAccess2
+
+class SemanticAdaptationChainGenerator extends SemanticAdaptationCustomGenerator {
+	
+	override void generate(Adaptation sa, IFileSystemAccess2 fsa, URI mainFile){
+		Log.push("SemanticAdaptationChainGenerator.generate")
+		
+		(new SemanticAdaptationCanonicalGenerator).doGenerate(sa, fsa, mainFile)
+		
+		Log.pop("SemanticAdaptationChainGenerator.generate")
+	}
+}

+ 8 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/pom.xml

@@ -27,6 +27,14 @@
 			<version>${project.version}</version>
 			<scope>compile</scope>
 		</dependency-->
+		<dependency>
+			<groupId>be.uantwerpen.ansymo.semanticadaptation</groupId>
+			<artifactId>
+				be.uantwerpen.ansymo.semanticadaptation
+			</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+			<type>eclipse-plugin</type>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 0 - 18
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.tests/src/be/uantwerpen/ansymo/semanticadaptation/tests/AbstractSemanticAdaptationGeneratorTest.xtend

@@ -8,7 +8,6 @@ import org.eclipse.xtext.generator.IGenerator2
 import org.junit.Assert
 import org.eclipse.xtext.generator.InMemoryFileSystemAccess
 import org.eclipse.xtext.generator.IFileSystemAccess
-import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationPythonGenerator
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
 
 abstract class AbstractSemanticAdaptationGeneratorTest extends AbstractSemanticAdaptationParserTest {
@@ -26,14 +25,6 @@ abstract class AbstractSemanticAdaptationGeneratorTest extends AbstractSemanticA
 		generator.doGenerate(root.eResource, this.fsa, null)
 	}
 	
-	/**
-	 * Compares the default file in memory to the given oracle file
-	 */
-	def void compareFiles(String oraclefilename) {
-		val inmemoryfilename = IFileSystemAccess::DEFAULT_OUTPUT+SemanticAdaptationPythonGenerator::FILENAME
-		compareFiles(inmemoryfilename, oraclefilename)
-	}
-	
 	/**
 	 * Compares a given file in memory to the given oracle file
 	 */
@@ -44,14 +35,5 @@ abstract class AbstractSemanticAdaptationGeneratorTest extends AbstractSemanticA
 		val expectedtext = readFile('oracles/'+oraclefilename)
 		Assert.assertEquals(expectedtext, actualtext)
 	}
-	
-	/**
-	 * Parses a given input file, generates code, and compares this to the given oracle file
-	 */
-	def void parseAndGenerateAndCompare(String inputfilename, String oraclefilename) {
-		val root = parseInputFile(inputfilename)
-		generateOutputFile(root)
-		compareFiles(oraclefilename)
-	}
 
 }

+ 12 - 10
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/META-INF/MANIFEST.MF

@@ -13,18 +13,20 @@ Require-Bundle: org.eclipse.xtext,
  org.antlr.runtime,
  org.eclipse.xtext.util,
  org.eclipse.xtend.lib,
- org.eclipse.emf.common
+ org.eclipse.emf.common,
+ org.eclipse.core.runtime;bundle-version="3.12.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.util,
- be.uantwerpen.ansymo.semanticadaptation.services,
+Export-Package: be.uantwerpen.ansymo.semanticadaptation,
+ be.uantwerpen.ansymo.semanticadaptation.formatting2,
+ be.uantwerpen.ansymo.semanticadaptation.parser.antlr,
+ be.uantwerpen.ansymo.semanticadaptation.parser.antlr.internal,
  be.uantwerpen.ansymo.semanticadaptation.scoping,
- be.uantwerpen.ansymo.semanticadaptation,
- be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.impl,
  be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation,
- be.uantwerpen.ansymo.semanticadaptation.parser.antlr.internal,
+ be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.impl,
+ be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.util,
  be.uantwerpen.ansymo.semanticadaptation.serializer,
+ be.uantwerpen.ansymo.semanticadaptation.services,
  be.uantwerpen.ansymo.semanticadaptation.validation,
- be.uantwerpen.ansymo.semanticadaptation.parser.antlr,
- be.uantwerpen.ansymo.semanticadaptation.generator,
- be.uantwerpen.ansymo.semanticadaptation.formatting2
-Import-Package: org.apache.log4j
+ be.uantwerpen.ansymo.semanticadaptation.generator
+Import-Package: be.uantwerpen.ansymo.semanticadaptation.log,
+ org.apache.log4j

+ 1 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/plugin.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="windows-1252"?>
 <?eclipse version="3.0"?>
 <plugin>
+   <extension-point id="generator_extension" name="generator_extension" schema="schema/generator_extension.exsd"/>
 	<extension point="org.eclipse.emf.ecore.generated_package">
 		<package 
 			uri = "http://www.uantwerpen.be/ansymo/semanticadaptation/SemanticAdaptation"

+ 102 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/schema/generator_extension.exsd

@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="be.uantwerpen.ansymo.semanticadaptation" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="be.uantwerpen.ansymo.semanticadaptation" id="generator_extension" name="generator_extension"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <choice>
+            <element ref="generator"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="generator">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationCustomGenerator:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

+ 3 - 3
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/SemanticAdaptationRuntimeModule.xtend

@@ -3,9 +3,9 @@
  */
 package be.uantwerpen.ansymo.semanticadaptation
 
-import be.uantwerpen.ansymo.semanticadaptation.valueconverter.SemanticAdaptationValueConverters
+import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationGenerator
 import be.uantwerpen.ansymo.semanticadaptation.scoping.SemanticAdaptationScopeProvider
-import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationCanonicalGenerator
+import be.uantwerpen.ansymo.semanticadaptation.valueconverter.SemanticAdaptationValueConverters
 
 /**
  * Use this class to register components to be used at runtime / without the Equinox extension registry.
@@ -19,6 +19,6 @@ class SemanticAdaptationRuntimeModule extends AbstractSemanticAdaptationRuntimeM
 		return SemanticAdaptationScopeProvider
 	}
 	override bindIGenerator2() {
-		return SemanticAdaptationCanonicalGenerator
+		return SemanticAdaptationGenerator
 	}
 }

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/formatting2/SemanticAdaptationFormatter.xtend

@@ -3,7 +3,6 @@
  */
 package be.uantwerpen.ansymo.semanticadaptation.formatting2
 
-import be.uantwerpen.ansymo.semanticadaptation.generator.Log
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CompositeOutputFunction
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CustomControlRule
@@ -11,6 +10,7 @@ import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DataRule
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.StateTransitionFunction
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Statement
+import be.uantwerpen.ansymo.semanticadaptation.log.Log
 import org.eclipse.xtext.formatting2.AbstractFormatter2
 import org.eclipse.xtext.formatting2.IFormattableDocument
 

+ 0 - 48
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/Log.xtend

@@ -1,48 +0,0 @@
-package be.uantwerpen.ansymo.semanticadaptation.generator
-
-import org.apache.log4j.Logger
-
-class Log {
-	var static Log l = null;
-	
-	var c = 0
-	
-	private static final Logger logger = Logger.getLogger("");
-	
-	protected new() {
-		// Exists only to defeat instantiation.
-	}
-
-	def protected static Log gl() {
-		if (l === null) {
-			l = new Log();
-		}
-		return l;
-	}
-	
-	def static String space(int indent){
-		var res = ""
-		for(var i = 0; i<indent; i++){
-			res += " "
-		}
-		return res;
-	}
-
-	def static void println(String msg){
-		val space = space(gl().c)
-		for(line : msg.split('\n')){
-			logger.info(space + line)
-		}
-	}
-	
-	def static void push(String msg){
-		logger.info(space(gl().c) + ">" + msg)
-		gl().c++
-	}
-	
-	def static void pop(String msg){
-		gl().c--
-		logger.info(space(gl().c) + "<" + msg)
-	}
-	
-}

+ 14 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationCustomGenerator.java

@@ -0,0 +1,14 @@
+package be.uantwerpen.ansymo.semanticadaptation.generator;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.generator.IFileSystemAccess2;
+
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation;
+
+public class SemanticAdaptationCustomGenerator {
+
+	public void generate(Adaptation sa, IFileSystemAccess2 fsa, URI mainFile) {
+		// To be overriden
+	}
+
+}

+ 0 - 25
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationGenerator.xtend

@@ -1,25 +0,0 @@
-/*
- * generated by Xtext 2.10.0
- */
-package be.uantwerpen.ansymo.semanticadaptation.generator
-
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.xtext.generator.AbstractGenerator
-import org.eclipse.xtext.generator.IFileSystemAccess2
-import org.eclipse.xtext.generator.IGeneratorContext
-
-/**
- * Generates code from your model files on save.
- * 
- * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
- */
-class SemanticAdaptationGenerator extends AbstractGenerator {
-
-	override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
-//		fsa.generateFile('greetings.txt', 'People to greet: ' + 
-//			resource.allContents
-//				.filter(typeof(Greeting))
-//				.map[name]
-//				.join(', '))
-	}
-}

+ 0 - 110
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/generator/SemanticAdaptationPythonGenerator.xtend

@@ -1,110 +0,0 @@
-/*
- * generated by Xtext 2.10.0
- */
-package be.uantwerpen.ansymo.semanticadaptation.generator
-
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.xtext.generator.AbstractGenerator
-import org.eclipse.xtext.generator.IFileSystemAccess2
-import org.eclipse.xtext.generator.IGeneratorContext
-
-/**
- * Generates code from your model files on save.
- * 
- * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
- */
-class SemanticAdaptationPythonGenerator extends AbstractGenerator {
-	
-	public final static String FILENAME = 'output.test.txt'
-
-	override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
-//		for (Adaptation a : resource.allContents.toIterable.filter(SemanticAdaptation).last.elements.filter(Adaptation)) {
-//			fsa.generateFile(FILENAME, a.compile)
-//			println(fsa.readTextFile(FILENAME))
-//		}
-	}
-	
-	def compile(Adaptation a) '''
-import logging
-
-from abstract_units.AbstractSimulationUnit import AbstractSimulationUnit, \
-    STEP_ACCEPT
-�/*FOR fmu:a.inner.instances.filter(AtomicFMU)�
-from case_study.units.ct_based.�fmu.name� import �fmu.name�
-�ENDFOR�
-�FOR i:a.inner.instances.filter(Adaptation)�
-NOT YET IMPLEMENTED
-�ENDFOR*/�
-
-l = logging.getLogger()
-
-class PowerInputAdaptation_Event(AbstractSimulationUnit):
-    """
-    This is the adaptation of the events coming out of the Controller Statechart.
-    It gets as input an event, and output two signals, to be coupled to the power system.
-    Whenever it gets an input, it stores the appropriate signals for the output until another event comes along.
-    It's basically a ZOH.
-    
-    Example interaction:_______________
-    f = PowerInputAdaptation_Event(...)
-    f.enterInitMode()
-    f.setValues(...,"SomeInEvent")
-        This tells the FMU what the input is.
-        The sFMU will record this input (if not "") to the internal state. 
-        and initial input ("SomeInEvent").
-    (up,down) = f.getValues(...)
-        The values that can be returned are initial_up and initial_down
-    f.exitInitMode()
-    
-    f.setValues(..., "SomeInEvent")
-        The definition of a new event gets recorded by the fmu
-    f.doStep(..., H)
-        The internal state gets updated according to the new input event.
-        Or kept the same if the new event is ""
-    (up,down) = f.getValues(...)
-        The last event processed is in the output variable, ready to be collected.
-    ______________________________
-    
-    """
-    
-    def __init__(self, name):
-        
-        self.in_event = "in_event"
-        self.out_down = "out_down"
-        self.out_up = "out_up"
-        input_vars = [self.in_event]
-        state_vars = [self.out_down, self.out_up]
-        
-        algebraic_functions = {}
-        
-        AbstractSimulationUnit.__init__(self, name, algebraic_functions, state_vars, input_vars)
-    
-    def _doInternalSteps(self, time, step, iteration, step_size):
-        l.debug(">%s._doInternalSteps(%f, %d, %d, %f)", self._name, time, step, iteration, step_size)
-        
-        assert iteration == 0, "Fixed point iterations not supported yet."
-        
-        previous_output = self.getValues(step-1, iteration, self._getStateVars())
-        current_input = self.getValues(step, iteration, self._getInputVars())
-        
-        l.debug("%s.previous_output=%s", self._name, previous_output)
-        l.debug("%s.current_input=%s", self._name, current_input)
-        
-        next_output = previous_output
-        in_ev = current_input[self.in_event]
-        if in_ev != "":
-            l.debug("Updating internal state due to input %s...", in_ev)
-            next_out_up = 1.0 if in_ev=="up" else 0.0
-            next_out_down = 1.0 if in_ev=="down" else 0.0
-            next_output = {self.out_down: next_out_down, self.out_up: next_out_up}
-            
-        # Store the values into the state
-        self.setValues(step, iteration, {self.out_down: next_output[self.out_down],
-                                         self.out_up: next_output[self.out_up] })
-        
-        
-        l.debug("<%s._doInternalSteps() = (%s, %d)", self._name, STEP_ACCEPT, step_size)
-        return (STEP_ACCEPT, step_size)
-'''
-}

+ 1 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/src/be/uantwerpen/ansymo/semanticadaptation/scoping/SemanticAdaptationScopeProvider.xtend

@@ -7,7 +7,6 @@
  *******************************************************************************/
 package be.uantwerpen.ansymo.semanticadaptation.scoping
 
-import be.uantwerpen.ansymo.semanticadaptation.generator.Log
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.AlgebraicLoopSolution
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Component
@@ -43,6 +42,7 @@ import org.eclipse.xtext.scoping.IScope
 import org.eclipse.xtext.scoping.Scopes
 import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
 import org.eclipse.xtext.scoping.impl.IScopeWrapper
+import be.uantwerpen.ansymo.semanticadaptation.log.Log
 
 /**
  * This class contains custom scoping description.

+ 2 - 0
DSL_SemanticAdaptation/pom.xml

@@ -13,6 +13,8 @@
 	<modules>
 		<module>be.uantwerpen.ansymo.semanticadaptation.testframework</module>
 		<module>be.uantwerpen.ansymo.semanticadaptation</module>
+		<module>be.uantwerpen.ansymo.semanticadaptation.log</module>
+		<module>be.uantwerpen.ansymo.semanticadaptation.cg.chain</module>
 		<module>be.uantwerpen.ansymo.semanticadaptation.tests</module>
 		<module>be.uantwerpen.ansymo.semanticadaptation.ide</module>
 		<module>be.uantwerpen.ansymo.semanticadaptation.ui</module>