nus-yam/ex-repair huggingface dataset:
Program: 74034
Project: 74034
Buggy source:
public void mousePressed(MouseEvent event){
  if (((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) || (event.getModifiers() == 0)) {
    PlotBox.this._zoomStart(event.getX(),event.getY());
  }
}

Fixed version (ground truth):
public void mousePressed(MouseEvent event){
  if (((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) && ((event.getModifiers() & InputEvent.BUTTON3_MASK) == 0) || (event.getModifiers() == 0)) {
    PlotBox.this._zoomStart(event.getX(),event.getY());
  }
}
Program: 74035
Project: 74035
Buggy source:
public void actionPerformed(ActionEvent e){
  JMenuItem target=(JMenuItem)e.getSource();
  String actionCommand=target.getActionCommand();
  NamedObj model=getModel();
  if (model instanceof CompositeActor) {
    try {
      Debuggable debug;
      if (actionCommand.equals("String_Node_Str")) {
        debug=((CompositeActor)model).getManager();
      }
 else       if (actionCommand.equals("String_Node_Str")) {
        debug=((CompositeActor)model).getDirector();
      }
 else {
        debug=null;
      }
      if (debug != null) {
        Effigy effigy=(Effigy)getContainer();
        Effigy textEffigy=new TextEffigy(effigy,effigy.uniqueName("String_Node_Str"));
        DebugListenerTableau tableau=new DebugListenerTableau(textEffigy,textEffigy.uniqueName("String_Node_Str"));
        tableau.setDebuggable(debug);
      }
    }
 catch (    KernelException ex) {
      try {
        MessageHandler.warning("String_Node_Str" + ex);
      }
 catch (      CancelException exception) {
      }
    }
  }
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent e){
  JMenuItem target=(JMenuItem)e.getSource();
  String actionCommand=target.getActionCommand();
  NamedObj model=getModel();
  if (model instanceof CompositeActor) {
    try {
      Debuggable debug;
      if (actionCommand.equals("String_Node_Str")) {
        debug=((CompositeActor)model).getManager();
      }
 else       if (actionCommand.equals("String_Node_Str")) {
        debug=((CompositeActor)model).getDirector();
      }
 else {
        debug=null;
      }
      if (debug != null) {
        Effigy effigy=(Effigy)RunTableau.this.getContainer();
        Effigy textEffigy=new TextEffigy(effigy,effigy.uniqueName("String_Node_Str"));
        DebugListenerTableau tableau=new DebugListenerTableau(textEffigy,textEffigy.uniqueName("String_Node_Str"));
        tableau.setDebuggable(debug);
      }
    }
 catch (    KernelException ex) {
      try {
        MessageHandler.warning("String_Node_Str" + ex);
      }
 catch (      CancelException exception) {
      }
    }
  }
}
Program: 74036
Project: 74036
Buggy source:
public void generateCode() throws KernelException {
  if (_codeGenerator == null) {
    _codeGenerator=new ModularCodeGenerator(this,"String_Node_Str");
    _codeGenerator.setPersistent(false);
  }
  _codeGenerator.generateCode();
}

Fixed version (ground truth):
public void generateCode() throws KernelException {
  _createCodeGenerator();
  _codeGenerator.generateCode();
}
Program: 74044
Project: 74044
Buggy source:
/** 
 * Return true if the current time is the right time for an output.
 * @return True if the current time matches the _nextOutputTime.
 * @throws IllegalActionException If the time is not right ana refiring cannot be requested.
 */
protected boolean _isTimeForOutput() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  return _tentativeNextOutputTime.equals(currentTime);
}

Fixed version (ground truth):
/** 
 * Return true if the current time is the right time for an output.
 * @return True if the current time matches the _nextOutputTime.
 * @exception IllegalActionException If the time is not right ana refiring cannot be requested.
 */
protected boolean _isTimeForOutput() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  return _tentativeNextOutputTime.equals(currentTime);
}
Program: 74045
Project: 74045
Buggy source:
/** 
 * Adjust the expected next output time and index so that they are greater than or equal to the current time and index.
 * @throws IllegalActionException If the period parameter cannotbe evaluated.
 * @return True if any outputs are skipped, false otherwise.
 */
protected boolean _catchUp() throws IllegalActionException {
  Director director=getDirector();
  Time currentTime=director.getModelTime();
  int currentIndex=0;
  if (director instanceof SuperdenseTimeDirector) {
    currentIndex=((SuperdenseTimeDirector)director).getIndex();
  }
  boolean result=false;
  double periodValue=((DoubleToken)period.getToken()).doubleValue();
  while (_nextOutputTime.compareTo(currentTime) < 0 || (_nextOutputTime.compareTo(currentTime) == 0 && _nextOutputIndex < currentIndex)) {
    if (!result && _debugging) {
      _debug("String_Node_Str" + _nextOutputTime + "String_Node_Str"+ _nextOutputIndex+ "String_Node_Str"+ currentTime+ "String_Node_Str"+ currentIndex+ "String_Node_Str");
    }
    result=true;
    _phase++;
    if (_phase >= _offsets.length) {
      _phase=0;
      _cycleStartTime=_cycleStartTime.add(periodValue);
    }
    Time nextOutputTime=_cycleStartTime.add(_offsets[_phase]);
    if (_nextOutputTime.equals(nextOutputTime)) {
      _nextOutputIndex++;
    }
 else {
      _nextOutputTime=nextOutputTime;
      _nextOutputIndex=0;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Adjust the expected next output time and index so that they are greater than or equal to the current time and index.
 * @exception IllegalActionException If the period parameter cannotbe evaluated.
 * @return True if any outputs are skipped, false otherwise.
 */
protected boolean _catchUp() throws IllegalActionException {
  Director director=getDirector();
  Time currentTime=director.getModelTime();
  int currentIndex=0;
  if (director instanceof SuperdenseTimeDirector) {
    currentIndex=((SuperdenseTimeDirector)director).getIndex();
  }
  boolean result=false;
  double periodValue=((DoubleToken)period.getToken()).doubleValue();
  while (_nextOutputTime.compareTo(currentTime) < 0 || (_nextOutputTime.compareTo(currentTime) == 0 && _nextOutputIndex < currentIndex)) {
    if (!result && _debugging) {
      _debug("String_Node_Str" + _nextOutputTime + "String_Node_Str"+ _nextOutputIndex+ "String_Node_Str"+ currentTime+ "String_Node_Str"+ currentIndex+ "String_Node_Str");
    }
    result=true;
    _phase++;
    if (_phase >= _offsets.length) {
      _phase=0;
      _cycleStartTime=_cycleStartTime.add(periodValue);
    }
    Time nextOutputTime=_cycleStartTime.add(_offsets[_phase]);
    if (_nextOutputTime.equals(nextOutputTime)) {
      _nextOutputIndex++;
    }
 else {
      _nextOutputTime=nextOutputTime;
      _nextOutputIndex=0;
    }
  }
  return result;
}
Program: 74046
Project: 74046
Buggy source:
/** 
 * Return an unique label for the given attribute referenced by the given helper. By default, this delegates to the helper to generate the reference. Subclass may override this method to generate the desire label according to the given parameters.
 * @param attribute The given attribute.
 * @param channelAndOffset The given channel and offset.
 * @param helper The specified helper.
 * @return an unique label for the given attribute.
 * @throws IllegalActionException If the helper throws it whilegenerating the label.
 */
public String getReference(Attribute attribute,String[] channelAndOffset,CodeGeneratorHelper helper) throws IllegalActionException {
  return helper.getReference(attribute,channelAndOffset);
}

Fixed version (ground truth):
/** 
 * Return an unique label for the given attribute referenced by the given helper. By default, this delegates to the helper to generate the reference. Subclass may override this method to generate the desire label according to the given parameters.
 * @param attribute The given attribute.
 * @param channelAndOffset The given channel and offset.
 * @param helper The specified helper.
 * @return an unique label for the given attribute.
 * @exception IllegalActionException If the helper throws it whilegenerating the label.
 */
public String getReference(Attribute attribute,String[] channelAndOffset,CodeGeneratorHelper helper) throws IllegalActionException {
  return helper.getReference(attribute,channelAndOffset);
}
Program: 74047
Project: 74047
Buggy source:
/** 
 * Generate the code for getting data from the specified port channel. This returns an empty string. Subclasses may override this method to generate domain-specific code for getting data.
 * @param port The specified port.
 * @param channel The specified channel.
 * @return An empty string in this base class.
 * @throws IllegalActionException Not thrown in this base class.
 */
public String generateCodeForGet(IOPort port,int channel) throws IllegalActionException {
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate the code for getting data from the specified port channel. This returns an empty string. Subclasses may override this method to generate domain-specific code for getting data.
 * @param port The specified port.
 * @param channel The specified channel.
 * @return An empty string in this base class.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateCodeForGet(IOPort port,int channel) throws IllegalActionException {
  return "String_Node_Str";
}
Program: 74048
Project: 74048
Buggy source:
/** 
 * Generate the code for sending data to the specified port channel. This returns an empty string. Subclasses may override this method to generate domain-specific code for sending data.
 * @param port The specified port.
 * @param channel The specified channel.
 * @param dataToken The data to send.
 * @return An empty string in this base class.
 * @throws IllegalActionException Not thrown in this base class.
 */
public String generateCodeForSend(IOPort port,int channel,String dataToken) throws IllegalActionException {
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate the code for sending data to the specified port channel. This returns an empty string. Subclasses may override this method to generate domain-specific code for sending data.
 * @param port The specified port.
 * @param channel The specified channel.
 * @param dataToken The data to send.
 * @return An empty string in this base class.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateCodeForSend(IOPort port,int channel,String dataToken) throws IllegalActionException {
  return "String_Node_Str";
}
Program: 74049
Project: 74049
Buggy source:
/** 
 * Return the reference channels for the specified port channel. If the port channel is input or contained by an opaque CompositeActor, then this will return a list containing the given port channel. Otherwise, it returns a list of the connected sink channels.
 * @param port The given port.
 * @param channelNumber The given channel.
 * @return The list of reference channels.
 * @throws IllegalActionException If {@link #getSinkChannels(IOPort,int)}throws it.
 */
public static List<Channel> getReferenceChannels(IOPort port,int channelNumber) throws IllegalActionException {
  boolean forComposite=false;
  if ((port.isOutput() && !forComposite) || (port.isInput() && forComposite)) {
    List sinkChannels=CodeGeneratorHelper.getSinkChannels(port,channelNumber);
    return sinkChannels;
  }
  List<Channel> result=new LinkedList<Channel>();
  if ((port.isInput() && !forComposite && port.isOutsideConnected()) || (port.isOutput() && forComposite)) {
    result.add(new Channel(port,channelNumber));
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Return the reference channels for the specified port channel. If the port channel is input or contained by an opaque CompositeActor, then this will return a list containing the given port channel. Otherwise, it returns a list of the connected sink channels.
 * @param port The given port.
 * @param channelNumber The given channel.
 * @return The list of reference channels.
 * @exception IllegalActionException If {@link #getSinkChannels(IOPort,int)}throws it.
 */
public static List<Channel> getReferenceChannels(IOPort port,int channelNumber) throws IllegalActionException {
  boolean forComposite=false;
  if ((port.isOutput() && !forComposite) || (port.isInput() && forComposite)) {
    List sinkChannels=CodeGeneratorHelper.getSinkChannels(port,channelNumber);
    return sinkChannels;
  }
  List<Channel> result=new LinkedList<Channel>();
  if ((port.isInput() && !forComposite && port.isOutsideConnected()) || (port.isOutput() && forComposite)) {
    result.add(new Channel(port,channelNumber));
  }
  return result;
}
Program: 74050
Project: 74050
Buggy source:
/** 
 * Return the code generated for sending the true input data. Iterate through the connections to the true port and append the "trueBlock" code block from the template.
 * @return The generated code.
 * @throws IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String sendTrueInputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSelect actor=(ptolemy.actor.lib.BooleanSelect)getComponent();
  int width=Math.min(actor.output.getWidth(),actor.trueInput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Return the code generated for sending the true input data. Iterate through the connections to the true port and append the "trueBlock" code block from the template.
 * @return The generated code.
 * @exception IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String sendTrueInputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSelect actor=(ptolemy.actor.lib.BooleanSelect)getComponent();
  int width=Math.min(actor.output.getWidth(),actor.trueInput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}
Program: 74051
Project: 74051
Buggy source:
/** 
 * Return the code generated for sending the false input data. Iterate through the connections to the true port and append the "falseBlock" code block from the template.
 * @return The generated code.
 * @throws IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String sendFalseInputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSelect actor=(ptolemy.actor.lib.BooleanSelect)getComponent();
  int width=Math.min(actor.output.getWidth(),actor.trueInput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Return the code generated for sending the false input data. Iterate through the connections to the true port and append the "falseBlock" code block from the template.
 * @return The generated code.
 * @exception IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String sendFalseInputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSelect actor=(ptolemy.actor.lib.BooleanSelect)getComponent();
  int width=Math.min(actor.output.getWidth(),actor.trueInput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}
Program: 74052
Project: 74052
Buggy source:
/** 
 * Return the code generated for sending data to the false output port. Iterate through the connections to the false port and append the "falseBlock" code block from the template.
 * @return The generated code.
 * @throws IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String generateFalseOutputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSwitch actor=(ptolemy.actor.lib.BooleanSwitch)getComponent();
  int width=Math.min(actor.input.getWidth(),actor.trueOutput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Return the code generated for sending data to the false output port. Iterate through the connections to the false port and append the "falseBlock" code block from the template.
 * @return The generated code.
 * @exception IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String generateFalseOutputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSwitch actor=(ptolemy.actor.lib.BooleanSwitch)getComponent();
  int width=Math.min(actor.input.getWidth(),actor.trueOutput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}
Program: 74053
Project: 74053
Buggy source:
/** 
 * Return the code generated for sending data to the true output port. Iterate through the connections to the true port and append the "trueBlock" code block from the template.
 * @return The generated code.
 * @throws IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String generateTrueOutputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSwitch actor=(ptolemy.actor.lib.BooleanSwitch)getComponent();
  int width=Math.min(actor.input.getWidth(),actor.trueOutput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Return the code generated for sending data to the true output port. Iterate through the connections to the true port and append the "trueBlock" code block from the template.
 * @return The generated code.
 * @exception IllegalActionException Thrown if an error occurswhen getting the width for the port or the code block.
 */
public String generateTrueOutputs() throws IllegalActionException {
  ptolemy.actor.lib.BooleanSwitch actor=(ptolemy.actor.lib.BooleanSwitch)getComponent();
  int width=Math.min(actor.input.getWidth(),actor.trueOutput.getWidth());
  StringBuffer code=new StringBuffer();
  ArrayList args=new ArrayList();
  args.add(0);
  for (int i=0; i < width; i++) {
    args.set(0,i);
    code.append(_generateBlockCode("String_Node_Str",args));
  }
  return processCode(code.toString());
}
Program: 74054
Project: 74054
Buggy source:
/** 
 * Generate actor function prototypes.
 * @throws IllegalActionException
 */
protected String _generateActorFuncProtoCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  for (  Actor actor : (List<Actor>)((CompositeActor)_director.getContainer()).deepEntityList()) {
    code.append("String_Node_Str" + CodeGeneratorHelper.generateName((NamedObj)actor) + "String_Node_Str"+ _eol);
  }
  code.append(_generateActuatorActuationFuncProtoCode());
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate actor function prototypes.
 * @exception IllegalActionException
 */
protected String _generateActorFuncProtoCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  for (  Actor actor : (List<Actor>)((CompositeActor)_director.getContainer()).deepEntityList()) {
    code.append("String_Node_Str" + CodeGeneratorHelper.generateName((NamedObj)actor) + "String_Node_Str"+ _eol);
  }
  code.append(_generateActuatorActuationFuncProtoCode());
  return code.toString();
}
Program: 74055
Project: 74055
Buggy source:
/** 
 * This code reset the Event_Head pointer for each channel to null.
 * @param actor The actor which the input channels reside, whose pointers are pointed to null
 * @return
 * @throws IllegalActionException
 */
private String _generateClearEventHeadCode(Actor actor) throws IllegalActionException {
  if (actor instanceof InputDevice) {
    return "String_Node_Str";
  }
  StringBuffer code=new StringBuffer();
  code.append("String_Node_Str" + _eol);
  for (  IOPort inputPort : (List<IOPort>)actor.inputPortList()) {
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      code.append("String_Node_Str" + generateName(inputPort) + "String_Node_Str"+ channel+ "String_Node_Str"+ _eol);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * This code reset the Event_Head pointer for each channel to null.
 * @param actor The actor which the input channels reside, whose pointers are pointed to null
 * @return
 * @exception IllegalActionException
 */
private String _generateClearEventHeadCode(Actor actor) throws IllegalActionException {
  if (actor instanceof InputDevice) {
    return "String_Node_Str";
  }
  StringBuffer code=new StringBuffer();
  code.append("String_Node_Str" + _eol);
  for (  IOPort inputPort : (List<IOPort>)actor.inputPortList()) {
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      code.append("String_Node_Str" + generateName(inputPort) + "String_Node_Str"+ channel+ "String_Node_Str"+ _eol);
    }
  }
  return code.toString();
}
Program: 74057
Project: 74057
Buggy source:
/** 
 * Get the shape that defines this geometry object. If any of the sites have been translated since this shape was set, a new shape will be produced and returned.
 */
public Shape getShape(){
  if (_path == null) {
    GeneralPath p=new GeneralPath(Path2D.WIND_NON_ZERO,_vertexCount + 2);
    int c=0;
    for (int i=0; i < _vertexCount; i++) {
switch (_type[i]) {
case PathIterator.SEG_CLOSE:
        p.closePath();
      break;
case PathIterator.SEG_MOVETO:
    p.moveTo(_coordinate[c],_coordinate[c + 1]);
  c+=2;
break;
case PathIterator.SEG_LINETO:
p.lineTo(_coordinate[c],_coordinate[c + 1]);
c+=2;
break;
case PathIterator.SEG_QUADTO:
p.quadTo(_coordinate[c],_coordinate[c + 1],_coordinate[c + 2],_coordinate[c + 3]);
c+=4;
break;
case PathIterator.SEG_CUBICTO:
p.curveTo(_coordinate[c],_coordinate[c + 1],_coordinate[c + 2],_coordinate[c + 3],_coordinate[c + 4],_coordinate[c + 5]);
c+=6;
break;
}
}
_path=p;
}
return _path;
}

Fixed version (ground truth):
/** 
 * Get the shape that defines this geometry object. If any of the sites have been translated since this shape was set, a new shape will be produced and returned.
 */
public Shape getShape(){
  if (_path == null) {
    GeneralPath p=new GeneralPath(GeneralPath.WIND_NON_ZERO,_vertexCount + 2);
    int c=0;
    for (int i=0; i < _vertexCount; i++) {
switch (_type[i]) {
case PathIterator.SEG_CLOSE:
        p.closePath();
      break;
case PathIterator.SEG_MOVETO:
    p.moveTo(_coordinate[c],_coordinate[c + 1]);
  c+=2;
break;
case PathIterator.SEG_LINETO:
p.lineTo(_coordinate[c],_coordinate[c + 1]);
c+=2;
break;
case PathIterator.SEG_QUADTO:
p.quadTo(_coordinate[c],_coordinate[c + 1],_coordinate[c + 2],_coordinate[c + 3]);
c+=4;
break;
case PathIterator.SEG_CUBICTO:
p.curveTo(_coordinate[c],_coordinate[c + 1],_coordinate[c + 2],_coordinate[c + 3],_coordinate[c + 4],_coordinate[c + 5]);
c+=6;
break;
}
}
_path=p;
}
return _path;
}
Program: 74062
Project: 74062
Buggy source:
/** 
 * Generate type convert variable declarations.
 * @param target The ProgramCodeGeneratorAdapter for which code needs to be generated.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration(ProgramCodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=target.getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      getStrategy();
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate type convert variable declarations.
 * @param target The ProgramCodeGeneratorAdapter for which code needs to be generated.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration(ProgramCodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=target.getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + targetType(portType) + "String_Node_Str"+ bufferSize+ "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}
Program: 74063
Project: 74063
Buggy source:
/** 
 * Reposition a small object in a big object according to a given direction (NORTH,  EAST, SOUTH, WEST). The small object will be aligned to the big object's  direction side and centered on the other coordinate.
 * @param originalBounds Big object's bounds
 * @param shrunkBounds Small object's bounds
 * @param direction Direction of the small object within the big object given by a SwingConstants direction constant
 * @return  New location of the small object.
 */
protected static Point2D _shrinkCoordinates(Rectangle2D originalBounds,Rectangle2D shrunkBounds,int direction){
  double widthDiff=(originalBounds.getWidth() - shrunkBounds.getWidth()) / 2;
  double heightDiff=(originalBounds.getHeight() - shrunkBounds.getHeight()) / 2;
  Point2D.Double location=new Point2D.Double();
switch (direction) {
case SwingConstants.NORTH:
    location.x=originalBounds.getMinX() + widthDiff;
  location.y=originalBounds.getMinY();
break;
case SwingConstants.EAST:
location.x=originalBounds.getMaxX() - widthDiff;
location.y=originalBounds.getMinY() + heightDiff;
break;
case SwingConstants.SOUTH:
location.x=originalBounds.getMinX() + widthDiff;
location.y=originalBounds.getMaxY() - heightDiff;
break;
default :
location.x=originalBounds.getMinX();
location.y=originalBounds.getMinY() + heightDiff;
break;
}
return location;
}

Fixed version (ground truth):
/** 
 * Reposition a small object in a big object according to a given direction (NORTH,  EAST, SOUTH, WEST). The small object will be aligned to the big object's  direction side and centered on the other coordinate.
 * @param originalBounds Big object's bounds
 * @param shrunkBounds Small object's bounds
 * @param direction Direction of the small object within the big object given by a SwingConstants direction constant
 * @param offset Offset of the lower bound of the port
 * @return  New location of the small object.
 */
protected static Point2D _shrinkCoordinates(Rectangle2D originalBounds,Rectangle2D shrunkBounds,int direction,float offset){
  double widthDiff=(originalBounds.getWidth() - shrunkBounds.getWidth());
  double heightDiff=(originalBounds.getHeight() - shrunkBounds.getHeight());
  Point2D.Double location=new Point2D.Double();
switch (direction) {
case SwingConstants.NORTH:
    location.x=originalBounds.getMinX() + widthDiff - offset;
  location.y=originalBounds.getMinY();
break;
case SwingConstants.EAST:
location.x=originalBounds.getMaxX() - widthDiff;
location.y=originalBounds.getMinY() + offset;
break;
case SwingConstants.SOUTH:
location.x=originalBounds.getMinX() + offset;
location.y=originalBounds.getMaxY() - heightDiff;
break;
default :
location.x=originalBounds.getMinX();
location.y=originalBounds.getMinY() + heightDiff - offset;
break;
}
return location;
}
Program: 74066
Project: 74066
Buggy source:
/** 
 * Flush all buffered change requests to the given Actor. Reset the buffer afterwards.
 * @param actor The target of the change request, e.g. the composite actorcontaining the objects for which changes are requested.
 */
protected void _performChangeRequest(CompositeActor actor){
  _momlChangeRequest.insert(0,"String_Node_Str");
  _momlChangeRequest.append("String_Node_Str");
  MoMLChangeRequest request=new MoMLChangeRequest(this,actor,_momlChangeRequest.toString());
  request.setUndoable(true);
  actor.requestChange(request);
  _momlChangeRequest=new StringBuffer();
}

Fixed version (ground truth):
/** 
 * Flush all buffered change requests to the given Actor. Reset the buffer afterwards.
 * @param actor The target of the change request, e.g. the composite actorcontaining the objects for which changes are requested.
 */
protected void _performChangeRequest(CompositeActor actor){
  _momlChangeRequest.insert(0,"String_Node_Str");
  _momlChangeRequest.append("String_Node_Str");
  System.out.println(_momlChangeRequest);
  MoMLChangeRequest request=new MoMLChangeRequest(this,actor,_momlChangeRequest.toString());
  request.setUndoable(true);
  actor.requestChange(request);
  _momlChangeRequest=new StringBuffer();
}
Program: 74067
Project: 74067
Buggy source:
/** 
 * Create a MoMLChangeRequest to remove a set of relations in a Ptolemy model object and schedule it immediately. 
 * @param relationSet Set of relation to be removed from the Ptolemy model
 */
protected void _removeRelations(Set<Relation> relationSet){
  StringBuffer moml=new StringBuffer();
  for (  Relation relation : relationSet) {
    moml.append("String_Node_Str" + relation.getName() + "String_Node_Str");
  }
  _momlChangeRequest.append(moml);
}

Fixed version (ground truth):
/** 
 * Create a MoMLChangeRequest to remove a set of relations in a Ptolemy model object
 * @param relationSet Set of relation to be removed from the Ptolemy model
 */
protected void _removeRelations(Set<Relation> relationSet){
  StringBuffer moml=new StringBuffer();
  for (  Relation relation : relationSet) {
    moml.append("String_Node_Str" + relation.getName() + "String_Node_Str");
  }
  _momlChangeRequest.append(moml);
}
Program: 74071
Project: 74071
Buggy source:
/** 
 * Generate type convert variable declarations.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      getStrategy();
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate type convert variable declarations.
 * @param target The ProgramCodeGeneratorAdapter for which code needs to be generated.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration(ProgramCodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=target.getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      getStrategy();
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}
Program: 74073
Project: 74073
Buggy source:
/** 
 * Generate type convert variable declarations.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      getStrategy();
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate type convert variable declarations.
 * @param target The ProgramCodeGeneratorAdapter for which code needs to be generated.
 * @return a String that declares type convert variables.
 * @exception IllegalActionException If thrown whilegetting port information.
 */
private String _generateTypeConvertVariableDeclaration(ProgramCodeGeneratorAdapter target) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<?> channels=target.getStrategy().getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel channel=(Channel)channels.next();
    Type portType=((TypedIOPort)channel.port).getType();
    if (getStrategy().isPrimitive(portType)) {
      code.append("String_Node_Str");
      code.append(targetType(portType));
      getStrategy();
      code.append("String_Node_Str" + ProgramCodeGeneratorAdapterStrategy.getTypeConvertReference(channel));
      int bufferSize=Math.max(DFUtilities.getTokenProductionRate(channel.port),DFUtilities.getTokenConsumptionRate(channel.port));
      if (bufferSize > 1) {
        code.append("String_Node_Str" + bufferSize + "String_Node_Str");
      }
      code.append("String_Node_Str" + _eol);
    }
  }
  return code.toString();
}
Program: 74074
Project: 74074
Buggy source:
/** 
 * Generate the type conversion fire code. This method is called by the Director to append necessary fire code to handle type conversion.
 * @param forComposite True if we are generating code for a composite.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateTypeConvertFireCode(boolean forComposite) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<Channel> channels=getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel source=channels.next();
    if (!forComposite && source.port.isOutput() || forComposite && source.port.isInput()) {
      Iterator<Channel> sinkChannels=_getTypeConvertSinkChannels(source).iterator();
      while (sinkChannels.hasNext()) {
        Channel sink=sinkChannels.next();
        code.append(_generateTypeConvertStatements(source,sink));
      }
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the type conversion fire code. This method is called by the Director to append necessary fire code to handle type conversion.
 * @param forComposite True if we are generating code for a composite.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateTypeConvertFireCode(boolean forComposite) throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator<Channel> channels=getTypeConvertChannels().iterator();
  while (channels.hasNext()) {
    Channel source=channels.next();
    if (!forComposite && source.port.isOutput() || forComposite && source.port.isInput()) {
      Iterator<Channel> sinkChannels=getTypeConvertSinkChannels(source).iterator();
      while (sinkChannels.hasNext()) {
        Channel sink=sinkChannels.next();
        code.append(_generateTypeConvertStatements(source,sink));
      }
    }
  }
  return code.toString();
}
Program: 74076
Project: 74076
Buggy source:
/** 
 * Create a Kieler KNode for a Ptolemy inner port. That is the graphical representation for a port of a CompositeActor if you see the contents of this CompositeActor. It is represented by a node where the connection may touch the node corresponding to its type (input, output, both) on the right, left or top. For now this results a crude approximation of the node, because the figure of the original Ptolemy port cannot be obtained by the layout target. Hence we cannot ask the port for its original bounds.
 * @param node the Ptolemy inner port.
 * @return A new Kieler KNode corresponding to the Ptolemy inner port.
 */
private KNode _createKNodeForPort(Port node){
  KNode knode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(knode);
  layout.setHeight(DEFAULT_INNER_PORT_SIZE);
  layout.setWidth(DEFAULT_INNER_PORT_SIZE);
  LayoutOptions.setFixedSize(layout,true);
  return knode;
}

Fixed version (ground truth):
/** 
 * Create a Kieler KNode for a Ptolemy inner port. That is the graphical representation for a port of a CompositeActor if you see the contents of this CompositeActor. It is represented by a node where the connection may touch the node corresponding to its type (input, output, both) on the right, left or top. For now this results a crude approximation of the node, because the figure of the original Ptolemy port cannot be obtained by the layout target. Hence we cannot ask the port for its original bounds.
 * @param node the Ptolemy inner port.
 * @return A new Kieler KNode corresponding to the Ptolemy inner port.
 */
private KNode _createKNodeForPort(Port node){
  KNode knode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(knode);
  layout.setHeight(DEFAULT_INNER_PORT_HEIGHT);
  layout.setWidth(DEFAULT_INNER_PORT_WIDTH);
  LayoutOptions.setFixedSize(layout,true);
  return knode;
}
Program: 74077
Project: 74077
Buggy source:
private void _replaceRelation(KPort kPort,KNode kNode,Relation newRelation,Relation oldRelation) throws IllegalActionException {
  Port port=null;
  Relation sourceRelation=null;
  if (kPort != null) {
    port=_kieler2PtolemyPorts.get(kPort);
  }
  if (port == null) {
    NamedObj namedObj=_kieler2ptolemyEntityNodes.get(kNode);
    if (namedObj instanceof Port) {
      port=(Port)namedObj;
    }
 else     if (namedObj instanceof Relation) {
      sourceRelation=(Relation)namedObj;
    }
  }
  if (port != null) {
    boolean outsideLink=true;
    List<Relation> linkedRelations=port.linkedRelationList();
    if (linkedRelations.isEmpty() && port instanceof ComponentPort) {
      linkedRelations=((ComponentPort)port).insideRelationList();
      outsideLink=false;
    }
    int index=linkedRelations.indexOf(oldRelation);
    if (outsideLink) {
      _ptolemyModelUtil._unlinkPort(port.getName(_compositeActor),index);
      _ptolemyModelUtil._performChangeRequest(_compositeActor);
      _ptolemyModelUtil._linkPort(port.getName(_compositeActor),"String_Node_Str",newRelation.getName(_compositeActor),index);
    }
 else {
      if (port instanceof ComponentPort) {
        ((ComponentPort)port).unlinkInside(index);
        ((ComponentPort)port).insertInsideLink(index,newRelation);
      }
    }
  }
 else   if (sourceRelation != null) {
    _ptolemyModelUtil._link("String_Node_Str",sourceRelation.getName(),"String_Node_Str",newRelation.getName(_compositeActor));
  }
}

Fixed version (ground truth):
private void _replaceRelation(KPort kPort,KNode kNode,Relation newRelation,Relation oldRelation) throws IllegalActionException {
  Port port=null;
  Relation sourceRelation=null;
  if (kPort != null) {
    port=_kieler2PtolemyPorts.get(kPort);
  }
  if (port == null) {
    NamedObj namedObj=_kieler2ptolemyEntityNodes.get(kNode);
    if (namedObj instanceof Port) {
      port=(Port)namedObj;
    }
 else     if (namedObj instanceof Relation) {
      sourceRelation=(Relation)namedObj;
    }
  }
  if (port != null) {
    boolean outsideLink=true;
    List<Relation> linkedRelations=port.linkedRelationList();
    int index=linkedRelations.indexOf(oldRelation);
    if (index == -1 && port instanceof ComponentPort) {
      linkedRelations=((ComponentPort)port).insideRelationList();
      outsideLink=false;
      index=linkedRelations.indexOf(oldRelation);
    }
    if (outsideLink) {
      _ptolemyModelUtil._unlinkPort(port.getName(_compositeActor),index);
      _ptolemyModelUtil._performChangeRequest(_compositeActor);
      _ptolemyModelUtil._linkPort(port.getName(_compositeActor),"String_Node_Str",newRelation.getName(_compositeActor),index);
    }
 else {
      if (port instanceof ComponentPort) {
        ((ComponentPort)port).unlinkInside(index);
        ((ComponentPort)port).insertInsideLink(index,newRelation);
      }
    }
  }
 else   if (sourceRelation != null) {
    _ptolemyModelUtil._link("String_Node_Str",sourceRelation.getName(),"String_Node_Str",newRelation.getName(_compositeActor));
  }
}
Program: 74079
Project: 74079
Buggy source:
/** 
 * Create a Kieler KNode for a Ptolemy Vertex. Vertices of Ptolemy can be handles as usual KNodes in Kieler (an alternative would be to handle them as connection bendpoints). As Kieler does not support KNodes without port constraints (as in usual graphs without ports), the corresponding KNode will contain one input port and one output port. Size of the node and positions of the ports are all set to zero.
 * @param vertex The Ptolemy vertex for which to create a KNode
 * @return An initialized KNode with one input and one output port
 */
private KNode _createKNodeForVertex(Vertex vertex){
  KNode knode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(knode);
  layout.setHeight(1);
  layout.setWidth(1);
  LayoutOptions.setFixedSize(layout,true);
  KPort kinputport=KimlLayoutUtil.createInitializedPort();
  KShapeLayout portLayout=KimlLayoutUtil.getShapeLayout(knode);
  portLayout.setHeight(0);
  portLayout.setWidth(0);
  portLayout.setXpos(0);
  portLayout.setYpos(0);
  kinputport.setType(KPortType.INPUT);
  kinputport.setNode(knode);
  KPort koutputport=KimlLayoutUtil.createInitializedPort();
  portLayout=KimlLayoutUtil.getShapeLayout(knode);
  portLayout.setHeight(0);
  portLayout.setWidth(0);
  portLayout.setXpos(0);
  portLayout.setYpos(0);
  koutputport.setType(KPortType.OUTPUT);
  koutputport.setNode(knode);
  return knode;
}

Fixed version (ground truth):
/** 
 * Create a Kieler KNode for a Ptolemy Vertex. Vertices of Ptolemy can be handles as usual KNodes in Kieler (an alternative would be to handle them as connection bendpoints). As Kieler does not support KNodes without port constraints (as in usual graphs without ports), the corresponding KNode will contain one input port and one output port. Size of the node and positions of the ports are all set to zero.
 * @param vertex The Ptolemy vertex for which to create a KNode
 * @return An initialized KNode with one input and one output port
 */
private KNode _createKNodeForVertex(Vertex vertex){
  KNode kNode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(kNode);
  layout.setHeight(1);
  layout.setWidth(1);
  layout.setXpos((float)vertex.getLocation()[0]);
  layout.setYpos((float)vertex.getLocation()[1]);
  LayoutOptions.setFixedSize(layout,true);
  KPort kInputPort=KimlLayoutUtil.createInitializedPort();
  KShapeLayout portLayout=KimlLayoutUtil.getShapeLayout(kInputPort);
  portLayout.setHeight(0);
  portLayout.setWidth(0);
  portLayout.setXpos(0);
  portLayout.setYpos(0);
  kInputPort.setType(KPortType.INPUT);
  kInputPort.setNode(kNode);
  KPort kOutputPort=KimlLayoutUtil.createInitializedPort();
  portLayout=KimlLayoutUtil.getShapeLayout(kOutputPort);
  portLayout.setHeight(0);
  portLayout.setWidth(0);
  portLayout.setXpos(0);
  portLayout.setYpos(0);
  kOutputPort.setType(KPortType.OUTPUT);
  kOutputPort.setNode(kNode);
  return kNode;
}
Program: 74081
Project: 74081
Buggy source:
/** 
 * Construct an instance and initialize the internal request buffer.
 */
public PtolemyModelUtil(){
  _momlChangeRequest=new StringBuffer();
  _nameSuffix=0;
}

Fixed version (ground truth):
/** 
 * Construct an instance and initialize the internal request buffer.
 */
public PtolemyModelUtil(){
  _momlChangeRequest=new StringBuffer();
}