Commit 4d5ce9e8 authored by Michael Schwarz's avatar Michael Schwarz

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 {
// These are the cases where nothing is affected
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
cupConflictsView.insertSinglePrecedence(srdetails.reduce,Precedence.Type.Left);
cupConflictsView.insertSinglePrecedence(srdetails.reduce,Precedence.Type.NonAssoc);
}
else {
......@@ -653,7 +653,7 @@ class ConflictPanel extends Composite {
lr_item_core item2 = new lr_item_core(rrc.getConflictItem2().the_production(),rrc.getConflictItem2().dot_pos());
if(!cupConflictsView.settingOrderAffetsOtherConflicts(item1, item2)){
ReduceReduceReorder rrr = new ReduceReduceReorder(cupConflictsView.getDocument(),cupConflictsView.isThresholdPresent());
ReduceReduceReorder rrr = new ReduceReduceReorder(cupConflictsView.getDocument());
if(resolutionOptions.getSelectionIndex() == 1){
rrr.moveItemToVeryEnd(rrc.getConflictItem1());
......
......@@ -561,28 +561,9 @@ public class CupConflictsView extends FailableView
* the associativity
*/
void insertSinglePrecedence(terminal terminal, Precedence.Type assoc) {
try {
String toInsert = "precedence " + assoc.toString().toLowerCase() + " " + terminal.name()
+ "; // Inserted by Eclipse plugin";
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();
}
PrecedenceToInsert pti = new PrecedenceToInsert();
pti.setAssoc(terminal, assoc);
pti.apply(editor.getDocument());
}
boolean insertingPrecAffectsOtherConflicts(terminal t) {
......
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