Commit 942ab083 authored by Sebastian Pretscher's avatar Sebastian Pretscher

Some jumper magic

parent 7c7ee465
......@@ -17,10 +17,10 @@ public class Jumper {
}
public void jumpToConflictGraphState(ConflictType conflictType, int index) {
PluginUtility.showMessage("Jumper: Jump to conflict graph state - not yet implemented!");
//PluginUtility.showMessage("Jumper: Jump to conflict graph state - not yet implemented!");
mpe.jumpTo(mpe.CONFLICT_GRAPH_PAGE_INDEX);
// TODO!
// mpe.getConflictGraphView().
mpe.getConflictGraphView().showConflict(conflictType, index);
}
......
......@@ -55,6 +55,7 @@ import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;
import de.in.tum.www2.cup.Conflict;
import de.in.tum.www2.cup.ConflictResolutionManager;
import de.in.tum.www2.cup.ConflictType;
import de.in.tum.www2.cup.CupConflictState;
import de.in.tum.www2.cup.CupContext;
import de.in.tum.www2.cup.LALRResult;
......@@ -97,11 +98,12 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
private boolean isVisible = false;
private boolean useDijkstra = true;
private boolean jumperTriggered = false;
private HashMap<Integer, lalr_state> stateHashMap;
private HashSet<lalr_state> visitedStates;
private ConflictResolutionManager conflictResulutionManager;
private ConflictResolutionManager conflictResolutionManager;
public CupConflictGraphView(Composite parent, Jumper jumper,
CupTextEditor editor) {
......@@ -113,8 +115,8 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
this.parseModel = Model.getInstanceForDocument(doc);
this.parseModel.registerModelObserver(this);
this.parentComposite = parent;
this.conflictResulutionManager = new ConflictResolutionManager(
null, true);
this.conflictResolutionManager = new ConflictResolutionManager(null,
true);
this.stateHashMap = new HashMap<Integer, lalr_state>();
......@@ -322,9 +324,9 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
}
conflictResulutionManager.setLaLrContext(lalrContext);
conflictResolutionManager.setLaLrContext(lalrContext);
// TODO: This should only contain tainted states!!
List<Conflict> allInterstingConflicts = conflictResulutionManager
List<Conflict> allInterstingConflicts = conflictResolutionManager
.getAllConflicts();
List<String> stateNames = new ArrayList<String>();
for (Conflict conf : allInterstingConflicts) {
......@@ -366,11 +368,11 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
private void setModelForDFSAfterState(lalr_state state) {
if (!useDijkstra) {
conflictResulutionManager.setUseDijkstar(false);
conflictResolutionManager.setUseDijkstar(false);
} else {
conflictResulutionManager.setUseDijkstar(true);
conflictResolutionManager.setUseDijkstar(true);
}
List<CupConflictState> resultList = conflictResulutionManager
List<CupConflictState> resultList = conflictResolutionManager
.searchForState(state);
if (resultList != null) {
String resultString = "";
......@@ -408,6 +410,10 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
public void willBecomeVisible() {
// this.graphViewer.refresh();
isVisible = true;
if (jumperTriggered) {
jumperTriggered = false;
return;
}
if (!Controller.getInstance(editor).requestJobRun()) {
// TODO: Handle no rerun!!
IDocument doc = editor.getDocumentProvider().getDocument(
......@@ -422,6 +428,38 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
public void showConflict(ConflictType conflictType, int index) {
jumperTriggered = true;
if (!Controller.getInstance(editor).requestJobRun()) {
// TODO: Handle no rerun!!
IDocument doc = editor.getDocumentProvider().getDocument(
editor.getEditorInput());
modelChanged(Model.getInstanceForDocument(doc));
}
String itemString = "";
switch (conflictType) {
case ReduceReduce:
itemString = "RR:State " + index;
break;
case ShiftReduce:
itemString = "SR:State: " + index;
break;
default:
return;
}
int idx = 0;
for (String item : nodeSelection.getItems()) {
if(item.equals(itemString)) {
break;
} else {
idx++;
}
}
nodeSelection.select(idx);
setModelForDFSAfterState(stateHashMap.get(index));
}
static class ParserConflictNode {
private final int id;
private final String name;
......@@ -556,9 +594,9 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
} else {
newNode.setIsNonTerm(true);
}
if(state.getTransition()!=null) {
newNode.setTransitionSymbol(state.getTransition().on_symbol()
.toString());
if (state.getTransition() != null) {
newNode.setTransitionSymbol(state.getTransition()
.on_symbol().toString());
}
nodes.add(newNode);
nodeMap.put(state.getState().index(), newNode);
......@@ -666,6 +704,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
if (entity instanceof ParserConflictNode) {
ParserConflictNode n = (ParserConflictNode) entity;
description = new org.eclipse.draw2d.Label(n.getDescription());
description.setText(n.getDescription());
return description;
}
description = new org.eclipse.draw2d.Label("");
......
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