nus-yam/ex-repair huggingface dataset:
Program: 31122
Project: 31122
Buggy source:
public boolean LabelKeyboardHandler(int KeyCode,AttributeSet attrs,String ComponentName,Component comp,Circuit circ,SetAttributeAction act,boolean CreateAction){
switch (KeyCode) {
case KeyEvent.VK_L:
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String OldLabel=attrs.getValue(StdAttr.LABEL);
      String NewLabel=AskAndSetLabel(ComponentName,OldLabel,circ,comp,attrs,act,CreateAction);
      if (!NewLabel.equals(OldLabel)) {
        if (!NewLabel.isEmpty() && LabelEndsWithNumber(NewLabel)) {
          Activate(circ);
        }
 else {
          active.put(circ,false);
        }
      }
    }
  return true;
case KeyEvent.VK_T:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY)) {
  if (CreateAction)   act.set(comp,StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
 else   attrs.setValue(StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
}
return true;
case KeyEvent.VK_V:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && !attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,true);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,true);
}
return true;
case KeyEvent.VK_H:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,false);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,false);
}
return true;
case KeyEvent.VK_A:
Stop(circ);
return true;
}
return false;
}

Fixed version (ground truth):
public boolean LabelKeyboardHandler(int KeyCode,AttributeSet attrs,String ComponentName,Component comp,ComponentFactory compfac,Circuit circ,SetAttributeAction act,boolean CreateAction){
switch (KeyCode) {
case KeyEvent.VK_L:
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String OldLabel=attrs.getValue(StdAttr.LABEL);
      String NewLabel=AskAndSetLabel(ComponentName,OldLabel,circ,comp,compfac,attrs,act,CreateAction);
      if (!NewLabel.equals(OldLabel)) {
        if (!NewLabel.isEmpty() && LabelEndsWithNumber(NewLabel)) {
          Activate(circ);
        }
 else {
          active.put(circ,false);
        }
      }
    }
  return true;
case KeyEvent.VK_T:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY)) {
  if (CreateAction)   act.set(comp,StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
 else   attrs.setValue(StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
}
return true;
case KeyEvent.VK_V:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && !attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,true);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,true);
}
return true;
case KeyEvent.VK_H:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,false);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,false);
}
return true;
case KeyEvent.VK_A:
Stop(circ);
return true;
}
return false;
}
Program: 31123
Project: 31123
Buggy source:
public String GetCurrent(Circuit circ){
  if (circ == null || !CurrentLabel.containsKey(circ) || CurrentLabel.get(circ).isEmpty())   return "String_Node_Str";
  if (Circuit.IsCorrectLabel(CurrentLabel.get(circ),circ.getNonWires(),null,false))   return CurrentLabel.get(circ);
 else   if (hasNext(circ)) {
    return GetNext(circ);
  }
 else {
    SetLabel("String_Node_Str",circ);
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
public String GetCurrent(Circuit circ,ComponentFactory me){
  if (circ == null || !CurrentLabel.containsKey(circ) || CurrentLabel.get(circ).isEmpty())   return "String_Node_Str";
  if (Circuit.IsCorrectLabel(CurrentLabel.get(circ),circ.getNonWires(),null,me,false))   return CurrentLabel.get(circ);
 else   if (hasNext(circ)) {
    return GetNext(circ,me);
  }
 else {
    SetLabel("String_Node_Str",circ,me);
  }
  return "String_Node_Str";
}
Program: 31124
Project: 31124
Buggy source:
private void update(Circuit circ,String Label,boolean UseFirstLabel){
  if (circ == null)   return;
  if (Label.isEmpty() || !SyntaxChecker.isVariableNameAcceptable(Label,false)) {
    LabelBase.put(circ,"String_Node_Str");
    CurrentIndex.put(circ,0);
    UseLabelBaseOnly.put(circ,false);
    CurrentLabel.put(circ,"String_Node_Str");
    return;
  }
  UseLabelBaseOnly.put(circ,UseFirstLabel);
  if (LabelEndsWithNumber(Label)) {
    int Index=GetLabelBaseEndIndex(Label);
    CurrentIndex.put(circ,Integer.valueOf(Label.substring(Index + 1,Label.length())));
    LabelBase.put(circ,Label.substring(0,Index + 1));
    UseUnderscore.put(circ,false);
    UseLabelBaseOnly.put(circ,false);
  }
 else {
    LabelBase.put(circ,Label);
    CurrentIndex.put(circ,0);
    UseUnderscore.put(circ,!Label.substring(Label.length() - 1).equals("String_Node_Str"));
  }
  if (UseFirstLabel)   CurrentLabel.put(circ,Label);
 else   CurrentLabel.put(circ,GetNext(circ));
}

Fixed version (ground truth):
private void update(Circuit circ,String Label,boolean UseFirstLabel,ComponentFactory me){
  if (circ == null)   return;
  if (Label.isEmpty() || !SyntaxChecker.isVariableNameAcceptable(Label,false)) {
    LabelBase.put(circ,"String_Node_Str");
    CurrentIndex.put(circ,0);
    UseLabelBaseOnly.put(circ,false);
    CurrentLabel.put(circ,"String_Node_Str");
    return;
  }
  UseLabelBaseOnly.put(circ,UseFirstLabel);
  if (LabelEndsWithNumber(Label)) {
    int Index=GetLabelBaseEndIndex(Label);
    CurrentIndex.put(circ,Integer.valueOf(Label.substring(Index + 1,Label.length())));
    LabelBase.put(circ,Label.substring(0,Index + 1));
    UseUnderscore.put(circ,false);
    UseLabelBaseOnly.put(circ,false);
  }
 else {
    LabelBase.put(circ,Label);
    CurrentIndex.put(circ,0);
    UseUnderscore.put(circ,!Label.substring(Label.length() - 1).equals("String_Node_Str"));
  }
  if (UseFirstLabel)   CurrentLabel.put(circ,Label);
 else   CurrentLabel.put(circ,GetNext(circ,me));
}
Program: 31125
Project: 31125
Buggy source:
public String GetNext(Circuit circ){
  if (circ == null)   return "String_Node_Str";
  if (UseLabelBaseOnly.get(circ)) {
    UseLabelBaseOnly.put(circ,false);
    return LabelBase.get(circ);
  }
  String NewLabel="String_Node_Str";
  int CurIdx=CurrentIndex.get(circ);
  String BaseLab=LabelBase.get(circ);
  boolean Undescore=UseUnderscore.get(circ);
  do {
    CurIdx++;
    NewLabel=BaseLab;
    if (Undescore)     NewLabel=NewLabel.concat("String_Node_Str");
    NewLabel=NewLabel.concat(Integer.toString(CurIdx));
  }
 while (!Circuit.IsCorrectLabel(NewLabel,circ.getNonWires(),null,false));
  CurrentIndex.put(circ,CurIdx);
  CurrentLabel.put(circ,NewLabel);
  return NewLabel;
}

Fixed version (ground truth):
public String GetNext(Circuit circ,ComponentFactory me){
  if (circ == null)   return "String_Node_Str";
  if (UseLabelBaseOnly.get(circ)) {
    UseLabelBaseOnly.put(circ,false);
    return LabelBase.get(circ);
  }
  String NewLabel="String_Node_Str";
  int CurIdx=CurrentIndex.get(circ);
  String BaseLab=LabelBase.get(circ);
  boolean Undescore=UseUnderscore.get(circ);
  do {
    CurIdx++;
    NewLabel=BaseLab;
    if (Undescore)     NewLabel=NewLabel.concat("String_Node_Str");
    NewLabel=NewLabel.concat(Integer.toString(CurIdx));
  }
 while (!Circuit.IsCorrectLabel(NewLabel,circ.getNonWires(),null,me,false));
  CurrentIndex.put(circ,CurIdx);
  CurrentLabel.put(circ,NewLabel);
  return NewLabel;
}
Program: 31126
Project: 31126
Buggy source:
public void SetLabel(String Label,Circuit circ){
  if (circ == null)   return;
  update(circ,Label,true);
}

Fixed version (ground truth):
public void SetLabel(String Label,Circuit circ,ComponentFactory me){
  if (circ == null)   return;
  update(circ,Label,true,me);
}
Program: 31127
Project: 31127
Buggy source:
public String AskAndSetLabel(String ComponentName,String OldLabel,Circuit circ,Component comp,AttributeSet attrs,SetAttributeAction act,boolean CreateAction){
  boolean correct=false;
  String NewLabel=OldLabel;
  while (!correct) {
    NewLabel=(String)JOptionPane.showInputDialog(null,Strings.get("String_Node_Str") + "String_Node_Str" + ComponentName,Strings.get("String_Node_Str"),JOptionPane.QUESTION_MESSAGE,null,null,OldLabel);
    if (NewLabel != null) {
      if (Circuit.IsCorrectLabel(NewLabel,circ.getNonWires(),attrs,true) && SyntaxChecker.isVariableNameAcceptable(NewLabel,true) && !CorrectLabel.IsKeyword(NewLabel,true)) {
        if (CreateAction)         act.set(comp,StdAttr.LABEL,NewLabel);
 else         SetLabel(NewLabel,circ);
        correct=true;
      }
    }
 else {
      correct=true;
      NewLabel=OldLabel;
    }
  }
  return NewLabel;
}

Fixed version (ground truth):
public String AskAndSetLabel(String ComponentName,String OldLabel,Circuit circ,Component comp,ComponentFactory compfac,AttributeSet attrs,SetAttributeAction act,boolean CreateAction){
  boolean correct=false;
  String NewLabel=OldLabel;
  while (!correct) {
    NewLabel=(String)JOptionPane.showInputDialog(null,Strings.get("String_Node_Str") + "String_Node_Str" + ComponentName,Strings.get("String_Node_Str"),JOptionPane.QUESTION_MESSAGE,null,null,OldLabel);
    if (NewLabel != null) {
      if (Circuit.IsCorrectLabel(NewLabel,circ.getNonWires(),attrs,compfac,true) && SyntaxChecker.isVariableNameAcceptable(NewLabel,true) && !CorrectLabel.IsKeyword(NewLabel,true)) {
        if (CreateAction)         act.set(comp,StdAttr.LABEL,NewLabel);
 else         SetLabel(NewLabel,circ,compfac);
        correct=true;
      }
    }
 else {
      correct=true;
      NewLabel=OldLabel;
    }
  }
  return NewLabel;
}
Program: 31128
Project: 31128
Buggy source:
AttrTableComponentModel(Project proj,Circuit circ,Component comp){
  super(comp.getAttributeSet());
  this.proj=proj;
  this.circ=circ;
  this.comp=comp;
}

Fixed version (ground truth):
AttrTableComponentModel(Project proj,Circuit circ,Component comp){
  super(comp.getAttributeSet());
  this.proj=proj;
  this.circ=circ;
  this.comp=comp;
  SetInstance(comp.getFactory());
}
Program: 31129
Project: 31129
Buggy source:
public boolean LabelKeyboardHandler(int KeyCode,AttributeSet attrs,String ComponentName,Component comp,Circuit circ,SetAttributeAction act,boolean CreateAction){
switch (KeyCode) {
case KeyEvent.VK_L:
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String OldLabel=attrs.getValue(StdAttr.LABEL);
      String NewLabel=AskAndSetLabel(ComponentName,OldLabel,circ,comp,attrs,act,CreateAction);
      if (!NewLabel.equals(OldLabel)) {
        if (!NewLabel.isEmpty() && LabelEndsWithNumber(NewLabel)) {
          Activate(circ);
        }
 else {
          Stop(circ);
        }
      }
    }
  return true;
case KeyEvent.VK_T:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY)) {
  if (CreateAction)   act.set(comp,StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
 else   attrs.setValue(StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
}
return true;
case KeyEvent.VK_V:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && !attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,true);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,true);
}
return true;
case KeyEvent.VK_H:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,false);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,false);
}
return true;
case KeyEvent.VK_A:
Stop(circ);
return true;
}
return false;
}

Fixed version (ground truth):
public boolean LabelKeyboardHandler(int KeyCode,AttributeSet attrs,String ComponentName,Component comp,Circuit circ,SetAttributeAction act,boolean CreateAction){
switch (KeyCode) {
case KeyEvent.VK_L:
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String OldLabel=attrs.getValue(StdAttr.LABEL);
      String NewLabel=AskAndSetLabel(ComponentName,OldLabel,circ,comp,attrs,act,CreateAction);
      if (!NewLabel.equals(OldLabel)) {
        if (!NewLabel.isEmpty() && LabelEndsWithNumber(NewLabel)) {
          Activate(circ);
        }
 else {
          active.put(circ,false);
        }
      }
    }
  return true;
case KeyEvent.VK_T:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY)) {
  if (CreateAction)   act.set(comp,StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
 else   attrs.setValue(StdAttr.LABEL_VISABILITY,!attrs.getValue(StdAttr.LABEL_VISABILITY));
}
return true;
case KeyEvent.VK_V:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && !attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,true);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,true);
}
return true;
case KeyEvent.VK_H:
if (attrs.containsAttribute(StdAttr.LABEL_VISABILITY) && attrs.getValue(StdAttr.LABEL_VISABILITY)) {
if (CreateAction) act.set(comp,StdAttr.LABEL_VISABILITY,false);
 else attrs.setValue(StdAttr.LABEL_VISABILITY,false);
}
return true;
case KeyEvent.VK_A:
Stop(circ);
return true;
}
return false;
}
Program: 31130
Project: 31130
Buggy source:
public void attributeValueChanged(AttributeEvent e){
  if (e.getAttribute() == NAMED_CIRCUIT_BOX) {
    source.RecalcDefaultShape();
  }
  if (e.getAttribute() == NAME_ATTR) {
    String NewName=(String)e.getValue();
    String OldName=e.getOldValue() == null ? "String_Node_Str" : (String)e.getOldValue();
    if (!NewName.equals(OldName)) {
      if (NewName.isEmpty()) {
        JOptionPane.showMessageDialog(null,Strings.get("String_Node_Str"));
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else       if (!SyntaxChecker.isVariableNameAcceptable(NewName,true)) {
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else       if (CorrectLabel.IsKeyword(NewName,false)) {
        JOptionPane.showMessageDialog(null,Strings.get("String_Node_Str"));
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else {
        source.fireEvent(CircuitEvent.ACTION_CHECK_NAME,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,NewName);
        source.RecalcDefaultShape();
      }
    }
  }
}

Fixed version (ground truth):
public void attributeValueChanged(AttributeEvent e){
  if (e.getAttribute() == NAME_ATTR) {
    String NewName=(String)e.getValue();
    String OldName=e.getOldValue() == null ? "String_Node_Str" : (String)e.getOldValue();
    if (!NewName.equals(OldName)) {
      if (NewName.isEmpty()) {
        JOptionPane.showMessageDialog(null,Strings.get("String_Node_Str"));
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else       if (!SyntaxChecker.isVariableNameAcceptable(NewName,true)) {
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else       if (CorrectLabel.IsKeyword(NewName,false)) {
        JOptionPane.showMessageDialog(null,Strings.get("String_Node_Str"));
        e.getSource().setValue(NAME_ATTR,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,OldName);
        return;
      }
 else {
        source.fireEvent(CircuitEvent.ACTION_CHECK_NAME,OldName);
        source.fireEvent(CircuitEvent.ACTION_SET_NAME,NewName);
      }
    }
  }
}
Program: 31131
Project: 31131
Buggy source:
boolean concernsSupercircuit(){
switch (type) {
case CLEAR:
    return true;
case ADD:
case REMOVE:
  return comp.getFactory() instanceof Pin;
case ADD_ALL:
case REMOVE_ALL:
for (Component comp : comps) {
  if (comp.getFactory() instanceof Pin)   return true;
}
return false;
case REPLACE:
ReplacementMap repl=(ReplacementMap)newValue;
for (Component comp : repl.getRemovals()) {
if (comp.getFactory() instanceof Pin) return true;
}
for (Component comp : repl.getAdditions()) {
if (comp.getFactory() instanceof Pin) return true;
}
return false;
case SET:
return comp.getFactory() instanceof Pin && (attr == StdAttr.WIDTH || attr == Pin.ATTR_TYPE);
default :
return false;
}
}

Fixed version (ground truth):
boolean concernsSupercircuit(){
switch (type) {
case CLEAR:
    return true;
case ADD:
case REMOVE:
  return comp.getFactory() instanceof Pin;
case ADD_ALL:
case REMOVE_ALL:
for (Component comp : comps) {
  if (comp.getFactory() instanceof Pin)   return true;
}
return false;
case REPLACE:
ReplacementMap repl=(ReplacementMap)newValue;
for (Component comp : repl.getRemovals()) {
if (comp.getFactory() instanceof Pin) return true;
}
for (Component comp : repl.getAdditions()) {
if (comp.getFactory() instanceof Pin) return true;
}
return false;
case SET:
return comp.getFactory() instanceof Pin && (attr == StdAttr.WIDTH || attr == Pin.ATTR_TYPE);
case SET_FOR_CIRCUIT:
return (attr == CircuitAttributes.NAME_ATTR || attr == CircuitAttributes.NAMED_CIRCUIT_BOX);
default :
return false;
}
}
Program: 31132
Project: 31132
Buggy source:
public void setForCircuit(Circuit circuit,Attribute<?> attr,Object newValue){
  @SuppressWarnings("String_Node_Str") Attribute<Object> a=(Attribute<Object>)attr;
  AttributeSet attrs=circuit.getStaticAttributes();
  Object oldValue=attrs.getValue(a);
  log.add(CircuitChange.setForCircuit(circuit,attr,oldValue,newValue));
  attrs.setValue(a,newValue);
}

Fixed version (ground truth):
public void setForCircuit(Circuit circuit,Attribute<?> attr,Object newValue){
  @SuppressWarnings("String_Node_Str") Attribute<Object> a=(Attribute<Object>)attr;
  AttributeSet attrs=circuit.getStaticAttributes();
  Object oldValue=attrs.getValue(a);
  log.add(CircuitChange.setForCircuit(circuit,attr,oldValue,newValue));
  attrs.setValue(a,newValue);
  if (attr == CircuitAttributes.NAME_ATTR || attr == CircuitAttributes.NAMED_CIRCUIT_BOX) {
    circuit.getAppearance().recomputeDefaultAppearance();
  }
}
Program: 31133
Project: 31133
Buggy source:
public void SetInstance(ComponentFactory comp){
  CompInst=comp;
}

Fixed version (ground truth):
public void SetInstance(ComponentFactory fact){
  CompInst=fact;
}
Program: 31134
Project: 31134
Buggy source:
@Override public void setValueRequested(Attribute<Object> attr,Object value) throws AttrTableSetException {
  Selection selection=frame.getCanvas().getSelection();
  Circuit circuit=frame.getCanvas().getCircuit();
  if (selection.isEmpty() && circuit != null) {
    AttrTableCircuitModel circuitModel=new AttrTableCircuitModel(project,circuit);
    circuitModel.setValueRequested(attr,value);
  }
 else {
    SetAttributeAction act=new SetAttributeAction(circuit,Strings.getter("String_Node_Str"));
    for (    Component comp : selection.getComponents()) {
      if (!(comp instanceof Wire)) {
        act.set(comp,attr,value);
      }
    }
    project.doAction(act);
  }
}

Fixed version (ground truth):
@Override public void setValueRequested(Attribute<Object> attr,Object value) throws AttrTableSetException {
  Selection selection=frame.getCanvas().getSelection();
  Circuit circuit=frame.getCanvas().getCircuit();
  if (selection.isEmpty() && circuit != null) {
    AttrTableCircuitModel circuitModel=new AttrTableCircuitModel(project,circuit);
    circuitModel.setValueRequested(attr,value);
  }
 else {
    SetAttributeAction act=new SetAttributeAction(circuit,Strings.getter("String_Node_Str"));
    for (    Component comp : selection.getComponents()) {
      if (!(comp instanceof Wire)) {
        if (comp.getFactory() instanceof SubcircuitFactory) {
          SubcircuitFactory fac=(SubcircuitFactory)comp.getFactory();
          if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX) || attr.equals(CircuitAttributes.NAME_ATTR)) {
            try {
              CircuitMutation mutation=new CircuitMutation(fac.getSubcircuit());
              mutation.setForCircuit(attr,value);
              Action action=mutation.toAction(null);
              project.doAction(action);
            }
 catch (            CircuitException ex) {
              JOptionPane.showMessageDialog(project.getFrame(),ex.getMessage());
            }
            return;
          }
        }
        act.set(comp,attr,value);
      }
    }
    project.doAction(act);
  }
}
Program: 31135
Project: 31135
Buggy source:
@Override public void setValueRequested(Attribute<Object> attr,Object value){
  proj.doAction(ToolAttributeAction.create(tool,attr,value));
}

Fixed version (ground truth):
@Override public void setValueRequested(Attribute<Object> attr,Object value){
  if (tool instanceof AddTool) {
    AddTool mytool=(AddTool)tool;
    if (mytool.getFactory() instanceof SubcircuitFactory) {
      SubcircuitFactory fac=(SubcircuitFactory)mytool.getFactory();
      if (attr.equals(CircuitAttributes.NAMED_CIRCUIT_BOX) || attr.equals(CircuitAttributes.NAME_ATTR)) {
        try {
          CircuitMutation mutation=new CircuitMutation(fac.getSubcircuit());
          mutation.setForCircuit(attr,value);
          Action action=mutation.toAction(null);
          proj.doAction(action);
        }
 catch (        CircuitException ex) {
          JOptionPane.showMessageDialog(proj.getFrame(),ex.getMessage());
        }
        return;
      }
    }
  }
  proj.doAction(ToolAttributeAction.create(tool,attr,value));
}
Program: 31136
Project: 31136
Buggy source:
public static Action loadLibraries(Library[] libs){
  return new LoadLibraries(libs);
}

Fixed version (ground truth):
public static Action loadLibraries(Library[] libs,LogisimFile source){
  return new LoadLibraries(libs,source);
}
Program: 31137
Project: 31137
Buggy source:
LoadLibraries(Library[] libs){
  this.libs=libs;
}

Fixed version (ground truth):
LoadLibraries(Library[] libs,LogisimFile source){
  HashSet<String> LibNames=new HashSet<String>();
  HashSet<String> ToolList=new HashSet<String>();
  HashMap<String,String> Error=new HashMap<String,String>();
  for (  Library lib : source.getLibraries()) {
    LibraryTools.BuildLibraryList(lib,LibNames);
  }
  LibraryTools.BuildToolList(source,ToolList);
  for (int i=0; i < libs.length; i++) {
    if (LibNames.contains(libs[i].getName().toUpperCase())) {
      JOptionPane.showMessageDialog(null,"String_Node_Str" + libs[i].getName() + "String_Node_Str"+ Strings.get("String_Node_Str"),Strings.get("String_Node_Str") + "String_Node_Str" + libs[i].getName()+ "String_Node_Str",JOptionPane.WARNING_MESSAGE);
    }
 else {
      LibraryTools.RemovePresentLibraries(libs[i],LibNames);
      if (LibraryTools.LibraryIsConform(libs[i],new HashSet<String>(),new HashSet<String>(),Error)) {
        HashSet<String> AddedToolList=new HashSet<String>();
        LibraryTools.BuildToolList(libs[i],AddedToolList);
        for (        String tool : AddedToolList)         if (ToolList.contains(tool))         Error.put(tool,Strings.get("String_Node_Str"));
        if (Error.keySet().isEmpty()) {
          LibraryTools.BuildLibraryList(libs[i],LibNames);
          ToolList.addAll(AddedToolList);
          MergedLibs.add(libs[i]);
        }
 else         LibraryTools.ShowErrors(libs[i].getName(),Error);
      }
 else       LibraryTools.ShowErrors(libs[i].getName(),Error);
    }
  }
}
Program: 31138
Project: 31138
Buggy source:
public static Action loadLibrary(Library lib){
  return new LoadLibraries(new Library[]{lib});
}

Fixed version (ground truth):
public static Action loadLibrary(Library lib,LogisimFile source){
  return new LoadLibraries(new Library[]{lib},source);
}
Program: 31139
Project: 31139
Buggy source:
public static void doLoadBuiltinLibrary(Project proj){
  LogisimFile file=proj.getLogisimFile();
  List<Library> baseBuilt=file.getLoader().getBuiltin().getLibraries();
  ArrayList<Library> builtins=new ArrayList<Library>(baseBuilt);
  builtins.removeAll(file.getLibraries());
  if (builtins.isEmpty()) {
    JOptionPane.showMessageDialog(proj.getFrame(),Strings.get("String_Node_Str"),Strings.get("String_Node_Str"),JOptionPane.INFORMATION_MESSAGE);
    return;
  }
  LibraryJList list=new LibraryJList(builtins);
  JScrollPane listPane=new JScrollPane(list);
  int action=JOptionPane.showConfirmDialog(proj.getFrame(),listPane,Strings.get("String_Node_Str"),JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
  if (action == JOptionPane.OK_OPTION) {
    Library[] libs=list.getSelectedLibraries();
    if (libs != null)     proj.doAction(LogisimFileActions.loadLibraries(libs));
  }
}

Fixed version (ground truth):
public static void doLoadBuiltinLibrary(Project proj){
  LogisimFile file=proj.getLogisimFile();
  List<Library> baseBuilt=file.getLoader().getBuiltin().getLibraries();
  ArrayList<Library> builtins=new ArrayList<Library>(baseBuilt);
  builtins.removeAll(file.getLibraries());
  if (builtins.isEmpty()) {
    JOptionPane.showMessageDialog(proj.getFrame(),Strings.get("String_Node_Str"),Strings.get("String_Node_Str"),JOptionPane.INFORMATION_MESSAGE);
    return;
  }
  LibraryJList list=new LibraryJList(builtins);
  JScrollPane listPane=new JScrollPane(list);
  int action=JOptionPane.showConfirmDialog(proj.getFrame(),listPane,Strings.get("String_Node_Str"),JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
  if (action == JOptionPane.OK_OPTION) {
    Library[] libs=list.getSelectedLibraries();
    if (libs != null)     proj.doAction(LogisimFileActions.loadLibraries(libs,proj.getLogisimFile()));
  }
}
Program: 31140
Project: 31140
Buggy source:
public static void doLoadJarLibrary(Project proj){
  Loader loader=proj.getLogisimFile().getLoader();
  JFileChooser chooser=loader.createChooser();
  chooser.setDialogTitle(Strings.get("String_Node_Str"));
  chooser.setFileFilter(Loader.JAR_FILTER);
  int check=chooser.showOpenDialog(proj.getFrame());
  if (check == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    String className=null;
    JarFile jarFile=null;
    try {
      jarFile=new JarFile(f);
      Manifest manifest=jarFile.getManifest();
      className=manifest.getMainAttributes().getValue("String_Node_Str");
    }
 catch (    IOException e) {
    }
 finally {
      if (jarFile != null) {
        try {
          jarFile.close();
        }
 catch (        IOException e) {
        }
      }
    }
    if (className == null) {
      className=JOptionPane.showInputDialog(proj.getFrame(),Strings.get("String_Node_Str"),Strings.get("String_Node_Str"),JOptionPane.QUESTION_MESSAGE);
      if (className == null)       return;
    }
    Library lib=loader.loadJarLibrary(f,className);
    if (lib != null) {
      proj.doAction(LogisimFileActions.loadLibrary(lib));
    }
  }
}

Fixed version (ground truth):
public static void doLoadJarLibrary(Project proj){
  Loader loader=proj.getLogisimFile().getLoader();
  JFileChooser chooser=loader.createChooser();
  chooser.setDialogTitle(Strings.get("String_Node_Str"));
  chooser.setFileFilter(Loader.JAR_FILTER);
  int check=chooser.showOpenDialog(proj.getFrame());
  if (check == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    String className=null;
    JarFile jarFile=null;
    try {
      jarFile=new JarFile(f);
      Manifest manifest=jarFile.getManifest();
      className=manifest.getMainAttributes().getValue("String_Node_Str");
    }
 catch (    IOException e) {
    }
 finally {
      if (jarFile != null) {
        try {
          jarFile.close();
        }
 catch (        IOException e) {
        }
      }
    }
    if (className == null) {
      className=JOptionPane.showInputDialog(proj.getFrame(),Strings.get("String_Node_Str"),Strings.get("String_Node_Str"),JOptionPane.QUESTION_MESSAGE);
      if (className == null)       return;
    }
    Library lib=loader.loadJarLibrary(f,className);
    if (lib != null) {
      proj.doAction(LogisimFileActions.loadLibrary(lib,proj.getLogisimFile()));
    }
  }
}
Program: 31141
Project: 31141
Buggy source:
public static void doLoadLogisimLibrary(Project proj){
  Loader loader=proj.getLogisimFile().getLoader();
  JFileChooser chooser=loader.createChooser();
  chooser.setDialogTitle(Strings.get("String_Node_Str"));
  chooser.setFileFilter(Loader.LOGISIM_FILTER);
  int check=chooser.showOpenDialog(proj.getFrame());
  if (check == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    Library lib=loader.loadLogisimLibrary(f);
    if (lib != null) {
      proj.doAction(LogisimFileActions.loadLibrary(lib));
    }
  }
}

Fixed version (ground truth):
public static void doLoadLogisimLibrary(Project proj){
  Loader loader=proj.getLogisimFile().getLoader();
  JFileChooser chooser=loader.createChooser();
  chooser.setDialogTitle(Strings.get("String_Node_Str"));
  chooser.setFileFilter(Loader.LOGISIM_FILTER);
  int check=chooser.showOpenDialog(proj.getFrame());
  if (check == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    Library lib=loader.loadLogisimLibrary(f);
    if (lib != null) {
      proj.doAction(LogisimFileActions.loadLibrary(lib,proj.getLogisimFile()));
    }
  }
}
Program: 31142
Project: 31142
Buggy source:
public void LabelChanged(ComponentEvent e){
  AttributeEvent attre=(AttributeEvent)e.getData();
  if (attre.getSource() == null && attre.getValue() == null && attre.getOldValue() != null) {
    String oldLabel=(String)attre.getOldValue();
    if (UsedLabels.contains(oldLabel.toUpperCase()))     UsedLabels.remove(oldLabel.toUpperCase());
    return;
  }
  String newLabel=(String)attre.getValue();
  String oldLabel=attre.getOldValue() != null ? (String)attre.getOldValue() : "String_Node_Str";
  @SuppressWarnings("String_Node_Str") Attribute<String> lattr=(Attribute<String>)attre.getAttribute();
  if (UsedLabels.contains(newLabel.toUpperCase())) {
    JOptionPane.showMessageDialog(null,"String_Node_Str" + newLabel + "String_Node_Str"+ Strings.get("String_Node_Str"));
    if (UsedLabels.contains(oldLabel.toUpperCase()))     UsedLabels.remove(oldLabel.toUpperCase());
    attre.getSource().setValue(lattr,oldLabel);
  }
 else   if (UsedComponentNames.contains(newLabel.toUpperCase())) {
    JOptionPane.showMessageDialog(null,"String_Node_Str" + newLabel + "String_Node_Str"+ Strings.get("String_Node_Str"));
    if (UsedLabels.contains(oldLabel.toUpperCase()))     UsedLabels.remove(oldLabel.toUpperCase());
    attre.getSource().setValue(lattr,oldLabel);
  }
 else {
    if (UsedLabels.contains(oldLabel.toUpperCase()))     UsedLabels.remove(oldLabel.toUpperCase());
    if (!newLabel.isEmpty())     UsedLabels.add(newLabel.toUpperCase());
  }
}

Fixed version (ground truth):
public void LabelChanged(ComponentEvent e){
  AttributeEvent attre=(AttributeEvent)e.getData();
  if (attre.getSource() == null || attre.getValue() == null) {
    return;
  }
  String newLabel=(String)attre.getValue();
  String oldLabel=attre.getOldValue() != null ? (String)attre.getOldValue() : "String_Node_Str";
  @SuppressWarnings("String_Node_Str") Attribute<String> lattr=(Attribute<String>)attre.getAttribute();
  if (IsExistingLabel(newLabel,attre.getSource())) {
    JOptionPane.showMessageDialog(null,"String_Node_Str" + newLabel + "String_Node_Str"+ Strings.get("String_Node_Str"));
    attre.getSource().setValue(lattr,oldLabel);
  }
 else   if (IsComponentName(newLabel)) {
    JOptionPane.showMessageDialog(null,"String_Node_Str" + newLabel + "String_Node_Str"+ Strings.get("String_Node_Str"));
    attre.getSource().setValue(lattr,oldLabel);
  }
}
Program: 31143
Project: 31143
Buggy source:
void mutatorAdd(Component c){
  locker.checkForWritePermission("String_Node_Str");
  Annotated=false;
  MyNetList.clear();
  if (c instanceof Wire) {
    Wire w=(Wire)c;
    if (w.getEnd0().equals(w.getEnd1()))     return;
    boolean added=wires.add(w);
    if (!added)     return;
  }
 else {
    boolean added=comps.add(c);
    if (!added)     return;
    wires.add(c);
    ComponentFactory factory=c.getFactory();
    if (factory instanceof Clock) {
      clocks.add(c);
    }
 else     if (factory instanceof SubcircuitFactory) {
      SubcircuitFactory subcirc=(SubcircuitFactory)factory;
      subcirc.getSubcircuit().circuitsUsingThis.put(c,this);
    }
    c.addComponentListener(myComponentListener);
  }
  String ComponentName=c.getFactory().getName().toUpperCase();
  if (!UsedComponentNames.contains(ComponentName))   UsedComponentNames.add(ComponentName);
  if (c.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
    String Label=c.getAttributeSet().getValue(StdAttr.LABEL);
    if (!UsedLabels.contains(Label.toUpperCase()) && !Label.isEmpty())     UsedLabels.add(Label.toUpperCase());
  }
  if (UsedLabels.contains(ComponentName)) {
    RemoveWrongLabels(ComponentName);
  }
  fireEvent(CircuitEvent.ACTION_ADD,c);
}

Fixed version (ground truth):
void mutatorAdd(Component c){
  locker.checkForWritePermission("String_Node_Str");
  Annotated=false;
  MyNetList.clear();
  if (c instanceof Wire) {
    Wire w=(Wire)c;
    if (w.getEnd0().equals(w.getEnd1()))     return;
    boolean added=wires.add(w);
    if (!added)     return;
  }
 else {
    boolean added=comps.add(c);
    if (!added)     return;
    wires.add(c);
    ComponentFactory factory=c.getFactory();
    if (factory instanceof Clock) {
      clocks.add(c);
    }
 else     if (factory instanceof SubcircuitFactory) {
      SubcircuitFactory subcirc=(SubcircuitFactory)factory;
      subcirc.getSubcircuit().circuitsUsingThis.put(c,this);
    }
    c.addComponentListener(myComponentListener);
  }
  RemoveWrongLabels(c.getFactory().getName());
  fireEvent(CircuitEvent.ACTION_ADD,c);
}
Program: 31144
Project: 31144
Buggy source:
void mutatorRemove(Component c){
  locker.checkForWritePermission("String_Node_Str");
  Annotated=false;
  MyNetList.clear();
  if (c instanceof Wire) {
    wires.remove(c);
  }
 else {
    wires.remove(c);
    comps.remove(c);
    ComponentFactory factory=c.getFactory();
    if (factory instanceof Clock) {
      clocks.remove(c);
    }
 else     if (factory instanceof SubcircuitFactory) {
      SubcircuitFactory subcirc=(SubcircuitFactory)factory;
      subcirc.getSubcircuit().circuitsUsingThis.remove(c);
    }
    c.removeComponentListener(myComponentListener);
  }
  if (c.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
    String Label=c.getAttributeSet().getValue(StdAttr.LABEL);
    if (!Label.isEmpty() && UsedLabels.contains(Label.toUpperCase())) {
      UsedLabels.remove(Label.toUpperCase());
    }
  }
  RebuildComponentNames();
  fireEvent(CircuitEvent.ACTION_REMOVE,c);
}

Fixed version (ground truth):
void mutatorRemove(Component c){
  locker.checkForWritePermission("String_Node_Str");
  Annotated=false;
  MyNetList.clear();
  if (c instanceof Wire) {
    wires.remove(c);
  }
 else {
    wires.remove(c);
    comps.remove(c);
    ComponentFactory factory=c.getFactory();
    if (factory instanceof Clock) {
      clocks.remove(c);
    }
 else     if (factory instanceof SubcircuitFactory) {
      SubcircuitFactory subcirc=(SubcircuitFactory)factory;
      subcirc.getSubcircuit().circuitsUsingThis.remove(c);
    }
    c.removeComponentListener(myComponentListener);
  }
  fireEvent(CircuitEvent.ACTION_REMOVE,c);
}
Program: 31145
Project: 31145
Buggy source:
public void mutatorClear(){
  locker.checkForWritePermission("String_Node_Str");
  Set<Component> oldComps=comps;
  comps=new HashSet<Component>();
  wires=new CircuitWires();
  clocks.clear();
  MyNetList.clear();
  Annotated=false;
  for (  Component comp : oldComps) {
    if (comp.getFactory() instanceof SubcircuitFactory) {
      SubcircuitFactory sub=(SubcircuitFactory)comp.getFactory();
      sub.getSubcircuit().circuitsUsingThis.remove(comp);
    }
  }
  UsedComponentNames.clear();
  UsedLabels.clear();
  fireEvent(CircuitEvent.ACTION_CLEAR,oldComps);
}

Fixed version (ground truth):
public void mutatorClear(){
  locker.checkForWritePermission("String_Node_Str");
  Set<Component> oldComps=comps;
  comps=new HashSet<Component>();
  wires=new CircuitWires();
  clocks.clear();
  MyNetList.clear();
  Annotated=false;
  for (  Component comp : oldComps) {
    if (comp.getFactory() instanceof SubcircuitFactory) {
      SubcircuitFactory sub=(SubcircuitFactory)comp.getFactory();
      sub.getSubcircuit().circuitsUsingThis.remove(comp);
    }
  }
  fireEvent(CircuitEvent.ACTION_CLEAR,oldComps);
}
Program: 31146
Project: 31146
Buggy source:
private void RemoveWrongLabels(String Label){
  for (  Component comp : comps) {
    AttributeSet attrs=comp.getAttributeSet();
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String CompLabel=attrs.getValue(StdAttr.LABEL);
      if (Label.equals(CompLabel.toUpperCase())) {
        attrs.setValue(StdAttr.LABEL,"String_Node_Str");
      }
    }
  }
  Iterator<? extends Component> wire=wires.getComponents();
  while (wire.hasNext()) {
    Component comp=wire.next();
    AttributeSet attrs=comp.getAttributeSet();
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String CompLabel=attrs.getValue(StdAttr.LABEL);
      if (Label.equals(CompLabel.toUpperCase())) {
        attrs.setValue(StdAttr.LABEL,"String_Node_Str");
      }
    }
  }
  UsedLabels.remove(Label);
  JOptionPane.showMessageDialog(null,"String_Node_Str" + Label + "String_Node_Str"+ Strings.get("String_Node_Str"));
}

Fixed version (ground truth):
private void RemoveWrongLabels(String Label){
  boolean HaveAChange=false;
  for (  Component comp : comps) {
    AttributeSet attrs=comp.getAttributeSet();
    if (attrs.containsAttribute(StdAttr.LABEL)) {
      String CompLabel=attrs.getValue(StdAttr.LABEL);
      if (Label.toUpperCase().equals(CompLabel.toUpperCase())) {
        attrs.setValue(StdAttr.LABEL,"String_Node_Str");
        HaveAChange=true;
      }
    }
  }
  if (HaveAChange)   JOptionPane.showMessageDialog(null,"String_Node_Str" + Label + "String_Node_Str"+ Strings.get("String_Node_Str"));
}
Program: 31147
Project: 31147
Buggy source:
private boolean NameIsInUse(String Name,Circuit changed){
  for (  Library mylib : getLibraries()) {
    if (NameIsInLibraries(mylib,Name))     return true;
  }
  for (  Circuit mytool : this.getCircuits()) {
    if (Name.toUpperCase().equals(mytool.getName().toUpperCase()) && !mytool.equals(changed))     return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean NameIsInUse(String Name,Circuit changed){
  if (Name.isEmpty())   return false;
  for (  Library mylib : getLibraries()) {
    if (NameIsInLibraries(mylib,Name))     return true;
  }
  for (  Circuit mytool : this.getCircuits()) {
    if (Name.toUpperCase().equals(mytool.getName().toUpperCase()) && !mytool.equals(changed))     return true;
  }
  return false;
}
Program: 31148
Project: 31148
Buggy source:
private boolean NameIsInLibraries(Library lib,String Name){
  for (  Library mylib : lib.getLibraries()) {
    if (NameIsInLibraries(mylib,Name))     return true;
  }
  for (  Tool mytool : lib.getTools()) {
    if (Name.toUpperCase().equals(mytool.getName().toUpperCase()))     return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean NameIsInLibraries(Library lib,String Name){
  if (Name.isEmpty())   return false;
  for (  Library mylib : lib.getLibraries()) {
    if (NameIsInLibraries(mylib,Name))     return true;
  }
  for (  Tool mytool : lib.getTools()) {
    if (Name.toUpperCase().equals(mytool.getName().toUpperCase()))     return true;
  }
  return false;
}
Program: 31149
Project: 31149
Buggy source:
public int getWidth(){
  if (dimsKnown)   return this.width;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int width=fm.stringWidth(text);
  frame.setVisible(false);
  return width;
}

Fixed version (ground truth):
public int getWidth(){
  if (dimsKnown)   return this.width;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int width=fm.stringWidth(text);
  frame.setVisible(false);
  frame.dispose();
  return width;
}
Program: 31150
Project: 31150
Buggy source:
public int getHeight(){
  if (dimsKnown)   return ascent + descent;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int height=fm.getAscent() + fm.getDescent();
  frame.setVisible(false);
  return height;
}

Fixed version (ground truth):
public int getHeight(){
  if (dimsKnown)   return ascent + descent;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int height=fm.getAscent() + fm.getDescent();
  frame.setVisible(false);
  frame.dispose();
  return height;
}
Program: 31151
Project: 31151
Buggy source:
public int getAscent(){
  if (dimsKnown)   return ascent;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int height=fm.getAscent();
  frame.setVisible(false);
  return height;
}

Fixed version (ground truth):
public int getAscent(){
  if (dimsKnown)   return ascent;
  JPanel panel=new JPanel();
  JFrame frame=new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setVisible(true);
  Graphics g=panel.getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  int height=fm.getAscent();
  frame.setVisible(false);
  frame.dispose();
  return height;
}
Program: 31153
Project: 31153
Buggy source:
LoadLibraries(Library[] libs,LogisimFile source){
  HashSet<String> LibNames=new HashSet<String>();
  HashSet<String> ToolList=new HashSet<String>();
  HashMap<String,String> Error=new HashMap<String,String>();
  for (  Library lib : source.getLibraries()) {
    LibraryTools.BuildLibraryList(lib,LibNames);
  }
  LibraryTools.BuildToolList(source,ToolList);
  for (int i=0; i < libs.length; i++) {
    if (LibNames.contains(libs[i].getName().toUpperCase())) {
      JOptionPane.showMessageDialog(null,"String_Node_Str" + libs[i].getName() + "String_Node_Str"+ Strings.get("String_Node_Str"),Strings.get("String_Node_Str") + "String_Node_Str" + libs[i].getName()+ "String_Node_Str",JOptionPane.WARNING_MESSAGE);
    }
 else {
      LibraryTools.RemovePresentLibraries(libs[i],LibNames);
      if (LibraryTools.LibraryIsConform(libs[i],new HashSet<String>(),new HashSet<String>(),Error)) {
        HashSet<String> AddedToolList=new HashSet<String>();
        LibraryTools.BuildToolList(libs[i],AddedToolList);
        for (        String tool : AddedToolList)         if (ToolList.contains(tool))         Error.put(tool,Strings.get("String_Node_Str"));
        if (Error.keySet().isEmpty()) {
          LibraryTools.BuildLibraryList(libs[i],LibNames);
          ToolList.addAll(AddedToolList);
          MergedLibs.add(libs[i]);
        }
 else         LibraryTools.ShowErrors(libs[i].getName(),Error);
      }
 else       LibraryTools.ShowErrors(libs[i].getName(),Error);
    }
  }
}

Fixed version (ground truth):
LoadLibraries(Library[] libs,LogisimFile source){
  HashSet<String> LibNames=new HashSet<String>();
  HashSet<String> ToolList=new HashSet<String>();
  HashMap<String,String> Error=new HashMap<String,String>();
  for (  Library lib : source.getLibraries()) {
    LibraryTools.BuildLibraryList(lib,LibNames);
  }
  LibraryTools.BuildToolList(source,ToolList);
  for (int i=0; i < libs.length; i++) {
    if (LibNames.contains(libs[i].getName().toUpperCase())) {
      JOptionPane.showMessageDialog(null,"String_Node_Str" + libs[i].getName() + "String_Node_Str"+ Strings.get("String_Node_Str"),Strings.get("String_Node_Str") + "String_Node_Str" + libs[i].getName()+ "String_Node_Str",JOptionPane.WARNING_MESSAGE);
    }
 else {
      LibraryTools.RemovePresentLibraries(libs[i],LibNames,false);
      if (LibraryTools.LibraryIsConform(libs[i],new HashSet<String>(),new HashSet<String>(),Error)) {
        HashSet<String> AddedToolList=new HashSet<String>();
        LibraryTools.BuildToolList(libs[i],AddedToolList);
        for (        String tool : AddedToolList)         if (ToolList.contains(tool))         Error.put(tool,Strings.get("String_Node_Str"));
        if (Error.keySet().isEmpty()) {
          LibraryTools.BuildLibraryList(libs[i],LibNames);
          ToolList.addAll(AddedToolList);
          MergedLibs.add(libs[i]);
        }
 else         LibraryTools.ShowErrors(libs[i].getName(),Error);
      }
 else       LibraryTools.ShowErrors(libs[i].getName(),Error);
    }
  }
}
Program: 31154
Project: 31154
Buggy source:
private static void updatecircs(LogisimFile lib,Project proj){
  for (  Circuit circ : lib.getCircuits()) {
    circ.SetProject(proj);
  }
}

Fixed version (ground truth):
private static void updatecircs(LogisimFile lib,Project proj){
  for (  Circuit circ : lib.getCircuits()) {
    circ.SetProject(proj);
  }
  for (  Library libs : lib.getLibraries()) {
    if (libs instanceof LoadedLibrary) {
      LoadedLibrary test=(LoadedLibrary)libs;
      if (test.getBase() instanceof LogisimFile) {
        updatecircs((LogisimFile)test.getBase(),proj);
      }
    }
  }
}
Program: 31155
Project: 31155
Buggy source:
private static Project completeProject(SplashScreen monitor,Loader loader,LogisimFile file,boolean isStartup){
  if (monitor != null)   monitor.setProgress(SplashScreen.PROJECT_CREATE);
  Project ret=new Project(file);
  if (monitor != null)   monitor.setProgress(SplashScreen.FRAME_CREATE);
  SwingUtilities.invokeLater(new CreateFrame(loader,ret,isStartup));
  updatecircs(ret.getLogisimFile(),ret);
  return ret;
}

Fixed version (ground truth):
private static Project completeProject(SplashScreen monitor,Loader loader,LogisimFile file,boolean isStartup){
  if (monitor != null)   monitor.setProgress(SplashScreen.PROJECT_CREATE);
  Project ret=new Project(file);
  if (monitor != null)   monitor.setProgress(SplashScreen.FRAME_CREATE);
  SwingUtilities.invokeLater(new CreateFrame(loader,ret,isStartup));
  updatecircs(file,ret);
  return ret;
}
Program: 31156
Project: 31156
Buggy source:
public static void RemovePresentLibraries(Library lib,HashSet<String> KnownLibs){
  HashSet<String> ToBeRemoved=new HashSet<String>();
  for (  Library sublib : lib.getLibraries()) {
    RemovePresentLibraries(sublib,KnownLibs);
    if (KnownLibs.contains(sublib.getName().toUpperCase())) {
      ToBeRemoved.add(sublib.getName());
    }
  }
  for (  String remove : ToBeRemoved)   lib.removeLibrary(remove);
}

Fixed version (ground truth):
public static void RemovePresentLibraries(Library lib,HashSet<String> KnownLibs,boolean AddToSet){
  HashSet<String> ToBeRemoved=new HashSet<String>();
  for (  Library sublib : lib.getLibraries()) {
    if (KnownLibs.contains(sublib.getName().toUpperCase())) {
      ToBeRemoved.add(sublib.getName());
    }
 else     if (AddToSet) {
      KnownLibs.add(sublib.getName().toUpperCase());
    }
  }
  for (  String remove : ToBeRemoved)   lib.removeLibrary(remove);
  for (  Library sublib : lib.getLibraries())   RemovePresentLibraries(sublib,KnownLibs,AddToSet);
}
Program: 31157
Project: 31157
Buggy source:
private boolean performDRC(){
  clearAllMessages();
  String CircuitName=circuitsList.getSelectedItem().toString();
  Circuit root=MyProject.getLogisimFile().getCircuit(CircuitName);
  ArrayList<String> SheetNames=new ArrayList<String>();
  int DRCResult;
  if (root == null) {
    DRCResult=Netlist.DRC_ERROR;
  }
 else {
    DRCResult=root.getNetList().DesignRuleCheckResult(MyReporter,HDLType.getText(),true,MyBoardInformation.fpga.getVendor(),SheetNames);
  }
  return (DRCResult == Netlist.DRC_PASSED);
}

Fixed version (ground truth):
private boolean performDRC(){
  clearAllMessages();
  String CircuitName=circuitsList.getSelectedItem().toString();
  Circuit root=MyProject.getLogisimFile().getCircuit(CircuitName);
  ArrayList<String> SheetNames=new ArrayList<String>();
  int DRCResult;
  if (root == null) {
    DRCResult=Netlist.DRC_ERROR;
  }
 else {
    root.getNetList().ClearNetlist();
    DRCResult=root.getNetList().DesignRuleCheckResult(MyReporter,HDLType.getText(),true,MyBoardInformation.fpga.getVendor(),SheetNames);
  }
  return (DRCResult == Netlist.DRC_PASSED);
}