Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2014-08-06 12:56:38 +0000
committerHenrik Rentz-Reichert2014-08-06 12:56:38 +0000
commitcc931d088f87d69a2deeb145d541f83aae8bab50 (patch)
tree332ee8870baa362e5ca4340ceb89a9ac97be65cb /plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice
parent19c21a758ce51f0e207158a216ede3477f7cf353 (diff)
downloadorg.eclipse.etrice-cc931d088f87d69a2deeb145d541f83aae8bab50.tar.gz
org.eclipse.etrice-cc931d088f87d69a2deeb145d541f83aae8bab50.tar.xz
org.eclipse.etrice-cc931d088f87d69a2deeb145d541f83aae8bab50.zip
static utility methods converted to class methods to be able to use
inheritance and overriding in super classes. This was done mainly for * BaseHelpers.java * RoomHelpers.java and had a lot of impacts on the whole code base
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice')
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend23
-rw-r--r--plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java33
2 files changed, 33 insertions, 23 deletions
diff --git a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
index b762b63b9..cd4e7a2aa 100644
--- a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/DataConfiguration.xtend
@@ -41,6 +41,9 @@ import org.eclipse.xtext.scoping.impl.ImportUriResolver
class DataConfiguration implements IDataConfiguration {
@Inject
+ protected extension DataConfigurationHelper
+
+ @Inject
protected ILogger logger;
@Inject
@@ -53,7 +56,7 @@ class DataConfiguration implements IDataConfiguration {
}
override setResources(ResourceSet resource, ILogger logger) {
- DataConfigurationHelper::setConfigModels(resource, logger)
+ setConfigModels(resource, logger)
}
// static
@@ -71,12 +74,12 @@ class DataConfiguration implements IDataConfiguration {
def private getAttrClassConfig(ActorClass actor, List<Attribute> path) {
var id = '''/«actor.name»/«path.toStringPath»'''.toString
- DataConfigurationHelper::actorClassAttrMap.get(id)
+ actorClassAttrMap.get(id)
}
override getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path) {
var id = '''/«pc.name»/«IF regular»regular«ELSE»conjugated«ENDIF»/«path.toStringPath»'''.toString
- DataConfigurationHelper::protocolClassAttrMap.get(id)?.value?.toStringExpr
+ protocolClassAttrMap.get(id)?.value?.toStringExpr
}
def private toStringPath(List<Attribute> path) {
@@ -85,11 +88,11 @@ class DataConfiguration implements IDataConfiguration {
override getAttrInstanceConfigValue(ActorInstance ai, List<Attribute> path) {
var id = ai.path + "/" + path.toStringPath
- DataConfigurationHelper::actorInstanceAttrMap.get(id)?.value?.toStringExpr
+ actorInstanceAttrMap.get(id)?.value?.toStringExpr
}
override getAttrInstanceConfigValue(InterfaceItemInstance item, List<Attribute> path) {
- DataConfigurationHelper::actorInstanceAttrMap.get(item.path + "/" + path.toStringPath)?.value?.toStringExpr
+ actorInstanceAttrMap.get(item.path + "/" + path.toStringPath)?.value?.toStringExpr
}
// dynamic
@@ -117,7 +120,7 @@ class DataConfiguration implements IDataConfiguration {
override getDynConfigReadAttributes(ActorInstance ai) {
val result = new ArrayList<Attribute>
- var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(ai.path)
+ var configs = dynActorInstanceAttrMap.get(ai.path)
configs?.forEach(c|if(c.readOnly) result.add(c.attribute))
return result
@@ -125,7 +128,7 @@ class DataConfiguration implements IDataConfiguration {
override getDynConfigWriteAttributes(ActorInstance ai) {
val result = new ArrayList<Attribute>
- var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(ai.path)
+ var configs = dynActorInstanceAttrMap.get(ai.path)
configs?.forEach(c|if(!c.readOnly) result.add(c.attribute))
return result
@@ -156,19 +159,19 @@ class DataConfiguration implements IDataConfiguration {
}
def private getConfig(SubSystemInstance cc) {
- DataConfigurationHelper::subSystemConfigMap.get(cc.path)
+ subSystemConfigMap.get(cc.path)
}
override getDynConfigReadAttributes(ActorClass actor) {
val result = new HashSet<Attribute>
- var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
+ val configs = dynActorClassAttrMap.get(actor)
configs?.forEach(c|if(c.readOnly) result.add(c.attribute))
return result.toList
}
override getDynConfigWriteAttributes(ActorClass actor) {
val result = new HashSet<Attribute>
- var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
+ val configs = dynActorClassAttrMap.get(actor)
configs?.forEach(c|if(!c.readOnly) result.add(c.attribute))
return result.toList
}
diff --git a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java
index da8d187b4..2a8612f66 100644
--- a/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java
+++ b/plugins/org.eclipse.etrice.generator.config/src/org/eclipse/etrice/generator/config/util/DataConfigurationHelper.java
@@ -36,19 +36,26 @@ import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.ProtocolClass;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
public class DataConfigurationHelper {
+ @Inject
+ private ConfigUtil ConfigUtil;
+
// static
- public static Map<String, AttrClassConfig> actorClassAttrMap = new HashMap<String, AttrClassConfig>();
- public static Map<String, AttrClassConfig> protocolClassAttrMap = new HashMap<String, AttrClassConfig>();
- public static Map<String, AttrInstanceConfig> actorInstanceAttrMap = new HashMap<String, AttrInstanceConfig>();
+ public Map<String, AttrClassConfig> actorClassAttrMap = new HashMap<String, AttrClassConfig>();
+ public Map<String, AttrClassConfig> protocolClassAttrMap = new HashMap<String, AttrClassConfig>();
+ public Map<String, AttrInstanceConfig> actorInstanceAttrMap = new HashMap<String, AttrInstanceConfig>();
// dynamic
- public static Map<String, SubSystemConfig> subSystemConfigMap = new HashMap<String, SubSystemConfig>();
- public static Map<String, List<AttrInstanceConfig>> dynActorInstanceAttrMap = new HashMap<String, List<AttrInstanceConfig>>();
- public static Map<ActorClass, List<AttrInstanceConfig>> dynActorClassAttrMap = new HashMap<ActorClass, List<AttrInstanceConfig>>();
+ public Map<String, SubSystemConfig> subSystemConfigMap = new HashMap<String, SubSystemConfig>();
+ public Map<String, List<AttrInstanceConfig>> dynActorInstanceAttrMap = new HashMap<String, List<AttrInstanceConfig>>();
+ public Map<ActorClass, List<AttrInstanceConfig>> dynActorClassAttrMap = new HashMap<ActorClass, List<AttrInstanceConfig>>();
- public static boolean setConfigModels(ResourceSet rs, ILogger logger) {
+ public boolean setConfigModels(ResourceSet rs, ILogger logger) {
actorClassAttrMap.clear();
protocolClassAttrMap.clear();
actorInstanceAttrMap.clear();
@@ -121,7 +128,7 @@ public class DataConfigurationHelper {
return !error;
}
- private static void collectConfigs(ActorInstanceConfig actorConfig,
+ private void collectConfigs(ActorInstanceConfig actorConfig,
String path, Map<String, AttrInstanceConfig> map) {
for (AttrInstanceConfig c : actorConfig.getAttributes()) {
collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
@@ -150,7 +157,7 @@ public class DataConfigurationHelper {
}
}
- private static void collectConfigs(ProtocolClassConfig protocolConfig,
+ private void collectConfigs(ProtocolClassConfig protocolConfig,
Map<String, AttrClassConfig> map) {
String path = "/" + protocolConfig.getProtocol().getName();
if (protocolConfig.getRegular() != null)
@@ -165,14 +172,14 @@ public class DataConfigurationHelper {
+ c.getAttribute().getName(), map);
}
- private static void collectConfigs(ActorClassConfig actorConfig,
+ private void collectConfigs(ActorClassConfig actorConfig,
Map<String, AttrClassConfig> map) {
String path = "/" + actorConfig.getActor().getName();
for (AttrClassConfig c : actorConfig.getAttributes())
collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
}
- private static void collectConfigs(AttrClassConfig config, String path,
+ private void collectConfigs(AttrClassConfig config, String path,
Map<String, AttrClassConfig> map) {
Attribute a = config.getAttribute();
if (a.getType().getType() instanceof DataClass)
@@ -181,7 +188,7 @@ public class DataConfigurationHelper {
map.put(path, config);
}
- private static void collectConfigs(AttrInstanceConfig config, String path,
+ private void collectConfigs(AttrInstanceConfig config, String path,
Map<String, AttrInstanceConfig> map) {
Attribute a = config.getAttribute();
if (a.getType().getType() instanceof DataClass)
@@ -190,7 +197,7 @@ public class DataConfigurationHelper {
map.put(path, config);
}
- public static String toStringPath(Iterable<String> path, String pathDelim) {
+ public String toStringPath(Iterable<String> path, String pathDelim) {
StringBuilder b = new StringBuilder();
for (String p : path)
b.append(pathDelim + p);

Back to the top