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

- Add instantiateAnnotationsRecursive(IModelElement element)

parent 74911175
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getEClassForClass;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getParentsWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
......@@ -27,6 +28,8 @@ 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.util.EcoreUtil;
import org.fortiss.tooling.base.annotation.IAnnotationValueService;
import org.fortiss.tooling.base.decompose.HierarchicElementCompositorBase;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
......@@ -38,7 +41,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 727464C60F865D4C9D5ACEDA3A6F4561
* @ConQAT.Rating YELLOW Hash: 2CBB6FE26D2ACA2DC628D90CB72A9D3D
*/
public class AnnotationUtils {
......@@ -66,6 +69,23 @@ public class AnnotationUtils {
return newAnnotation;
}
/**
* Recursively instantiates the annotations for a given {@link IModelElement} and its offspring.
* This is useful to ensure that all annotations are available for programmatically created
* models. While the {@link HierarchicElementCompositorBase} could be used to ensure the
* instantiation of annotations in model-transformations, too, this is not always possible (or
* convenient).
*
* @param element
* {@link IModelElement} for which annotations should be instantiated recursively.
*/
public static void instantiateAnnotationsRecursive(IModelElement element) {
IAnnotationValueService.INSTANCE.instantiateAnnotations(element);
for(IModelElement child : getChildrenWithType(element, IModelElement.class)) {
IAnnotationValueService.INSTANCE.instantiateAnnotations(child);
}
}
/**
* <p>
* Returns the annotation of a given {@code Class<T>} from a given {@code modelElement}. If the
......
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