diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_properties_Property.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_properties_Property.gif
new file mode 100644
index 0000000000..4b36c8a973
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_properties_Property.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_target_EClass.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_target_EClass.gif
new file mode 100644
index 0000000000..0c070475d5
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateAnnotation_target_EClass.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateComplexType_features_Enumerator.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateComplexType_features_Enumerator.gif
new file mode 100644
index 0000000000..5d52b42ea3
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreateComplexType_features_Enumerator.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Annotation.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Annotation.gif
new file mode 100644
index 0000000000..1b402369f1
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Annotation.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Enumerator.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Enumerator.gif
new file mode 100644
index 0000000000..f61f198301
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Enumerator.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Event.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Event.gif
new file mode 100644
index 0000000000..51394a3580
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Event.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Property.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Property.gif
new file mode 100644
index 0000000000..6ed90b4ad7
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Property.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Type.gif b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Type.gif
new file mode 100644
index 0000000000..975d734c8a
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/ctool16/CreatePackage_member_Type.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/obj16/AnnotatableElement.gif b/plugins/org.yakindu.base.types.edit/icons/full/obj16/AnnotatableElement.gif
new file mode 100644
index 0000000000..420eee1775
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/obj16/AnnotatableElement.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/icons/full/obj16/Annotation.gif b/plugins/org.yakindu.base.types.edit/icons/full/obj16/Annotation.gif
new file mode 100644
index 0000000000..90d10f9470
Binary files /dev/null and b/plugins/org.yakindu.base.types.edit/icons/full/obj16/Annotation.gif differ
diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotatableElementItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotatableElementItemProvider.java
new file mode 100644
index 0000000000..db1a273cc1
--- /dev/null
+++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotatableElementItemProvider.java
@@ -0,0 +1,146 @@
+/**
+ */
+package org.yakindu.base.types.provider;
+
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+
+import org.yakindu.base.types.TypesPackage;
+
+/**
+ * This is the item provider adapter for a {@link org.yakindu.base.types.AnnotatableElement} object.
+ *
+ *
+ * @generated
+ */
+public class AnnotatableElementItemProvider
+ extends ItemProviderAdapter
+ implements
+ IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider,
+ IItemPropertySource {
+ /**
+ * This constructs an instance from a factory and a notifier.
+ *
+ *
+ * @generated
+ */
+ public AnnotatableElementItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ *
+ *
+ * @generated
+ */
+ @Override
+ public List getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addAnnotationsPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Annotations feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAnnotationsPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_AnnotatableElement_annotations_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_AnnotatableElement_annotations_feature", "_UI_AnnotatableElement_type"),
+ TypesPackage.Literals.ANNOTATABLE_ELEMENT__ANNOTATIONS,
+ true,
+ false,
+ true,
+ null,
+ null,
+ null));
+ }
+
+ /**
+ * This returns AnnotatableElement.gif.
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/AnnotatableElement"));
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_AnnotatableElement_type");
+ }
+
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection
*
+ * - {@link org.yakindu.base.types.impl.PackageMemberImpl#getAnnotations Annotations}
* - {@link org.yakindu.base.types.impl.PackageMemberImpl#getId Id}
*
*
* @generated
*/
public class PackageMemberImpl extends NamedElementImpl implements PackageMember {
+ /**
+ * The cached value of the '{@link #getAnnotations() Annotations}' reference list.
+ *
+ *
+ * @see #getAnnotations()
+ * @generated
+ * @ordered
+ */
+ protected EList annotations;
/**
* The default value of the '{@link #getId() Id}' attribute.
*
@@ -52,6 +68,18 @@ protected EClass eStaticClass() {
}
+ /**
+ *
+ *
+ * @generated
+ */
+ public EList getAnnotations() {
+ if (annotations == null) {
+ annotations = new EObjectResolvingEList(Annotation.class, this, TypesPackage.PACKAGE_MEMBER__ANNOTATIONS);
+ }
+ return annotations;
+ }
+
/**
*
*
@@ -70,12 +98,46 @@ public String getId() {
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
+ case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS:
+ return getAnnotations();
case TypesPackage.PACKAGE_MEMBER__ID:
return getId();
}
return super.eGet(featureID, resolve, coreType);
}
+ /**
+ *
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS:
+ getAnnotations().clear();
+ getAnnotations().addAll((Collection extends Annotation>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS:
+ getAnnotations().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
/**
*
*
@@ -84,10 +146,44 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS:
+ return annotations != null && !annotations.isEmpty();
case TypesPackage.PACKAGE_MEMBER__ID:
return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId());
}
return super.eIsSet(featureID);
}
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public int eBaseStructuralFeatureID(int derivedFeatureID, Class> baseClass) {
+ if (baseClass == AnnotatableElement.class) {
+ switch (derivedFeatureID) {
+ case TypesPackage.PACKAGE_MEMBER__ANNOTATIONS: return TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS;
+ default: return -1;
+ }
+ }
+ return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public int eDerivedStructuralFeatureID(int baseFeatureID, Class> baseClass) {
+ if (baseClass == AnnotatableElement.class) {
+ switch (baseFeatureID) {
+ case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: return TypesPackage.PACKAGE_MEMBER__ANNOTATIONS;
+ default: return -1;
+ }
+ }
+ return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
+ }
+
} //PackageMemberImpl
diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypeAliasImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypeAliasImpl.java
index f73a622806..eabaedc3d5 100644
--- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypeAliasImpl.java
+++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypeAliasImpl.java
@@ -16,6 +16,8 @@
import org.eclipse.emf.ecore.util.InternalEList;
import org.yakindu.base.base.BasePackage;
import org.yakindu.base.base.NamedElement;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.PackageMember;
import org.yakindu.base.types.Type;
import org.yakindu.base.types.TypeAlias;
@@ -33,6 +35,7 @@
* {@link org.yakindu.base.types.impl.TypeAliasImpl#getType Type}
* {@link org.yakindu.base.types.impl.TypeAliasImpl#getTypeArguments Type Arguments}
* {@link org.yakindu.base.types.impl.TypeAliasImpl#getName Name}
+ * {@link org.yakindu.base.types.impl.TypeAliasImpl#getAnnotations Annotations}
* {@link org.yakindu.base.types.impl.TypeAliasImpl#getId Id}
* {@link org.yakindu.base.types.impl.TypeAliasImpl#getConstraint Constraint}
* {@link org.yakindu.base.types.impl.TypeAliasImpl#isAbstract Abstract}
@@ -79,6 +82,16 @@ public class TypeAliasImpl extends EObjectImpl implements TypeAlias {
*/
protected String name = NAME_EDEFAULT;
+ /**
+ * The cached value of the '{@link #getAnnotations() Annotations}' reference list.
+ *
+ *
+ * @see #getAnnotations()
+ * @generated
+ * @ordered
+ */
+ protected EList annotations;
+
/**
* The default value of the '{@link #getId() Id}' attribute.
*
@@ -218,6 +231,18 @@ public void setName(String newName) {
eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.TYPE_ALIAS__NAME, oldName, name));
}
+ /**
+ *
+ *
+ * @generated
+ */
+ public EList getAnnotations() {
+ if (annotations == null) {
+ annotations = new EObjectResolvingEList(Annotation.class, this, TypesPackage.TYPE_ALIAS__ANNOTATIONS);
+ }
+ return annotations;
+ }
+
/**
*
* @generated
@@ -308,6 +333,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
return getTypeArguments();
case TypesPackage.TYPE_ALIAS__NAME:
return getName();
+ case TypesPackage.TYPE_ALIAS__ANNOTATIONS:
+ return getAnnotations();
case TypesPackage.TYPE_ALIAS__ID:
return getId();
case TypesPackage.TYPE_ALIAS__CONSTRAINT:
@@ -338,6 +365,10 @@ public void eSet(int featureID, Object newValue) {
case TypesPackage.TYPE_ALIAS__NAME:
setName((String)newValue);
return;
+ case TypesPackage.TYPE_ALIAS__ANNOTATIONS:
+ getAnnotations().clear();
+ getAnnotations().addAll((Collection extends Annotation>)newValue);
+ return;
case TypesPackage.TYPE_ALIAS__CONSTRAINT:
getConstraint().clear();
getConstraint().addAll((Collection extends TypeConstraint>)newValue);
@@ -368,6 +399,9 @@ public void eUnset(int featureID) {
case TypesPackage.TYPE_ALIAS__NAME:
setName(NAME_EDEFAULT);
return;
+ case TypesPackage.TYPE_ALIAS__ANNOTATIONS:
+ getAnnotations().clear();
+ return;
case TypesPackage.TYPE_ALIAS__CONSTRAINT:
getConstraint().clear();
return;
@@ -394,6 +428,8 @@ public boolean eIsSet(int featureID) {
return typeArguments != null && !typeArguments.isEmpty();
case TypesPackage.TYPE_ALIAS__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case TypesPackage.TYPE_ALIAS__ANNOTATIONS:
+ return annotations != null && !annotations.isEmpty();
case TypesPackage.TYPE_ALIAS__ID:
return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId());
case TypesPackage.TYPE_ALIAS__CONSTRAINT:
@@ -418,6 +454,12 @@ public int eBaseStructuralFeatureID(int derivedFeatureID, Class> baseClass) {
default: return -1;
}
}
+ if (baseClass == AnnotatableElement.class) {
+ switch (derivedFeatureID) {
+ case TypesPackage.TYPE_ALIAS__ANNOTATIONS: return TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS;
+ default: return -1;
+ }
+ }
if (baseClass == PackageMember.class) {
switch (derivedFeatureID) {
case TypesPackage.TYPE_ALIAS__ID: return TypesPackage.PACKAGE_MEMBER__ID;
@@ -447,6 +489,12 @@ public int eDerivedStructuralFeatureID(int baseFeatureID, Class> baseClass) {
default: return -1;
}
}
+ if (baseClass == AnnotatableElement.class) {
+ switch (baseFeatureID) {
+ case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: return TypesPackage.TYPE_ALIAS__ANNOTATIONS;
+ default: return -1;
+ }
+ }
if (baseClass == PackageMember.class) {
switch (baseFeatureID) {
case TypesPackage.PACKAGE_MEMBER__ID: return TypesPackage.TYPE_ALIAS__ID;
diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesFactoryImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesFactoryImpl.java
index f7637655d3..c1a0f34aba 100644
--- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesFactoryImpl.java
+++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesFactoryImpl.java
@@ -12,6 +12,8 @@
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.ComplexType;
import org.yakindu.base.types.Direction;
import org.yakindu.base.types.Domain;
@@ -93,6 +95,8 @@ public EObject create(EClass eClass) {
case TypesPackage.RANGE_CONSTRAINT: return createRangeConstraint();
case TypesPackage.DOMAIN: return createDomain();
case TypesPackage.TYPE_ALIAS: return createTypeAlias();
+ case TypesPackage.ANNOTATION: return createAnnotation();
+ case TypesPackage.ANNOTATABLE_ELEMENT: return createAnnotatableElement();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
@@ -298,6 +302,26 @@ public TypeAlias createTypeAlias() {
return typeAlias;
}
+ /**
+ *
+ *
+ * @generated
+ */
+ public Annotation createAnnotation() {
+ AnnotationImpl annotation = new AnnotationImpl();
+ return annotation;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public AnnotatableElement createAnnotatableElement() {
+ AnnotatableElementImpl annotatableElement = new AnnotatableElementImpl();
+ return annotatableElement;
+ }
+
/**
*
*
diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesPackageImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesPackageImpl.java
index 59f9eecfbb..53edfb2ab7 100644
--- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesPackageImpl.java
+++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/TypesPackageImpl.java
@@ -13,6 +13,8 @@
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.yakindu.base.base.BasePackage;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.ComplexType;
import org.yakindu.base.types.Declaration;
import org.yakindu.base.types.Direction;
@@ -164,6 +166,20 @@ public class TypesPackageImpl extends EPackageImpl implements TypesPackage {
*/
private EClass typeAliasEClass = null;
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass annotationEClass = null;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass annotatableElementEClass = null;
+
/**
*
*
@@ -630,6 +646,51 @@ public EClass getTypeAlias() {
return typeAliasEClass;
}
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getAnnotation() {
+ return annotationEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getAnnotation_Properties() {
+ return (EReference)annotationEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getAnnotation_Targets() {
+ return (EReference)annotationEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EClass getAnnotatableElement() {
+ return annotatableElementEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public EReference getAnnotatableElement_Annotations() {
+ return (EReference)annotatableElementEClass.getEStructuralFeatures().get(0);
+ }
+
/**
*
*
@@ -730,6 +791,13 @@ public void createPackageContents() {
typeAliasEClass = createEClass(TYPE_ALIAS);
+ annotationEClass = createEClass(ANNOTATION);
+ createEReference(annotationEClass, ANNOTATION__PROPERTIES);
+ createEReference(annotationEClass, ANNOTATION__TARGETS);
+
+ annotatableElementEClass = createEClass(ANNOTATABLE_ELEMENT);
+ createEReference(annotatableElementEClass, ANNOTATABLE_ELEMENT__ANNOTATIONS);
+
// Create enums
directionEEnum = createEEnum(DIRECTION);
}
@@ -781,9 +849,11 @@ public void initializePackageContents() {
typeParameterEClass.getESuperTypes().add(this.getType());
parameterizedTypeEClass.getESuperTypes().add(this.getType());
packageMemberEClass.getESuperTypes().add(theBasePackage.getNamedElement());
+ packageMemberEClass.getESuperTypes().add(this.getAnnotatableElement());
rangeConstraintEClass.getESuperTypes().add(this.getTypeConstraint());
typeAliasEClass.getESuperTypes().add(this.getTypedElement());
typeAliasEClass.getESuperTypes().add(this.getType());
+ annotationEClass.getESuperTypes().add(this.getPackageMember());
// Initialize classes and features; add operations and parameters
initEClass(packageEClass, org.yakindu.base.types.Package.class, "Package", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
@@ -855,6 +925,13 @@ public void initializePackageContents() {
initEClass(typeAliasEClass, TypeAlias.class, "TypeAlias", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEClass(annotationEClass, Annotation.class, "Annotation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getAnnotation_Properties(), this.getProperty(), null, "properties", null, 0, -1, Annotation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getAnnotation_Targets(), ecorePackage.getEObject(), null, "targets", null, 0, -1, Annotation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(annotatableElementEClass, AnnotatableElement.class, "AnnotatableElement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getAnnotatableElement_Annotations(), this.getAnnotation(), null, "annotations", null, 0, -1, AnnotatableElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
// Initialize enums and add enum literals
initEEnum(directionEEnum, Direction.class, "Direction");
addEEnumLiteral(directionEEnum, Direction.LOCAL);
diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesAdapterFactory.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesAdapterFactory.java
index 111b9c2b1d..d252f454d8 100644
--- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesAdapterFactory.java
+++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesAdapterFactory.java
@@ -11,6 +11,8 @@
import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EObject;
import org.yakindu.base.base.NamedElement;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.ComplexType;
import org.yakindu.base.types.Declaration;
import org.yakindu.base.types.Domain;
@@ -161,6 +163,14 @@ public Adapter caseTypeAlias(TypeAlias object) {
return createTypeAliasAdapter();
}
@Override
+ public Adapter caseAnnotation(Annotation object) {
+ return createAnnotationAdapter();
+ }
+ @Override
+ public Adapter caseAnnotatableElement(AnnotatableElement object) {
+ return createAnnotatableElementAdapter();
+ }
+ @Override
public Adapter caseNamedElement(NamedElement object) {
return createNamedElementAdapter();
}
@@ -467,6 +477,34 @@ public Adapter createTypeAliasAdapter() {
return null;
}
+ /**
+ * Creates a new adapter for an object of class '{@link org.yakindu.base.types.Annotation Annotation}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.yakindu.base.types.Annotation
+ * @generated
+ */
+ public Adapter createAnnotationAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.yakindu.base.types.AnnotatableElement Annotatable Element}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see org.yakindu.base.types.AnnotatableElement
+ * @generated
+ */
+ public Adapter createAnnotatableElementAdapter() {
+ return null;
+ }
+
/**
* Creates a new adapter for the default case.
* This
diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesSwitch.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesSwitch.java
index e77c7b3299..340421e79a 100644
--- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesSwitch.java
+++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/util/TypesSwitch.java
@@ -10,6 +10,8 @@
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.util.Switch;
import org.yakindu.base.base.NamedElement;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.ComplexType;
import org.yakindu.base.types.Declaration;
import org.yakindu.base.types.Domain;
@@ -95,6 +97,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
T result = caseType(type);
if (result == null) result = casePackageMember(type);
if (result == null) result = caseNamedElement(type);
+ if (result == null) result = caseAnnotatableElement(type);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -104,6 +107,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseTypedElement(declaration);
if (result == null) result = casePackageMember(declaration);
if (result == null) result = caseNamedElement(declaration);
+ if (result == null) result = caseAnnotatableElement(declaration);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -114,6 +118,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseTypedElement(operation);
if (result == null) result = casePackageMember(operation);
if (result == null) result = caseNamedElement(operation);
+ if (result == null) result = caseAnnotatableElement(operation);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -124,6 +129,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseTypedElement(property);
if (result == null) result = casePackageMember(property);
if (result == null) result = caseNamedElement(property);
+ if (result == null) result = caseAnnotatableElement(property);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -148,6 +154,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseTypedElement(event);
if (result == null) result = casePackageMember(event);
if (result == null) result = caseNamedElement(event);
+ if (result == null) result = caseAnnotatableElement(event);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -158,6 +165,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(enumerationType);
if (result == null) result = casePackageMember(enumerationType);
if (result == null) result = caseNamedElement(enumerationType);
+ if (result == null) result = caseAnnotatableElement(enumerationType);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -167,6 +175,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(primitiveType);
if (result == null) result = casePackageMember(primitiveType);
if (result == null) result = caseNamedElement(primitiveType);
+ if (result == null) result = caseAnnotatableElement(primitiveType);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -177,6 +186,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(complexType);
if (result == null) result = casePackageMember(complexType);
if (result == null) result = caseNamedElement(complexType);
+ if (result == null) result = caseAnnotatableElement(complexType);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -187,6 +197,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseTypedElement(enumerator);
if (result == null) result = casePackageMember(enumerator);
if (result == null) result = caseNamedElement(enumerator);
+ if (result == null) result = caseAnnotatableElement(enumerator);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -202,6 +213,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(typeParameter);
if (result == null) result = casePackageMember(typeParameter);
if (result == null) result = caseNamedElement(typeParameter);
+ if (result == null) result = caseAnnotatableElement(typeParameter);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -211,6 +223,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(parameterizedType);
if (result == null) result = casePackageMember(parameterizedType);
if (result == null) result = caseNamedElement(parameterizedType);
+ if (result == null) result = caseAnnotatableElement(parameterizedType);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -218,6 +231,7 @@ protected T doSwitch(int classifierID, EObject theEObject) {
PackageMember packageMember = (PackageMember)theEObject;
T result = casePackageMember(packageMember);
if (result == null) result = caseNamedElement(packageMember);
+ if (result == null) result = caseAnnotatableElement(packageMember);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -241,6 +255,22 @@ protected T doSwitch(int classifierID, EObject theEObject) {
if (result == null) result = caseType(typeAlias);
if (result == null) result = casePackageMember(typeAlias);
if (result == null) result = caseNamedElement(typeAlias);
+ if (result == null) result = caseAnnotatableElement(typeAlias);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TypesPackage.ANNOTATION: {
+ Annotation annotation = (Annotation)theEObject;
+ T result = caseAnnotation(annotation);
+ if (result == null) result = casePackageMember(annotation);
+ if (result == null) result = caseNamedElement(annotation);
+ if (result == null) result = caseAnnotatableElement(annotation);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case TypesPackage.ANNOTATABLE_ELEMENT: {
+ AnnotatableElement annotatableElement = (AnnotatableElement)theEObject;
+ T result = caseAnnotatableElement(annotatableElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
@@ -539,6 +569,36 @@ public T caseTypeAlias(TypeAlias object) {
return null;
}
+ /**
+ * Returns the result of interpreting the object as an instance of 'Annotation'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Annotation'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseAnnotation(Annotation object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Annotatable Element'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Annotatable Element'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseAnnotatableElement(AnnotatableElement object) {
+ return null;
+ }
+
/**
* Returns the result of interpreting the object as an instance of 'EObject'.
* This implementation returns
diff --git a/plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/LocalReactionImpl.java b/plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/LocalReactionImpl.java
index 2d1bc22a3c..b8cdb3a069 100644
--- a/plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/LocalReactionImpl.java
+++ b/plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/LocalReactionImpl.java
@@ -5,6 +5,7 @@
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
@@ -12,6 +13,7 @@
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.yakindu.base.base.BasePackage;
import org.yakindu.base.base.NamedElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.Declaration;
import org.yakindu.base.types.PackageMember;
import org.yakindu.base.types.Type;
@@ -351,5 +353,10 @@ public String toString() {
public String getId() {
return getName();
}
+
+ @Override
+ public EList getAnnotations() {
+ return new BasicEList<>();
+ }
} //LocalReactionImpl
diff --git a/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java b/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
index f05ba00d0c..fcce4bebc1 100644
--- a/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
+++ b/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
@@ -20,6 +20,7 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -50,6 +51,8 @@
import org.yakindu.base.expressions.expressions.ExpressionsPackage;
import org.yakindu.base.expressions.expressions.FeatureCall;
import org.yakindu.base.expressions.validation.ExpressionsJavaValidator;
+import org.yakindu.base.types.AnnotatableElement;
+import org.yakindu.base.types.Annotation;
import org.yakindu.base.types.Declaration;
import org.yakindu.base.types.Direction;
import org.yakindu.base.types.Event;
@@ -725,6 +728,25 @@ public void checkChoiceWithoutDefaultTransition(final Choice choice) {
if (!found)
warning(CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS);
}
+ //TODO Extract TypesValidator
+ @Check
+ public void checkAnnotationTarget(final AnnotatableElement element) {
+ EList annotations = element.getAnnotations();
+ for (Annotation annotation : annotations) {
+ EList targets = annotation.getTargets();
+ boolean found = Iterables.any(targets, new Predicate() {
+ @Override
+ public boolean apply(EObject input) {
+ return ((EClass) input).isInstance(element);
+ }
+ });
+ if (!found) {
+ error(String.format(ERROR_WRONG_ANNOTATION_TARGET_MSG, annotation.getName(), element.eClass()),
+ TypesPackage.Literals.ANNOTATABLE_ELEMENT__ANNOTATIONS,
+ element.getAnnotations().indexOf(annotation), ERROR_WRONG_ANNOTATION_TARGET_CODE);
+ }
+ }
+ }
protected boolean isDefault(Trigger trigger) {
diff --git a/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java b/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java
index 1243a16868..ee15d2dc79 100644
--- a/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java
+++ b/plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java
@@ -51,4 +51,7 @@ public interface STextValidationMessages {
public static final String REFERENCE_TO_VARIABLE = "Cannot reference a variable in a constant initialization.";
public static final String REFERENCE_CONSTANT_BEFORE_DEFINED = "Cannot reference a constant from different scope or before it is defined.";
public static final String INTERNAL_DECLARATION_UNUSED = "Internal declaration is not used in statechart.";
+ public static final String ERROR_WRONG_ANNOTATION_TARGET_CODE = "WrongAnnotationTarget";
+ public static final String ERROR_WRONG_ANNOTATION_TARGET_MSG = "Annotation '%s' can not be applied on %s ";
+
}
\ No newline at end of file
diff --git a/test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/validation/STextJavaValidatorTest.java b/test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/validation/STextJavaValidatorTest.java
index b3dd7121dd..21c6d2b4e7 100644
--- a/test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/validation/STextJavaValidatorTest.java
+++ b/test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/validation/STextJavaValidatorTest.java
@@ -12,7 +12,9 @@
package org.yakindu.sct.model.stext.test.validation;
import static org.eclipse.xtext.junit4.validation.AssertableDiagnostics.errorCode;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.yakindu.sct.test.models.AbstractTestModelsUtil.VALIDATION_TESTMODEL_DIR;
import java.lang.reflect.Method;
@@ -29,10 +31,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.yakindu.base.expressions.expressions.Expression;
-import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.base.types.Annotation;
+import org.yakindu.base.types.Operation;
+import org.yakindu.base.types.Package;
+import org.yakindu.base.types.Type;
+import org.yakindu.base.types.TypesFactory;
+import org.yakindu.base.types.TypesPackage;
import org.yakindu.sct.model.sgraph.Entry;
import org.yakindu.sct.model.sgraph.Exit;
-import org.yakindu.sct.model.sgraph.Region;
import org.yakindu.sct.model.sgraph.Scope;
import org.yakindu.sct.model.sgraph.State;
import org.yakindu.sct.model.sgraph.Statechart;
@@ -47,7 +53,6 @@
import org.yakindu.sct.model.stext.stext.StatechartSpecification;
import org.yakindu.sct.model.stext.stext.TransitionSpecification;
import org.yakindu.sct.model.stext.stext.impl.StextFactoryImpl;
-import org.yakindu.sct.model.stext.test.util.AbstractSTextTest;
import org.yakindu.sct.model.stext.test.util.STextInjectorProvider;
import org.yakindu.sct.model.stext.validation.STextJavaValidator;
import org.yakindu.sct.model.stext.validation.STextValidationMessages;
@@ -56,8 +61,6 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
/**
* @author andreas muelder - Initial contribution and API
@@ -67,7 +70,6 @@
@InjectWith(STextInjectorProvider.class)
public class STextJavaValidatorTest extends AbstractSTextValidationTest implements STextValidationMessages {
-
/**
* @see STextJavaValidator#checkVariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition)
*/
@@ -157,9 +159,8 @@ public void checkLeftHandAssignment() {
*/
@Test
public void checkOperationArguments_FeatureCall() {
- Scope scope = (Scope) parseExpression(
- "interface if : operation myOperation(param1 : integer, param2: boolean)", null,
- InterfaceScope.class.getSimpleName());
+ Scope scope = (Scope) parseExpression("interface if : operation myOperation(param1 : integer, param2: boolean)",
+ null, InterfaceScope.class.getSimpleName());
EObject model = super.parseExpression("if.myOperation(5,true)", Expression.class.getSimpleName(), scope);
AssertableDiagnostics validationResult = tester.validate(model);
validationResult.assertOK();
@@ -190,8 +191,8 @@ public void checkGuard() {
validationResult = tester.validate(expression);
validationResult.assertOK();
}
-
- @Test
+
+ @Test
public void checkNoAssignmentInGuard() {
Scope context = createInternalScope("internal: var myInt : integer var myBool : boolean = true");
EObject expression = super.parseExpression("[myBool = false]", context, ReactionTrigger.class.getSimpleName());
@@ -209,7 +210,7 @@ public void checkNoAssignmentInGuard() {
assertEquals(STextJavaValidator.GUARD_CONTAINS_ASSIGNMENT, d.getMessage());
}
}
-
+
}
/**
@@ -306,7 +307,7 @@ public void checkEventDefinition() {
// No in declarations in internal scope
model = super.parseExpression("internal: in event Event1", null, InternalScope.class.getSimpleName());
result = tester.validate(model);
- result.assertDiagnosticsCount(1);
+ result.assertDiagnosticsCount(1);
result.assertErrorContains(STextJavaValidator.IN_OUT_DECLARATIONS);
// No out declarations in internal scope
model = super.parseExpression("internal: out event Event1", null, InternalScope.class.getSimpleName());
@@ -350,11 +351,11 @@ public void checkUnresolvableProxies() {
public void checkSyntaxErrors() {
// Nothing to do
}
-
+
@Test
public void checkExpression() {
// Nothing to do
- }
+ }
/**
* checks tht each @Check method of {@link STextJavaValidator} has a @Test
@@ -389,17 +390,20 @@ public void checkUnusedEntry() {
assertIssueCount(diagnostics, 1);
assertWarning(diagnostics, ENTRY_UNUSED);
}
+
@Test
- public void checkTopLeveEntryIsDefaultEntry(){
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "TopLevelEntryIsDefaultEntryError.sct");
+ public void checkTopLeveEntryIsDefaultEntry() {
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TopLevelEntryIsDefaultEntryError.sct");
doValidateAllContents(Entry.class);
-
+
assertIssueCount(diagnostics, 1);
assertError(diagnostics, TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY);
resetDiagnostics();
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "TopLevelEntryIsDefaultEntryWarn.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TopLevelEntryIsDefaultEntryWarn.sct");
doValidateAllContents(Entry.class);
-
+
assertIssueCount(diagnostics, 1);
assertWarning(diagnostics, TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY);
}
@@ -429,6 +433,7 @@ protected void doValidateAllContents(Class extends EObject> clazz) {
}
}
}
+
protected void assertAllTransitionsAreValid(Class extends EObject> clazz) {
Iterator iter;
iter = statechart.eAllContents();
@@ -444,16 +449,16 @@ protected void assertAllTransitionsAreValid(Class extends EObject> clazz) {
@Test
public void checkTransitionPropertySpec() {
// Test source state isn't composite
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "TransitionEntrySpecNotComposite.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TransitionEntrySpecNotComposite.sct");
doValidateAllContents(Transition.class);
// Test target state isn't composite
assertIssueCount(diagnostics, 2);
assertWarning(diagnostics, TRANSITION_ENTRY_SPEC_NOT_COMPOSITE);
resetDiagnostics();
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "TransitionExitSpecNotComposite.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TransitionExitSpecNotComposite.sct");
assertAllTransitionsAreValid(Transition.class);
assertIssueCount(diagnostics, 1);
@@ -461,8 +466,8 @@ public void checkTransitionPropertySpec() {
// Test exit spec is used on multiple transition siblings.
resetDiagnostics();
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "TransitionExitSpecOnMultipleSiblings.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TransitionExitSpecOnMultipleSiblings.sct");
assertAllTransitionsAreValid(Transition.class);
assertIssueCount(diagnostics, 4);
@@ -470,16 +475,14 @@ public void checkTransitionPropertySpec() {
// Test transition unbound named exit point spec.
resetDiagnostics();
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "TransitionNotExistingNamedExitPoint.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "TransitionNotExistingNamedExitPoint.sct");
doValidateAllContents(Transition.class);
assertIssueCount(diagnostics, 1);
assertError(diagnostics, TRANSITION_NOT_EXISTING_NAMED_EXIT_POINT);
}
-
-
@Test
public void checkUnboundEntryPoints() {
statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundDefaultEntryPoints.sct");
@@ -524,8 +527,8 @@ public void checkUnboundEntryPoints() {
@Test
public void checkExitPointSpecWithTrigger() {
- statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "NoTriggerOnTransitionWithExitPointSpec.sct");
+ statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "NoTriggerOnTransitionWithExitPointSpec.sct");
Iterator iter = statechart.eAllContents();
while (iter.hasNext()) {
EObject element = iter.next();
@@ -540,8 +543,8 @@ public void checkExitPointSpecWithTrigger() {
@Test
public void checkAssignmentToFinalVariable() {
- Statechart statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "AssignmentToValue.sct");
+ Statechart statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "AssignmentToValue.sct");
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(statechart);
assertIssueCount(diagnostics, 2);
assertError(diagnostics, ASSIGNMENT_TO_VALUE);
@@ -549,8 +552,8 @@ public void checkAssignmentToFinalVariable() {
@Test
public void checkValueDefinitionExpression() {
- Statechart statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "ConstWithVariable.sct");
+ Statechart statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "ConstWithVariable.sct");
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(statechart);
assertIssueCount(diagnostics, 2); //
assertError(diagnostics, REFERENCE_TO_VARIABLE);
@@ -558,22 +561,21 @@ public void checkValueDefinitionExpression() {
@Test
public void checkValueReferenedBeforeDefined() {
- Statechart statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "ReferenceBeforeDefined.sct");
+ Statechart statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "ReferenceBeforeDefined.sct");
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(statechart);
assertIssueCount(diagnostics, 2);
assertError(diagnostics, REFERENCE_CONSTANT_BEFORE_DEFINED);
}
-
+
@Test
- public void checkUnusedVariablesInInternalScope(){
- Statechart statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR
- + "UnusedInternalDeclarations.sct");
+ public void checkUnusedVariablesInInternalScope() {
+ Statechart statechart = AbstractTestModelsUtil
+ .loadStatechart(VALIDATION_TESTMODEL_DIR + "UnusedInternalDeclarations.sct");
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(statechart);
assertIssueCount(diagnostics, 3);
assertWarning(diagnostics, INTERNAL_DECLARATION_UNUSED);
}
-
@Test
public void checkImportExists() {
@@ -583,11 +585,37 @@ public void checkImportExists() {
AssertableDiagnostics validationResult = tester.validate(importScope.getImports().get(0));
validationResult.assertError(STextJavaValidator.IMPORT_NOT_RESOLVED);
}
-
- /**
- * The erelevant testst are implemented by TransitionsWithNoTriggerTest.
- */
- @Test public void transitionsWithNoTrigger() {
+
+ @Test
+ public void checkAnnotationTarget() {
+
+ Package pack = TypesFactory.eINSTANCE.createPackage();
+ pack.setName("package");
+
+ Annotation annotation = TypesFactory.eINSTANCE.createAnnotation();
+ annotation.setName("OperationAnnotation");
+ annotation.getTargets().add(TypesPackage.Literals.OPERATION);
+ pack.getMember().add(annotation);
+
+ Operation operation = TypesFactory.eINSTANCE.createOperation();
+ operation.setName("MyOp");
+ operation.getAnnotations().add(annotation);
+ pack.getMember().add(operation);
+
+ AssertableDiagnostics validationResult = tester.validate(pack);
+ validationResult.assertOK();
+
+ Type type = TypesFactory.eINSTANCE.createType();
+ type.setName("primitive");
+ type.getAnnotations().add(annotation);
+ pack.getMember().add(type);
+
+ validationResult = tester.validate(pack);
+ validationResult.assertError(ERROR_WRONG_ANNOTATION_TARGET_CODE);
}
-
+
+ @Test
+ public void transitionsWithNoTrigger() {
+ }
+
}