diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/.ratings b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/.ratings index fa1cde135ad9a2ddfbe8d3dacc81e5ca0b4353de..426ad25bab8d577764e01a3ed46af79eb0d49792 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/.ratings +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/.ratings @@ -1,6 +1,6 @@ AnnotationInstSpec.java 7a6cb55bfa9cafa9ead1f72089e554ee8142e8bf GREEN DerivedAnnotationValueProviderBase.java afedd21d3469127bbb20adb34c191b5c9c980f6c GREEN -EStructuralFeatureDescriptor.java 9665d0d3040278243dd37591535e411a90fa63bf GREEN +EStructuralFeatureDescriptor.java 169ece3fc0740c6ca1e5dde06a1be577d7cb9f80 YELLOW EStructuralFeatureValueProviderBase.java 287facbbce47c16d892bae82a214f64ceeef2263 GREEN IAnnotationValueProvider.java 08e0e5f66dc97865e9ac03e1ac646af332845e14 GREEN ValueProviderBase.java e4e866840845346ec99a4304048f5327c4890996 GREEN diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/EStructuralFeatureDescriptor.java b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/EStructuralFeatureDescriptor.java index 9665d0d3040278243dd37591535e411a90fa63bf..169ece3fc0740c6ca1e5dde06a1be577d7cb9f80 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/EStructuralFeatureDescriptor.java +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/annotation/valueprovider/EStructuralFeatureDescriptor.java @@ -15,6 +15,8 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.base.annotation.valueprovider; +import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; + import java.util.HashMap; import java.util.Map; @@ -29,6 +31,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; import org.fortiss.tooling.base.model.element.IDerivedAnnotation; import org.fortiss.tooling.base.model.element.IModelElement; +import org.fortiss.tooling.kernel.model.IProjectRootElement; /** * Description of a {@link EStructuralFeature} managed by a @@ -150,9 +153,43 @@ public class EStructuralFeatureDescriptor { */ public boolean isAvailableObject(EObject obj, IAnnotatedSpecification specification, EObject modelElement) { + + // Prevent elements at are contained in nested IProjectRoot elements from being listed + // (e.g., elements in DSE ModelSnapshots). + boolean rootElementSeen = false; + while(obj != null) { + if(obj instanceof IProjectRootElement) { + if(rootElementSeen) { + return false; + } + rootElementSeen = true; + } + obj = obj.eContainer(); + } + return true; } + /** + * For the given {@link IModelElement}, return the model element used as the scope to provide + * reference values. + */ + public EObject getValueRootElement(IModelElement modelElement) { + switch(getEReferenceScope()) { + case PROJECT: + IProjectRootElement rootElement = + getParentElement(modelElement, IProjectRootElement.class, true); + return rootElement != null ? rootElement.eContainer() : null; + case MODEL: + return getParentElement(modelElement, IProjectRootElement.class, true); + case SUB_MODEL: + case STRICT_SUB_MODEL: + return modelElement; + default: + throw new RuntimeException("Unsupported reference scope: " + getEReferenceScope()); + } + } + /** * Returns the type of the structural feature managed by this * {@link EStructuralFeatureDescriptor}.