Return first ancestor of p that is not an only child including p. So if p.getParent().getChildCount()>1, this returns p. If we have found a chain rule at p's parent (p is its only child), then move p to its parent and try again.
(ParserRuleContext p)
| 408 | * move p to its parent and try again. |
| 409 | */ |
| 410 | public static ParserRuleContext getParentClosure(ParserRuleContext p) { |
| 411 | if ( p==null ) return null; |
| 412 | // if p not an only child, return p |
| 413 | if ( p.getParent()==null || p.getParent().getChildCount()>1 ) return p; |
| 414 | // we found a chain rule node |
| 415 | return getParentClosure(p.getParent()); |
| 416 | } |
| 417 | |
| 418 | /** Walk upwards from node while p.start == token; return null if there is |
| 419 | * no ancestor starting at token. |
nothing calls this directly
no test coverage detected