Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
#899 removed outlet parameters from IExecutionFlowGenerator interface,
Browse files Browse the repository at this point in the history
moved them to api package
  • Loading branch information
andreasmuelder committed Aug 12, 2016
1 parent 20a32cd commit f732547
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ package org.yakindu.sct.generator.c
import com.google.inject.Inject
import com.google.inject.name.Named
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry
import org.yakindu.sct.generator.c.GenArtifactConfigurations.GenArtifactConfiguration
import org.yakindu.sct.generator.core.IExecutionFlowGenerator
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry
import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*;

/**
* This is the C code generators main class.
Expand Down Expand Up @@ -68,22 +69,22 @@ class CGenerator implements IExecutionFlowGenerator {

def protected getHeaderOutput(GeneratorEntry entry) {
if (entry.apiTargetFolderValue != null) {
IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT
API_TARGET_FOLDER_OUTPUT
} else {
IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT
TARGET_FOLDER_OUTPUT
}
}

def protected getLibraryOutput(GeneratorEntry entry) {
if (entry.libraryTargetFolderValue != null) {
IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT
LIBRARY_TARGET_FOLDER_OUTPUT
} else {
entry.headerOutput
}
}

def protected getSourceOutput(GeneratorEntry entry) {
IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT
TARGET_FOLDER_OUTPUT
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
* committers of YAKINDU - initial API and implementation
*
*/
package org.yakindu.sct.generator.core.impl;
package org.yakindu.sct.generator.core;

import org.eclipse.xtext.generator.IFileSystemAccess;
import org.yakindu.sct.model.sexec.ExecutionFlow;
import org.yakindu.sct.model.sgen.GeneratorEntry;

/**
* Basic interface for all CodeGenerators that are built on top of the
* {@link ExecutionFlow}
*
* @author andreas muelder - Initial contribution and API
*
*/
public interface IExecutionFlowGenerator {

String TARGET_FOLDER_OUTPUT = IFileSystemAccess.DEFAULT_OUTPUT;
String LIBRARY_TARGET_FOLDER_OUTPUT = "LIBRARY_TARGET_FOLDER";
String API_TARGET_FOLDER_OUTPUT = "API_TARGET_FOLDER";

/**
*
* @param flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
* committers of YAKINDU - initial API and implementation
*
*/
package org.yakindu.sct.generator.core.impl;
package org.yakindu.sct.generator.core;

import org.eclipse.xtext.generator.IFileSystemAccess;
import org.yakindu.sct.model.sgen.GeneratorEntry;
import org.yakindu.sct.model.sgraph.Statechart;

/**
* Basic interface for all CodeGenerators that are build for {@link Statechart}s
*
* @author andreas muelder - Initial contribution and API
*
*/

public interface ISGraphGenerator {
abstract void generate(Statechart statechart, GeneratorEntry entry);

void generate(Statechart statechart, GeneratorEntry entry, IFileSystemAccess fsa);

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
*
*/
public interface ISCTFileSystemAccess {


String TARGET_FOLDER_OUTPUT = IFileSystemAccess.DEFAULT_OUTPUT;
String LIBRARY_TARGET_FOLDER_OUTPUT = "LIBRARY_TARGET_FOLDER";
String API_TARGET_FOLDER_OUTPUT = "API_TARGET_FOLDER";


/**
* Provides an absolute URI for further processing.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.yakindu.sct.generator.core.IExecutionFlowGenerator;
import org.yakindu.sct.model.sexec.ExecutionFlow;
import org.yakindu.sct.model.sexec.transformation.FlowOptimizer;
import org.yakindu.sct.model.sexec.transformation.IModelSequencer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
*/
package org.yakindu.sct.generator.core.impl;

import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.API_TARGET_FOLDER_OUTPUT;
import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.LIBRARY_TARGET_FOLDER_OUTPUT;
import static org.yakindu.sct.generator.core.library.ICoreLibraryConstants.OUTLET_FEATURE_TARGET_PROJECT;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.OutputConfiguration;
import org.yakindu.sct.generator.core.ISCTGenerator;
import org.yakindu.sct.generator.core.ISGraphGenerator;
import org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess;
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper;
import org.yakindu.sct.model.sexec.ExecutionFlow;
Expand All @@ -33,7 +36,7 @@
* abstract base class for all code generators that want to generate code based
* on the {@link ExecutionFlow}
*
* @author Andreas Mülder - Initial contribution and API
* @author Andreas Mülder - Initial contribution and API
* @author Johannes Dicks - decouple EFS
*
*/
Expand All @@ -49,7 +52,7 @@ public abstract class AbstractSGraphModelGenerator implements ISCTGenerator {
protected void runGenerator(Statechart statechart, GeneratorEntry entry) {
if (this instanceof ISGraphGenerator) {
ISGraphGenerator graphGenerator = (ISGraphGenerator) this;
graphGenerator.generate(statechart, entry);
graphGenerator.generate(statechart, entry, sctFsa.getIFileSystemAccess());
}
}

Expand Down Expand Up @@ -193,12 +196,12 @@ protected void initFileSystemAccess(GeneratorEntry entry) {
protected void initLibraryTargetFolder(GeneratorEntry entry) {
FeatureParameterValue libraryTargetFolderValue = coreFeatureHelper.getLibraryTargetFolderValue(entry);
if (libraryTargetFolderValue != null) {
sctFsa.setOutputPath(IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT,
sctFsa.setOutputPath(LIBRARY_TARGET_FOLDER_OUTPUT,
libraryTargetFolderValue.getStringValue());
}

OutputConfiguration librarytargetFolderOutputConfiguration = sctFsa.getOutputConfigurations()
.get(IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT);
.get(LIBRARY_TARGET_FOLDER_OUTPUT);
if (librarytargetFolderOutputConfiguration != null) {
librarytargetFolderOutputConfiguration.setCreateOutputDirectory(true);
// do not overwrite existing resources and ensure the folder is not
Expand All @@ -211,11 +214,11 @@ protected void initLibraryTargetFolder(GeneratorEntry entry) {
protected void initApiTargetFolder(GeneratorEntry entry) {
FeatureParameterValue apiTargetFolderValue = coreFeatureHelper.getApiTargetFolderValue(entry);
if (apiTargetFolderValue != null) {
sctFsa.setOutputPath(IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT,
sctFsa.setOutputPath(API_TARGET_FOLDER_OUTPUT,
apiTargetFolderValue.getStringValue());
}
OutputConfiguration apiTargetFolderOutputConfiguration = sctFsa.getOutputConfigurations()
.get(IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT);
.get(API_TARGET_FOLDER_OUTPUT);
if (apiTargetFolderOutputConfiguration != null) {
apiTargetFolderOutputConfiguration.setCreateOutputDirectory(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import com.google.inject.name.Named
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.c.GenArtifactConfigurations.GenArtifactConfiguration
import org.yakindu.sct.generator.c.IGenArtifactConfigurations
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import org.yakindu.sct.generator.core.IExecutionFlowGenerator
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*;

/**
* This is the CPP code generators main class.
Expand Down Expand Up @@ -74,22 +75,22 @@ class CppGenerator implements IExecutionFlowGenerator {

def protected getHeaderOutput(GeneratorEntry entry) {
if (entry.apiTargetFolderValue != null) {
IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT
API_TARGET_FOLDER_OUTPUT
} else {
IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT
TARGET_FOLDER_OUTPUT
}
}

def protected getLibraryOutput(GeneratorEntry entry) {
if (entry.libraryTargetFolderValue != null) {
IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT
LIBRARY_TARGET_FOLDER_OUTPUT
} else {
entry.headerOutput
}
}

def protected getSourceOutput(GeneratorEntry entry) {
IExecutionFlowGenerator.TARGET_FOLDER_OUTPUT
TARGET_FOLDER_OUTPUT
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.yakindu.sct.generator.csharp

import com.google.inject.Inject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import org.yakindu.sct.generator.core.IExecutionFlowGenerator
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ package org.yakindu.sct.generator.java

import com.google.inject.Inject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry

import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*

class IStatemachine {

Expand All @@ -31,11 +30,11 @@ class IStatemachine {
if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
// generate into library target folder in case one is specified, as the contents are static
fsa.generateFile(entry.basePackagePath + '/' + iStatemachine.java,
IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
} else if (outletFeatureHelper.getApiTargetFolderValue(entry) != null) {
// generate into API target folder in case one is specified, as it is an interface
fsa.generateFile(entry.basePackagePath + '/' + iStatemachine.java,
IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT, content(entry))
API_TARGET_FOLDER_OUTPUT, content(entry))
} else {
// use default target folder path in case no library or API target folder is specified (the file will be overwritten there)
fsa.generateFile(entry.basePackagePath + '/' + iStatemachine.java, content(entry))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ package org.yakindu.sct.generator.java

import com.google.inject.Inject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator

import org.yakindu.sct.model.sgen.GeneratorEntry
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry

import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*

class ITimer {

Expand All @@ -31,11 +31,11 @@ class ITimer {
if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
// generate into library target folder in case one is specified, as the contents are static
fsa.generateFile(entry.basePackagePath + '/' + iTimer.java,
IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
} else if (outletFeatureHelper.getApiTargetFolderValue(entry) != null) {
// generate into API target folder in case one is specified, as it is an interface
fsa.generateFile(entry.basePackagePath + '/' + iTimer.java,
IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT, content(entry))
API_TARGET_FOLDER_OUTPUT, content(entry))
} else {
// use default target folder path in case no library target folder is specified (the file will be overwritten there)
fsa.generateFile(entry.basePackagePath + '/' + iTimer.java, content(entry))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package org.yakindu.sct.generator.java

import com.google.inject.Inject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import static org.yakindu.sct.generator.core.filesystem.ISCTFileSystemAccess.*;
import org.yakindu.sct.model.sgen.GeneratorEntry
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.generator.core.library.ICoreLibraryHelper
Expand All @@ -23,18 +23,18 @@ class ITimerCallback {

@Inject
extension GenmodelEntries

@Inject ICoreLibraryHelper outletFeatureHelper

def generateITimerCallback(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
// generate into library target folder in case one is specified, as the contents are static
fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java,
IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java, LIBRARY_TARGET_FOLDER_OUTPUT,
content(entry))
} else if (outletFeatureHelper.getApiTargetFolderValue(entry) != null) {
// generate into API target folder in case one is specified, as it is an interface
fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java,
IExecutionFlowGenerator.API_TARGET_FOLDER_OUTPUT, content(entry))
fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java, API_TARGET_FOLDER_OUTPUT,
content(entry))
} else {
// use default target folder path in case no library or API target folder is specified (the file will be overwritten there)
fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java, content(entry))
Expand All @@ -61,4 +61,4 @@ class ITimerCallback {
}
'''
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ package org.yakindu.sct.generator.java

import com.google.inject.Inject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sgen.GeneratorEntry
import org.yakindu.sct.generator.java.features.EventBasedRunnableFeature
import org.yakindu.sct.generator.core.IExecutionFlowGenerator
import org.yakindu.sct.generator.java.features.CycleBasedWrapperFeature
import org.yakindu.sct.generator.java.features.EventBasedRunnableFeature
import org.yakindu.sct.model.sexec.ExecutionFlow
import org.yakindu.sct.model.sexec.naming.INamingService
import org.yakindu.sct.model.sgen.GeneratorEntry

/**
* This is the Java code generators main class.
Expand Down
Loading

0 comments on commit f732547

Please sign in to comment.