Skip to content

Commit

Permalink
manage null ast nodes and fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco authored and tkobayas committed Oct 11, 2024
1 parent bf34cbf commit 7e71947
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ public static boolean isAfterSymbol(ParseTree node, int symbol, int row, int col
}

public static int getNodeIndex(ParseTree node) {
// TODO Fix NPE
if (node instanceof TerminalNode) {
return ((TerminalNode) node).getSymbol().getTokenIndex();
}
return getNodeIndex(node.getChild(node.getChildCount()-1));
return node.getChildCount() == 0 ? 0: getNodeIndex(node.getChild(node.getChildCount()-1));
}
}

0 comments on commit 7e71947

Please sign in to comment.