Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.common/build.gradle1
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomHighlightingConfiguration.java9
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomSemanticHighlightingCalculator.java61
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java61
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java44
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/DataClassGen.xtend5
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/EnumerationTypeGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend15
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend9
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/EnumerationTypeGen.xtend13
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend10
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend2
18 files changed, 204 insertions, 60 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/build.gradle b/plugins/org.eclipse.etrice.core.common/build.gradle
index f48bc575f..38c3c557b 100644
--- a/plugins/org.eclipse.etrice.core.common/build.gradle
+++ b/plugins/org.eclipse.etrice.core.common/build.gradle
@@ -3,4 +3,5 @@ dependencies {
compile "org.eclipse.platform:org.eclipse.core.runtime:$versions.core_runtime"
compile "org.eclipse.platform:org.eclipse.core.resources:$versions.core_resources"
compile "org.eclipse.xtext:org.eclipse.xtext:$versions.xtext"
+ compile "com.google.guava:guava:$versions.guava"
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomHighlightingConfiguration.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomHighlightingConfiguration.java
index 4dd876bcb..a50aa3fee 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomHighlightingConfiguration.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomHighlightingConfiguration.java
@@ -16,6 +16,7 @@ package org.eclipse.etrice.core.ui.highlight;
import org.eclipse.etrice.core.common.ui.highlight.BaseHighlightingConfig;
import org.eclipse.etrice.expressions.ui.highlight.AbstractHighlightStyles;
+import org.eclipse.jface.text.TextAttribute;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor;
@@ -37,6 +38,7 @@ public class RoomHighlightingConfiguration extends BaseHighlightingConfig {
public static final String HL_EXPR_DATA_CLASS_ID = "hl_data_class";
public static final String HL_PRIMITIVE_TYPE_ID = "hl_primitve_type";
public static final String HL_EXTERNAL_TYPE_ID = "hl_external_type";
+ public static final String HL_DEPRECATED_ID = "hl_deprecated_type";
// default fonts used by this specific highlighting (defaults)
// private static FontData defaultAnnotationBlockFont = new
@@ -55,6 +57,7 @@ public class RoomHighlightingConfiguration extends BaseHighlightingConfig {
acceptor.acceptDefaultHighlighting(HL_EXPR_DATA_CLASS_ID, "Expression Data Class", dataClass());
acceptor.acceptDefaultHighlighting(HL_PRIMITIVE_TYPE_ID, "Expression Primitive Type", primitiveType());
acceptor.acceptDefaultHighlighting(HL_EXTERNAL_TYPE_ID, "Expression External Type", externalType());
+ acceptor.acceptDefaultHighlighting(HL_DEPRECATED_ID, "Deprecated", deprecated());
}
// method for calculating an actual text styles
@@ -114,5 +117,11 @@ public class RoomHighlightingConfiguration extends BaseHighlightingConfig {
textStyle.setColor(AbstractHighlightStyles.EXTERNAL_TYPE_RGB);
return textStyle;
}
+
+ public TextStyle deprecated() {
+ TextStyle textStyle = defaultTextStyle().copy();
+ textStyle.setStyle(TextAttribute.STRIKETHROUGH);
+ return textStyle;
+ }
}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomSemanticHighlightingCalculator.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomSemanticHighlightingCalculator.java
index 1b7fd2f88..e71ddcaa4 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomSemanticHighlightingCalculator.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/highlight/RoomSemanticHighlightingCalculator.java
@@ -14,10 +14,20 @@
package org.eclipse.etrice.core.ui.highlight;
+import static org.eclipse.etrice.core.ui.highlight.RoomHighlightingConfiguration.HL_ANNOTATION_ID;
+import static org.eclipse.etrice.core.ui.highlight.RoomHighlightingConfiguration.HL_DEPRECATED_ID;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.etrice.core.common.base.Annotation;
import org.eclipse.etrice.core.common.ui.highlight.BaseSemanticHighlighter;
import org.eclipse.etrice.core.converter.RoomValueConverterService;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
+import org.eclipse.etrice.core.room.RoomElement;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.services.RoomGrammarAccess;
import org.eclipse.etrice.core.ui.util.UIExpressionUtil;
import org.eclipse.etrice.core.ui.util.UIExpressionUtil.ExpressionCache;
@@ -29,13 +39,18 @@ import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.Token;
+import org.eclipse.xtext.CrossReference;
+import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor;
+import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.util.CancelIndicator;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
import com.google.inject.Inject;
/**
@@ -44,11 +59,9 @@ import com.google.inject.Inject;
*/
public class RoomSemanticHighlightingCalculator extends BaseSemanticHighlighter {
- @Inject
- RoomGrammarAccess grammar;
-
- @Inject
- RoomValueConverterService converterService;
+ @Inject RoomGrammarAccess grammar;
+ @Inject RoomValueConverterService converterService;
+ @Inject RoomHelpers roomHelpers;
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
@@ -67,13 +80,18 @@ public class RoomSemanticHighlightingCalculator extends BaseSemanticHighlighter
if (obj instanceof RuleCall) {
RuleCall ruleCall = (RuleCall) obj;
if(ruleCall.getRule() == grammar.getAnnotationRule()){
- acceptor.addPosition(node.getOffset(), node.getLength(), RoomHighlightingConfiguration.HL_ANNOTATION_ID);
+ acceptor.addPosition(node.getOffset(), node.getLength(), HL_ANNOTATION_ID);
}
else if(ruleCall.getRule() == grammar.getCC_STRINGRule()) {
detailCodeHighlight(node, acceptor, expressionCache);
}
+ else if(ruleCall.getRule() == grammar.getIDRule() || ruleCall.getRule() == grammar.getFQNRule()) {
+ highlightDeprecated(node, acceptor);
+ }
+ }
+ else if(obj instanceof CrossReference) {
+ highlightDeprecated(node, acceptor);
}
-
}
}
@@ -105,4 +123,33 @@ public class RoomSemanticHighlightingCalculator extends BaseSemanticHighlighter
}
+ Map<EClass, Boolean> annotatedClasses = Maps.newHashMap();
+
+ protected void highlightDeprecated(INode node, IHighlightedPositionAcceptor acceptor) {
+ if(node.getGrammarElement() instanceof CrossReference) {
+ EReference ref = GrammarUtil.getReference((CrossReference) node.getGrammarElement(), node.getSemanticElement().eClass());
+ EObject annotatedElement = (ref != null) ? (EObject) node.getSemanticElement().eGet(ref) : null;
+ if(annotatedElement instanceof RoomElement) {
+ Annotation annotation = roomHelpers.findDeprecatedAnnotation((RoomElement) annotatedElement);
+ if(annotation != null) {
+ acceptor.addPosition(node.getOffset(), node.getLength(), HL_DEPRECATED_ID);
+ }
+ }
+ } else {
+ EObject annotatedElement = node.getSemanticElement();
+ if(annotatedElement instanceof RoomElement) {
+ Annotation annotation = roomHelpers.findDeprecatedAnnotation((RoomElement) annotatedElement);
+ if(annotation != null) {
+ boolean noGenerate = roomHelpers.isDeprecatedGeneration((RoomElement) annotatedElement);
+ if(noGenerate) {
+ ICompositeNode completeNode = NodeModelUtils.findActualNodeFor(annotatedElement);
+ acceptor.addPosition(completeNode.getOffset(), completeNode.getLength(), HL_DEPRECATED_ID);
+ } else {
+ acceptor.addPosition(node.getOffset(), node.getLength(), HL_DEPRECATED_ID);
+ }
+ }
+ }
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
index 449ac7cfd..901058f7d 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
@@ -19,10 +19,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.core.common.base.Annotation;
+import org.eclipse.etrice.core.common.base.BooleanLiteral;
import org.eclipse.etrice.core.common.base.KeyValue;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
@@ -53,6 +55,7 @@ import org.eclipse.etrice.core.room.RefPath;
import org.eclipse.etrice.core.room.RefSegment;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.RoomElement;
import org.eclipse.etrice.core.room.RoomFactory;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.SAP;
@@ -1099,6 +1102,64 @@ public class RoomHelpers extends FSMHelpers {
public boolean isBehaviorAttributePresent(ActorClass ac, String name, String key) {
return isAttributePresent(ac.getBehaviorAnnotations(), name, key);
}
+
+ private static final Map<EClass, Boolean> annotatedClasses = Maps.newHashMap(); // table of room classes which can be annotated (static)
+
+ /**
+ * Checks if eObjs can be annotated.
+ *
+ * @return <code>true</code> if eObjs class has feature 'annotations'
+ */
+ public boolean canHaveAnnotations(RoomElement eObj) {
+ if(!annotatedClasses.containsKey(eObj.eClass())) {
+ EStructuralFeature annotationFeature = eObj.eClass().getEStructuralFeature("annotations");
+ annotatedClasses.put(eObj.eClass(), annotationFeature != null);
+ }
+
+ return annotatedClasses.get(eObj.eClass());
+ }
+
+ /**
+ * Returns list of {@link Annotation}s for this particular element if present and {@link #canHaveAnnotations(RoomElement)}.
+ *
+ * @returns list of annotations
+ */
+ @SuppressWarnings("unchecked")
+ public List<Annotation> getAnnotations(RoomElement eObj) {
+ if(canHaveAnnotations(eObj)) {
+ EStructuralFeature annotationFeature = eObj.eClass().getEStructuralFeature("annotations");
+ return (List<Annotation>) eObj.eGet(annotationFeature);
+ }
+
+ return Collections.emptyList();
+ }
+
+ /**
+ * Returns "Deprecated" {@link Annotation} for this particular element.
+ *
+ * @returns annotation
+ */
+ public Annotation findDeprecatedAnnotation(RoomElement eObj) {
+ return getAnnotations(eObj).stream()
+ .filter(anno -> anno.getType() != null && "Deprecated".equals(anno.getType().getName())).findFirst()
+ .orElse(null);
+ }
+
+ /**
+ * Checks if element should not be generated due deprecation.
+ *
+ * @returns noGenerate = true
+ */
+ public boolean isDeprecatedGeneration(RoomElement eObj) {
+ Annotation annotation = findDeprecatedAnnotation(eObj);
+ if(annotation != null) {
+ return annotation.getAttributes().stream().anyMatch(keyValue ->
+ "noGenerate".equals(keyValue.getKey()) && ((BooleanLiteral)keyValue.getValue()).isIsTrue()
+ );
+ } else {
+ return false;
+ }
+ }
/**
* Returns the value of an annotation attribute of an {@link ActorClass}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index da8eca855..8c4f7a98f 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -13,10 +13,10 @@
*
*******************************************************************************/
-
package org.eclipse.etrice.core.validation;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -27,8 +27,11 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.core.common.base.Annotation;
import org.eclipse.etrice.core.common.base.BasePackage;
+import org.eclipse.etrice.core.common.base.BooleanLiteral;
import org.eclipse.etrice.core.common.base.Import;
import org.eclipse.etrice.core.common.base.LiteralType;
import org.eclipse.etrice.core.common.base.util.ImportHelpers;
@@ -65,6 +68,8 @@ import org.eclipse.etrice.core.room.RefPath;
import org.eclipse.etrice.core.room.ReferenceType;
import org.eclipse.etrice.core.room.RoomAnnotationTargetEnum;
import org.eclipse.etrice.core.room.RoomClass;
+import org.eclipse.etrice.core.room.RoomElement;
+import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
@@ -76,19 +81,19 @@ import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.impl.ImportUriResolver;
import org.eclipse.xtext.validation.Check;
+import org.eclipse.xtext.validation.CheckType;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
-
-
public class RoomJavaValidator extends AbstractRoomJavaValidator {
-
+
@Inject protected RoomHelpers roomHelpers;
@Inject protected ValidationUtil validationUtil;
@@ -816,4 +821,35 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
warning("The data name of messages is deprecated (always named 'transitionData' in action code)", RoomPackage.Literals.MESSAGE_DATA__DEPRECATED_NAME, DEPRECATED_MESSAGE_DATA_NAME);
}
}
+
+ /* Validate cross references for "Deprecated" annotation. Check on resource save. */
+ @Check(CheckType.NORMAL)
+ public void checkDeprecatedRefs(RoomModel container) {
+ final Map<EObject, Annotation> deprecatedCandidates = Maps.newHashMap(); // cache instances of annotatable elements
+ Function<EObject, Annotation> findDeprecatedAnnotation = (eObj) -> {
+ if(eObj instanceof RoomElement && roomHelpers.canHaveAnnotations((RoomElement) eObj)) {
+ if(!deprecatedCandidates.containsKey(eObj)) {
+ Annotation annotation = roomHelpers.findDeprecatedAnnotation((RoomElement) eObj);
+ deprecatedCandidates.put(eObj, annotation);
+ }
+ }
+ return deprecatedCandidates.get(eObj);
+ };
+ Predicate<Annotation> isError = (anno) -> {
+ return anno.getAttributes().stream().anyMatch(keyValue -> "error".equals(keyValue.getKey()) && ((BooleanLiteral)keyValue.getValue()).isIsTrue());
+ };
+ // traverse all cross references of model
+ Map<EObject, Collection<Setting>> intCrossRefs = EcoreUtil.CrossReferencer.find(container.eContents());
+ Map<EObject, Collection<Setting>> extCrossRef = EcoreUtil.ExternalCrossReferencer.find(container);
+ FluentIterable.concat(intCrossRefs.entrySet(), extCrossRef.entrySet()).forEach(entry -> {
+ Annotation annotation = findDeprecatedAnnotation.apply(entry.getKey());
+ if(annotation != null) {
+ if(isError.apply(annotation)) {
+ entry.getValue().forEach(setting -> error("Deprecated - this element cannot be used anymore", setting.getEObject(), setting.getEStructuralFeature()));
+ } else {
+ entry.getValue().forEach(setting -> warning("Deprecated", setting.getEObject(), setting.getEStructuralFeature()));
+ }
+ }
+ });
+ }
}
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 9b702edd6..347375f60 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
@@ -46,7 +46,7 @@ class ActorClassGen extends GenericActorClassGenerator {
@Inject protected ILogger logger
def doGenerate(Root root) {
- for (xpac: root.actorClasses.map[root.getExpandedActorClass(it)]) {
+ root.actorClasses.filter[!isDeprecatedGeneration].map[root.getExpandedActorClass(it)].forEach[xpac |
val path = xpac.actorClass.getPath
var file = xpac.actorClass.getCHeaderFileName
@@ -65,7 +65,7 @@ class ActorClassGen extends GenericActorClassGenerator {
file = xpac.actorClass.getCSourceFileName
fileIO.generateFile("generating ActorClass source", path + file, root.generateSourceFile(xpac))
}
- }
+ ]
}
def protected generateHeaderFile(Root root, ExpandedActorClass 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 774ace9e6..5e4b83525 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
@@ -38,7 +38,7 @@ class DataClassGen {
@Inject ILogger logger
def doGenerate(Root root) {
- for (dc: root.dataClasses) {
+ root.dataClasses.filter[!isDeprecatedGeneration].forEach[dc |
val path = dc.getPath
var file = dc.getCHeaderFileName
@@ -52,8 +52,7 @@ class DataClassGen {
// source file
file = dc.getCSourceFileName
fileIO.generateFile("generating DataClass source", path + file, root.generateSourceFile(dc))
-
- }
+ ]
}
def generateHeaderFile(Root root, DataClass dc) {'''
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/EnumerationTypeGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/EnumerationTypeGen.xtend
index a8f88af50..c23be3521 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/EnumerationTypeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/EnumerationTypeGen.xtend
@@ -20,6 +20,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.room.EnumerationType
import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.core.room.util.RoomHelpers
/**
* @author Henrik Rentz-Reichert
@@ -28,12 +29,13 @@ import org.eclipse.etrice.generator.generic.TypeHelpers
class EnumerationTypeGen {
@Inject IGeneratorFileIO fileIO
+ @Inject extension RoomHelpers
@Inject extension CExtensions
@Inject extension RoomExtensions
@Inject extension TypeHelpers
def doGenerate(Root root) {
- for (et: root.enumClasses) {
+ root.enumClasses.filter[!isDeprecatedGeneration].forEach[et |
val path = et.getPath
var file = et.getCHeaderFileName
@@ -43,7 +45,7 @@ class EnumerationTypeGen {
// header file
file = et.getCSourceFileName
fileIO.generateFile("generating Enumeration source", path + file, root.generateSourceFile(et))
- }
+ ]
}
private def generateHeaderFile(Root root, EnumerationType et) {
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 f6fd647c4..1b6fde86b 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
@@ -45,7 +45,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject ILogger logger
def doGenerate(Root root) {
- for (pc: root.protocolClasses) {
+ root.protocolClasses.filter[!isDeprecatedGeneration].forEach[pc |
val path = pc.getPath
var file = pc.getCHeaderFileName
@@ -59,7 +59,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// source file
file = pc.getCSourceFileName
fileIO.generateFile("generating ProtocolClass source", path + file, root.generateSourceFile(pc))
- }
+ ]
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
index 626746a6b..d73cd7c06 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -47,14 +47,14 @@ class ActorClassGen extends GenericActorClassGenerator {
def doGenerate(Root root) {
val Map<ActorClass, WiredActorClass> ac2wired = newHashMap
root.wiredInstances.filter(typeof(WiredActorClass)).forEach[ac2wired.put(actorClass, it)]
- for (xpac: root.actorClasses.filter[isValidGenerationLocation].map[root.getExpandedActorClass(it)]) {
+ root.actorClasses.filter[!isDeprecatedGeneration].map[root.getExpandedActorClass(it)].forEach[xpac |
val wired = ac2wired.get(xpac.actorClass)
val manualBehavior = xpac.actorClass.isBehaviorAnnotationPresent("BehaviorManual")
val path = xpac.actorClass.getPath
var file = if (manualBehavior) 'Abstract' else ''
fileIO.generateFile("generating ActorClass declaration", path + file + xpac.actorClass.getCppHeaderFileName, root.generateHeaderFile(xpac, wired, manualBehavior))
fileIO.generateFile("generating ActorClass implementation", path + file + xpac.actorClass.getCppSourceFileName, root.generateSourceFile(xpac, wired, manualBehavior))
- }
+ ]
}
def protected generateHeaderFile(Root root, ExpandedActorClass xpac, WiredActorClass wired, boolean manualBehavior) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index 1cb380830..17f204fd0 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -37,7 +37,7 @@ class DataClassGen {
@Inject extension RoomHelpers
def doGenerate(Root root) {
- for (dc: root.dataClasses) {
+ root.dataClasses.filter[!isDeprecatedGeneration].forEach[dc |
var path = dc.getPath
// header file
@@ -46,8 +46,7 @@ class DataClassGen {
// source file
fileIO.generateFile("generating DataClass source", path + dc.getCppSourceFileName, root.generateSourceFile(dc))
- }
-
+ ]
}
def generateHeaderFile(Root root, DataClass dc) {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index 4f98c8cbb..569b62f59 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -18,6 +18,7 @@ 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.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.core.room.CommunicationType
import org.eclipse.etrice.core.room.InterfaceItem
import org.eclipse.etrice.core.room.Message
@@ -26,16 +27,14 @@ import org.eclipse.etrice.core.room.PortClass
import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.core.room.SAP
import org.eclipse.etrice.core.room.SPP
-import org.eclipse.etrice.generator.cpp.Main
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
+import org.eclipse.etrice.generator.cpp.Main
+import org.eclipse.etrice.generator.cpp.setup.GeneratorOptionsHelper
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.generator.generic.ILanguageExtension
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.ILanguageExtension
-import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
-import org.eclipse.etrice.generator.cpp.setup.GeneratorOptionsHelper
@Singleton
class ProtocolClassGen extends GenericProtocolClassGenerator {
@@ -45,14 +44,12 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject extension RoomExtensions roomExt
@Inject extension ProcedureHelpers helpers
@Inject extension TypeHelpers
- @Inject extension FileSystemHelpers
@Inject extension GeneratorOptionsHelper
@Inject Initialization initHelper
@Inject IDiagnostician diagnostician
def doGenerate(Root root) {
-
- for (pc: root.protocolClasses.filter(cl|cl.isValidGenerationLocation)) {
+ root.protocolClasses.filter[!isDeprecatedGeneration].forEach[pc |
val path = pc.getPath
switch (pc.commType) {
case CommunicationType::EVENT_DRIVEN:{
@@ -66,7 +63,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
case CommunicationType::SYNCHRONOUS:
diagnostician.error("synchronous protocols not supported yet", pc, null)
}
- }
+ ]
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend
index b8ad9fb1a..65c69abac 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassDataGen.xtend
@@ -21,31 +21,28 @@ import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass
import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
+import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.core.room.util.RoomHelpers
-
@Singleton
class ActorClassDataGen {
@Inject IGeneratorFileIO fileIO
@Inject extension RoomHelpers
@Inject extension RoomExtensions
- @Inject extension FileSystemHelpers
@Inject extension ProcedureHelpers
def doGenerate(Root root) {
val HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>
root.wiredInstances.filter(w|w instanceof WiredActorClass).forEach[w|ac2wired.put((w as WiredActorClass).actorClass, w as WiredActorClass)]
- for (xpac: root.actorClasses.filter[isValidGenerationLocation].map[root.getExpandedActorClass(it)]) {
+ root.actorClasses.filter[!isDeprecatedGeneration].map[root.getExpandedActorClass(it)].forEach[xpac |
val wired = ac2wired.get(xpac.actorClass)
val path = xpac.actorClass.getPath
var file = xpac.actorClass.name+"_DataObject.java"
fileIO.generateFile("generating ActorClass implementation", path + file, root.generate(xpac, wired))
- }
+ ]
}
def generate(Root root, ExpandedActorClass xpac, WiredActorClass wired) {
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 13e19f72e..50120f34a 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
@@ -62,7 +62,7 @@ class ActorClassGen extends GenericActorClassGenerator {
def doGenerate(Root root) {
val HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>
root.wiredInstances.filter(w|w instanceof WiredActorClass).forEach[w|ac2wired.put((w as WiredActorClass).actorClass, w as WiredActorClass)]
- for (xpac: root.actorClasses.filter[isValidGenerationLocation].map[root.getExpandedActorClass(it)]) {
+ root.actorClasses.filter[!isDeprecatedGeneration].map[root.getExpandedActorClass(it)].forEach[xpac |
val wired = ac2wired.get(xpac.actorClass)
val manualBehavior = xpac.actorClass.isBehaviorAnnotationPresent("BehaviorManual")
val path = xpac.actorClass.getPath
@@ -70,7 +70,7 @@ class ActorClassGen extends GenericActorClassGenerator {
if (manualBehavior)
file = "Abstract"+file
fileIO.generateFile("generating ActorClass implementation", path + file, root.generate(xpac, wired, manualBehavior))
- }
+ ]
}
def generate(Root root, ExpandedActorClass xpac, WiredActorClass wired, boolean manualBehavior) {
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 a3f909696..28c34dacb 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
@@ -23,7 +23,6 @@ import org.eclipse.etrice.core.room.ComplexType
import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
@@ -35,15 +34,15 @@ class DataClassGen {
@Inject extension RoomExtensions
@Inject extension ProcedureHelpers
@Inject extension Initialization
- @Inject extension FileSystemHelpers
+ @Inject extension RoomHelpers
@Inject RoomHelpers roomHelpers
def doGenerate(Root root) {
- for (dc: root.dataClasses.filter(cl|cl.isValidGenerationLocation)) {
+ root.dataClasses.filter[!isDeprecatedGeneration].forEach[dc |
var path = dc.getPath
var file = dc.getJavaFileName
fileIO.generateFile("generating DataClass implementation", path + file, root.generate(dc))
- }
+ ]
}
def generate(Root root, DataClass dc) {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/EnumerationTypeGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/EnumerationTypeGen.xtend
index 9bdfa987b..e92243555 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/EnumerationTypeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/EnumerationTypeGen.xtend
@@ -14,13 +14,12 @@
package org.eclipse.etrice.generator.java.gen
-import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
import com.google.inject.Inject
-import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.etrice.core.room.EnumerationType
-
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
+import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
+import org.eclipse.etrice.generator.generic.RoomExtensions
/**
* @author Henrik Rentz-Reichert
@@ -31,14 +30,14 @@ class EnumerationTypeGen {
@Inject IGeneratorFileIO fileIO
@Inject extension JavaExtensions
@Inject extension RoomExtensions
- @Inject extension FileSystemHelpers
+ @Inject extension RoomHelpers
def doGenerate(Root root) {
- for (et: root.enumClasses.filter(cl|cl.isValidGenerationLocation)) {
+ root.enumClasses.filter[!isDeprecatedGeneration].forEach[ et |
var path = et.getPath
var file = et.getJavaFileName
fileIO.generateFile("generating Enumeration implementation", path + file, root.generate(et))
- }
+ ]
}
def generate(Root root, EnumerationType et) {
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 749a6a1b3..57780cb3e 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
@@ -17,19 +17,18 @@ package org.eclipse.etrice.generator.java.gen
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
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.ProtocolClass
-import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
import org.eclipse.etrice.generator.base.io.IGeneratorFileIO
import org.eclipse.etrice.generator.generic.GenericProtocolClassGenerator
+import org.eclipse.etrice.generator.generic.ILanguageExtension
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.Main
-import org.eclipse.etrice.generator.generic.ILanguageExtension
-import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.generator.java.setup.GeneratorOptionsHelper
@Singleton
@@ -42,12 +41,11 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
@Inject extension Initialization
@Inject extension TypeHelpers
@Inject extension DataClassGen
- @Inject extension FileSystemHelpers
@Inject protected extension GeneratorOptionsHelper
@Inject IDiagnostician diagnostician
def doGenerate(Root root) {
- for (pc: root.protocolClasses.filter(cl|cl.isValidGenerationLocation)) {
+ root.protocolClasses.filter[!isDeprecatedGeneration].forEach[pc |
val path = pc.getPath
val file = pc.getJavaFileName
val contents =
@@ -63,7 +61,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
diagnostician.error("synchronous protocols not supported yet", pc, null)
else
fileIO.generateFile("generating ProtocolClass implementation", path + file, contents)
- }
+ ]
}
def generate(Root root, ProtocolClass pc) {'''
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 e6e16c013..20cb17476 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
@@ -16,6 +16,7 @@ package org.eclipse.etrice.generator.generic
import com.google.inject.Singleton
import java.util.ArrayList
+import java.util.Collections
import java.util.List
import javax.inject.Inject
import org.eclipse.emf.common.util.BasicEList
@@ -41,7 +42,6 @@ import org.eclipse.etrice.core.room.SPP
import org.eclipse.etrice.core.room.ServiceImplementation
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.fsm.generic.FSMExtensions
-import java.util.Collections
/**
collection of convenience functions for code generation

Back to the top