Skip to content

Commit

Permalink
[#6] Fix incorrect walk logic
Browse files Browse the repository at this point in the history
We need to descend into child nodes of the current node, even if we're
not actually visiting the current node because we're in an anonymous
state. After all, anonymous states appear becuase they're intermediate
states in transits that lead to named nodes, so not descending in this
case could mean failing to visit some nodes corresponding to named states.
  • Loading branch information
andylowry committed Sep 19, 2018
1 parent 6f172ab commit bac0cb4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ private Optional<JsonNode> visit(JsonNode node) {
boolean replaced = false;
boolean descend = true;
boolean keepVisiting = state != null ? (state.isAnonymous() ? visitAnonymousStates : true) : walkOffRoad;
// don't descend into children if we're not visiting this node in the first
// place
Disposition disp = keepVisiting ? Disposition.descend() : Disposition.done();
// set up default disposition if we're not visiting this state:
// - descend if because it's anonymous (we may hit named states during descent)
// - done if because we're off-road (we'll be off-road throughout descent)
Disposition disp = state != null || walkOffRoad ? Disposition.descend() : Disposition.done();
while (keepVisiting) {
State<E> currentState = tracker.getCurrentState();
disp = visitMethod.visit(node, currentState,
Expand Down

0 comments on commit bac0cb4

Please sign in to comment.