Browse Source

Added support for dump feature to java and c code generatro.
Minor refactorings of core generators.

markus.muehlbrandt@gmail.com 12 years ago
parent
commit
798992d1d4

+ 12 - 5
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java

@@ -1,16 +1,23 @@
 package org.yakindu.sct.generator.c;
 
+import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
+
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
 public class CCodeGenerator extends GenericJavaBasedGenerator {
 
 	@Override
-	public void runGenerator(Statechart flow, GeneratorEntry entry) {
-		CSCTGenerator delegate = getInjector(entry).getInstance(CSCTGenerator.class);		
-		delegate.generate(createExecutionFlow(flow, entry), entry, getFileSystemAccess(entry));
+	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
+		CSCTGenerator delegate = getInjector(entry).getInstance(CSCTGenerator.class);
+		
+		ExecutionFlow flow = createExecutionFlow(statechart, entry);
+		
+		if (isDumpSexec(entry)) {
+			dumpSexec(entry, flow);
+		}
+		delegate.generate(flow, entry, getFileSystemAccess(entry));
 	}
-
-	
 }

+ 1 - 2
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java

@@ -106,8 +106,7 @@ public abstract class AbstractSExecModelGenerator extends
 		return flow;
 	}
 
-	protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow,
-			Output output) {
+	protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow) {
 		ResourceSet resourceSet = new ResourceSetImpl();
 		resourceSet
 				.getResourceFactoryRegistry()

+ 1 - 1
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractXpandBasedCodeGenerator.java

@@ -78,7 +78,7 @@ public abstract class AbstractXpandBasedCodeGenerator extends
 			generatorFound = true;
 			ExecutionFlow flow = createExecutionFlow(statechart, entry);
 			if (isDumpSexec(entry)) {
-				dumpSexec(entry, flow, output);
+				dumpSexec(entry, flow);
 			}
 			facade.evaluate(templatePath, flow, entry);
 		}

+ 14 - 5
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java

@@ -16,6 +16,7 @@ import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureCo
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.GENERATOR_PROJECT;
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.TEMPLATE_FEATURE;
 import static org.yakindu.sct.generator.core.util.GeneratorUtils.getOutletFeatureConfiguration;
+import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -25,6 +26,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess;
 import org.eclipse.xtext.util.Strings;
 import org.yakindu.sct.commons.WorkspaceClassLoaderFactory;
 import org.yakindu.sct.generator.core.AbstractWorkspaceGenerator;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.FeatureConfiguration;
 import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
@@ -94,7 +96,7 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 	}
 
 	@Override
-	public void runGenerator(Statechart flow, GeneratorEntry entry) {
+	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
 		String templateClass = getTemplateClassName(entry);
 		final ClassLoader classLoader = getClassLoader(entry);
 		IFileSystemAccess fsa = getFileSystemAccess(entry);
@@ -111,23 +113,30 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 			Class<?> iType__ = IExecutionFlowGenerator.class;
 			Class<?> iType = (Class<?>) classLoader
 					.loadClass("org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator");
-
+			
+			ExecutionFlow flow = createExecutionFlow(statechart, entry);
+			
+			if (isDumpSexec(entry)) {
+				dumpSexec(entry, flow);
+			}
+			
 			if (delegate instanceof AbstractWorkspaceGenerator) {
 				((AbstractWorkspaceGenerator) delegate).setBridge(bridge);
 			}
+			
 			if (delegate instanceof IExecutionFlowGenerator) {
 				IExecutionFlowGenerator flowGenerator = (IExecutionFlowGenerator) delegate;
-				flowGenerator.generate(createExecutionFlow(flow, entry), entry,
+				flowGenerator.generate(flow, entry,
 						fsa);
 			}
 			if (iType.isInstance(delegate)) {
 				IExecutionFlowGenerator flowGenerator = (IExecutionFlowGenerator) delegate;
-				flowGenerator.generate(createExecutionFlow(flow, entry), entry,
+				flowGenerator.generate(flow, entry,
 						fsa);
 			}
 			if (delegate instanceof ISGraphGenerator) {
 				ISGraphGenerator graphGenerator = (ISGraphGenerator) delegate;
-				graphGenerator.generate(flow, entry);
+				graphGenerator.generate(statechart, entry);
 			}
 		} catch (Exception e) {
 			e.printStackTrace();

+ 13 - 3
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java

@@ -9,15 +9,25 @@
  */
 package org.yakindu.sct.generator.java;
 
+import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
+
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
 public class JavaCodeGenerator extends GenericJavaBasedGenerator {
 
 	@Override
-	public void runGenerator(Statechart flow, GeneratorEntry entry) {
-		JavaGenerator delegate = getInjector(entry).getInstance(JavaGenerator.class);		
-		delegate.generate(createExecutionFlow(flow, entry), entry, getFileSystemAccess(entry));
+	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
+		JavaGenerator delegate = getInjector(entry).getInstance(JavaGenerator.class);
+		
+		ExecutionFlow flow = createExecutionFlow(statechart, entry);
+		
+		if (isDumpSexec(entry)) {
+			dumpSexec(entry, flow);
+		}
+		
+		delegate.generate(flow, entry, getFileSystemAccess(entry));
 	}
 }