Commit e183076d authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

ignoreRRAFterLine location improved

parent bd40666b
...@@ -73,6 +73,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -73,6 +73,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
private HashMap<terminal,Integer> terminalsAffectConflicts; private HashMap<terminal,Integer> terminalsAffectConflicts;
PrecedenceToInsert currentPrecs; PrecedenceToInsert currentPrecs;
private int ignoreRRAfterLine;
class ShiftReduceDetails { class ShiftReduceDetails {
terminal shift,reduce; terminal shift,reduce;
boolean shiftAffectsOthers,reduceAffectsOthers; boolean shiftAffectsOthers,reduceAffectsOthers;
...@@ -193,6 +195,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -193,6 +195,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
} }
private void updateConflicts(ConflictResolutionManager crm) { private void updateConflicts(ConflictResolutionManager crm) {
ignoreRRAfterLine = computeIgnoreRRAfter();
List<Conflict> conflicts = new ArrayList<>(); List<Conflict> conflicts = new ArrayList<>();
terminalsAffectConflicts = new HashMap<>(); terminalsAffectConflicts = new HashMap<>();
for (int i = 0; i < crm.getAllConflicts().size(); i++) { for (int i = 0; i < crm.getAllConflicts().size(); i++) {
...@@ -524,26 +528,28 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -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){ private boolean isIgnored(Conflict c){
if(c instanceof ReduceReduceConflict){ if(c instanceof ReduceReduceConflict){
ReduceReduceConflict rrc = (ReduceReduceConflict) c; ReduceReduceConflict rrc = (ReduceReduceConflict) c;
IDocument document = editor.getDocument(); return ((ignoreRRAfterLine >= 0)
&& (rrc.getConflictItem1().the_production().getAstNode().getEnd().getLine() > ignoreRRAfterLine)
int offset = document.get().indexOf(TRESHOLD_STRING); && (rrc.getConflictItem2().the_production().getAstNode().getEnd().getLine() > ignoreRRAfterLine));
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);
} }
else { else {
return false; return false;
......
Supports Markdown
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