Commit 80ef9020 authored by Michael Schwarz's avatar Michael Schwarz

Refactoring to get ride of 900 line method

parent 88a1cea3
......@@ -73,6 +73,42 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
class ShiftReduceDetails {
terminal shift,reduce;
boolean shiftAffectsOthers,reduceAffectsOthers;
ShiftReduceDetails(ShiftReduceConflict src,ConflictResolutionManager crm){
shift = src.getTerminal();
reduce = null;
ProductionRight conflict1Ast = src.getConflictItem1().the_production().getAstNode();
// If the precedence is specifically set via %prec
if(conflict1Ast.hasSpecifiedPrecedence()){
reduce = terminal.getShared(crm.getLaLrContext()).find(
conflict1Ast.getPrecedenceLike().getNameStringOrNull());
}
// Terminal defining precedence is the last one in the current production
else {
for(IProductionRightPart part : conflict1Ast.getList()){
if(part instanceof ProductionSymbolRef){
ProductionSymbolRef ppsr = (ProductionSymbolRef)part;
terminal candidate = terminal.getShared(crm.getLaLrContext()).find(
ppsr.getNameStringOrNull());
if(candidate != null){
reduce = candidate;
}
}
}
}
// RHS is only nonterminal and no %prec directive => sourceOfReducePrec == null
shiftAffectsOthers = insertingPrecAffectsOtherConflicts(shift);
reduceAffectsOthers = insertingPrecAffectsOtherConflicts(reduce);
}
boolean shiftAndReducePrecedenceFromSameTerminal(){
return shift.equals(reduce);
}
}
public CupConflictsView(Composite realParent, Jumper jumper,CupTextEditor editor) {
......@@ -252,7 +288,6 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
scrolled.setMinSize(list.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
public void dispose() {
editor.getModel().unregisterModelObserver(this);
Controller.getInstance(editor).unregisterObserver(this);
......@@ -374,15 +409,13 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
// Conflicts are part of current connected conflicts that are not resolved yet.
for(ConflictPanel p: conflictPanels){
if(p.partOfCurrentConnected){
if(p.resolutionOptions.getSelectionIndex() == 0){
if(p.requiresResolutionButNotChosen()) {
Shell shell = new Shell(Display.getCurrent());
MessageBox box = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK);
box.setText("Information");
box.setMessage("Please choose a way to resolve all conflicts that are affected. Then click this button again.");
box.open();
return;
}
}
}
......
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