private static boolean hasParentInSet(IJavaScriptElement elem, Set set) { IJavaScriptElement parent = elem.getParent(); while (parent != null) { if (set.contains(parent)) return true; parent = parent.getParent(); } return false; }
/** * Returns a collection of all the parents of this element up to (but not including) the root of * this tree in bottom-up order. If the given element is not a descendant of the root of this * tree, <code>null</code> is returned. */ private ArrayList getAncestors(IJavaScriptElement element) { IJavaScriptElement parent = element.getParent(); if (parent == null) { return null; } ArrayList parents = new ArrayList(); while (!parent.equals(this.changedElement)) { parents.add(parent); parent = parent.getParent(); if (parent == null) { return null; } } parents.trimToSize(); return parents; }
/** Returns whether the two java elements are equals and have the same parent. */ protected boolean equalsAndSameParent(IJavaScriptElement e1, IJavaScriptElement e2) { IJavaScriptElement parent1; return e1.equals(e2) && ((parent1 = e1.getParent()) != null) && parent1.equals(e2.getParent()); }