Commit 4d5ce9e8 authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

treat insert single prec as special connected res.

Fixed bug that caused assoc to be left if resolving single item
parent 55068302
...@@ -613,9 +613,9 @@ class ConflictPanel extends Composite { ...@@ -613,9 +613,9 @@ class ConflictPanel extends Composite {
// These are the cases where nothing is affected // These are the cases where nothing is affected
if(resolutionOptions.getSelectionIndex() == 1) // Shift if(resolutionOptions.getSelectionIndex() == 1) // Shift
cupConflictsView.insertSinglePrecedence(srdetails.shift,Precedence.Type.Left); cupConflictsView.insertSinglePrecedence(srdetails.shift,Precedence.Type.NonAssoc);
else if (resolutionOptions.getSelectionIndex() == 2) // Reduce else if (resolutionOptions.getSelectionIndex() == 2) // Reduce
cupConflictsView.insertSinglePrecedence(srdetails.reduce,Precedence.Type.Left); cupConflictsView.insertSinglePrecedence(srdetails.reduce,Precedence.Type.NonAssoc);
} }
else { else {
...@@ -653,7 +653,7 @@ class ConflictPanel extends Composite { ...@@ -653,7 +653,7 @@ class ConflictPanel extends Composite {
lr_item_core item2 = new lr_item_core(rrc.getConflictItem2().the_production(),rrc.getConflictItem2().dot_pos()); lr_item_core item2 = new lr_item_core(rrc.getConflictItem2().the_production(),rrc.getConflictItem2().dot_pos());
if(!cupConflictsView.settingOrderAffetsOtherConflicts(item1, item2)){ if(!cupConflictsView.settingOrderAffetsOtherConflicts(item1, item2)){
ReduceReduceReorder rrr = new ReduceReduceReorder(cupConflictsView.getDocument(),cupConflictsView.isThresholdPresent()); ReduceReduceReorder rrr = new ReduceReduceReorder(cupConflictsView.getDocument());
if(resolutionOptions.getSelectionIndex() == 1){ if(resolutionOptions.getSelectionIndex() == 1){
rrr.moveItemToVeryEnd(rrc.getConflictItem1()); rrr.moveItemToVeryEnd(rrc.getConflictItem1());
......
...@@ -561,28 +561,9 @@ public class CupConflictsView extends FailableView ...@@ -561,28 +561,9 @@ public class CupConflictsView extends FailableView
* the associativity * the associativity
*/ */
void insertSinglePrecedence(terminal terminal, Precedence.Type assoc) { void insertSinglePrecedence(terminal terminal, Precedence.Type assoc) {
try { PrecedenceToInsert pti = new PrecedenceToInsert();
String toInsert = "precedence " + assoc.toString().toLowerCase() + " " + terminal.name() pti.setAssoc(terminal, assoc);
+ "; // Inserted by Eclipse plugin"; pti.apply(editor.getDocument());
IDocument document = editor.getDocument();
ParserResult r = Model.getInstanceForDocument(document).getAstModel();
int positionForPrec = 0;
if (r.precedences.size() == 0) {
// Precedences are located immediately after the last symbol
// decl
positionForPrec = r.symbols.get(r.symbols.size() - 1).getEnd().getOffsetFromStart();
toInsert = "\n\n//Precedences added by Eclipse plugin\n" + toInsert;
} else {
positionForPrec = r.precedences.get(0).getRange().getBegin().getOffsetFromStart();
toInsert = toInsert + "\n";
}
document.replace(positionForPrec, 0, toInsert);
} catch (BadLocationException e) {
e.printStackTrace();
}
} }
boolean insertingPrecAffectsOtherConflicts(terminal t) { boolean insertingPrecAffectsOtherConflicts(terminal t) {
......
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