Skip to content
Snippets Groups Projects
Commit fe4c4952 authored by Simon Barner's avatar Simon Barner
Browse files

DerivedAnnotationBase -> IDerivedAnnotation<T>

 - Change return type of getValue() to T
 - This allows for more type safe implementation of the underlying calculations
 - The former abstract base class DerivedAnnotationBase used Object as a return type for getValue() to due an EMF code generation bug for generics if the base class is located in a different .ecore file than the concrete class. For interfaces, this bug is not triggered.
  
refs 1841
parent 6086120c
No related branches found
No related tags found
No related merge requests found
...@@ -21,24 +21,24 @@ import org.eclipse.emf.ecore.EClass; ...@@ -21,24 +21,24 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EFactory; import org.eclipse.emf.ecore.EFactory;
import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.EditingSupport;
import org.fortiss.tooling.base.model.base.DerivedAnnotationBase;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IDerivedAnnotation;
/** /**
* Base class for {@link IAnnotationValueProvider} for derived annotations (i.e., based on * Base class for {@link IAnnotationValueProvider} for derived annotations (i.e., based on
* {@link DerivedAnnotationBase}). * {@link IDerivedAnnotation}).
* *
* @author barner * @author barner
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating RED Hash: * @ConQAT.Rating RED Hash:
*/ */
public abstract class DerivedAnnotationValueProviderBase<T extends DerivedAnnotationBase> extends public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnotation<?>> extends
ValueProviderBase<T> { ValueProviderBase<T> {
/** /**
* Constructs a {@link IAnnotationValueProvider} for derived annotations (i.e., based on * Constructs a {@link IAnnotationValueProvider} for derived annotations (i.e., based on
* {@link DerivedAnnotationBase}). * {@link IDerivedAnnotation}).
*/ */
public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass, public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass,
EFactory annotationFactory) { EFactory annotationFactory) {
......
...@@ -64,8 +64,9 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect ...@@ -64,8 +64,9 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
Set<IModelElement> watchedModelElements = new HashSet<IModelElement>(); Set<IModelElement> watchedModelElements = new HashSet<IModelElement>();
/** /**
* {@link Adapter} to watch for the addition or removal of model elements to/from elements * {@link Adapter} to watch for the addition, removal or value change of model elements
* visible in this {@link AnnotationViewPartBase} (to trigger according updates). * to/from/in elements visible in this {@link AnnotationViewPartBase} (to trigger according
* updates).
*/ */
private final Adapter changeListener = new AdapterImpl() { private final Adapter changeListener = new AdapterImpl() {
@Override @Override
......
...@@ -152,6 +152,16 @@ ...@@ -152,6 +152,16 @@
<details key="documentation" value="An array of model element specifications."/> <details key="documentation" value="An array of model element specifications."/>
</eAnnotations> </eAnnotations>
</eClassifiers> </eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IDerivedAnnotation" abstract="true"
interface="true" eSuperTypes="#//element/IAnnotatedSpecification #//element/IHiddenSpecification">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Base class for {@link IAnnotationSpecification}s that are derived from the state of other annotations and/or model elements.&#xD;&#xA;&#xD;&#xA;&lt;ul>&#xD;&#xA;&lt;li>Concrete specifications must provide a specialized getValue() {@link EOperation}s that perform the required calculation. Example: Calculation of {@link Component} WCET for current deployment (if available) based on {@link Component} instruction count and performance (e.g., MIPS) of {@link ExecutionUnit}, some warning indicator otherwise. &lt;/li>&#xD;&#xA;&lt;li>Concrete specifications may provide additional {@link EOperation} that provide an advanced query interface to the annoation. Example: WCET for an explicitly specified {@link ExecutionUnit}. This can be used e.g. in a DSE to explore different deployments.&lt;/li>&#xD;&#xA;&lt;li>The corresponding {@link IAnnotationValueProvider} should be based on {@link DerivedAnnotationValueProviderBase}.&#xD;&#xA;&lt;/ul>"/>
</eAnnotations>
<eTypeParameters name="T"/>
<eOperations name="getValue">
<eGenericType eTypeParameter="#//element/IDerivedAnnotation/T"/>
</eOperations>
</eClassifiers>
</eSubpackages> </eSubpackages>
<eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout" <eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout"
nsPrefix="org-fortiss-tooling-base-model-layout"> nsPrefix="org-fortiss-tooling-base-model-layout">
...@@ -294,16 +304,5 @@ ...@@ -294,16 +304,5 @@
</eAnnotations> </eAnnotations>
</eOperations> </eOperations>
</eClassifiers> </eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DerivedAnnotationBase" abstract="true"
eSuperTypes="#//element/IAnnotatedSpecification #//element/IHiddenSpecification">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Base class for {@link IAnnotationSpecification}s that are derived from the state of other annotations and/or model elements.&#xD;&#xA;&#xD;&#xA;&lt;ul>&#xD;&#xA;&lt;li>Concrete specifications must provide a specialized getValue() {@link EOperation}s that perform the required calculation. Example: Calculation of {@link Component} WCET for current deployment (if available) based on {@link Component} instruction count and performance (e.g., MIPS) of {@link ExecutionUnit}, some warning indicator otherwise. &lt;/li>&#xD;&#xA;&lt;li>Concrete specifications may provide additional {@link EOperation} that provide an advanced query interface to the annoation. Example: WCET for an explicitly specified {@link ExecutionUnit}. This can be used e.g. in a DSE to explore different deployments.&lt;/li>&#xD;&#xA;&lt;li>The corresponding {@link IAnnotationValueProvider} should be based on {@link DerivedAnnotationValueProviderBase}.&#xD;&#xA;&lt;/ul>"/>
</eAnnotations>
<eOperations name="getValue" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return null;"/>
</eAnnotations>
</eOperations>
</eClassifiers>
</eSubpackages> </eSubpackages>
</ecore:EPackage> </ecore:EPackage>
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
</genClasses> </genClasses>
<genClasses image="false" ecoreClass="base.ecore#//element/IHiddenSpecification"/> <genClasses image="false" ecoreClass="base.ecore#//element/IHiddenSpecification"/>
<genClasses ecoreClass="base.ecore#//element/IAnnotatedSpecification"/> <genClasses ecoreClass="base.ecore#//element/IAnnotatedSpecification"/>
<genClasses image="false" ecoreClass="base.ecore#//element/IDerivedAnnotation">
<genTypeParameters ecoreTypeParameter="base.ecore#//element/IDerivedAnnotation/T"/>
<genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/getValue"/>
</genClasses>
</nestedGenPackages> </nestedGenPackages>
<nestedGenPackages prefix="Layout" basePackage="org.fortiss.tooling.base.model" <nestedGenPackages prefix="Layout" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//layout"> disposableProviderFactory="true" ecorePackage="base.ecore#//layout">
...@@ -97,9 +101,6 @@ ...@@ -97,9 +101,6 @@
<genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getURI"/> <genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getURI"/>
<genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getName"/> <genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getName"/>
</genClasses> </genClasses>
<genClasses image="false" ecoreClass="base.ecore#//base/DerivedAnnotationBase">
<genOperations ecoreOperation="base.ecore#//base/DerivedAnnotationBase/getValue"/>
</genClasses>
</nestedGenPackages> </nestedGenPackages>
</genPackages> </genPackages>
</genmodel:GenModel> </genmodel:GenModel>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment