MCPcopy Create free account
hub / github.com/antlr/codebuff / getDeltaToAncestor

Method getDeltaToAncestor

src/org/antlr/codebuff/Trainer.java:491–500  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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;

Callers 1

getAlignmentCategoryMethod · 0.95

Calls 1

getParentMethod · 0.45

Tested by

no test coverage detected