Return the number of hops to get to ancestor from node or -1 if we don't find ancestor on path to root.
(ParserRuleContext node, ParserRuleContext ancestor)
| 489 | * don't find ancestor on path to root. |
| 490 | */ |
| 491 | public static int getDeltaToAncestor(ParserRuleContext node, ParserRuleContext ancestor) { |
| 492 | int n = 0; |
| 493 | ParserRuleContext p = node; |
| 494 | while ( p!=null && p!=ancestor ) { |
| 495 | n++; |
| 496 | p = p.getParent(); |
| 497 | } |
| 498 | if ( p==null ) return -1; |
| 499 | return n; |
| 500 | } |
| 501 | |
| 502 | public static ParserRuleContext getAncestor(ParserRuleContext node, int delta) { |
| 503 | int n = 0; |
no test coverage detected