Skip to content

Commit

Permalink
Fix changed rule detection during IncrementalParserData walk
Browse files Browse the repository at this point in the history
  • Loading branch information
dberlin committed Apr 7, 2019
1 parent 363a23d commit 57b6761
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions runtime/Java/src/org/antlr/v4/runtime/IncrementalParserData.java
Expand Up @@ -234,6 +234,11 @@ private void indexAndAdjustParseTree(IncrementalParserRuleContext tree) {
ParseTreeWalker.DEFAULT.walk(listener, tree);
}

@Override
public void exitEveryRule(ParserRuleContext ctx) {

}

/**
* This class does two things: 1. Simple indexer to record the rule index and
* token index start of each rule. 2. Adjust the min max token ranges for any
Expand Down Expand Up @@ -344,22 +349,20 @@ public void enterEveryRule(ParserRuleContext ctx) {
// reuse. Also don't touch contexts without an epoch. They must
// represent something the incremental parser never saw,
// since it sets epochs on all contexts it touches.
boolean usableContext = (incCtx.epoch != -1) && !ruleAffectedByTokenChanges(incCtx);
if (usableContext) {
if (tokenOffsets != null && tokenOffsets.size() != 0) {
adjustMinMax(incCtx);
if (incCtx.epoch == -1)
return;
boolean mayNeedAdjustment = tokenOffsets != null && tokenOffsets.size() != 0
if (mayNeedAdjustment) {
adjustMinMax(incCtx);
}
if (!ruleAffectedByTokenChanges(incCtx)) {
if (mayNeedAdjustment) {
adjustStartStop(incCtx);
}
String key = getKeyFromContext(incCtx);
ruleStartMap.put(key, incCtx);
}
}

@Override
public void exitEveryRule(ParserRuleContext ctx) {

}
}

;
}

0 comments on commit 57b6761

Please sign in to comment.