Commit 2d58e6e1 authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

truncate state in conflicts view if it exceeds certain length

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