Skip to content
Snippets Groups Projects
Commit 0ac40bdc authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

added a small utility function

parent 9608e213
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService; ...@@ -32,7 +32,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author hoelzl * @author hoelzl
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating YELLOW Hash: E77DC792D810E6886DD06EC35AB21D0D * @ConQAT.Rating YELLOW Hash: 4C3069E19588989D191FB58D5D51CE66
*/ */
public final class KernelModelElementUtils { public final class KernelModelElementUtils {
...@@ -138,4 +138,34 @@ public final class KernelModelElementUtils { ...@@ -138,4 +138,34 @@ public final class KernelModelElementUtils {
} }
return null; 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;
}
} }
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