|
@@ -11,41 +11,30 @@
|
|
|
package org.yakindu.sct.generator.c
|
|
|
|
|
|
import com.google.inject.Inject
|
|
|
-import org.eclipse.core.resources.ResourcesPlugin
|
|
|
-import org.eclipse.core.runtime.Path
|
|
|
import org.eclipse.xtext.generator.IFileSystemAccess
|
|
|
import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
|
|
|
import org.yakindu.sct.model.sgraph.Statechart
|
|
|
-import org.yakindu.sct.generator.core.filesystem.EFSResourceFileSystemAccess
|
|
|
import org.yakindu.sct.model.sexec.ExecutionFlow
|
|
|
import org.yakindu.sct.model.sgen.GeneratorEntry
|
|
|
-import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl
|
|
|
+import org.yakindu.sct.generator.core.library.IOutletFeatureHelper
|
|
|
|
|
|
class Types {
|
|
|
|
|
|
@Inject extension Naming
|
|
|
@Inject extension GenmodelEntries
|
|
|
+ @Inject IOutletFeatureHelper outletFeatureHelper
|
|
|
|
|
|
def generateTypesH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
|
|
|
- if (new OutletFeatureHelperImpl().getLibraryTargetFolderValue(entry) != null) {
|
|
|
+ if (outletFeatureHelper.getLibraryTargetFolderValue(entry) != null) {
|
|
|
// sc_types.h is static, so we use the library target folder in case its configured
|
|
|
fsa.generateFile(flow.typesModule.h, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT,
|
|
|
flow.typesHContent(entry))
|
|
|
} else {
|
|
|
// use default target folder path in case no library target folder is specified (the file will be overwritten there)
|
|
|
- if (fsa instanceof EFSResourceFileSystemAccess &&
|
|
|
- !exists(flow.typesModule.h, fsa as EFSResourceFileSystemAccess)) {
|
|
|
fsa.generateFile(flow.typesModule.h, flow.typesHContent(entry))
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- def protected exists(String filename, EFSResourceFileSystemAccess fsa) {
|
|
|
- val uri = fsa.getURI(filename);
|
|
|
- val file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
|
|
|
- return file.exists;
|
|
|
- }
|
|
|
-
|
|
|
def typesHContent(ExecutionFlow it, GeneratorEntry entry) '''
|
|
|
«entry.licenseText»
|
|
|
|