Commit fb7becf8 authored by Michael Schwarz's avatar Michael Schwarz

further cleanup

parent 80ef9020
......@@ -225,46 +225,9 @@ class ConflictPanel extends Composite {
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
changeColors(backgroundColorReduceReduce, foregroundColorReduceReduce);
conflictTypeLabel.setText("Reduce-Reduce conflict");
resolutionOptions.setVisible(false);
resolutionButton.setVisible(false);
ProductionRight conflict1Ast = rrc.getConflictItem1()
.the_production().getAstNode();
// TODO: clean up the string builder mess ... ; OAOO!
StringBuilder builder = new StringBuilder();
builder.append("between ");
if (conflict1Ast != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict1Ast.getRange());
}
try {
builder.append(prettyString(rrc.getConflictItem1()));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict1Ast != null)
builder.append("</a>");
builder.append(" and ");
ProductionRight conflict2Ast = rrc.getConflictItem2()
.the_production().getAstNode();
if (conflict2Ast != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict2Ast.getRange());
}
try {
builder.append(prettyString(rrc.getConflictItem2()));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict2Ast != null)
builder.append("</a>");
detailText.setText(builder.toString());
detailText.setText(makeReduceReduceDetailText(rrc,linkCounter));
StringBuilder symbolsBuilder = new StringBuilder();
symbolsBuilder.append("Under symbols: ");
......@@ -280,68 +243,106 @@ class ConflictPanel extends Composite {
resolutionOptions.removeAll();
} else if (conflict instanceof ShiftReduceConflict) {
} else if (conflict instanceof ShiftReduceConflict) {
ShiftReduceConflict src = (ShiftReduceConflict) conflict;
srdetails = this.cupConflictsView.new ShiftReduceDetails(src,crm);
ProductionRight conflict1Ast = src.getConflictItem1().the_production().getAstNode();
changeColors(backgroundColorShiftReduce, foregroundColorShiftReduce);
conflictTypeLabel.setText("Shift-Reduce conflict");
symbolLabel.setText("Under symbol: " + src.getTerminal().name());
detailText.setText(makeShiftReduceDetailText(src,linkCounter));
resolutionOptions.setVisible(true);
resolutionButton.setVisible(true);
setShiftReduceResolutionOptions();
// TODO: clean up the string builder mess ... ; OAOO!
gridData.heightHint += detailText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
} else {
throw new RuntimeException("unexpected conflict type.");
}
}
private String makeShiftReduceDetailText(ShiftReduceConflict src,int linkCounter){
ProductionRight conflict1Ast = src.getConflictItem1().the_production().getAstNode();
StringBuilder builder = new StringBuilder();
builder.append("between ");
if (conflict1Ast != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict1Ast.getRange());
}
try {
builder.append(prettyString(src.getConflictItem1()));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict1Ast != null)
builder.append("</a>");
StringBuilder builder = new StringBuilder();
builder.append("between ");
if (conflict1Ast != null) {
builder.append(" and ");
int size = src.getConflictItems2().size();
for (int i = 0; i < size; i++) {
lalr_item item = src.getConflictItems2().get(i);
ProductionRight conflict2ItemAst = item.the_production()
.getAstNode();
if (conflict2ItemAst != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict1Ast.getRange());
links.add(conflict2ItemAst.getRange());
}
try {
builder.append(prettyString(src.getConflictItem1()));
builder.append(prettyString(item));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict1Ast != null)
if (conflict2ItemAst != null)
builder.append("</a>");
if (i != size - 1)
builder.append(", ");
// gridData.heightHint += SIZE_INCREASE_PER_LINE;
}
return builder.toString();
}
private String makeReduceReduceDetailText(ReduceReduceConflict rrc,int linkCounter){
ProductionRight conflict1Ast = rrc.getConflictItem1().the_production().getAstNode();
builder.append(" and ");
int size = src.getConflictItems2().size();
for (int i = 0; i < size; i++) {
lalr_item item = src.getConflictItems2().get(i);
ProductionRight conflict2ItemAst = item.the_production()
.getAstNode();
if (conflict2ItemAst != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict2ItemAst.getRange());
}
try {
builder.append(prettyString(item));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict2ItemAst != null)
builder.append("</a>");
if (i != size - 1)
builder.append(", ");
// gridData.heightHint += SIZE_INCREASE_PER_LINE;
}
detailText.setText(builder.toString());
resolutionOptions.setVisible(true);
resolutionButton.setVisible(true);
setShiftReduceResolutionOptions();
gridData.heightHint += detailText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
} else {
throw new RuntimeException("unexpected conflict type.");
StringBuilder builder = new StringBuilder();
builder.append("between ");
if (conflict1Ast != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict1Ast.getRange());
}
try {
builder.append(prettyString(rrc.getConflictItem1()));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict1Ast != null)
builder.append("</a>");
builder.append(" and ");
ProductionRight conflict2Ast = rrc.getConflictItem2().the_production().getAstNode();
if (conflict2Ast != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict2Ast.getRange());
}
try {
builder.append(prettyString(rrc.getConflictItem2()));
} catch (internal_error e1) {
e1.printStackTrace();
}
if (conflict2Ast != null)
builder.append("</a>");
return builder.toString();
}
private void setShiftReduceResolutionOptions(){
resolutionOptions.removeAll();
resolutionOptions.add("-- Choose an option --");
......
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