Commit 2d58e6e1 authored by Michael Schwarz's avatar Michael Schwarz

truncate state in conflicts view if it exceeds certain length

parent 0670175a
......@@ -475,12 +475,19 @@ class ConflictPanel extends Composite {
/**
* replace (*) generated by CUP with BULLET U+2022 •
* and display the lookahead depending on its length
* @param item the item for which the pretty string is needed
* @return pretty string
* @throws internal_error
*/
private String prettyString(lalr_item item) throws internal_error {
return item.toString().replace("(*)", "\u2022");
String s = item.toString();
if(s.length() > 100){
s = item.to_simple_string();
}
return s.replace("(*)", "\u2022");
}
private SelectionListener resolutionButtonClick = new SelectionListener() {
......
......@@ -192,6 +192,8 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
private void updateConflicts(ConflictResolutionManager crm) {
List<Conflict> conflicts = crm.getAllConflicts();
int size = conflicts.size();
scrolled.setLayoutDeferred(true);
matchPanelNumber(size);
// Do this first, otherwise the affects others is wrong because it operates on a subset of actual terminals
......@@ -201,15 +203,16 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
addToTerminalSet(crm,conflict);
}
System.out.println("UI");
for (int i = 0; i < size; i++) {
Conflict conflict = conflicts.get(i);
ConflictPanel panel = conflictPanels.get(i);
panel.update(crm, conflict);
}
scrolled.setLayoutDeferred(false);
refreshScrolledLayout();
}
//TODO: This fragment is duplicated code
private void addToTerminalSet(ConflictResolutionManager crm,Conflict conflict){
if(conflict instanceof ShiftReduceConflict){
ShiftReduceConflict src = (ShiftReduceConflict)conflict;
......
......@@ -79,7 +79,7 @@ class PrecedenceToInsert {
* @return true iff conflict is resolved in favor of Shift
*/
public boolean isResolvedInFavorOfShift(ShiftReduceDetails srd){
if(!srd.reduce.equals(srd.shift))
if(!srd.shift.equals(srd.reduce))
//TODO: Check if precedence set for terminal at all
return hasPrecedence(srd.shift,srd.reduce);
else
......@@ -92,7 +92,7 @@ class PrecedenceToInsert {
* @return true iff conflict is resolved in favor of Reduce
*/
public boolean isResolvedInFavorOfReduce(ShiftReduceDetails srd) {
if(!srd.reduce.equals(srd.shift))
if(!srd.shift.equals(srd.reduce))
//TODO: Check if precedence set for terminal at all
return hasPrecedence(srd.reduce,srd.shift);
else
......
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