nus-yam/ex-repair huggingface dataset:
Program: 133656
Project: 133656
Buggy source:
/** 
 * Checks the new value before attempting to set it. The value must be an integer that lies within the port range (inclusive) defined by its associated   {@link PortEntryContentProvider}.
 */
@Override public boolean setValue(String newValue){
  boolean returnCode=false;
  List<String> allowedValues=iEntryContentProvider.getAllowedValues();
  int lowerBound=Integer.valueOf(allowedValues.get(0));
  int upperBound=Integer.valueOf(allowedValues.get(1));
  try {
    int newValueInt=Integer.valueOf(newValue);
    if (newValueInt >= lowerBound && newValueInt <= upperBound) {
      value=newValue;
      returnCode=true;
    }
  }
 catch (  NumberFormatException e) {
  }
  if (returnCode) {
    changeState=true;
    errorMessage=null;
    notifyListeners();
  }
 else {
    String error=continuousErrMsg;
    error=error.replace("String_Node_Str",newValue);
    error=error.replace("String_Node_Str",allowedValues.get(0));
    error=error.replace("String_Node_Str",allowedValues.get(1));
    errorMessage=error;
  }
  return returnCode;
}

Fixed version (ground truth):
/** 
 * Checks the new value before attempting to set it. The value must be an integer that lies within the port range (inclusive) defined by its associated   {@link PortEntryContentProvider}.
 */
@Override public boolean setValue(String newValue){
  boolean returnCode=false;
  List<String> allowedValues=iEntryContentProvider.getAllowedValues();
  int lowerBound=Integer.valueOf(allowedValues.get(0));
  int upperBound=Integer.valueOf(allowedValues.get(1));
  try {
    int newValueInt=Integer.valueOf(newValue);
    if (newValueInt >= lowerBound && newValueInt <= upperBound) {
      value=newValue;
      returnCode=true;
    }
  }
 catch (  NumberFormatException e) {
  }
  if (returnCode) {
    changeState=true;
    errorMessage=null;
    notifyListeners();
  }
 else {
    String error=continuousErrMsg;
    error=error.replace("String_Node_Str",newValue != null ? newValue : "String_Node_Str");
    error=error.replace("String_Node_Str",allowedValues.get(0));
    error=error.replace("String_Node_Str",allowedValues.get(1));
    errorMessage=error;
  }
  return returnCode;
}
Program: 133657
Project: 133657
Buggy source:
/** 
 * This checks the constructor for   {@code KeyEntry} to ensure that thedefault values are properly set.
 */
@Test public void checkConstruction(){
}

Fixed version (ground truth):
/** 
 * This checks the constructor for   {@code KeyEntry} to ensure that thedefault values are properly set.
 */
@Test public void checkConstruction(){
  PortEntry entry;
  PortEntryContentProvider contentProvider;
  final PortEntryContentProvider nullContentProvider=null;
  int defaultValue=5555;
  int value=-1;
  contentProvider=new PortEntryContentProvider();
  contentProvider.setDefaultValue(defaultValue);
  entry=new PortEntry(contentProvider);
  value=parseIntString(entry.getDefaultValue());
  assertEquals(defaultValue,value);
  value=parseIntString(entry.getValue());
  assertEquals(defaultValue,value);
  assertEquals(contentProvider.getAllowedValueType(),entry.getValueType());
  contentProvider=new PortEntryContentProvider();
  defaultValue=Integer.parseInt(contentProvider.getDefaultValue());
  entry=new PortEntry(nullContentProvider);
  value=parseIntString(entry.getDefaultValue());
  assertEquals(defaultValue,value);
  value=parseIntString(entry.getValue());
  assertEquals(defaultValue,value);
  assertEquals(contentProvider.getAllowedValueType(),entry.getValueType());
  return;
}
Program: 133658
Project: 133658
Buggy source:
/** 
 * Tests the clone operation to ensure that it properly returns a copied  {@code PortEntry} rather than a plain {@code Entry}.
 */
@Test public void checkCopy(){
}

Fixed version (ground truth):
/** 
 * Tests the clone operation to ensure that it properly returns a copied  {@code PortEntry} rather than a plain {@code Entry}.
 */
@Test public void checkCopy(){
  PortEntry entry;
  PortEntry copy;
  Object clone;
  PortEntryContentProvider contentProvider=new PortEntryContentProvider();
  contentProvider.setRange(50000,60000);
  contentProvider.setDefaultValue(55000);
  entry=new PortEntry(contentProvider);
  entry.setName("String_Node_Str");
  entry.setValue(Integer.toString(55001));
  copy=new PortEntry(new PortEntryContentProvider());
  copy.setName("String_Node_Str");
  assertFalse(entry.equals(copy));
  copy.copy(entry);
  assertNotSame(entry,copy);
  assertEquals(entry,copy);
  assertEquals(copy,entry);
  clone=entry.clone();
  assertNotNull(clone);
  assertTrue(clone instanceof PortEntry);
  assertNotSame(entry,clone);
  assertEquals(entry,clone);
  assertEquals(clone,entry);
  return;
}
Program: 133659
Project: 133659
Buggy source:
/** 
 * Checks that the   {@link PortEntry#setValue(String)} properly assigns validvalues (integers managed by the  {@link PortEntryContentProvider}) and rejects invalid values (non-integers or integers outside the range).
 */
@Test public void checkValue(){
}

Fixed version (ground truth):
/** 
 * Checks that the   {@link PortEntry#setValue(String)} properly assigns validvalues (integers managed by the  {@link PortEntryContentProvider}) and rejects invalid values (non-integers or integers outside the range).
 */
@Test public void checkValue(){
  PortEntry entry;
  PortEntryContentProvider contentProvider;
  final int defaultValue=1337;
  final int min=343;
  final int max=43770;
  int lastValue=8000;
  int value=-1;
  final String nullString=null;
  boolean changed;
  contentProvider=new PortEntryContentProvider();
  contentProvider.setRange(min,max);
  contentProvider.setDefaultValue(defaultValue);
  entry=new PortEntry(contentProvider);
  value=parseIntString(entry.getDefaultValue());
  assertEquals(defaultValue,value);
  value=parseIntString(entry.getValue());
  assertEquals(defaultValue,value);
  assertNull(entry.getErrorMessage());
  lastValue=8000;
  changed=entry.setValue(Integer.toString(lastValue));
  assertTrue(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertNull(entry.getErrorMessage());
  lastValue=min;
  changed=entry.setValue(Integer.toString(lastValue));
  assertTrue(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertNull(entry.getErrorMessage());
  changed=entry.setValue(Integer.toString(min - 1));
  assertFalse(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertEquals("String_Node_Str" + "String_Node_Str",entry.getErrorMessage());
  lastValue=max;
  changed=entry.setValue(Integer.toString(lastValue));
  assertTrue(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertNull(entry.getErrorMessage());
  changed=entry.setValue(Integer.toString(max + 1));
  assertFalse(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertEquals("String_Node_Str" + "String_Node_Str",entry.getErrorMessage());
  changed=entry.setValue(nullString);
  assertFalse(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertEquals("String_Node_Str" + "String_Node_Str",entry.getErrorMessage());
  changed=entry.setValue("String_Node_Str");
  assertFalse(changed);
  value=parseIntString(entry.getValue());
  assertEquals(lastValue,value);
  assertEquals("String_Node_Str" + "String_Node_Str",entry.getErrorMessage());
  return;
}
Program: 133660
Project: 133660
Buggy source:
/** 
 * This realization of IReader.findAll() reads a Form in from the given file reference and walks the corresponding TreeComposite for occurrences of the  given regular expression.
 * @param file The reference to the file we are searching in.
 * @param regex The regular expression we should search for.
 */
@Override public ArrayList<Entry> findAll(IFile file,String regex){
  ArrayList<Entry> retEntries=new ArrayList<Entry>();
  Form form=read(file);
  TreeComposite tree=(TreeComposite)form.getComponent(MOOSEModel.mooseTreeCompositeId);
  if (tree == null || tree.getNumberOfChildren() < 1) {
    return retEntries;
  }
  BreadthFirstTreeCompositeIterator iter=new BreadthFirstTreeCompositeIterator(tree);
  while (iter.hasNext()) {
    TreeComposite child=iter.next();
    if (child.getActiveDataNode() != null) {
      DataComponent data=(DataComponent)child.getActiveDataNode();
      for (      Entry e : data.retrieveAllEntries()) {
        if (!"String_Node_Str".equals(e.getTag()) && e.getValue() != null && !e.getValue().isEmpty() && e.getName().toLowerCase().contains(regex) && !e.getName().toLowerCase().contains("String_Node_Str")) {
          if ("String_Node_Str".equals(e.getName().toLowerCase()) || "String_Node_Str".equals(e.getName().toLowerCase())) {
            e.setName(child.getName());
          }
          retEntries.add((Entry)e.clone());
        }
      }
    }
  }
  return retEntries;
}

Fixed version (ground truth):
/** 
 * This realization of IReader.findAll() reads a Form in from the given file reference and walks the corresponding TreeComposite for occurrences of the  given regular expression.
 * @param file The reference to the file we are searching in.
 * @param regex The regular expression we should search for.
 */
@Override public ArrayList<Entry> findAll(IFile file,String regex){
  ArrayList<Entry> retEntries=new ArrayList<Entry>();
  Form form=read(file);
  TreeComposite tree=(TreeComposite)form.getComponent(MOOSEModel.mooseTreeCompositeId);
  if (tree == null || tree.getNumberOfChildren() < 1) {
    return retEntries;
  }
  BreadthFirstTreeCompositeIterator iter=new BreadthFirstTreeCompositeIterator(tree);
  while (iter.hasNext()) {
    TreeComposite child=iter.next();
    if (child.getActiveDataNode() != null) {
      DataComponent data=(DataComponent)child.getActiveDataNode();
      for (      Entry e : data.retrieveAllEntries()) {
        if (!"String_Node_Str".equals(e.getTag()) && e.getValue() != null && !e.getValue().isEmpty() && e.getName().toLowerCase().contains(regex) && !e.getName().toLowerCase().contains("String_Node_Str") && !e.getName().toLowerCase().contains("String_Node_Str")) {
          if ("String_Node_Str".equals(e.getName().toLowerCase()) || "String_Node_Str".equals(e.getName().toLowerCase())) {
            e.setName(child.getName());
          }
          retEntries.add((Entry)e.clone());
        }
      }
    }
  }
  return retEntries;
}
Program: 133661
Project: 133661
Buggy source:
/** 
 * This operation sets the TreeComposite that should be displayed for the current FormEditor.
 * @param tree The tree composite
 * @param source The source editor for the tree.
 */
public void setInput(TreeComposite tree,ICEFormEditor source){
  if (tree != inputTree) {
    if (tree != null) {
      tree.unregister(this);
    }
    inputTree=tree;
    clearMetaData();
    if (inputTree != null) {
      loadTree(inputTree);
      inputTree.register(this);
    }
    treeViewer.setInput(inputTree);
    setPartName(inputTree.getName() + "String_Node_Str");
  }
  this.editor=source;
  return;
}

Fixed version (ground truth):
/** 
 * This operation sets the TreeComposite that should be displayed for the current FormEditor.
 * @param tree The tree composite
 * @param source The source editor for the tree.
 */
public void setInput(TreeComposite tree,ICEFormEditor source){
  if (tree != inputTree) {
    if (tree != null) {
      tree.unregister(this);
    }
    inputTree=tree;
    clearMetaData();
    if (inputTree != null) {
      loadTree(inputTree);
      inputTree.register(this);
    }
    Tree treeWidget=treeViewer.getTree();
    if (treeWidget != null && !treeWidget.isDisposed()) {
      treeViewer.setInput(inputTree);
    }
    setPartName(inputTree.getName() + "String_Node_Str");
  }
  this.editor=source;
  return;
}
Program: 133663
Project: 133663
Buggy source:
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  Shell shell=HandlerUtil.getActiveWorkbenchWindow(event).getShell();
  wizard=new GenerateYAMLWizard();
  WizardDialog dialog=new WizardDialog(shell,wizard);
  launcher=new MOOSELauncher(ResourcesPlugin.getWorkspace().getRoot().getProject("String_Node_Str"));
  if (dialog.open() != 0) {
    return null;
  }
  IEntryContentProvider execContentProvider=new BasicEntryContentProvider();
  ArrayList<String> execList=((DataComponent)launcher.getForm().getComponent(5)).retrieveEntry("String_Node_Str").getAllowedValues();
  execList.add("String_Node_Str");
  execContentProvider.setAllowedValues(execList);
  execContentProvider.setAllowedValueType(AllowedValueType.Discrete);
  execContentProvider.setDefaultValue("String_Node_Str");
  ((DataComponent)launcher.getForm().getComponent(5)).retrieveEntry("String_Node_Str").setContentProvider(execContentProvider);
  ((DataComponent)launcher.getForm().getComponent(5)).retrieveEntry("String_Node_Str").setValue("String_Node_Str");
  ((TableComponent)launcher.getForm().getComponent(4)).getRow(0).get(0).setValue(wizard.getHostName());
  ((TableComponent)launcher.getForm().getComponent(4)).getRow(0).get(2).setValue(wizard.getExecPath());
  launcher.submitForm(launcher.getForm());
  Thread thread=new Thread(this);
  thread.start();
  return null;
}

Fixed version (ground truth):
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  Shell shell=HandlerUtil.getActiveWorkbenchWindow(event).getShell();
  wizard=new GenerateYAMLWizard();
  WizardDialog dialog=new WizardDialog(shell,wizard);
  launcher=new MOOSELauncher(ResourcesPlugin.getWorkspace().getRoot().getProject("String_Node_Str"));
  if (dialog.open() != 0) {
    return null;
  }
  IEntryContentProvider execContentProvider=new BasicEntryContentProvider();
  ArrayList<String> execList=((DataComponent)launcher.getForm().getComponent(JobLauncherForm.parallelId + 2)).retrieveEntry("String_Node_Str").getAllowedValues();
  execList.add("String_Node_Str");
  execContentProvider.setAllowedValues(execList);
  execContentProvider.setAllowedValueType(AllowedValueType.Discrete);
  execContentProvider.setDefaultValue("String_Node_Str");
  ((DataComponent)launcher.getForm().getComponent(JobLauncherForm.filesId)).clearEntries();
  ((DataComponent)launcher.getForm().getComponent(JobLauncherForm.parallelId + 2)).retrieveEntry("String_Node_Str").setContentProvider(execContentProvider);
  ((DataComponent)launcher.getForm().getComponent(JobLauncherForm.parallelId + 2)).retrieveEntry("String_Node_Str").setValue("String_Node_Str");
  ((TableComponent)launcher.getForm().getComponent(JobLauncherForm.parallelId + 1)).getRow(0).get(0).setValue(wizard.getHostName());
  ((TableComponent)launcher.getForm().getComponent(JobLauncherForm.parallelId + 1)).getRow(0).get(2).setValue(wizard.getExecPath());
  launcher.submitForm(launcher.getForm());
  Thread thread=new Thread(this);
  thread.start();
  return null;
}
Program: 133664
Project: 133664
Buggy source:
/** 
 * In additon to the default behavior when saved, this makes sure the plant and/or mesh view pages are visible depending on the current MOOSE app and input file settings.
 */
@Override public void doSave(IProgressMonitor monitor){
  super.doSave(monitor);
  String appStr=appsEntry.getValue();
  if ("String_Node_Str".equals(appStr)) {
    addPlantPage();
  }
 else {
    removePlantPage();
  }
  return;
}

Fixed version (ground truth):
/** 
 * In additon to the default behavior when saved, this makes sure the plant and/or mesh view pages are visible depending on the current MOOSE app and input file settings.
 */
@Override public void doSave(IProgressMonitor monitor){
  super.doSave(monitor);
  String appStr=appsEntry.getValue().toLowerCase();
  if ("String_Node_Str".equals(appStr)) {
    addPlantPage();
  }
 else {
    removePlantPage();
  }
  return;
}
Program: 133665
Project: 133665
Buggy source:
/** 
 * Adds a plot to be drawn inside the plot grid. Note that the same plot can be added more than once.
 * @param plot The plot to draw inside the grid.
 * @return The index of the plot in the grid, or -1 if the plot could not bedrawn.
 * @throws Exception An exception is thrown if the  {@link IPlot} implementationcannot be rendered.
 */
public int addPlot(IPlot plot) throws Exception {
  int index=-1;
  if (plot != null && drawnPlots.size() < rows * columns) {
    Map<String,String[]> plotTypes=plot.getPlotTypes();
    String category=null;
    String type=null;
    for (    Entry<String,String[]> entry : plotTypes.entrySet()) {
      category=entry.getKey();
      String[] types=entry.getValue();
      if (category != null && types != null) {
        for (int i=0; i < types.length && type == null; i++) {
          type=types[i];
        }
        if (type != null) {
          break;
        }
      }
    }
    if (category != null && type != null) {
      final DrawnPlot drawnPlot=new DrawnPlot(gridComposite,plot);
      try {
        drawnPlot.draw(category,type);
      }
 catch (      Exception e) {
        drawnPlot.dispose();
      }
      index=drawnPlots.size();
      drawnPlots.add(drawnPlot);
      drawnPlotMap.put(drawnPlot,index);
      drawnPlot.addDisposeListener(plotDisposeListener);
      GridData gridData=new GridData(SWT.FILL,SWT.FILL,true,true);
      drawnPlot.setLayoutData(gridData);
      refreshLayout();
    }
  }
  return index;
}

Fixed version (ground truth):
/** 
 * Adds a plot to be drawn inside the plot grid. Note that the same plot can be added more than once.
 * @param plot The plot to draw inside the grid.
 * @return The index of the plot in the grid, or -1 if the plot could not bedrawn.
 * @throws Exception An exception is thrown if the  {@link IPlot} implementationcannot be rendered.
 */
public int addPlot(IPlot plot) throws Exception {
  int index=-1;
  if (plot != null && drawnPlots.size() < rows * columns) {
    Map<String,String[]> plotTypes=plot.getPlotTypes();
    String category=null;
    String type=null;
    for (    Entry<String,String[]> entry : plotTypes.entrySet()) {
      category=entry.getKey();
      String[] types=entry.getValue();
      if (category != null && types != null) {
        for (int i=0; i < types.length && type == null; i++) {
          type=types[i];
        }
        if (type != null) {
          break;
        }
      }
    }
    if (category != null && type != null) {
      final DrawnPlot drawnPlot=new DrawnPlot(gridComposite,plot);
      try {
        drawnPlot.draw(category,type);
      }
 catch (      Exception e) {
        drawnPlot.dispose();
        throw e;
      }
      index=drawnPlots.size();
      drawnPlots.add(drawnPlot);
      drawnPlotMap.put(drawnPlot,index);
      drawnPlot.addDisposeListener(plotDisposeListener);
      GridData gridData=new GridData(SWT.FILL,SWT.FILL,true,true);
      drawnPlot.setLayoutData(gridData);
      refreshLayout();
    }
  }
  return index;
}
Program: 133666
Project: 133666
Buggy source:
private void hideCloseButton(MouseEvent e){
  Control c=null;
  if (e.widget instanceof Composite) {
    c=(Composite)e.widget;
  }
 else {
    c=(Control)e.widget;
  }
  if (c instanceof Composite) {
    for (    Control child : ((Composite)c).getChildren()) {
      if (child.getBounds().contains(new Point(e.x,e.y))) {
        return;
      }
    }
  }
  if (closeButton != null && !closeButton.isDisposed()) {
    closeButton.dispose();
    closeButton=null;
  }
  return;
}

Fixed version (ground truth):
private void hideCloseButton(MouseEvent e){
  if (closeButton != null && !closeButton.isDisposed() && !closeButton.getBounds().contains(e.x,e.y)) {
    closeButton.dispose();
    closeButton=null;
  }
  return;
}
Program: 133667
Project: 133667
Buggy source:
private void showCloseButton(MouseEvent e){
  Composite comp=(Composite)e.widget;
  if (closeButton == null || closeButton.isDisposed()) {
    closeButton=new Button(comp,SWT.FLAT | SWT.CENTER);
    closeButton.setText("String_Node_Str");
    FontData[] smallFont=closeButton.getFont().getFontData();
    for (    FontData fd : smallFont) {
      fd.setHeight(7);
    }
    closeButton.setFont(new Font(comp.getDisplay(),smallFont));
    closeButton.setToolTipText("String_Node_Str");
    closeButton.addSelectionListener(new SelectionAdapter(){
      @Override public void widgetSelected(      SelectionEvent e){
        Control c=(Control)e.widget;
        for (        Control plot : gridManager) {
          if (!(plot instanceof EmptyControl) && isChildControl(c,(Composite)plot)) {
            plot.dispose();
            break;
          }
        }
      }
    }
);
    closeButton.pack();
    pageComposite.layout();
  }
  closeButton.setLocation(comp.getBounds().width - closeButton.getBounds().width - 4,0);
  return;
}

Fixed version (ground truth):
private void showCloseButton(MouseEvent e){
  if (closeButton == null || closeButton.isDisposed()) {
    Composite comp=(Composite)e.widget;
    closeButton=new Button(comp,SWT.FLAT | SWT.CENTER);
    closeButton.addMouseTrackListener(closeButtonListener);
    closeButton.setText("String_Node_Str");
    FontData[] smallFont=closeButton.getFont().getFontData();
    for (    FontData fd : smallFont) {
      fd.setHeight(7);
    }
    closeButton.setFont(new Font(comp.getDisplay(),smallFont));
    closeButton.setToolTipText("String_Node_Str");
    closeButton.addSelectionListener(new SelectionAdapter(){
      @Override public void widgetSelected(      SelectionEvent e){
        Control c=(Control)e.widget;
        for (        Control plot : gridManager) {
          if (!(plot instanceof EmptyControl) && isChildControl(c,(Composite)plot)) {
            plot.dispose();
            break;
          }
        }
      }
    }
);
    closeButton.pack();
    pageComposite.layout();
    closeButton.setLocation(comp.getBounds().width - closeButton.getBounds().width - 4,0);
  }
  return;
}
Program: 133668
Project: 133668
Buggy source:
@Override public void widgetDisposed(DisposeEvent e){
  Composite c=(Composite)e.widget;
  gridManager.remove(c);
  addEmptyControls(gridComposite);
  Display display=pageComposite.getDisplay();
  display.asyncExec(new Runnable(){
    @Override public void run(){
      if (!pageComposite.isDisposed()) {
        gridComposite.pack();
        drawingComposite.pack();
        pageComposite.layout();
        child.removeMouseTrackListener(closeButtonListener);
      }
      return;
    }
  }
);
}

Fixed version (ground truth):
@Override public void widgetDisposed(DisposeEvent e){
  Composite c=(Composite)e.widget;
  gridManager.remove(c);
  addEmptyControls(gridComposite);
  Display display=pageComposite.getDisplay();
  display.asyncExec(new Runnable(){
    @Override public void run(){
      if (!pageComposite.isDisposed()) {
        gridComposite.pack();
        drawingComposite.pack();
        pageComposite.layout();
      }
      return;
    }
  }
);
}
Program: 133670
Project: 133670
Buggy source:
/** 
 * Adds a plot to be drawn inside the plot grid. Note that the same plot can be added more than once.
 * @param plot The plot to draw inside the grid.
 * @return The index of the plot in the grid, or -1 if the plot could not bedrawn.
 * @throws Exception An exception is thrown if the  {@link IPlot} implementationcannot be rendered.
 */
public int addPlot(IPlot plot) throws Exception {
  int index=-1;
  if (plot != null) {
    Map<String,String[]> plotTypes=plot.getPlotTypes();
    String category=null;
    String type=null;
    for (    Entry<String,String[]> entry : plotTypes.entrySet()) {
      category=entry.getKey();
      String[] types=entry.getValue();
      if (category != null && types != null) {
        for (int i=0; i < types.length && type == null; i++) {
          type=types[i];
        }
        if (type != null) {
          break;
        }
      }
    }
    if (category != null && type != null) {
      Composite composite=new Composite(gridComposite,SWT.NONE);
      DrawnPlot drawnPlot;
      try {
        drawnPlot=new DrawnPlot(plot,composite,category,type);
      }
 catch (      Exception e) {
        composite.dispose();
        throw e;
      }
      drawnPlot.childComposite.addMouseTrackListener(closeButtonListener);
      index=drawnPlots.size();
      drawnPlots.add(drawnPlot);
      refreshLayout();
    }
  }
  return index;
}

Fixed version (ground truth):
/** 
 * Adds a plot to be drawn inside the plot grid. Note that the same plot can be added more than once.
 * @param plot The plot to draw inside the grid.
 * @return The index of the plot in the grid, or -1 if the plot could not bedrawn.
 * @throws Exception An exception is thrown if the  {@link IPlot} implementationcannot be rendered.
 */
public int addPlot(IPlot plot) throws Exception {
  int index=-1;
  if (plot != null) {
    Map<String,String[]> plotTypes=plot.getPlotTypes();
    String category=null;
    String type=null;
    for (    Entry<String,String[]> entry : plotTypes.entrySet()) {
      category=entry.getKey();
      String[] types=entry.getValue();
      if (category != null && types != null) {
        for (int i=0; i < types.length && type == null; i++) {
          type=types[i];
        }
        if (type != null) {
          break;
        }
      }
    }
    if (category != null && type != null) {
      Composite composite=new Composite(gridComposite,SWT.NONE);
      DrawnPlot drawnPlot;
      try {
        drawnPlot=new DrawnPlot(plot,composite,category,type);
      }
 catch (      Exception e) {
        composite.dispose();
        throw e;
      }
      index=drawnPlots.size();
      drawnPlots.add(drawnPlot);
      drawnPlot.childComposite.addMouseTrackListener(closeButtonListener);
      GridData gridData=new GridData(SWT.FILL,SWT.FILL,true,true);
      drawnPlot.composite.setLayoutData(gridData);
      drawnPlot.composite.setLayout(new FillLayout());
      refreshLayout();
    }
  }
  return index;
}
Program: 133671
Project: 133671
Buggy source:
/** 
 * This function is called whenever a Workbench part is closed. If the current   {@link #editor} is closed, then we need to clear the view'scontents.
 */
@Override public void partClosed(IWorkbenchPartReference partRef){
  if (ICEFormEditor.ID.equals(partRef.getId())) {
    ICEFormEditor activeEditor=(ICEFormEditor)partRef.getPart(false);
    if (activeEditor == editor) {
      setActiveEditor(null);
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * This function is called whenever a Workbench part is closed. If the current   {@link #editor} is closed, then we need to clear the view'scontents.
 */
@Override public void partClosed(IWorkbenchPartReference partRef){
  IWorkbenchPart part=partRef.getPart(false);
  if (part != null && part instanceof ICEFormEditor) {
    ICEFormEditor activeEditor=(ICEFormEditor)partRef.getPart(false);
    if (activeEditor == editor) {
      setActiveEditor(null);
    }
  }
  return;
}
Program: 133672
Project: 133672
Buggy source:
/** 
 * This function is called whenever a Workbench part gains focus. Here, we are only interested if the part is an ICEFormEditor. When a new ICEFormEditor is activated, sync the view with the activated editor.
 */
@Override public void partActivated(IWorkbenchPartReference partRef){
  if (ICEFormEditor.ID.equals(partRef.getId())) {
    ICEFormEditor activeEditor=(ICEFormEditor)partRef.getPart(false);
    if (activeEditor != editor) {
      setActiveEditor(activeEditor);
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * This function is called whenever a Workbench part gains focus. Here, we are only interested if the part is an ICEFormEditor. When a new ICEFormEditor is activated, sync the view with the activated editor.
 */
@Override public void partActivated(IWorkbenchPartReference partRef){
  IWorkbenchPart part=partRef.getPart(false);
  if (part != null && part instanceof ICEFormEditor) {
    ICEFormEditor activeEditor=(ICEFormEditor)part;
    if (activeEditor != editor) {
      setActiveEditor(activeEditor);
    }
  }
  return;
}
Program: 133673
Project: 133673
Buggy source:
@Override public void widgetDisposed(DisposeEvent e){
  Composite c=(Composite)e.widget;
  gridManager.remove(c);
  addEmptyControls(gridComposite);
  Display display=pageComposite.getDisplay();
  display.asyncExec(new Runnable(){
    @Override public void run(){
      gridComposite.pack();
      drawingComposite.pack();
      pageComposite.layout();
    }
  }
);
}

Fixed version (ground truth):
@Override public void widgetDisposed(DisposeEvent e){
  Composite c=(Composite)e.widget;
  gridManager.remove(c);
  addEmptyControls(gridComposite);
  Display display=pageComposite.getDisplay();
  display.asyncExec(new Runnable(){
    @Override public void run(){
      if (!pageComposite.isDisposed()) {
        gridComposite.pack();
        drawingComposite.pack();
        pageComposite.layout();
      }
    }
  }
);
}
Program: 133675
Project: 133675
Buggy source:
public boolean isRemote(){
  return "String_Node_Str".equals(getHost());
}

Fixed version (ground truth):
public boolean isRemote(){
  return !("String_Node_Str".equals(getHost()));
}
Program: 133676
Project: 133676
Buggy source:
@Override protected Map<String,String[]> findPlotTypes(URI file) throws IOException, Exception {
  Map<String,String[]> plotTypes=new HashMap<String,String[]>();
  ParaViewConnectionAdapter adapter=getParaViewConnectionAdapter();
  VtkWebClient client=adapter.getConnection();
  List<Object> args=new ArrayList<Object>();
  JSONObject object;
  args.clear();
  args.add(adapter.findRelativePath(file.getPath()));
  object=client.call("String_Node_Str",args).get();
  viewId=object.getInt("String_Node_Str");
  fileId=object.getInt("String_Node_Str");
  repId=object.getInt("String_Node_Str");
  args.clear();
  args.add(fileId);
  object=client.call("String_Node_Str",args).get();
  JSONArray array=object.getJSONArray("String_Node_Str");
  for (int i=0; i < array.length(); i++) {
    object=array.getJSONObject(i);
    String name=object.getString("String_Node_Str");
    JSONArray valueArray=object.getJSONArray("String_Node_Str");
    String[] values=new String[valueArray.length()];
    for (int j=0; j < values.length; j++) {
      values[j]=valueArray.getString(j);
    }
    plotTypes.put(name,values);
  }
  return plotTypes;
}

Fixed version (ground truth):
@Override protected Map<String,String[]> findPlotTypes(URI file) throws IOException, Exception {
  Map<String,String[]> plotTypes=new HashMap<String,String[]>();
  ParaViewConnectionAdapter adapter=getParaViewConnectionAdapter();
  VtkWebClient client=adapter.getConnection();
  List<Object> args=new ArrayList<Object>();
  JSONObject object;
  args.clear();
  args.add(adapter.findRelativePath(file.getPath()));
  object=client.call("String_Node_Str",args).get();
  viewId=object.getInt("String_Node_Str");
  fileId=object.getInt("String_Node_Str");
  repId=object.getInt("String_Node_Str");
  args.clear();
  args.add(fileId);
  object=client.call("String_Node_Str",args).get();
  JSONArray array=object.getJSONArray("String_Node_Str");
  for (int i=0; i < array.length(); i++) {
    object=array.getJSONObject(i);
    String name=object.getString("String_Node_Str");
    if (!"String_Node_Str".equals(name)) {
      JSONArray valueArray=object.getJSONArray("String_Node_Str");
      String[] values=new String[valueArray.length()];
      for (int j=0; j < values.length; j++) {
        values[j]=valueArray.getString(j);
      }
      plotTypes.put(name,values);
    }
  }
  return plotTypes;
}
Program: 133677
Project: 133677
Buggy source:
/** 
 * Refreshes the widget by activating the associated view (and, of course, it's related file and representation proxies). <p> This method handles the proper JSON RPC to activate the associated view. </p>
 * @param connection The current connection.
 * @throws Exception If the connection is invalid or the command could not be completed.
 */
private void refreshWidget(VtkWebClient connection) throws Exception {
  List<Object> args=new ArrayList<Object>(1);
  args.add(viewId);
  connection.call("String_Node_Str",args).get();
}

Fixed version (ground truth):
/** 
 * Refreshes the widget by activating the associated view (and, of course, it's related file and representation proxies). <p> This method handles the proper JSON RPC to activate the associated view. </p>
 * @param render If true, the widget will be re-rendered. If false, then the associated view will only be "activated".
 * @param connection The current connection.
 * @throws Exception If the connection is invalid or the command could not be completed.
 */
private void refreshWidget(boolean render,VtkWebClient connection) throws Exception {
  List<Object> args=new ArrayList<Object>(1);
  args.add(viewId);
  connection.call("String_Node_Str",args).get();
  if (render) {
    System.out.println("String_Node_Str");
    renderPanel.dirty();
  }
  return;
}
Program: 133680
Project: 133680
Buggy source:
@Override protected void updatePlotComposite(Composite plotComposite,VtkWebClient connection) throws Exception {
  refreshToolBar(toolBar);
  final String representation=getPlotRepresentation();
  boolean representationChanged=(representation != null && !representation.equals(plotRepresentation) && getPlotRepresentations().contains(representation));
  final String category=getPlotCategory();
  final String type=getPlotType();
  boolean plotTypeChanged=((category != null && !category.equals(plotCategory)) || (type != null && !type.equals(plotType)));
  if (plotTypeChanged && type != null) {
    plotTypeChanged=false;
    String[] types=plot.getPlotTypes().get(category);
    if (types != null) {
      for (int i=0; !plotTypeChanged && i < types.length; i++) {
        if (type.equals(types[i])) {
          plotTypeChanged=true;
        }
      }
    }
  }
  if (representationChanged || plotTypeChanged) {
    refreshWidget(connection);
  }
  if (representationChanged) {
    plotRepresentation=representation;
    refreshRepresentation(representation,connection);
  }
  if (plotTypeChanged) {
    if (category != null) {
      plotCategory=category;
    }
    if (type != null) {
      plotType=type;
    }
    refreshPlotType(type,connection);
  }
  if (representationChanged || plotTypeChanged) {
    refreshWidget(connection);
  }
  return;
}

Fixed version (ground truth):
@Override protected void updatePlotComposite(Composite plotComposite,VtkWebClient connection) throws Exception {
  refreshToolBar(toolBar);
  final String representation=getPlotRepresentation();
  boolean representationChanged=(representation != null && !representation.equals(plotRepresentation) && getPlotRepresentations().contains(representation));
  final String category=getPlotCategory();
  final String type=getPlotType();
  boolean plotTypeChanged=((category != null && !category.equals(plotCategory)) || (type != null && !type.equals(plotType)));
  if (plotTypeChanged && type != null) {
    plotTypeChanged=false;
    String[] types=plot.getPlotTypes().get(category);
    if (types != null) {
      for (int i=0; !plotTypeChanged && i < types.length; i++) {
        if (type.equals(types[i])) {
          plotTypeChanged=true;
        }
      }
    }
  }
  if (representationChanged || plotTypeChanged) {
    refreshWidget(false,connection);
  }
  if (representationChanged) {
    refreshRepresentation(representation,connection);
    plotRepresentation=representation;
  }
  if (plotTypeChanged) {
    refreshPlotType(category,type,connection);
    if (category != null) {
      plotCategory=category;
    }
    if (type != null) {
      plotType=type;
    }
  }
  if (representationChanged || plotTypeChanged) {
    refreshWidget(true,connection);
  }
  return;
}
Program: 133681
Project: 133681
Buggy source:
/** 
 * The full constructor. <i>This should only be called once per plot so that the view created to read the file's contents is not wasted.</i>
 * @param parent The parent Composite that contains the plot render.
 * @param plot The rendered ConnectionPlot. This cannot be changed.
 * @param viewId The ID of the view that was created to read the file's contents, or -1 to indicate that a view has not been created.
 * @param repId The ID of the representation (i.e., the render properties) of the file.
 */
public ParaViewPlotRender(Composite parent,ParaViewPlot plot,int viewId,int fileId,int repId){
  super(parent,plot);
  this.viewId=viewId;
  this.fileId=fileId;
  this.repId=repId;
  this.adapter=plot.getParaViewConnectionAdapter();
  return;
}

Fixed version (ground truth):
/** 
 * The full constructor. <i>This should only be called once per plot so that the view created to read the file's contents is not wasted.</i>
 * @param parent The parent Composite that contains the plot render.
 * @param plot The rendered ConnectionPlot. This cannot be changed.
 * @param viewId The ID of the view that was created to read the file's contents, or -1 to indicate that a view has not been created.
 * @param repId The ID of the representation (i.e., the render properties) of the file.
 */
public ParaViewPlotRender(Composite parent,ParaViewPlot plot,int viewId,int fileId,int repId){
  super(parent,plot);
  this.viewId=viewId;
  this.fileId=fileId;
  this.repId=repId;
  this.adapter=plot.getParaViewConnectionAdapter();
  plotTypeArrays=new HashMap<String,String>();
  plotTypeArrays.put("String_Node_Str","String_Node_Str");
  plotTypeArrays.put("String_Node_Str","String_Node_Str");
  plotTypeArrays.put("String_Node_Str","String_Node_Str");
  plotTypeArrays.put("String_Node_Str","String_Node_Str");
  return;
}
Program: 133682
Project: 133682
Buggy source:
@Override protected void disposePlotComposite(Composite plotComposite){
  if (plotTypeTree != null) {
    plotTypeTree.dispose();
    plotTypeTree=null;
  }
  if (representationTree != null) {
    representationTree.dispose();
    representationTree=null;
  }
  return;
}

Fixed version (ground truth):
@Override protected void disposePlotComposite(Composite plotComposite){
  if (plotTypeTree != null) {
    plotTypeTree.dispose();
    plotTypeTree=null;
  }
  if (representationTree != null) {
    representationTree.dispose();
    representationTree=null;
  }
  renderPanel=null;
  return;
}
Program: 133685
Project: 133685
Buggy source:
/** 
 * Load the data for a component that was listed in the ports table and return the information as a DataComponent. Each parameter in the component is added to the DataComponent as an entry.
 * @param it Iterator over the lines of the INI file as an ArrayList
 * @return A DataComponent containing information for one of the portentries.
 */
private DataComponent loadComponent(Iterator<String> it){
  DataComponent portComponent=new DataComponent();
  Entry entry;
  String[] splitLine=null;
  String line=it.next();
  while (!line.contains("String_Node_Str") && !line.contains("String_Node_Str") && it.hasNext()) {
    line=it.next();
  }
  String portName=line.replaceAll("String_Node_Str","String_Node_Str");
  portComponent.setName(portName);
  portComponent.setDescription("String_Node_Str");
  portComponent.setId(currID);
  currID++;
  while (line.trim().length() > 0) {
    if (line.contains("String_Node_Str")) {
      if (line.contains("String_Node_Str")) {
        line=line.split("String_Node_Str",2)[0];
      }
      splitLine=line.split("String_Node_Str",2);
      entry=makeIPSEntry();
      entry.setName(splitLine[0]);
      entry.setValue(splitLine[1]);
      entry.setId(currID);
      currID++;
      portComponent.addEntry(entry);
    }
    line=it.next();
  }
  if (!it.hasNext()) {
    System.err.println("String_Node_Str" + "String_Node_Str");
    return null;
  }
  return portComponent;
}

Fixed version (ground truth):
/** 
 * Load the data for a component that was listed in the ports table and return the information as a DataComponent. Each parameter in the component is added to the DataComponent as an entry.
 * @param it Iterator over the lines of the INI file as an ArrayList
 * @return A DataComponent containing information for one of the portentries.
 */
private DataComponent loadComponent(Iterator<String> it){
  DataComponent portComponent=new DataComponent();
  Entry entry;
  String[] splitLine=null;
  String line=it.next();
  while (!line.contains("String_Node_Str") && !line.contains("String_Node_Str") && it.hasNext()) {
    line=it.next();
  }
  String portName=line.replaceAll("String_Node_Str","String_Node_Str");
  portComponent.setName(portName);
  portComponent.setDescription("String_Node_Str");
  portComponent.setId(currID);
  currID++;
  if (portComponent.getName().equals("String_Node_Str")) {
    return portComponent;
  }
  while (line.trim().length() > 0) {
    if (line.contains("String_Node_Str")) {
      if (line.contains("String_Node_Str")) {
        line=line.split("String_Node_Str",2)[0];
      }
      splitLine=line.split("String_Node_Str",2);
      entry=makeIPSEntry();
      entry.setName(splitLine[0]);
      entry.setValue(splitLine[1]);
      entry.setId(currID);
      currID++;
      portComponent.addEntry(entry);
    }
    line=it.next();
  }
  if (!it.hasNext()) {
    System.err.println("String_Node_Str" + "String_Node_Str");
    return null;
  }
  return portComponent;
}
Program: 133687
Project: 133687
Buggy source:
/** 
 * Load the Time Loop Data from the INI file and return the data as a DataComponent. Each parameter in the section is added to the DataComponent as an Entry.
 * @param it Iterator over the lines of the INI file as an ArrayList
 * @return a DataComponent of Entries containing the information from theTime Loop Component of the INI file.
 */
private DataComponent loadTimeLoopComponent(Iterator<String> it){
  DataComponent timeLoopData=new DataComponent();
  Entry entry;
  String[] splitLine=null;
  String line="String_Node_Str";
  if (it.hasNext()) {
    line=it.next();
  }
 else {
    System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    return null;
  }
  while (!line.contains("String_Node_Str") && it.hasNext()) {
    line=it.next();
  }
  timeLoopData.setName("String_Node_Str");
  timeLoopData.setDescription("String_Node_Str");
  timeLoopData.setId(currID);
  currID++;
  while (it.hasNext()) {
    if (line.contains("String_Node_Str")) {
      if (line.contains("String_Node_Str")) {
        line=line.split("String_Node_Str",2)[0];
      }
      splitLine=line.split("String_Node_Str",2);
      entry=makeIPSEntry();
      entry.setName(splitLine[0]);
      entry.setValue(splitLine[1]);
      entry.setId(currID);
      currID++;
      timeLoopData.addEntry(entry);
    }
    line=it.next();
  }
  return timeLoopData;
}

Fixed version (ground truth):
/** 
 * Load the Time Loop Data from the INI file and return the data as a DataComponent. Each parameter in the section is added to the DataComponent as an Entry.
 * @param it Iterator over the lines of the INI file as an ArrayList
 * @return a DataComponent of Entries containing the information from theTime Loop Component of the INI file.
 */
private DataComponent loadTimeLoopComponent(Iterator<String> it){
  DataComponent timeLoopData=new DataComponent();
  Entry entry;
  String[] splitLine=null;
  String line="String_Node_Str";
  if (it.hasNext()) {
    line=it.next();
  }
 else {
    System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    return null;
  }
  timeLoopData.setName("String_Node_Str");
  timeLoopData.setDescription("String_Node_Str");
  timeLoopData.setId(currID);
  currID++;
  while (it.hasNext()) {
    if (line.contains("String_Node_Str")) {
      if (line.contains("String_Node_Str")) {
        line=line.split("String_Node_Str",2)[0];
      }
      splitLine=line.split("String_Node_Str",2);
      entry=makeIPSEntry();
      entry.setName(splitLine[0]);
      entry.setValue(splitLine[1]);
      entry.setId(currID);
      currID++;
      timeLoopData.addEntry(entry);
    }
    line=it.next();
  }
  return timeLoopData;
}
Program: 133690
Project: 133690
Buggy source:
/** 
 * Override of update so that the CaebatLauncher can check if the user wants to select a  custom KV Pair file.
 */
public void update(IUpdateable component){
  refreshProjectSpace();
  super.update(component);
  if (component.getName() == "String_Node_Str" && ((Entry)component).getValue() == "String_Node_Str") {
    addInputType("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  }
 else   if (component.getName() == "String_Node_Str" && ((Entry)component).getValue() == "String_Node_Str") {
    removeInputType("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Override of update so that the CaebatLauncher can check if the user wants to select a  custom KV Pair file.
 */
public void update(IUpdateable component){
  refreshProjectSpace();
  if (component instanceof Entry) {
    if (component.getName() == "String_Node_Str" && ((Entry)component).getValue() == "String_Node_Str") {
      addInputType("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    }
 else     if (component.getName() == "String_Node_Str" && ((Entry)component).getValue() == "String_Node_Str") {
      DataComponent fileComponent=(DataComponent)form.getComponent(1);
      fileComponent.deleteEntry("String_Node_Str");
    }
  }
}
Program: 133691
Project: 133691
Buggy source:
/** 
 * The Constructor
 * @param editor The FormEditor for which the Page should be constructed.
 * @param id The id of the page.
 * @param title The title of the page.
 */
public ICEResourcePage(FormEditor editor,String id,String title){
  super(editor,id,title);
  if (editor instanceof ICEFormEditor) {
  }
 else {
    System.out.println("String_Node_Str");
  }
  plotMap=new Hashtable<String,IPlot>();
  return;
}

Fixed version (ground truth):
/** 
 * The Constructor
 * @param editor 	The FormEditor for which the Page should be constructed.
 * @param id		The id of the page.
 * @param title		The title of the page.
 */
public ICEResourcePage(FormEditor editor,String id,String title){
  super(editor,id,title);
  if (editor instanceof ICEFormEditor) {
  }
 else {
    System.out.println("String_Node_Str");
  }
  plotMap=new Hashtable<String,IPlot>();
  return;
}
Program: 133694
Project: 133694
Buggy source:
/** 
 * This update method is called whenever the ResourceComponent is updated. It compares the contents of the ResourceComponent to the plotMap, and adds any VizResources to the plotMap that haven't been added yet.
 */
@Override public void update(IUpdateable component){
  if (component instanceof ResourceComponent) {
    if (resourceComponent != null) {
      for (      ICEResource resource : resourceComponent.getResources()) {
        if (resource instanceof VizResource && !plotMap.containsKey(resource.getPath().toString())) {
          try {
            IPlot plot=vizFactory.get().createPlot(resource.getPath());
            plotMap.put(plot.getDataSource().toString(),plot);
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * This update method is called whenever the ResourceComponent is updated. It compares the contents of the ResourceComponent to the plotMap, and adds any VizResources to the plotMap that haven't been added yet.
 */
@Override public void update(IUpdateable component){
  if (component instanceof ResourceComponent) {
    if (resourceComponent != null) {
      for (      ICEResource resource : resourceComponent.getResources()) {
        if (resource instanceof VizResource && !plotMap.containsKey(resource.getPath().toString())) {
          try {
            IPlot plot=vizFactory.get().createPlot(resource.getPath());
            if (plot != null) {
              plotMap.put(plot.getDataSource().toString(),plot);
            }
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
  return;
}