/** Return true if t is u's parent or a node on path to root from u. * Use == not equals(). * * @since 4.5.1 */ public static boolean isAncestorOf(Tree t, Tree u) { if ( t==null || u==null || t.getParent()==null ) return false; Tree p = u.getParent(); while ( p!=null ) { if ( t==p ) return true; p = p.getParent(); } return false; }
/** Return a list of all ancestors of this node. The first node of * list is the root and the last is the parent of this node. * * @since 4.5.1 */ public static List<? extends Tree> getAncestors(Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(0, t); // insert at start t = t.getParent(); } return ancestors; }
@Override public boolean isChildOfParent(Tree node, Tree parentNode) { return node.getParent() == parentNode; }
@Override public boolean isChildOfParent(Tree node, Tree parentNode) { return node.getParent() == parentNode; }
@Override public boolean isChildOfParent(Tree node, Tree parentNode) { return node.getParent() == parentNode; }
/** Return true if t is u's parent or a node on path to root from u. * Use == not equals(). * * @since 4.5.1 */ public static boolean isAncestorOf(Tree t, Tree u) { if ( t==null || u==null || t.getParent()==null ) return false; Tree p = u.getParent(); while ( p!=null ) { if ( t==p ) return true; p = p.getParent(); } return false; }
/** Return true if t is u's parent or a node on path to root from u. * Use == not equals(). * * @since 4.5.1 */ public static boolean isAncestorOf(Tree t, Tree u) { if ( t==null || u==null || t.getParent()==null ) return false; Tree p = u.getParent(); while ( p!=null ) { if ( t==p ) return true; p = p.getParent(); } return false; }
/** Return true if t is u's parent or a node on path to root from u. * Use == not equals(). * * @since 4.5.1 */ public static boolean isAncestorOf(Tree t, Tree u) { if ( t==null || u==null || t.getParent()==null ) return false; Tree p = u.getParent(); while ( p!=null ) { if ( t==p ) return true; p = p.getParent(); } return false; }
@Override public boolean isChildOfParent(Tree node, Tree parentNode) { return node.getParent() == parentNode; }
@Override public boolean isChildOfParent(Tree node, Tree parentNode) { return node.getParent() == parentNode; }
/** Get ancestors where the first element of the list is the parent of t */ public static List<? extends Tree> getAncestors(Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(t); // insert at start t = t.getParent(); } return ancestors; }
/** Return a list of all ancestors of this node. The first node of * list is the root and the last is the parent of this node. * * @since 4.5.1 */ public static List<? extends Tree> getAncestors(Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(0, t); // insert at start t = t.getParent(); } return ancestors; }
/** Return a list of all ancestors of this node. The first node of * list is the root and the last is the parent of this node. */ public static List<? extends Tree> getAncestors(Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(0, t); // insert at start t = t.getParent(); } return ancestors; }
/** Return a list of all ancestors of this node. The first node of * list is the root and the last is the parent of this node. * * @since 4.5.1 */ public static List<? extends Tree> getAncestors(Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(0, t); // insert at start t = t.getParent(); } return ancestors; }
/** Return a list of all ancestors of this node. The first node of * list is the root and the last is the parent of this node. * * @since 4.5.1 */ @NotNull public static List<? extends Tree> getAncestors(@NotNull Tree t) { if ( t.getParent()==null ) return Collections.emptyList(); List<Tree> ancestors = new ArrayList<Tree>(); t = t.getParent(); while ( t!=null ) { ancestors.add(0, t); // insert at start t = t.getParent(); } return ancestors; }
public static ParseTree getAncestorWithType(ParseTree t, Class<? extends ParseTree> clazz) { if ( t==null || clazz==null || t.getParent()==null ) return null; Tree p = t.getParent(); while ( p!=null ) { if ( p.getClass()==clazz ) return (ParseTree)p; p = p.getParent(); } return null; }