示例#1
0
  public static List<Expression> getAllExpressions(ThingMLElement self, Class clazz) {
    List<Expression> result = new ArrayList<Expression>();
    TreeIterator<EObject> it = self.eAllContents();
    while (it.hasNext()) {
      EObject o = it.next();
      if (clazz.isInstance(o)) result.add((Expression) o);
    }

    if (clazz.isInstance(self)) result.add((Expression) self);
    return result;
  }
示例#2
0
 public static <C> C findContainer(EObject eObject, Class<C> cClass) {
   while (eObject != null && !cClass.isAssignableFrom(eObject.getClass())) {
     eObject = eObject.eContainer();
   }
   return (C) eObject;
 }