Commit e183076d authored by Michael Schwarz's avatar Michael Schwarz

ignoreRRAFterLine location improved

parent bd40666b
......@@ -73,6 +73,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
private HashMap<terminal,Integer> terminalsAffectConflicts;
PrecedenceToInsert currentPrecs;
private int ignoreRRAfterLine;
class ShiftReduceDetails {
terminal shift,reduce;
boolean shiftAffectsOthers,reduceAffectsOthers;
......@@ -193,6 +195,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
}
private void updateConflicts(ConflictResolutionManager crm) {
ignoreRRAfterLine = computeIgnoreRRAfter();
List<Conflict> conflicts = new ArrayList<>();
terminalsAffectConflicts = new HashMap<>();
for (int i = 0; i < crm.getAllConflicts().size(); i++) {
......@@ -524,26 +528,28 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
}
}
private int computeIgnoreRRAfter(){
IDocument document = editor.getDocument();
int offset = document.get().indexOf(TRESHOLD_STRING);
if(offset == -1){
return -1;
}
try {
return document.getLineOfOffset(offset)+1;
} catch (BadLocationException e) {
return -1;
}
}
private boolean isIgnored(Conflict c){
if(c instanceof ReduceReduceConflict){
ReduceReduceConflict rrc = (ReduceReduceConflict) c;
IDocument document = editor.getDocument();
int offset = document.get().indexOf(TRESHOLD_STRING);
if(offset == -1){
return false;
}
int treshold;
try {
treshold = document.getLineOfOffset(offset)+1;
} catch (BadLocationException e) {
return false;
}
return (rrc.getConflictItem1().the_production().getAstNode().getEnd().getLine() > treshold)
&& (rrc.getConflictItem2().the_production().getAstNode().getEnd().getLine() > treshold);
return ((ignoreRRAfterLine >= 0)
&& (rrc.getConflictItem1().the_production().getAstNode().getEnd().getLine() > ignoreRRAfterLine)
&& (rrc.getConflictItem2().the_production().getAstNode().getEnd().getLine() > ignoreRRAfterLine));
}
else {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment