Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-04-03 08:54:37 +0000
committerHenrik Rentz-Reichert2013-04-03 08:54:37 +0000
commit2c008b4e35ad4f5a94fb9a0af992531bac210578 (patch)
tree34a9ac0cd831b395e3a899ab24b629e2d240f366 /plugins
parentcefa8fbcabdf55cd0098bbee39ac17e02f78ffb5 (diff)
downloadorg.eclipse.etrice-2c008b4e35ad4f5a94fb9a0af992531bac210578.tar.gz
org.eclipse.etrice-2c008b4e35ad4f5a94fb9a0af992531bac210578.tar.xz
org.eclipse.etrice-2c008b4e35ad4f5a94fb9a0af992531bac210578.zip
[core.genmodel, generator, generator.c, generator.java] bug 403721: incremental codegeneration
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403721 - introduced interface IGeneratorFileIo for code generation - added standard implementation IncrementalFileIo - using default non-incremental
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java7
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend16
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend23
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend32
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend36
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend13
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java48
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java31
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java67
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend11
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend20
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend42
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend17
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend30
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java23
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java19
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java32
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java25
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java19
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java34
-rw-r--r--plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IGeneratorFileIo.java36
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IncrementalGenerationFileIo.java118
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend18
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java20
32 files changed, 468 insertions, 358 deletions
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
index 4b8ec851a..fcca7d71a 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/etricegen/impl/RootImpl.java
@@ -688,6 +688,13 @@ public class RootImpl extends EObjectImpl implements Root {
usedActorClasses = new BasicEList<ActorClass>(actorClasses);
usedRoomModels = new BasicEList<RoomModel>(models);
}
+
+ RoomClassComparator rcComp = new RoomClassComparator();
+ RoomModelComparator mdlComp = new RoomModelComparator();
+ Collections.sort(usedDataClasses, rcComp);
+ Collections.sort(usedProtocolClasses, rcComp);
+ Collections.sort(usedActorClasses, rcComp);
+ Collections.sort(usedRoomModels, mdlComp);
}
private void getReferencedClassesAndModels(HashSet<DataClass> dataClasses,
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 7ef8db0a4..85b866c8b 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -21,11 +21,11 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.room.ActorCommunicationType
import org.eclipse.etrice.core.room.CommunicationType
import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@@ -38,26 +38,26 @@ class ActorClassGen extends GenericActorClassGenerator {
@Inject extension StateMachineGen
@Inject protected ILanguageExtension langExt
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject ILogger logger
def doGenerate(Root root) {
for (xpac: root.xpActorClasses) {
val path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath
+ val infopath = xpac.actorClass.generationInfoPath+xpac.actorClass.getPath
+ var file = xpac.actorClass.getCHeaderFileName
// header file
- logger.logInfo("generating ActorClass header '"+xpac.actorClass.getCHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(xpac.actorClass.getCHeaderFileName, root.generateHeaderFile(xpac))
+ fileIO.generateFile("generating ActorClass header", path, infopath, file, root.generateHeaderFile(xpac))
// source file
+ fileIO.generateFile("generating ActorClass header", path, infopath, file, root.generateHeaderFile(xpac))
if (xpac.actorClass.isBehaviorAnnotationPresent("BehaviorManual")) {
logger.logInfo("omitting ActorClass source for '"+xpac.actorClass.name+"' since @BehaviorManual is specified")
}
else {
- logger.logInfo("generating ActorClass source '"+xpac.actorClass.getCSourceFileName +"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(xpac.actorClass.getCSourceFileName , root.generateSourceFile(xpac))
+ file = xpac.actorClass.getCSourceFileName
+ fileIO.generateFile("generating ActorClass source", path, infopath, file, root.generateSourceFile(xpac))
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
index e9933c85a..f5eea50b9 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend
@@ -15,19 +15,19 @@ package org.eclipse.etrice.generator.c.gen
import com.google.inject.Inject
import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.ProcedureHelpers
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class DataClassGen {
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension CExtensions
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
@@ -35,17 +35,16 @@ class DataClassGen {
def doGenerate(Root root) {
for (dc: root.usedDataClasses) {
- var path = dc.generationTargetPath+dc.getPath
+ val path = dc.generationTargetPath+dc.getPath
+ val infopath = dc.generationInfoPath+dc.getPath
+ var file = dc.getCHeaderFileName
// header file
- logger.logInfo("generating DataClass header '"+dc.getCHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCHeaderFileName, root.generateHeaderFile(dc))
+ fileIO.generateFile("generating DataClass header", path, infopath, file, root.generateHeaderFile(dc))
// source file
- logger.logInfo("generating DataClass source '"+dc.getCSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(dc.getCSourceFileName, root.generateSourceFile(dc))
+ file = dc.getCSourceFileName
+ fileIO.generateFile("generating DataClass header", path, infopath, file, root.generateSourceFile(dc))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index b8cad55a1..3c33f0921 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -15,25 +15,24 @@ package org.eclipse.etrice.generator.c.gen
import com.google.inject.Inject
import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.ProtocolClass
-import org.eclipse.etrice.core.room.CommunicationType
-import org.eclipse.etrice.core.room.PrimitiveType
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.generator.base.AbstractGenerator
-
-import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension CExtensions
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
@@ -42,15 +41,16 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def doGenerate(Root root) {
for (pc: root.usedProtocolClasses) {
- var path = pc.generationTargetPath+pc.getPath
+ val path = pc.generationTargetPath+pc.getPath
+ val infopath = pc.generationInfoPath+pc.getPath
+ var file = pc.getCHeaderFileName
- logger.logInfo("generating ProtocolClass header '"+pc.getCHeaderFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(pc.getCHeaderFileName, root.generateHeaderFile(pc))
+ // header file
+ fileIO.generateFile("generating ProtocolClass header", path, infopath, file, root.generateHeaderFile(pc))
- logger.logInfo("generating ProtocolClass source '"+pc.getCSourceFileName+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(pc.getCSourceFileName, root.generateSourceFile(pc))
+ // source file
+ file = pc.getCSourceFileName
+ fileIO.generateFile("generating ProtocolClass source", path, infopath, file, root.generateSourceFile(pc))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index 69d91bcf0..ed0dd0c71 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -17,65 +17,57 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.ArrayList
import java.util.HashMap
-import org.eclipse.etrice.core.genmodel.base.ILogger
+import java.util.HashSet
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician
import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance
import org.eclipse.etrice.core.genmodel.etricegen.PortInstance
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
import org.eclipse.etrice.core.room.ActorCommunicationType
import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.Port
import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.SAPRef
+import org.eclipse.etrice.core.room.SPPRef
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
-import org.eclipse.etrice.core.room.Port
-import org.eclipse.etrice.core.room.SAPRef
-import org.eclipse.etrice.core.room.SPPRef
-import java.util.HashSet
-import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician
@Singleton
class SubSystemClassGen {
- @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension CExtensions stdExt
@Inject extension RoomExtensions roomExt
@Inject extension ProcedureHelpers helpers
@Inject Initialization attrInitGenAddon
@Inject ILanguageExtension languageExt
- @Inject ILogger logger
@Inject IDiagnostician diagnostician
def doGenerate(Root root) {
for (ssi: root.subSystemInstances) {
- var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ val ssc = ssi.subSystemClass
+ val path = ssc.generationTargetPath+ssc.getPath
+ val infopath = ssc.generationInfoPath+ssc.getPath
var file = ssi.subSystemClass.getCHeaderFileName
checkDataPorts(ssi)
- logger.logInfo("generating SubSystemClass declaration: '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generateHeaderFile(ssi))
+ fileIO.generateFile("generating SubSystemClass declaration", path, infopath, file, root.generateHeaderFile(ssi))
file = ssi.subSystemClass.getCSourceFileName
- logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generateSourceFile(ssi))
+ fileIO.generateFile("generating SubSystemClass implementation", path, infopath, file, root.generateSourceFile(ssi))
file = ssi.subSystemClass.getInstSourceFileName
- logger.logInfo("generating SubSystemClass instance file: '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generateInstanceFile(ssi))
+ fileIO.generateFile("generating SubSystemClass instance file", path, infopath, file, root.generateInstanceFile(ssi))
file = ssi.subSystemClass.getDispSourceFileName
- logger.logInfo("generating SubSystemClass dispatcher file: '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generateDispatcherFile(ssi))
+ fileIO.generateFile("generating SubSystemClass dispatcher file", path, infopath, file, root.generateDispatcherFile(ssi))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
index 18dd17143..b776cb453 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend
@@ -17,19 +17,22 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.RoomExtensions
@Singleton
class SubSystemRunnerGen {
- @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension RoomExtensions roomExt
def doGenerate(Root root) {
- for (sc: root.subSystemInstances) {
- fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
- fileAccess.generateFile( sc.subSystemClass.name+"_Runner.c", root.generateSourceFile(sc))
+ for (ssi: root.subSystemInstances) {
+ val ssc = ssi.subSystemClass
+ val path = ssc.generationTargetPath+ssc.getPath
+ val infopath = ssc.generationInfoPath+ssc.getPath
+ var file = ssi.subSystemClass.name+"_Runner.c"
+ fileIO.generateFile("generating SubSystemRunner implementation", path, infopath, file, root.generateSourceFile(ssi))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
index f40633e9e..e2dc45d2c 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ActorClassGen.java
@@ -34,6 +34,7 @@ import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.c.gen.StateMachineGen;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
@@ -41,7 +42,6 @@ import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -69,7 +69,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
protected ILanguageExtension langExt;
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
private ILogger logger;
@@ -84,38 +84,30 @@ public class ActorClassGen extends GenericActorClassGenerator {
String _path = this._roomExtensions.getPath(_actorClass_1);
final String path = (_generationTargetPath + _path);
ActorClass _actorClass_2 = xpac.getActorClass();
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(_actorClass_2);
- String _plus = ("generating ActorClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_actorClass_2);
ActorClass _actorClass_3 = xpac.getActorClass();
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(_actorClass_3);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ String _path_1 = this._roomExtensions.getPath(_actorClass_3);
+ final String infopath = (_generationInfoPath + _path_1);
ActorClass _actorClass_4 = xpac.getActorClass();
- boolean _isBehaviorAnnotationPresent = RoomHelpers.isBehaviorAnnotationPresent(_actorClass_4, "BehaviorManual");
+ String file = this._cExtensions.getCHeaderFileName(_actorClass_4);
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac);
+ this.fileIO.generateFile("generating ActorClass header", path, infopath, file, _generateHeaderFile);
+ CharSequence _generateHeaderFile_1 = this.generateHeaderFile(root, xpac);
+ this.fileIO.generateFile("generating ActorClass header", path, infopath, file, _generateHeaderFile_1);
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ boolean _isBehaviorAnnotationPresent = RoomHelpers.isBehaviorAnnotationPresent(_actorClass_5, "BehaviorManual");
if (_isBehaviorAnnotationPresent) {
- ActorClass _actorClass_5 = xpac.getActorClass();
- String _name = _actorClass_5.getName();
- String _plus_4 = ("omitting ActorClass source for \'" + _name);
- String _plus_5 = (_plus_4 + "\' since @BehaviorManual is specified");
- this.logger.logInfo(_plus_5);
- } else {
ActorClass _actorClass_6 = xpac.getActorClass();
- String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_6);
- String _plus_6 = ("generating ActorClass source \'" + _cSourceFileName);
- String _plus_7 = (_plus_6 + "\' in \'");
- String _plus_8 = (_plus_7 + path);
- String _plus_9 = (_plus_8 + "\'");
- this.logger.logInfo(_plus_9);
- this.fileAccess.setOutputPath(path);
+ String _name = _actorClass_6.getName();
+ String _plus = ("omitting ActorClass source for \'" + _name);
+ String _plus_1 = (_plus + "\' since @BehaviorManual is specified");
+ this.logger.logInfo(_plus_1);
+ } else {
ActorClass _actorClass_7 = xpac.getActorClass();
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(_actorClass_7);
+ String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_7);
+ file = _cSourceFileName;
CharSequence _generateSourceFile = this.generateSourceFile(root, xpac);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ this.fileIO.generateFile("generating ActorClass source", path, infopath, file, _generateSourceFile);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
index 256b2447d..3c707f208 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/DataClassGen.java
@@ -23,18 +23,18 @@ import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
@Singleton
@SuppressWarnings("all")
public class DataClassGen {
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -57,27 +57,17 @@ public class DataClassGen {
{
String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
String _path = this._roomExtensions.getPath(dc);
- String path = (_generationTargetPath + _path);
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(dc);
- String _plus = ("generating DataClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(dc);
+ final String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(dc);
+ String _path_1 = this._roomExtensions.getPath(dc);
+ final String infopath = (_generationInfoPath + _path_1);
+ String file = this._cExtensions.getCHeaderFileName(dc);
CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ this.fileIO.generateFile("generating DataClass header", path, infopath, file, _generateHeaderFile);
String _cSourceFileName = this._cExtensions.getCSourceFileName(dc);
- String _plus_4 = ("generating DataClass source \'" + _cSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(dc);
+ file = _cSourceFileName;
CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ this.fileIO.generateFile("generating DataClass header", path, infopath, file, _generateSourceFile);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 9a2b42b56..8ee4ab2a9 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -34,13 +34,13 @@ import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -49,8 +49,7 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject
- @Extension
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -77,27 +76,17 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
String _path = this._roomExtensions.getPath(pc);
- String path = (_generationTargetPath + _path);
- String _cHeaderFileName = this._cExtensions.getCHeaderFileName(pc);
- String _plus = ("generating ProtocolClass header \'" + _cHeaderFileName);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- String _cHeaderFileName_1 = this._cExtensions.getCHeaderFileName(pc);
+ final String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(pc);
+ String _path_1 = this._roomExtensions.getPath(pc);
+ final String infopath = (_generationInfoPath + _path_1);
+ String file = this._cExtensions.getCHeaderFileName(pc);
CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cHeaderFileName_1, _generateHeaderFile);
+ this.fileIO.generateFile("generating ProtocolClass header", path, infopath, file, _generateHeaderFile);
String _cSourceFileName = this._cExtensions.getCSourceFileName(pc);
- String _plus_4 = ("generating ProtocolClass source \'" + _cSourceFileName);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
- String _cSourceFileName_1 = this._cExtensions.getCSourceFileName(pc);
+ file = _cSourceFileName;
CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cSourceFileName_1, _generateSourceFile);
+ this.fileIO.generateFile("generating ProtocolClass source", path, infopath, file, _generateSourceFile);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index 9e81841dd..27aaa6dcb 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician;
@@ -50,13 +49,13 @@ import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.c.gen.Initialization;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IntegerRange;
@@ -67,8 +66,7 @@ import org.eclipse.xtext.xbase.lib.ListExtensions;
@SuppressWarnings("all")
public class SubSystemClassGen {
@Inject
- @Extension
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -89,64 +87,39 @@ public class SubSystemClassGen {
private ILanguageExtension languageExt;
@Inject
- private ILogger logger;
-
- @Inject
private IDiagnostician diagnostician;
public void doGenerate(final Root root) {
EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
for (final SubSystemInstance ssi : _subSystemInstances) {
{
+ final SubSystemClass ssc = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(ssc);
+ String _path = this.roomExt.getPath(ssc);
+ final String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this.roomExt.getGenerationInfoPath(ssc);
+ String _path_1 = this.roomExt.getPath(ssc);
+ final String infopath = (_generationInfoPath + _path_1);
SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String file = this.stdExt.getCHeaderFileName(_subSystemClass_2);
+ String file = this.stdExt.getCHeaderFileName(_subSystemClass);
this.checkDataPorts(ssi);
- String _plus = ("generating SubSystemClass declaration: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
CharSequence _generateHeaderFile = this.generateHeaderFile(root, ssi);
- this.fileAccess.generateFile(file, _generateHeaderFile);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_3);
+ this.fileIO.generateFile("generating SubSystemClass declaration", path, infopath, file, _generateHeaderFile);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_1);
file = _cSourceFileName;
- String _plus_4 = ("generating SubSystemClass implementation: \'" + file);
- String _plus_5 = (_plus_4 + "\' in \'");
- String _plus_6 = (_plus_5 + path);
- String _plus_7 = (_plus_6 + "\'");
- this.logger.logInfo(_plus_7);
- this.fileAccess.setOutputPath(path);
CharSequence _generateSourceFile = this.generateSourceFile(root, ssi);
- this.fileAccess.generateFile(file, _generateSourceFile);
- SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
- String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_4);
+ this.fileIO.generateFile("generating SubSystemClass implementation", path, infopath, file, _generateSourceFile);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_2);
file = _instSourceFileName;
- String _plus_8 = ("generating SubSystemClass instance file: \'" + file);
- String _plus_9 = (_plus_8 + "\' in \'");
- String _plus_10 = (_plus_9 + path);
- String _plus_11 = (_plus_10 + "\'");
- this.logger.logInfo(_plus_11);
- this.fileAccess.setOutputPath(path);
CharSequence _generateInstanceFile = this.generateInstanceFile(root, ssi);
- this.fileAccess.generateFile(file, _generateInstanceFile);
- SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
- String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_5);
+ this.fileIO.generateFile("generating SubSystemClass instance file", path, infopath, file, _generateInstanceFile);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_3);
file = _dispSourceFileName;
- String _plus_12 = ("generating SubSystemClass dispatcher file: \'" + file);
- String _plus_13 = (_plus_12 + "\' in \'");
- String _plus_14 = (_plus_13 + path);
- String _plus_15 = (_plus_14 + "\'");
- this.logger.logInfo(_plus_15);
- this.fileAccess.setOutputPath(path);
CharSequence _generateDispatcherFile = this.generateDispatcherFile(root, ssi);
- this.fileAccess.generateFile(file, _generateDispatcherFile);
+ this.fileIO.generateFile("generating SubSystemClass dispatcher file", path, infopath, file, _generateDispatcherFile);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
index 7918680a8..abe070699 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java
@@ -17,17 +17,16 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
@Singleton
@SuppressWarnings("all")
public class SubSystemRunnerGen {
@Inject
- @Extension
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -35,19 +34,20 @@ public class SubSystemRunnerGen {
public void doGenerate(final Root root) {
EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance sc : _subSystemInstances) {
+ for (final SubSystemInstance ssi : _subSystemInstances) {
{
- SubSystemClass _subSystemClass = sc.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String _plus = (_generationTargetPath + _path);
- this.fileAccess.setOutputPath(_plus);
- SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String _plus_1 = (_name + "_Runner.c");
- CharSequence _generateSourceFile = this.generateSourceFile(root, sc);
- this.fileAccess.generateFile(_plus_1, _generateSourceFile);
+ final SubSystemClass ssc = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(ssc);
+ String _path = this.roomExt.getPath(ssc);
+ final String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this.roomExt.getGenerationInfoPath(ssc);
+ String _path_1 = this.roomExt.getPath(ssc);
+ final String infopath = (_generationInfoPath + _path_1);
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _name = _subSystemClass.getName();
+ String file = (_name + "_Runner.c");
+ CharSequence _generateSourceFile = this.generateSourceFile(root, ssi);
+ this.fileIO.generateFile("generating SubSystemRunner implementation", path, infopath, file, _generateSourceFile);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index bd64d9c8d..d8548eec3 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -14,22 +14,21 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
-import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.generator.base.AbstractGenerator
import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class ActorClassGen extends GenericActorClassGenerator {
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension JavaExtensions
@Inject extension RoomExtensions
@Inject IDataConfiguration dataConfigExt
@@ -38,18 +37,16 @@ class ActorClassGen extends GenericActorClassGenerator {
@Inject extension ProcedureHelpers
@Inject extension Initialization
@Inject extension StateMachineGen
- @Inject ILogger logger
def doGenerate(Root root) {
for (xpac: root.xpActorClasses) {
val manualBehavior = xpac.actorClass.isBehaviorAnnotationPresent("BehaviorManual")
val path = xpac.actorClass.generationTargetPath+xpac.actorClass.getPath
+ val infopath = xpac.actorClass.generationInfoPath+xpac.actorClass.getPath
var file = xpac.actorClass.getJavaFileName
if (manualBehavior)
file = "Abstract"+file
- logger.logInfo("generating ActorClass implementation '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generate(xpac, manualBehavior))
+ fileIO.generateFile("generating ActorClass implementation", path, infopath, file, root.generate(xpac, manualBehavior))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
index a1d4b89a9..68ec41b2c 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
@@ -54,7 +54,7 @@ class ConfigGenAddon {
'''
}
- def private applyInstanceConfig(InstanceBase instance, String invokes, List<Attribute> path){
+ def private CharSequence applyInstanceConfig(InstanceBase instance, String invokes, List<Attribute> path){
var a = path.last
var aType = a.refType.type
switch aType {
@@ -115,7 +115,7 @@ class ConfigGenAddon {
return result
}
- def private genMinMaxConstantsRec(ActorClass ac, String varNamePath, List<Attribute> path){
+ def private CharSequence genMinMaxConstantsRec(ActorClass ac, String varNamePath, List<Attribute> path){
var aType = path.last.refType.type
switch aType {
DataClass:
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
index 681f76942..6ba37b004 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
@@ -15,35 +15,31 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.List
+import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.room.Attribute
-import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.room.ComplexType
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
-
-import org.eclipse.etrice.core.genmodel.base.ILogger
-import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class DataClassGen {
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension JavaExtensions
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
@Inject extension Initialization
- @Inject ILogger logger
def doGenerate(Root root) {
for (dc: root.usedDataClasses) {
var path = dc.generationTargetPath+dc.getPath
+ var infopath = dc.generationInfoPath+dc.getPath
var file = dc.getJavaFileName
- logger.logInfo("generating DataClass implementation '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generate(dc))
+ fileIO.generateFile("generating DataClass implementation", path, infopath, file, root.generate(dc))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
index d559c356d..c2dd7f7a0 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
@@ -64,7 +64,7 @@ class Initialization {
}
}
- def private attributeInitPrimitiveRec(List<Attribute> path, EObject roomClass){
+ def private CharSequence attributeInitPrimitiveRec(List<Attribute> path, EObject roomClass){
var a = path.last
var aType = a.refType.type
if(aType.dataClass){
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index a20cb366f..a81641de4 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -14,28 +14,25 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
-import org.eclipse.etrice.core.room.Message
-import org.eclipse.etrice.core.room.ProtocolClass
-import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.core.room.DataClass
-
import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.Root
-
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-
-import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.room.CommunicationType
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
+import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
-import org.eclipse.etrice.core.room.CommunicationType
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
@Singleton
class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension JavaExtensions
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
@@ -46,19 +43,22 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def doGenerate(Root root) {
for (pc: root.usedProtocolClasses) {
- var path = pc.generationTargetPath+pc.getPath
- var file = pc.getJavaFileName
- logger.logInfo("generating ProtocolClass implementation '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
-
+ val path = pc.generationTargetPath+pc.getPath
+ val infopath = pc.generationInfoPath+pc.getPath
+ val file = pc.getJavaFileName
+ val contents =
switch (pc.commType) {
case CommunicationType::EVENT_DRIVEN:
- fileAccess.generateFile(file, root.generate(pc))
+ root.generate(pc)
case CommunicationType::DATA_DRIVEN:
- fileAccess.generateFile(file, root.generateDataDriven(pc))
+ root.generateDataDriven(pc)
case CommunicationType::SYNCHRONOUS:
- logger.logError("synchronous protocols not supported yet", pc)
+ ""
}
+ if (contents.toString.empty)
+ logger.logError("synchronous protocols not supported yet", pc)
+ else
+ fileIO.generateFile("generating ProtocolClass implementation", path, infopath, file, contents)
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
index 2bdfaa6b0..0be1dd730 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
@@ -15,7 +15,6 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.HashSet
-import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician
import org.eclipse.etrice.core.genmodel.etricegen.Root
@@ -23,16 +22,16 @@ import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
import org.eclipse.etrice.core.room.CommunicationType
import org.eclipse.etrice.core.room.LogicalThread
import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.generator.base.Indexed.*
@Singleton
class SubSystemClassGen {
- @Inject JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension JavaExtensions
@Inject extension RoomExtensions
@Inject IDataConfiguration dataConfigExt
@@ -40,18 +39,16 @@ class SubSystemClassGen {
@Inject extension ProcedureHelpers
@Inject VariableServiceGen varService
- @Inject ILogger logger
@Inject IDiagnostician diagnostician
def doGenerate(Root root) {
for (ssi: root.subSystemInstances) {
- var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
- var file = ssi.subSystemClass.getJavaFileName
- logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
+ val path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ val infopath = ssi.subSystemClass.generationInfoPath+ssi.subSystemClass.getPath
+ val file = ssi.subSystemClass.getJavaFileName
checkDataPorts(ssi)
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generate(ssi))
- if(dataConfigExt.hasVariableService(ssi))
+ fileIO.generateFile("generating SubSystemClass implementation", path, infopath, file, root.generate(ssi))
+ if (dataConfigExt.hasVariableService(ssi))
varService.doGenerate(root, ssi);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.xtend
index a339698dd..69247fcb3 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.xtend
@@ -16,20 +16,22 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
+import org.eclipse.etrice.generator.generic.RoomExtensions
@Singleton
class SubSystemRunnerGen {
- @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension RoomExtensions roomExt
def doGenerate(Root root) {
for (sc: root.subSystemInstances) {
- fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
- fileAccess.generateFile(sc.subSystemClass.name+"Runner.java", root.generate(sc))
+ val path = sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath
+ val infopath = sc.subSystemClass.generationInfoPath+sc.subSystemClass.getPath
+ val file = sc.subSystemClass.name+"Runner.java"
+ fileIO.generateFile("generating SubSystemRunner implementation", path, infopath, file, root.generate(sc))
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
index c13b83d87..a9a91745d 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
@@ -15,43 +15,41 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.ArrayList
+import java.util.Collection
import java.util.HashMap
import java.util.HashSet
import java.util.LinkedList
import java.util.List
-import org.eclipse.etrice.core.genmodel.base.ILogger
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.room.RoomModel
import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.base.IGeneratorFileIo
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.core.room.ActorClass
-import java.util.Collection
-import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
-
+
+import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
+
@Singleton
class VariableServiceGen {
- @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject IGeneratorFileIo fileIO
@Inject extension JavaExtensions stdExt
@Inject extension RoomExtensions roomExt
@Inject IDataConfiguration configExt
@Inject extension ProcedureHelpers helpers
@Inject extension TypeHelpers
- @Inject ILogger logger
def doGenerate(Root root, SubSystemInstance ssi) {
- var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
- var file = ssi.subSystemClass.name+"VariableService.java"
- logger.logInfo("generating VariableService implementation: '"+file+"' in '"+path+"'")
- fileAccess.setOutputPath(path)
- fileAccess.generateFile(file, root.generate(ssi))
+ val path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ val infopath = ssi.subSystemClass.generationInfoPath+ssi.subSystemClass.getPath
+ val file = ssi.subSystemClass.name+"VariableService.java"
+ fileIO.generateFile("generating VariableService implementation", path, infopath, file, root.generate(ssi))
}
def private generate(Root root, SubSystemInstance comp) {
@@ -206,7 +204,7 @@ class VariableServiceGen {
'''«FOR p : ai.path.split('/').drop(2) SEPARATOR '_'»«p»«ENDFOR»'''
}
- def private genGetAttributeValues(List<Attribute> path, ActorInstance ai){
+ def private CharSequence genGetAttributeValues(List<Attribute> path, ActorInstance ai){
val a = path.last
if (a.refType.type.primitive) {
'''
@@ -223,7 +221,7 @@ class VariableServiceGen {
}
}
- def private genSetAttributeValues1(List<Attribute> path, ActorInstance ai){
+ def private CharSequence genSetAttributeValues1(List<Attribute> path, ActorInstance ai){
var a = path.last
var aVarName = path.toAbsolutePath("_")
if(a.refType.type.primitive){'''
@@ -248,7 +246,7 @@ class VariableServiceGen {
}
}
- def private genSetAttributeValues2(List<Attribute> path, ActorInstance ai){
+ def private CharSequence genSetAttributeValues2(List<Attribute> path, ActorInstance ai){
var a = path.last
var aVarName = path.toAbsolutePath("_")
if (a.refType.type.primitive) {
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index a306d01fb..247908637 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -15,7 +15,6 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.room.ActorClass;
@@ -32,6 +31,7 @@ import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -40,7 +40,6 @@ import org.eclipse.etrice.generator.java.gen.Initialization;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.etrice.generator.java.gen.StateMachineGen;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -49,7 +48,7 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class ActorClassGen extends GenericActorClassGenerator {
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -77,9 +76,6 @@ public class ActorClassGen extends GenericActorClassGenerator {
@Extension
private StateMachineGen _stateMachineGen;
- @Inject
- private ILogger logger;
-
public void doGenerate(final Root root) {
EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
for (final ExpandedActorClass xpac : _xpActorClasses) {
@@ -92,19 +88,18 @@ public class ActorClassGen extends GenericActorClassGenerator {
String _path = this._roomExtensions.getPath(_actorClass_2);
final String path = (_generationTargetPath + _path);
ActorClass _actorClass_3 = xpac.getActorClass();
- String file = this._javaExtensions.getJavaFileName(_actorClass_3);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ String _path_1 = this._roomExtensions.getPath(_actorClass_4);
+ final String infopath = (_generationInfoPath + _path_1);
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String file = this._javaExtensions.getJavaFileName(_actorClass_5);
if (manualBehavior) {
String _plus = ("Abstract" + file);
file = _plus;
}
- String _plus_1 = ("generating ActorClass implementation \'" + file);
- String _plus_2 = (_plus_1 + "\' in \'");
- String _plus_3 = (_plus_2 + path);
- String _plus_4 = (_plus_3 + "\'");
- this.logger.logInfo(_plus_4);
- this.fileAccess.setOutputPath(path);
CharSequence _generate = this.generate(root, xpac, manualBehavior);
- this.fileAccess.generateFile(file, _generate);
+ this.fileIO.generateFile("generating ActorClass implementation", path, infopath, file, _generate);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
index 4a2b40bd7..829facf56 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
@@ -145,7 +145,7 @@ public class ConfigGenAddon {
CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
String _plus_1 = (_plus + _invokeGetter);
List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- Object _applyInstanceConfig = this.applyInstanceConfig(instance, _plus_1, _union);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(instance, _plus_1, _union);
_builder.append(_applyInstanceConfig, "");
_builder.newLineIfNotEmpty();
}
@@ -383,7 +383,7 @@ public class ConfigGenAddon {
String _name = e.getName();
String _plus_1 = (_plus + _name);
List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- Object _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
_builder.append(_genMinMaxConstantsRec, "");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index 16ab62063..1a8472723 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -15,7 +15,6 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.ComplexType;
@@ -26,12 +25,12 @@ import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.java.gen.Initialization;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -40,7 +39,7 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class DataClassGen {
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -58,9 +57,6 @@ public class DataClassGen {
@Extension
private Initialization _initialization;
- @Inject
- private ILogger logger;
-
public void doGenerate(final Root root) {
EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
for (final DataClass dc : _usedDataClasses) {
@@ -68,15 +64,12 @@ public class DataClassGen {
String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(dc);
String _path = this._roomExtensions.getPath(dc);
String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(dc);
+ String _path_1 = this._roomExtensions.getPath(dc);
+ String infopath = (_generationInfoPath + _path_1);
String file = this._javaExtensions.getJavaFileName(dc);
- String _plus = ("generating DataClass implementation \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
CharSequence _generate = this.generate(root, dc);
- this.fileAccess.generateFile(file, _generate);
+ this.fileIO.generateFile("generating DataClass implementation", path, infopath, file, _generate);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
index e94abef9f..4ef1ea343 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
@@ -170,12 +170,12 @@ public class Initialization {
List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(((DataClass) aType));
for(final Attribute e : _allAttributes) {
List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
- Object _attributeInitPrimitiveRec = this.attributeInitPrimitiveRec(_union, roomClass);
+ CharSequence _attributeInitPrimitiveRec = this.attributeInitPrimitiveRec(_union, roomClass);
_builder.append(_attributeInitPrimitiveRec, "");
_builder.newLineIfNotEmpty();
}
}
- return _builder.toString();
+ return _builder;
} else {
CharSequence _xifexpression_1 = null;
boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index 837530750..706e555ec 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -32,6 +32,7 @@ import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -41,7 +42,6 @@ import org.eclipse.etrice.generator.java.gen.GlobalSettings;
import org.eclipse.etrice.generator.java.gen.Initialization;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -50,7 +50,7 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions;
@SuppressWarnings("all")
public class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -85,14 +85,12 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(pc);
String _path = this._roomExtensions.getPath(pc);
- String path = (_generationTargetPath + _path);
- String file = this._javaExtensions.getJavaFileName(pc);
- String _plus = ("generating ProtocolClass implementation \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
+ final String path = (_generationTargetPath + _path);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(pc);
+ String _path_1 = this._roomExtensions.getPath(pc);
+ final String infopath = (_generationInfoPath + _path_1);
+ final String file = this._javaExtensions.getJavaFileName(pc);
+ CharSequence _switchResult = null;
CommunicationType _commType = pc.getCommType();
final CommunicationType _switchValue = _commType;
boolean _matched = false;
@@ -100,22 +98,30 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (Objects.equal(_switchValue,CommunicationType.EVENT_DRIVEN)) {
_matched=true;
CharSequence _generate = this.generate(root, pc);
- this.fileAccess.generateFile(file, _generate);
+ _switchResult = _generate;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,CommunicationType.DATA_DRIVEN)) {
_matched=true;
CharSequence _generateDataDriven = this.generateDataDriven(root, pc);
- this.fileAccess.generateFile(file, _generateDataDriven);
+ _switchResult = _generateDataDriven;
}
}
if (!_matched) {
if (Objects.equal(_switchValue,CommunicationType.SYNCHRONOUS)) {
_matched=true;
- this.logger.logError("synchronous protocols not supported yet", pc);
+ _switchResult = "";
}
}
+ final CharSequence contents = _switchResult;
+ String _string = contents.toString();
+ boolean _isEmpty = _string.isEmpty();
+ if (_isEmpty) {
+ this.logger.logError("synchronous protocols not supported yet", pc);
+ } else {
+ this.fileIO.generateFile("generating ProtocolClass implementation", path, infopath, file, contents);
+ }
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index 853464856..4bc85a322 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -17,7 +17,6 @@ import java.util.HashSet;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician;
import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
@@ -32,6 +31,7 @@ import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.base.Indexed;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -39,14 +39,13 @@ import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.etrice.generator.java.gen.VariableServiceGen;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
@Singleton
@SuppressWarnings("all")
public class SubSystemClassGen {
@Inject
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -70,9 +69,6 @@ public class SubSystemClassGen {
private VariableServiceGen varService;
@Inject
- private ILogger logger;
-
- @Inject
private IDiagnostician diagnostician;
public void doGenerate(final Root root) {
@@ -83,18 +79,17 @@ public class SubSystemClassGen {
String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_subSystemClass);
SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
String _path = this._roomExtensions.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
+ final String path = (_generationTargetPath + _path);
SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String file = this._javaExtensions.getJavaFileName(_subSystemClass_2);
- String _plus = ("generating SubSystemClass implementation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
+ String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_subSystemClass_2);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ String _path_1 = this._roomExtensions.getPath(_subSystemClass_3);
+ final String infopath = (_generationInfoPath + _path_1);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ final String file = this._javaExtensions.getJavaFileName(_subSystemClass_4);
this.checkDataPorts(ssi);
- this.fileAccess.setOutputPath(path);
CharSequence _generate = this.generate(root, ssi);
- this.fileAccess.generateFile(file, _generate);
+ this.fileIO.generateFile("generating SubSystemClass implementation", path, infopath, file, _generate);
boolean _hasVariableService = this.dataConfigExt.hasVariableService(ssi);
if (_hasVariableService) {
this.varService.doGenerate(root, ssi);
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
index 4ab792769..8bb578aa2 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemRunnerGen.java
@@ -18,17 +18,16 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Extension;
@Singleton
@SuppressWarnings("all")
public class SubSystemRunnerGen {
@Inject
- @Extension
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -42,13 +41,17 @@ public class SubSystemRunnerGen {
String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
String _path = this.roomExt.getPath(_subSystemClass_1);
- String _plus = (_generationTargetPath + _path);
- this.fileAccess.setOutputPath(_plus);
+ final String path = (_generationTargetPath + _path);
SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String _plus_1 = (_name + "Runner.java");
+ String _generationInfoPath = this.roomExt.getGenerationInfoPath(_subSystemClass_2);
+ SubSystemClass _subSystemClass_3 = sc.getSubSystemClass();
+ String _path_1 = this.roomExt.getPath(_subSystemClass_3);
+ final String infopath = (_generationInfoPath + _path_1);
+ SubSystemClass _subSystemClass_4 = sc.getSubSystemClass();
+ String _name = _subSystemClass_4.getName();
+ final String file = (_name + "Runner.java");
CharSequence _generate = this.generate(root, sc);
- this.fileAccess.generateFile(_plus_1, _generate);
+ this.fileIO.generateFile("generating SubSystemRunner implementation", path, infopath, file, _generate);
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
index 093acb982..2980752a7 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
@@ -36,12 +35,12 @@ import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
@@ -52,8 +51,7 @@ import org.eclipse.xtext.xbase.lib.StringExtensions;
@SuppressWarnings("all")
public class VariableServiceGen {
@Inject
- @Extension
- private JavaIoFileSystemAccess fileAccess;
+ private IGeneratorFileIo fileIO;
@Inject
@Extension
@@ -74,26 +72,22 @@ public class VariableServiceGen {
@Extension
private TypeHelpers _typeHelpers;
- @Inject
- private ILogger logger;
-
public void doGenerate(final Root root, final SubSystemInstance ssi) {
SubSystemClass _subSystemClass = ssi.getSubSystemClass();
String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
String _path = this.roomExt.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
+ final String path = (_generationTargetPath + _path);
SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String file = (_name + "VariableService.java");
- String _plus = ("generating VariableService implementation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
+ String _generationInfoPath = this.roomExt.getGenerationInfoPath(_subSystemClass_2);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ String _path_1 = this.roomExt.getPath(_subSystemClass_3);
+ final String infopath = (_generationInfoPath + _path_1);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ String _name = _subSystemClass_4.getName();
+ final String file = (_name + "VariableService.java");
CharSequence _generate = this.generate(root, ssi);
- this.fileAccess.generateFile(file, _generate);
+ this.fileIO.generateFile("generating VariableService implementation", path, infopath, file, _generate);
}
private CharSequence generate(final Root root, final SubSystemInstance comp) {
@@ -731,7 +725,7 @@ public class VariableServiceGen {
List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
- Object _genGetAttributeValues = this.genGetAttributeValues(_union, ai);
+ CharSequence _genGetAttributeValues = this.genGetAttributeValues(_union, ai);
_builder_1.append(_genGetAttributeValues, "");
_builder_1.newLineIfNotEmpty();
}
@@ -881,7 +875,7 @@ public class VariableServiceGen {
List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
- Object _genSetAttributeValues1 = this.genSetAttributeValues1(_union, ai);
+ CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(_union, ai);
_builder_1.append(_genSetAttributeValues1, "");
_builder_1.newLineIfNotEmpty();
}
@@ -969,7 +963,7 @@ public class VariableServiceGen {
List<Attribute> _allAttributes = RoomHelpers.getAllAttributes(dataClass);
for(final Attribute at : _allAttributes) {
List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
- Object _genSetAttributeValues2 = this.genSetAttributeValues2(_union, ai);
+ CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(_union, ai);
_builder.append(_genSetAttributeValues2, "");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
index fafdba7dd..dc9a42961 100644
--- a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.3.0",
org.eclipse.core.resources;bundle-version="3.7.100",
org.eclipse.xtext.generator;bundle-version="2.1.1",
org.eclipse.xtext;bundle-version="2.1.1",
- org.eclipse.xtend.lib;bundle-version="2.3.0"
+ org.eclipse.xtend.lib;bundle-version="2.3.0",
+ org.apache.commons.io;bundle-version="2.0.1"
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.etrice.generator.generic
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IGeneratorFileIo.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IGeneratorFileIo.java
new file mode 100644
index 000000000..037eb8f87
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IGeneratorFileIo.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+@ImplementedBy(IncrementalGenerationFileIo.class)
+public interface IGeneratorFileIo {
+
+ /**
+ * This method saves the contents in a file in the given path.
+ * Implementations may use the infopath for extra information like a hash key
+ * for incremental generation.
+ *
+ * @param desc a description which is may be logged
+ * @param path the file system path for the generated file
+ * @param infopath the file system path for the generated info file (if used by the implementation)
+ * @param file the file name of the generated file
+ * @param contents the contents of the generated file
+ */
+ void generateFile(String desc, String path, String infopath, String file, CharSequence contents);
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IncrementalGenerationFileIo.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IncrementalGenerationFileIo.java
new file mode 100644
index 000000000..12f7c84db
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IncrementalGenerationFileIo.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.zip.CRC32;
+
+import org.apache.commons.io.FileUtils;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.util.RuntimeIOException;
+
+import com.google.inject.Inject;
+
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class IncrementalGenerationFileIo implements IGeneratorFileIo {
+
+ @Inject JavaIoFileSystemAccess fileAccess;
+ @Inject ILogger logger;
+
+ private static boolean generateIncremental = false;
+
+ /**
+ * @return {@code true} if incremental generation is chosen
+ */
+ public static boolean isGenerateIncremental() {
+ return generateIncremental;
+ }
+
+ /**
+ * @param generateIncremental select {@code true} if incremental generation is desired
+ */
+ public static void setGenerateIncremental(boolean generateIncremental) {
+ IncrementalGenerationFileIo.generateIncremental = generateIncremental;
+ }
+
+ /**
+ * This method computes a hash key (a {@link java.util.zip.CRC32 CRC32} value) for the file contents
+ * and compares it to the
+ * one stored in the {@code infopath} directory with an added extension ".info". If the values are equal
+ * then the file stored in the {@code infopath} is copied to {@code path} while preserving the file data.
+ * In the other case the key is stored and the file is stored to {@code infopath} and {@code path}.
+ */
+ public void generateFile(String desc, String path, String infopath, String file, CharSequence contents) {
+
+ long oldCRC = 0;
+
+ // use local copy to avoid inconsistencies due to concurrent change
+ boolean genInc = generateIncremental;
+
+ if (genInc) {
+ // read old CRC value
+ fileAccess.setOutputPath(infopath);
+ try {
+ CharSequence val = fileAccess.readTextFile(file+".info", JavaIoFileSystemAccess.DEFAULT_OUTPUT);
+ oldCRC = Long.parseLong(val.toString());
+ }
+ catch (RuntimeIOException e) {
+ }
+ catch (NumberFormatException e) {
+ }
+ }
+
+ boolean write = true;
+ long newCRC = 0;
+
+ if (genInc) {
+ CRC32 crc32 = new CRC32();
+ crc32.update(contents.toString().getBytes());
+ newCRC = crc32.getValue();
+ if (oldCRC==newCRC) {
+ write = false;
+ }
+ else {
+ fileAccess.generateFile(file+".info", ""+newCRC);
+ }
+ }
+
+ if (write) {
+ logger.logInfo(desc+" '"+file+"' in '"+path+"'");
+ fileAccess.setOutputPath(path);
+ fileAccess.generateFile(file, contents);
+
+ if (genInc) {
+ // save a copy in the info directory which is not cleared (and not compiled)
+ fileAccess.setOutputPath(infopath);
+ fileAccess.generateFile(file, contents);
+ }
+ }
+ else {
+ logger.logInfo(desc+" (unchanged) '"+file+"' in '"+path+"'");
+ File src = new File(infopath+file);
+ File dst = new File(path+file);
+ try {
+ FileUtils.copyFile(src, dst, true);
+ }
+ catch (IOException e) {
+ fileAccess.setOutputPath(path);
+ fileAccess.generateFile(file, contents);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index 3ef8d2e61..2829b5092 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -111,6 +111,13 @@ class RoomExtensions {
def String getGenerationPathSegment() {
return "/src-gen/"
}
+
+ /**
+ * @return the relative path to the destination folder for the generated code
+ */
+ def String getGenerationInfoSegment() {
+ return "/src-gen-info/"
+ }
/**
* @return the relative path to the destination folder for the generated documentation
@@ -194,12 +201,21 @@ class RoomExtensions {
/**
* @param e an {@link EObject}
- * @return the concatenation of the objects project path
+ * @return the concatenation of the object's project path
* with the {@link #getGenerationPathSegment()}
*/
def String getGenerationTargetPath(EObject e){
return getProjectPath(e)+getGenerationPathSegment()
}
+
+ /**
+ * @param e an {@link EObject}
+ * @return the concatenation of the object's project path
+ * with the {@link #getGenerationInfoSegment()}
+ */
+ def String getGenerationInfoPath(EObject e){
+ return getProjectPath(e)+getGenerationInfoSegment()
+ }
/**
* @param e an {@link EObject}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
index 52bc62905..524426dcb 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
@@ -127,6 +127,13 @@ public class RoomExtensions {
}
/**
+ * @return the relative path to the destination folder for the generated code
+ */
+ public String getGenerationInfoSegment() {
+ return "/src-gen-info/";
+ }
+
+ /**
* @return the relative path to the destination folder for the generated documentation
*/
public String getDocGenerationPathSegment() {
@@ -228,7 +235,7 @@ public class RoomExtensions {
/**
* @param e an {@link EObject}
- * @return the concatenation of the objects project path
+ * @return the concatenation of the object's project path
* with the {@link #getGenerationPathSegment()}
*/
public String getGenerationTargetPath(final EObject e) {
@@ -239,6 +246,17 @@ public class RoomExtensions {
/**
* @param e an {@link EObject}
+ * @return the concatenation of the object's project path
+ * with the {@link #getGenerationInfoSegment()}
+ */
+ public String getGenerationInfoPath(final EObject e) {
+ String _projectPath = this.getProjectPath(e);
+ String _generationInfoSegment = this.getGenerationInfoSegment();
+ return (_projectPath + _generationInfoSegment);
+ }
+
+ /**
+ * @param e an {@link EObject}
* @return the concatenation of the objects project path
* with the {@link #getDocGenerationPathSegment()}
*/

Back to the top