diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/KernelModelElementUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/KernelModelElementUtils.java index 9394ecb8d5b9047f68b2539478cd8176ec78352e..e44ff67f593815366722034bc4cf6b16d939b9f3 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/KernelModelElementUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/KernelModelElementUtils.java @@ -32,7 +32,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: E77DC792D810E6886DD06EC35AB21D0D + * @ConQAT.Rating YELLOW Hash: 4C3069E19588989D191FB58D5D51CE66 */ public final class KernelModelElementUtils { @@ -138,4 +138,34 @@ public final class KernelModelElementUtils { } return null; } + + /** + * Computes the qualified name relative to a parent element. + * + * @param parent + * the parent element. + * @param element + * the element whose relative name will be computed. + * @return the qualified name relative to the parent element or null if the + * parent element is not a container for element + */ + public static String computeRelativeName(INamedElement parent, + INamedElement element) { + String qualifiedName = element.getName(); + + EObject current = element.eContainer(); + while (current != null && current != parent) { + if (current instanceof INamedElement) { + qualifiedName = ((INamedElement) current).getName() + "." + + qualifiedName; + } + current = current.eContainer(); + } + + if (current == null) { + return null; + } + + return qualifiedName; + } }