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 newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return TypesEditPlugin.INSTANCE; + } + +} diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotationItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotationItemProvider.java new file mode 100644 index 0000000000..6f2f8bb590 --- /dev/null +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/AnnotationItemProvider.java @@ -0,0 +1,142 @@ +/** + */ +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.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.yakindu.base.types.Annotation; +import org.yakindu.base.types.TypesFactory; +import org.yakindu.base.types.TypesPackage; + +/** + * This is the item provider adapter for a {@link org.yakindu.base.types.Annotation} object. + * + * + * @generated + */ +public class AnnotationItemProvider extends PackageMemberItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public AnnotationItemProvider(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); + + } + return itemPropertyDescriptors; + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (childrenFeatures == null) { + super.getChildrenFeatures(object); + childrenFeatures.add(TypesPackage.Literals.ANNOTATION__PROPERTIES); + } + return childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns Annotation.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/Annotation")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((Annotation)object).getName(); + return label == null || label.length() == 0 ? + getString("_UI_Annotation_type") : + getString("_UI_Annotation_type") + " " + label; + } + + + /** + * 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); + + switch (notification.getFeatureID(Annotation.class)) { + case TypesPackage.ANNOTATION__PROPERTIES: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + 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 newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.ANNOTATION__PROPERTIES, + TypesFactory.eINSTANCE.createProperty())); + } + +} diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/ComplexTypeItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/ComplexTypeItemProvider.java index f03837e2c1..7b19e2543d 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/ComplexTypeItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/ComplexTypeItemProvider.java @@ -179,6 +179,11 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors (createChildParameter (TypesPackage.Literals.COMPLEX_TYPE__FEATURES, TypesFactory.eINSTANCE.createEvent())); + + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.COMPLEX_TYPE__FEATURES, + TypesFactory.eINSTANCE.createEnumerator())); } } diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/DeclarationItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/DeclarationItemProvider.java index 65c43b27c3..c7400a49f7 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/DeclarationItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/DeclarationItemProvider.java @@ -35,10 +35,9 @@ import org.yakindu.base.types.TypesPackage; /** - * This is the item provider adapter for a - * {@link org.yakindu.base.types.Declaration} object. + * This is the item provider adapter for a {@link org.yakindu.base.types.Declaration} object. + * * - * * @generated */ public class DeclarationItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, @@ -67,24 +66,32 @@ public List getPropertyDescriptors(Object object) { addTypePropertyDescriptor(object); addTypeArgumentsPropertyDescriptor(object); addNamePropertyDescriptor(object); + addAnnotationsPropertyDescriptor(object); + addIdPropertyDescriptor(object); } return itemPropertyDescriptors; } /** - * This adds a property descriptor for the Type feature. - * * @generated */ protected void addTypePropertyDescriptor(Object object) { - itemPropertyDescriptors.add(createItemPropertyDescriptor( - ((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_TypedElement_type_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_type_feature", - "_UI_TypedElement_type"), TypesPackage.Literals.TYPED_ELEMENT__TYPE, true, false, true, null, - null, null)); + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_TypedElement_type_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_type_feature", "_UI_TypedElement_type"), + TypesPackage.Literals.TYPED_ELEMENT__TYPE, + true, + false, + true, + null, + null, + null)); } /** @@ -94,29 +101,85 @@ protected void addTypePropertyDescriptor(Object object) { * @generated */ protected void addTypeArgumentsPropertyDescriptor(Object object) { - itemPropertyDescriptors.add(createItemPropertyDescriptor( - ((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_TypedElement_typeArguments_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_typeArguments_feature", - "_UI_TypedElement_type"), TypesPackage.Literals.TYPED_ELEMENT__TYPE_ARGUMENTS, true, false, - true, null, null, null)); + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_TypedElement_typeArguments_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_typeArguments_feature", "_UI_TypedElement_type"), + TypesPackage.Literals.TYPED_ELEMENT__TYPE_ARGUMENTS, + true, + false, + true, + null, + null, + null)); } /** - * This adds a property descriptor for the Name feature. - * * @generated */ protected void addNamePropertyDescriptor(Object object) { - itemPropertyDescriptors.add(createItemPropertyDescriptor( - ((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_NamedElement_name_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_NamedElement_name_feature", - "_UI_NamedElement_type"), BasePackage.Literals.NAMED_ELEMENT__NAME, true, false, false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_NamedElement_name_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_NamedElement_name_feature", "_UI_NamedElement_type"), + BasePackage.Literals.NAMED_ELEMENT__NAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * 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 adds a property descriptor for the Id feature. + * + * + * @generated + */ + protected void addIdPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_PackageMember_id_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_PackageMember_id_feature", "_UI_PackageMember_type"), + TypesPackage.Literals.PACKAGE_MEMBER__ID, + false, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** @@ -132,11 +195,10 @@ public String getText(Object object) { } /** - * 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 @@ -144,9 +206,10 @@ public void notifyChanged(Notification notification) { updateChildren(notification); switch (notification.getFeatureID(Declaration.class)) { - case TypesPackage.DECLARATION__NAME: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); - return; + case TypesPackage.DECLARATION__NAME: + case TypesPackage.DECLARATION__ID: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; } super.notifyChanged(notification); } diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/EnumeratorItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/EnumeratorItemProvider.java index c871cfe9be..827c7b4058 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/EnumeratorItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/EnumeratorItemProvider.java @@ -32,7 +32,7 @@ * @generated */ public class EnumeratorItemProvider - extends NamedElementItemProvider { + extends DeclarationItemProvider { /** * This constructs an instance from a factory and a notifier. * @@ -73,10 +73,10 @@ protected void addLiteralValuePropertyDescriptor(Object object) { getString("_UI_Enumerator_literalValue_feature"), getString("_UI_PropertyDescriptor_description", "_UI_Enumerator_literalValue_feature", "_UI_Enumerator_type"), TypesPackage.Literals.ENUMERATOR__LITERAL_VALUE, - true, false, false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); } @@ -137,15 +137,4 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors super.collectNewChildDescriptors(newChildDescriptors, object); } - /** - * Return the resource locator for this item provider's resources. - * - * - * @generated - */ - @Override - public ResourceLocator getResourceLocator() { - return TypesEditPlugin.INSTANCE; - } - } diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageItemProvider.java index 4c825771fd..6b6ab96ce9 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageItemProvider.java @@ -18,6 +18,7 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ViewerNotification; import org.yakindu.base.base.provider.NamedElementItemProvider; @@ -53,10 +54,33 @@ public List getPropertyDescriptors(Object object) { if (itemPropertyDescriptors == null) { super.getPropertyDescriptors(object); + addImportPropertyDescriptor(object); } return itemPropertyDescriptors; } + /** + * This adds a property descriptor for the Import feature. + * + * + * @generated + */ + protected void addImportPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Package_import_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Package_import_feature", "_UI_Package_type"), + TypesPackage.Literals.PACKAGE__IMPORT, + true, + false, + true, + null, + null, + null)); + } + /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or @@ -149,11 +173,26 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors (TypesPackage.Literals.PACKAGE__MEMBER, TypesFactory.eINSTANCE.createPackageMember())); + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.PACKAGE__MEMBER, + TypesFactory.eINSTANCE.createType())); + newChildDescriptors.add (createChildParameter (TypesPackage.Literals.PACKAGE__MEMBER, TypesFactory.eINSTANCE.createOperation())); + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.PACKAGE__MEMBER, + TypesFactory.eINSTANCE.createProperty())); + + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.PACKAGE__MEMBER, + TypesFactory.eINSTANCE.createEvent())); + newChildDescriptors.add (createChildParameter (TypesPackage.Literals.PACKAGE__MEMBER, @@ -174,6 +213,11 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors (TypesPackage.Literals.PACKAGE__MEMBER, TypesFactory.eINSTANCE.createComplexType())); + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.PACKAGE__MEMBER, + TypesFactory.eINSTANCE.createEnumerator())); + newChildDescriptors.add (createChildParameter (TypesPackage.Literals.PACKAGE__MEMBER, @@ -184,6 +228,11 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors (TypesPackage.Literals.PACKAGE__MEMBER, TypesFactory.eINSTANCE.createTypeAlias())); + newChildDescriptors.add + (createChildParameter + (TypesPackage.Literals.PACKAGE__MEMBER, + TypesFactory.eINSTANCE.createAnnotation())); + newChildDescriptors.add (createChildParameter (TypesPackage.Literals.PACKAGE__DOMAIN, diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageMemberItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageMemberItemProvider.java index 6f15be2d57..b19ff776b5 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageMemberItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PackageMemberItemProvider.java @@ -17,9 +17,13 @@ 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.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; import org.yakindu.base.base.provider.NamedElementItemProvider; import org.yakindu.base.types.PackageMember; +import org.yakindu.base.types.TypesPackage; /** * This is the item provider adapter for a {@link org.yakindu.base.types.PackageMember} object. @@ -50,10 +54,56 @@ public List getPropertyDescriptors(Object object) { if (itemPropertyDescriptors == null) { super.getPropertyDescriptors(object); + addAnnotationsPropertyDescriptor(object); + addIdPropertyDescriptor(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 adds a property descriptor for the Id feature. + * + * + * @generated + */ + protected void addIdPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_PackageMember_id_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_PackageMember_id_feature", "_UI_PackageMember_type"), + TypesPackage.Literals.PACKAGE_MEMBER__ID, + false, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + /** * This returns PackageMember.gif. * @@ -89,6 +139,12 @@ public String getText(Object object) { @Override public void notifyChanged(Notification notification) { updateChildren(notification); + + switch (notification.getFeatureID(PackageMember.class)) { + case TypesPackage.PACKAGE_MEMBER__ID: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } super.notifyChanged(notification); } diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PrimitiveTypeItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PrimitiveTypeItemProvider.java index e34117a944..8a0f07cb42 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PrimitiveTypeItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/PrimitiveTypeItemProvider.java @@ -21,10 +21,9 @@ import org.yakindu.base.types.TypesPackage; /** - * This is the item provider adapter for a - * {@link org.yakindu.base.types.PrimitiveType} object. + * This is the item provider adapter for a {@link org.yakindu.base.types.PrimitiveType} object. + * * - * * @generated */ public class PrimitiveTypeItemProvider extends TypeItemProvider { @@ -61,13 +60,19 @@ public List getPropertyDescriptors(Object object) { * @generated */ protected void addBaseTypePropertyDescriptor(Object object) { - itemPropertyDescriptors.add(createItemPropertyDescriptor( - ((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_PrimitiveType_baseType_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_PrimitiveType_baseType_feature", - "_UI_PrimitiveType_type"), TypesPackage.Literals.PRIMITIVE_TYPE__BASE_TYPE, true, false, true, - null, null, null)); + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_PrimitiveType_baseType_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_PrimitiveType_baseType_feature", "_UI_PrimitiveType_type"), + TypesPackage.Literals.PRIMITIVE_TYPE__BASE_TYPE, + true, + false, + true, + null, + null, + null)); } /** @@ -94,11 +99,10 @@ public String getText(Object object) { } /** - * 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 diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeAliasItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeAliasItemProvider.java index 1935535a75..b43fee0137 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeAliasItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeAliasItemProvider.java @@ -71,7 +71,10 @@ public List getPropertyDescriptors(Object object) { addTypePropertyDescriptor(object); addTypeArgumentsPropertyDescriptor(object); addNamePropertyDescriptor(object); + addAnnotationsPropertyDescriptor(object); + addIdPropertyDescriptor(object); addAbstractPropertyDescriptor(object); + addVisiblePropertyDescriptor(object); } return itemPropertyDescriptors; } @@ -142,6 +145,50 @@ protected void addNamePropertyDescriptor(Object object) { null)); } + /** + * 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 adds a property descriptor for the Id feature. + * + * + * @generated + */ + protected void addIdPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_PackageMember_id_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_PackageMember_id_feature", "_UI_PackageMember_type"), + TypesPackage.Literals.PACKAGE_MEMBER__ID, + false, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + /** * This adds a property descriptor for the Abstract feature. * @@ -164,6 +211,28 @@ protected void addAbstractPropertyDescriptor(Object object) { null)); } + /** + * This adds a property descriptor for the Visible feature. + * + * + * @generated + */ + protected void addVisiblePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Type_visible_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Type_visible_feature", "_UI_Type_type"), + TypesPackage.Literals.TYPE__VISIBLE, + true, + false, + false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, + null, + null)); + } + /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or @@ -245,7 +314,9 @@ public void notifyChanged(Notification notification) { switch (notification.getFeatureID(TypeAlias.class)) { case TypesPackage.TYPE_ALIAS__NAME: + case TypesPackage.TYPE_ALIAS__ID: case TypesPackage.TYPE_ALIAS__ABSTRACT: + case TypesPackage.TYPE_ALIAS__VISIBLE: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case TypesPackage.TYPE_ALIAS__CONSTRAINT: diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeItemProvider.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeItemProvider.java index dc9ed299cd..9dd6cc392d 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeItemProvider.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypeItemProvider.java @@ -55,6 +55,7 @@ public List getPropertyDescriptors(Object object) { super.getPropertyDescriptors(object); addAbstractPropertyDescriptor(object); + addVisiblePropertyDescriptor(object); } return itemPropertyDescriptors; } @@ -81,6 +82,28 @@ protected void addAbstractPropertyDescriptor(Object object) { null)); } + /** + * This adds a property descriptor for the Visible feature. + * + * + * @generated + */ + protected void addVisiblePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Type_visible_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Type_visible_feature", "_UI_Type_type"), + TypesPackage.Literals.TYPE__VISIBLE, + true, + false, + false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, + null, + null)); + } + /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or @@ -149,6 +172,7 @@ public void notifyChanged(Notification notification) { switch (notification.getFeatureID(Type.class)) { case TypesPackage.TYPE__ABSTRACT: + case TypesPackage.TYPE__VISIBLE: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case TypesPackage.TYPE__CONSTRAINT: diff --git a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypesItemProviderAdapterFactory.java b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypesItemProviderAdapterFactory.java index 14a418ae8c..21d484846b 100644 --- a/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypesItemProviderAdapterFactory.java +++ b/plugins/org.yakindu.base.types.edit/src/org/yakindu/base/types/provider/TypesItemProviderAdapterFactory.java @@ -100,6 +100,29 @@ public Adapter createPackageAdapter() { return packageItemProvider; } + /** + * This keeps track of the one adapter used for all {@link org.yakindu.base.types.Type} instances. + * + * + * @generated + */ + protected TypeItemProvider typeItemProvider; + + /** + * This creates an adapter for a {@link org.yakindu.base.types.Type}. + * + * + * @generated + */ + @Override + public Adapter createTypeAdapter() { + if (typeItemProvider == null) { + typeItemProvider = new TypeItemProvider(this); + } + + return typeItemProvider; + } + /** * This keeps track of the one adapter used for all {@link org.yakindu.base.types.Operation} instances. * @@ -445,6 +468,52 @@ public Adapter createTypeAliasAdapter() { return typeAliasItemProvider; } + /** + * This keeps track of the one adapter used for all {@link org.yakindu.base.types.Annotation} instances. + * + * + * @generated + */ + protected AnnotationItemProvider annotationItemProvider; + + /** + * This creates an adapter for a {@link org.yakindu.base.types.Annotation}. + * + * + * @generated + */ + @Override + public Adapter createAnnotationAdapter() { + if (annotationItemProvider == null) { + annotationItemProvider = new AnnotationItemProvider(this); + } + + return annotationItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link org.yakindu.base.types.AnnotatableElement} instances. + * + * + * @generated + */ + protected AnnotatableElementItemProvider annotatableElementItemProvider; + + /** + * This creates an adapter for a {@link org.yakindu.base.types.AnnotatableElement}. + * + * + * @generated + */ + @Override + public Adapter createAnnotatableElementAdapter() { + if (annotatableElementItemProvider == null) { + annotatableElementItemProvider = new AnnotatableElementItemProvider(this); + } + + return annotatableElementItemProvider; + } + /** * This returns the root adapter factory that contains this factory. * @@ -545,6 +614,7 @@ public void fireNotifyChanged(Notification notification) { */ public void dispose() { if (packageItemProvider != null) packageItemProvider.dispose(); + if (typeItemProvider != null) typeItemProvider.dispose(); if (operationItemProvider != null) operationItemProvider.dispose(); if (propertyItemProvider != null) propertyItemProvider.dispose(); if (parameterItemProvider != null) parameterItemProvider.dispose(); @@ -560,6 +630,8 @@ public void dispose() { if (rangeConstraintItemProvider != null) rangeConstraintItemProvider.dispose(); if (domainItemProvider != null) domainItemProvider.dispose(); if (typeAliasItemProvider != null) typeAliasItemProvider.dispose(); + if (annotationItemProvider != null) annotationItemProvider.dispose(); + if (annotatableElementItemProvider != null) annotatableElementItemProvider.dispose(); } } diff --git a/plugins/org.yakindu.base.types/model/types.ecore b/plugins/org.yakindu.base.types/model/types.ecore index 2746186a21..e84d3c01a2 100644 --- a/plugins/org.yakindu.base.types/model/types.ecore +++ b/plugins/org.yakindu.base.types/model/types.ecore @@ -74,7 +74,7 @@ - + @@ -86,4 +86,14 @@ + + + + + + + diff --git a/plugins/org.yakindu.base.types/plugin.xml b/plugins/org.yakindu.base.types/plugin.xml index 52393aa73e..9766bc6bde 100644 --- a/plugins/org.yakindu.base.types/plugin.xml +++ b/plugins/org.yakindu.base.types/plugin.xml @@ -12,6 +12,7 @@ uri="http://www.yakindu.org/base/base/2.0.0"> + + * A representation of the model object 'Annotatable Element'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.yakindu.base.types.AnnotatableElement#getAnnotations Annotations}
  • + *
+ * + * @see org.yakindu.base.types.TypesPackage#getAnnotatableElement() + * @model + * @generated + */ +public interface AnnotatableElement extends EObject { + /** + * Returns the value of the 'Annotations' reference list. + * The list contents are of type {@link org.yakindu.base.types.Annotation}. + * + *

+ * If the meaning of the 'Annotations' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Annotations' reference list. + * @see org.yakindu.base.types.TypesPackage#getAnnotatableElement_Annotations() + * @model + * @generated + */ + EList getAnnotations(); + +} // AnnotatableElement diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Annotation.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Annotation.java new file mode 100644 index 0000000000..1b1993d007 --- /dev/null +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Annotation.java @@ -0,0 +1,58 @@ +/** + */ +package org.yakindu.base.types; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Annotation'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.yakindu.base.types.Annotation#getProperties Properties}
  • + *
  • {@link org.yakindu.base.types.Annotation#getTargets Targets}
  • + *
+ * + * @see org.yakindu.base.types.TypesPackage#getAnnotation() + * @model + * @generated + */ +public interface Annotation extends PackageMember { + /** + * Returns the value of the 'Properties' containment reference list. + * The list contents are of type {@link org.yakindu.base.types.Property}. + * + *

+ * If the meaning of the 'Properties' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Properties' containment reference list. + * @see org.yakindu.base.types.TypesPackage#getAnnotation_Properties() + * @model containment="true" + * @generated + */ + EList getProperties(); + + /** + * Returns the value of the 'Targets' reference list. + * The list contents are of type {@link org.eclipse.emf.ecore.EObject}. + * + *

+ * If the meaning of the 'Targets' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Targets' reference list. + * @see org.yakindu.base.types.TypesPackage#getAnnotation_Targets() + * @model + * @generated + */ + EList getTargets(); + +} // Annotation diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/PackageMember.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/PackageMember.java index 27b427928c..68eaf6a737 100644 --- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/PackageMember.java +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/PackageMember.java @@ -20,7 +20,7 @@ * @model * @generated */ -public interface PackageMember extends NamedElement { +public interface PackageMember extends NamedElement, AnnotatableElement { /** * Returns the value of the 'Id' attribute. diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Parameter.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Parameter.java index 5927e03274..fb0ab6c34b 100644 --- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Parameter.java +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/Parameter.java @@ -8,7 +8,6 @@ import org.yakindu.base.base.NamedElement; - /** * * A representation of the model object 'Parameter'. diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/TypesFactory.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/TypesFactory.java index 59df8dec1e..db99f08262 100644 --- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/TypesFactory.java +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/TypesFactory.java @@ -178,6 +178,24 @@ public interface TypesFactory extends EFactory { */ TypeAlias createTypeAlias(); + /** + * Returns a new object of class 'Annotation'. + * + * + * @return a new object of class 'Annotation'. + * @generated + */ + Annotation createAnnotation(); + + /** + * Returns a new object of class 'Annotatable Element'. + * + * + * @return a new object of class 'Annotatable Element'. + * @generated + */ + AnnotatableElement createAnnotatableElement(); + /** * Returns the package supported by this factory. * diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotatableElementImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotatableElementImpl.java new file mode 100644 index 0000000000..e54f4cdeef --- /dev/null +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotatableElementImpl.java @@ -0,0 +1,130 @@ +/** + */ +package org.yakindu.base.types.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.yakindu.base.types.AnnotatableElement; +import org.yakindu.base.types.Annotation; +import org.yakindu.base.types.TypesPackage; + +/** + * + * An implementation of the model object 'Annotatable Element'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.yakindu.base.types.impl.AnnotatableElementImpl#getAnnotations Annotations}
  • + *
+ * + * @generated + */ +public class AnnotatableElementImpl extends EObjectImpl implements AnnotatableElement { + /** + * The cached value of the '{@link #getAnnotations() Annotations}' reference list. + * + * + * @see #getAnnotations() + * @generated + * @ordered + */ + protected EList annotations; + + /** + * + * + * @generated + */ + protected AnnotatableElementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return TypesPackage.Literals.ANNOTATABLE_ELEMENT; + } + + /** + * + * + * @generated + */ + public EList getAnnotations() { + if (annotations == null) { + annotations = new EObjectResolvingEList(Annotation.class, this, TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS); + } + return annotations; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: + return getAnnotations(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: + getAnnotations().clear(); + getAnnotations().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: + getAnnotations().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: + return annotations != null && !annotations.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //AnnotatableElementImpl diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotationImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotationImpl.java new file mode 100644 index 0000000000..3c27df2e3e --- /dev/null +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/AnnotationImpl.java @@ -0,0 +1,184 @@ +/** + */ +package org.yakindu.base.types.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.yakindu.base.types.Annotation; +import org.yakindu.base.types.Property; +import org.yakindu.base.types.TypesPackage; + +/** + * + * An implementation of the model object 'Annotation'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.yakindu.base.types.impl.AnnotationImpl#getProperties Properties}
  • + *
  • {@link org.yakindu.base.types.impl.AnnotationImpl#getTargets Targets}
  • + *
+ * + * @generated + */ +public class AnnotationImpl extends PackageMemberImpl implements Annotation { + /** + * The cached value of the '{@link #getProperties() Properties}' containment reference list. + * + * + * @see #getProperties() + * @generated + * @ordered + */ + protected EList properties; + + /** + * The cached value of the '{@link #getTargets() Targets}' reference list. + * + * + * @see #getTargets() + * @generated + * @ordered + */ + protected EList targets; + + /** + * + * + * @generated + */ + protected AnnotationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return TypesPackage.Literals.ANNOTATION; + } + + /** + * + * + * @generated + */ + public EList getProperties() { + if (properties == null) { + properties = new EObjectContainmentEList(Property.class, this, TypesPackage.ANNOTATION__PROPERTIES); + } + return properties; + } + + /** + * + * + * @generated + */ + public EList getTargets() { + if (targets == null) { + targets = new EObjectResolvingEList(EObject.class, this, TypesPackage.ANNOTATION__TARGETS); + } + return targets; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case TypesPackage.ANNOTATION__PROPERTIES: + return ((InternalEList)getProperties()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case TypesPackage.ANNOTATION__PROPERTIES: + return getProperties(); + case TypesPackage.ANNOTATION__TARGETS: + return getTargets(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case TypesPackage.ANNOTATION__PROPERTIES: + getProperties().clear(); + getProperties().addAll((Collection)newValue); + return; + case TypesPackage.ANNOTATION__TARGETS: + getTargets().clear(); + getTargets().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case TypesPackage.ANNOTATION__PROPERTIES: + getProperties().clear(); + return; + case TypesPackage.ANNOTATION__TARGETS: + getTargets().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case TypesPackage.ANNOTATION__PROPERTIES: + return properties != null && !properties.isEmpty(); + case TypesPackage.ANNOTATION__TARGETS: + return targets != null && !targets.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //AnnotationImpl diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/DeclarationImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/DeclarationImpl.java index e9fdd70b9d..0df3f7af49 100644 --- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/DeclarationImpl.java +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/DeclarationImpl.java @@ -13,6 +13,8 @@ import org.eclipse.emf.ecore.util.EObjectResolvingEList; 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.Declaration; import org.yakindu.base.types.PackageMember; import org.yakindu.base.types.Type; @@ -30,6 +32,7 @@ *
  • {@link org.yakindu.base.types.impl.DeclarationImpl#getType Type}
  • *
  • {@link org.yakindu.base.types.impl.DeclarationImpl#getTypeArguments Type Arguments}
  • *
  • {@link org.yakindu.base.types.impl.DeclarationImpl#getName Name}
  • + *
  • {@link org.yakindu.base.types.impl.DeclarationImpl#getAnnotations Annotations}
  • *
  • {@link org.yakindu.base.types.impl.DeclarationImpl#getId Id}
  • * * @@ -76,6 +79,16 @@ public abstract class DeclarationImpl extends EObjectImpl implements Declaration */ 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. * @@ -176,6 +189,18 @@ public void setName(String newName) { eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.DECLARATION__NAME, oldName, name)); } + /** + * + * + * @generated + */ + public EList getAnnotations() { + if (annotations == null) { + annotations = new EObjectResolvingEList(Annotation.class, this, TypesPackage.DECLARATION__ANNOTATIONS); + } + return annotations; + } + /** * * @@ -191,6 +216,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return getTypeArguments(); case TypesPackage.DECLARATION__NAME: return getName(); + case TypesPackage.DECLARATION__ANNOTATIONS: + return getAnnotations(); case TypesPackage.DECLARATION__ID: return getId(); } @@ -216,6 +243,10 @@ public void eSet(int featureID, Object newValue) { case TypesPackage.DECLARATION__NAME: setName((String)newValue); return; + case TypesPackage.DECLARATION__ANNOTATIONS: + getAnnotations().clear(); + getAnnotations().addAll((Collection)newValue); + return; } super.eSet(featureID, newValue); } @@ -237,6 +268,9 @@ public void eUnset(int featureID) { case TypesPackage.DECLARATION__NAME: setName(NAME_EDEFAULT); return; + case TypesPackage.DECLARATION__ANNOTATIONS: + getAnnotations().clear(); + return; } super.eUnset(featureID); } @@ -255,6 +289,8 @@ public boolean eIsSet(int featureID) { return typeArguments != null && !typeArguments.isEmpty(); case TypesPackage.DECLARATION__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case TypesPackage.DECLARATION__ANNOTATIONS: + return annotations != null && !annotations.isEmpty(); case TypesPackage.DECLARATION__ID: return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId()); } @@ -274,6 +310,12 @@ public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { default: return -1; } } + if (baseClass == AnnotatableElement.class) { + switch (derivedFeatureID) { + case TypesPackage.DECLARATION__ANNOTATIONS: return TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS; + default: return -1; + } + } if (baseClass == PackageMember.class) { switch (derivedFeatureID) { case TypesPackage.DECLARATION__ID: return TypesPackage.PACKAGE_MEMBER__ID; @@ -296,6 +338,12 @@ public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { default: return -1; } } + if (baseClass == AnnotatableElement.class) { + switch (baseFeatureID) { + case TypesPackage.ANNOTATABLE_ELEMENT__ANNOTATIONS: return TypesPackage.DECLARATION__ANNOTATIONS; + default: return -1; + } + } if (baseClass == PackageMember.class) { switch (baseFeatureID) { case TypesPackage.PACKAGE_MEMBER__ID: return TypesPackage.DECLARATION__ID; diff --git a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/PackageMemberImpl.java b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/PackageMemberImpl.java index 6d8e541ac3..c983827e70 100644 --- a/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/PackageMemberImpl.java +++ b/plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/PackageMemberImpl.java @@ -2,8 +2,14 @@ */ package org.yakindu.base.types.impl; +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; import org.yakindu.base.base.impl.NamedElementImpl; +import org.yakindu.base.types.AnnotatableElement; +import org.yakindu.base.types.Annotation; import org.yakindu.base.types.PackageMember; import org.yakindu.base.types.TypesPackage; import org.yakindu.base.types.TypesUtil; @@ -16,12 +22,22 @@ * The following features are implemented: *

    *
      + *
    • {@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)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)newValue); + return; case TypesPackage.TYPE_ALIAS__CONSTRAINT: getConstraint().clear(); getConstraint().addAll((Collection)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 clazz) { } } } + protected void assertAllTransitionsAreValid(Class clazz) { Iterator iter; iter = statechart.eAllContents(); @@ -444,16 +449,16 @@ protected void assertAllTransitionsAreValid(Class 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() { + } + }