/** * Allows to register given wrap as a parent of the current wrap. * * <p><code>'Parent'</code> wrap registration here means that {@link #isChildOf(WrapImpl, * LeafBlockWrapper)} returns <code>'true'</code> if given wrap is used as a <code>'parent'</code> * argument. * * @param parent parent wrap to register for the current wrap */ void registerParent(@Nullable WrapImpl parent) { if (parent == this) return; if (parent == null) return; if (parent.isChildOf(this, null)) return; if (myParents == emptyParentsSet) myParents = new HashSet<WrapImpl>(5); myParents.add(parent); }
public boolean isChildOf(@Nullable final WrapImpl wrap, LeafBlockWrapper leaf) { if (getIgnoreParentWraps()) return false; if (leaf != null && myIgnoredWraps != null) { Collection<LeafBlockWrapper> leaves = myIgnoredWraps.get(wrap); if (leaves != null && leaves.contains(leaf)) { return false; } } for (WrapImpl parent : myParents) { if (parent == wrap) return true; if (parent.isChildOf(wrap, leaf)) return true; } return false; }