Commit 1ec32a0f authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

update buildfile after each parser run to reflect expected conflicts

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