Commit 863d9661 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

adds the method isAncestor

refs 2955
parent 74a4199f
......@@ -60,7 +60,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: DC361AE6E00DAE9F9178257FA915CCC4
* @ConQAT.Rating YELLOW Hash: A74FA7C1F289F4F252E353D4F2AEC64E
*/
public class EcoreUtils {
......@@ -308,6 +308,22 @@ public class EcoreUtils {
return null;
}
/**
* Returns true if <code>candidateAncestor</code> is an ancestor of <code>startElement</code>.
*
* An element is not an ancestor of itself!
*/
public static boolean isAncestor(EObject startElement, EObject candidateAncestor) {
EObject currentParent = startElement.eContainer();
while(currentParent != null) {
if(currentParent == candidateAncestor) {
return true;
}
currentParent = currentParent.eContainer();
}
return false;
}
/**
* Posts a {@link Notification} with an event type ID outside the EMF
* default notification IDs to cause UI refreshes.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment