Commit 1ec32a0f authored by Michael Schwarz's avatar Michael Schwarz

update buildfile after each parser run to reflect expected conflicts

parent b7ac611e
......@@ -26,7 +26,7 @@ import org.xml.sax.SAXException;
public class BuildfileUpdater {
public static void updateExpectedConflicts(IProject project,int number) throws ParserConfigurationException, SAXException, IOException, CoreException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError{
public static void updateExpectedConflicts(IProject project,int number) throws ParserConfigurationException, SAXException, CoreException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError, IOException{
boolean modified = false;
Path path = new Path("build.xml");
......@@ -37,7 +37,7 @@ public class BuildfileUpdater {
Document doc = db.parse(file.getContents());
if(doc.getElementsByTagName("cup").getLength() != 1){
//TODO: error
throw new IOException();
}
else {
Node n = doc.getElementsByTagName("cup").item(0);
......
......@@ -210,38 +210,47 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
refreshScrolledLayout();
}
private void updateBuildfile(){
//DEBUG
private void updateBuildfile(int number){
try {
IFileEditorInput input = (IFileEditorInput)editor.getEditorInput();
IFile file = input.getFile();
IProject project = file.getProject();
BuildfileUpdater.updateExpectedConflicts(project,42);
BuildfileUpdater.updateExpectedConflicts(project,number);
} catch (ParserConfigurationException | SAXException | IOException | CoreException | TransformerException
| TransformerFactoryConfigurationError e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Shell shell = new Shell(Display.getCurrent());
MessageBox box = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK);
box.setText("Information");
box.setMessage("Failed to update the expect label in the buildfile.\nThere was no file named build.xml containing a cup section.\n"
+ "Please update your buildfile and set the expect label to number.");
box.open();
}
}
private void updateConflicts(ConflictResolutionManager crm) {
updateBuildfile();
ignoreRRAfterLine = computeIgnoreRRAfter();
List<Conflict> conflicts = new ArrayList<>();
terminalsAffectConflicts = new HashMap<>();
ordersAffectConflicts = new HashMap<>();
int ignored = 0;
for (int i = 0; i < crm.getAllConflicts().size(); i++) {
Conflict c = crm.getAllConflicts().get(i);
if(!isIgnored(c)){
conflicts.add(c);
addToTerminalSet(crm,c);
addToOrderSet(c);
} else{
ignored++;
}
}
int size = conflicts.size();
//TODO:Do this less often
updateBuildfile(ignored);
scrolled.setLayoutDeferred(true);
matchPanelNumber(size);
......
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