Skip to content

Instantly share code, notes, and snippets.

@Clemzd
Created January 6, 2015 10:56
Show Gist options
  • Save Clemzd/63cb84b6f431eef08e5d to your computer and use it in GitHub Desktop.
Save Clemzd/63cb84b6f431eef08e5d to your computer and use it in GitHub Desktop.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
IStructuredSelection selection = (IStructuredSelection) targetPart
.getSite().getSelectionProvider().getSelection();
EObject object = (EObject) selection.getFirstElement();
EList<EReference> references = object.eClass().getEAllReferences();
int sum = 0;
for(EReference r : references){
EList children = (EList) object.eGet(r);
sum += children.size();
}
System.out.println("The element has " + sum + " children");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment