nus-yam/ex-repair huggingface dataset:
Program: 21925
Project: 21925
Buggy source:
@Override public void renderItem(ItemRenderType type,ItemStack item,Object... data){
  String texture=ConstantValue.SYNTHESIS_MODEL;
  GL11.glPushMatrix();
  GL11.glBindTexture(GL11.GL_TEXTURE_2D,FMLClientHandler.instance().getClient().renderEngine.getTexture(texture));
  if (type == ItemRenderType.ENTITY) {
    GL11.glTranslatef(0.0F,1.5F,0.0F);
    GL11.glRotatef(180f,0.1f,0.0f,1f);
  }
 else   if (type == ItemRenderType.EQUIPPED) {
    GL11.glTranslatef(0.5F,1.6F,0.0F);
    GL11.glRotatef(180f,0.1f,0.0f,1f);
  }
 else {
    GL11.glTranslatef(0.0F,1.0F,0.0F);
    GL11.glRotatef(180f,0f,0f,1f);
  }
  if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
    GL11.glTranslatef(0.5F,1.6F,0.0F);
    GL11.glRotatef(180f,-1f,0f,1f);
  }
  model.render(0.0625F);
  GL11.glPopMatrix();
}

Fixed version (ground truth):
@Override public void renderItem(ItemRenderType type,ItemStack item,Object... data){
  String texture=ConstantValue.SYNTHESIS_MODEL;
  GL11.glPushMatrix();
  GL11.glBindTexture(GL11.GL_TEXTURE_2D,FMLClientHandler.instance().getClient().renderEngine.getTexture(texture));
switch (type) {
case EQUIPPED:
    GL11.glTranslatef(0.5F,1.6F,0.0F);
  GL11.glRotatef(180f,-1f,0f,1f);
break;
case EQUIPPED_FIRST_PERSON:
GL11.glTranslatef(0.5F,1.6F,0.0F);
GL11.glRotatef(180f,-1f,0f,1f);
break;
case INVENTORY:
GL11.glTranslatef(0.0F,1.0F,0.0F);
GL11.glRotatef(180f,0f,0f,1f);
break;
case ENTITY:
GL11.glTranslatef(0.0F,0.7f,0.0F);
GL11.glRotatef(180f,0f,0f,1f);
GL11.glScalef(0.5f,0.5f,0.5f);
break;
}
model.render(0.0625F);
GL11.glPopMatrix();
}
Program: 21927
Project: 21927
Buggy source:
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer,int slot){
  return null;
}

Fixed version (ground truth):
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer,int slot){
  Slot slotObject=(Slot)inventorySlots.get(slot);
  if (slotObject != null && slotObject.getHasStack()) {
    ItemStack stackInSlot=slotObject.getStack();
    ItemStack stack=stackInSlot.copy();
    if (slot >= 0 && slot < fusion.getSizeInventory()) {
      if (!mergeItemStack(stackInSlot,fusion.getSizeInventory(),inventorySlots.size(),true))       return null;
    }
 else     if (slot >= fusion.getSizeInventory()) {
      if (!mergeItemStack(stackInSlot,fusion.kStartInput1,fusion.kStartInput1 + 1,false))       return null;
    }
    if (stackInSlot.stackSize == 0)     slotObject.putStack(null);
 else     slotObject.onSlotChanged();
    return stack;
  }
  return null;
}
Program: 21928
Project: 21928
Buggy source:
@Override public boolean canInteractWith(EntityPlayer var1){
  return fusion.isUseableByPlayer(var1);
}

Fixed version (ground truth):
@Override public boolean canInteractWith(EntityPlayer var1){
  return true;
}
Program: 21929
Project: 21929
Buggy source:
public TileEntityFusion(){
  inputInventory=new BoundedInventory(this,kInput);
  outputInventory=new BoundedInventory(this,kOutput);
  starInventory=new BoundedInventory(this,kFusionStar);
  inputTransactor=new Transactor(inputInventory);
  outputTransactor=new Transactor(outputInventory);
  starTransactor=new Transactor(starInventory,1);
  this.inventory=new ItemStack[this.getSizeInventory()];
  setBlueprint(new BlueprintFusion());
}

Fixed version (ground truth):
public TileEntityFusion(){
  inventory=new ItemStack[getSizeInventory()];
  inputInventory=new BoundedInventory(this,kInput);
  outputInventory=new BoundedInventory(this,kOutput);
  starInventory=new BoundedInventory(this,kFusionStar);
  inputTransactor=new Transactor(inputInventory);
  outputTransactor=new Transactor(outputInventory);
  starTransactor=new Transactor(starInventory,1);
  this.inventory=new ItemStack[this.getSizeInventory()];
  setBlueprint(new BlueprintFusion());
}
Program: 21930
Project: 21930
Buggy source:
@Override public boolean func_102007_a(int i,ItemStack itemstack,int j){
  return false;
}

Fixed version (ground truth):
@Override public boolean func_102007_a(int i,ItemStack itemstack,int j){
  return true;
}
Program: 21931
Project: 21931
Buggy source:
@Override public boolean func_102008_b(int i,ItemStack itemstack,int j){
  return false;
}

Fixed version (ground truth):
@Override public boolean func_102008_b(int i,ItemStack itemstack,int j){
  return true;
}
Program: 21932
Project: 21932
Buggy source:
@Override public boolean func_102007_a(int i,ItemStack itemstack,int j){
  return true;
}

Fixed version (ground truth):
@Override public boolean func_102007_a(int i,ItemStack itemstack,int j){
  return false;
}
Program: 21933
Project: 21933
Buggy source:
@Override public boolean func_102008_b(int i,ItemStack itemstack,int j){
  return true;
}

Fixed version (ground truth):
@Override public boolean func_102008_b(int i,ItemStack itemstack,int j){
  return false;
}
Program: 21935
Project: 21935
Buggy source:
private void setBlock(int x,int y,int z,LocalPosition position,int structureId,HashMap<Integer,BlueprintBlock> blockLookup,TileEntity managerTileEntity){
  Pos3 worldPos=position.getLocalPos(x,y,z);
  if (structureId == MinechemBlueprint.wildcard) {
    return;
  }
  if (structureId == air) {
    worldObj.setBlockToAir(worldPos.x,worldPos.y,worldPos.z);
  }
 else {
    BlueprintBlock blueprintBlock=blockLookup.get(structureId);
    if (blueprintBlock.type == Type.MANAGER)     return;
    worldObj.setBlock(worldPos.x,worldPos.y,worldPos.z,blueprintBlock.block.blockID,blueprintBlock.metadata,3);
    if (blueprintBlock.type == Type.PROXY) {
      TileEntityProxy proxy=(TileEntityProxy)worldObj.getBlockTileEntity(worldPos.x,worldPos.y,worldPos.z);
      if (proxy instanceof TileEntityProxy) {
        if (proxy != null)         proxy.setManager(managerTileEntity);
      }
    }
  }
}

Fixed version (ground truth):
private void setBlock(int x,int y,int z,LocalPosition position,int structureId,HashMap<Integer,BlueprintBlock> blockLookup,TileEntity managerTileEntity){
  Pos3 worldPos=position.getLocalPos(x,y,z);
  if (structureId == MinechemBlueprint.wildcard) {
    return;
  }
  if (structureId == air) {
    worldObj.setBlockToAir(worldPos.x,worldPos.y,worldPos.z);
  }
 else {
    BlueprintBlock blueprintBlock=blockLookup.get(structureId);
    if (blueprintBlock.type == Type.MANAGER)     return;
    worldObj.setBlock(worldPos.x,worldPos.y,worldPos.z,blueprintBlock.block.blockID,blueprintBlock.metadata,3);
    if (blueprintBlock.type == Type.PROXY) {
      TileEntity te=worldObj.getBlockTileEntity(worldPos.x,worldPos.y,worldPos.z);
      if (te instanceof TileEntityProxy) {
        TileEntityProxy proxy=(TileEntityProxy)te;
      }
    }
  }
}
Program: 21936
Project: 21936
Buggy source:
@Override public void updateEntity(){
  super.updateEntity();
  powerProvider.receiveEnergy((float)wattsReceived / 437.5F,ForgeDirection.UP);
  powerProvider.update(this);
  if (!worldObj.isRemote && powerProvider.didEnergyStoredChange()) {
    sendUpdatePacket();
  }
  if (powerProvider.getEnergyStored() >= powerProvider.getMaxEnergyStored())   hasFullEnergy=true;
  if (hasFullEnergy && powerProvider.getEnergyStored() < powerProvider.getMaxEnergyStored() / 2)   hasFullEnergy=false;
  if (currentRecipe != null && inventory[kOutput[0]] == null) {
    inventory[kOutput[0]]=currentRecipe.getOutput().copy();
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  super.updateEntity();
  powerProvider.receiveEnergy((float)wattsReceived / 437.5F,ForgeDirection.UP);
  powerProvider.update(this);
  if (!worldObj.isRemote && (powerProvider.didEnergyStoredChange() || powerProvider.didEnergyUsageChange()))   sendUpdatePacket();
  float energyStored=powerProvider.getEnergyStored();
  if (energyStored >= powerProvider.getMaxEnergyStored())   hasFullEnergy=true;
  if (hasFullEnergy && energyStored < powerProvider.getMaxEnergyStored() / 2)   hasFullEnergy=false;
  if (powerProvider.getEnergyStored() >= powerProvider.getMaxEnergyStored())   hasFullEnergy=true;
  if (hasFullEnergy && powerProvider.getEnergyStored() < powerProvider.getMaxEnergyStored() / 2)   hasFullEnergy=false;
  if (currentRecipe != null && inventory[kOutput[0]] == null) {
    inventory[kOutput[0]]=currentRecipe.getOutput().copy();
  }
}
Program: 21938
Project: 21938
Buggy source:
private void func_77008_a(EntityPainting par1EntityPainting,float par2,float par3){
  int i=MathHelper.floor_double(par1EntityPainting.posX);
  int j=MathHelper.floor_double(par1EntityPainting.posY + (double)(par3 / 16.0F));
  int k=MathHelper.floor_double(par1EntityPainting.posZ);
  if (par1EntityPainting.hangingDirection == 2) {
    i=MathHelper.floor_double(par1EntityPainting.posX + (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 1) {
    k=MathHelper.floor_double(par1EntityPainting.posZ - (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 0) {
    i=MathHelper.floor_double(par1EntityPainting.posX - (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 3) {
    k=MathHelper.floor_double(par1EntityPainting.posZ + (double)(par2 / 16.0F));
  }
  int l=this.renderManager.worldObj.getLightBrightnessForSkyBlocks(i,j,k,0);
  int i1=l % 65536;
  int j1=l / 65536;
  OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,(float)i1,(float)j1);
  GL11.glColor3f(1.0F,1.0F,1.0F);
}

Fixed version (ground truth):
private void func_77008_a(EntityTableOfElements par1EntityPainting,float par2,float par3){
  int i=MathHelper.floor_double(par1EntityPainting.posX);
  int j=MathHelper.floor_double(par1EntityPainting.posY + (double)(par3 / 16.0F));
  int k=MathHelper.floor_double(par1EntityPainting.posZ);
  if (par1EntityPainting.hangingDirection == 2) {
    i=MathHelper.floor_double(par1EntityPainting.posX + (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 1) {
    k=MathHelper.floor_double(par1EntityPainting.posZ - (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 0) {
    i=MathHelper.floor_double(par1EntityPainting.posX - (double)(par2 / 16.0F));
  }
  if (par1EntityPainting.hangingDirection == 3) {
    k=MathHelper.floor_double(par1EntityPainting.posZ + (double)(par2 / 16.0F));
  }
  int l=this.renderManager.worldObj.getLightBrightnessForSkyBlocks(i,j,k,0);
  int i1=l % 65536;
  int j1=l / 65536;
  OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,(float)i1,(float)j1);
  GL11.glColor3f(1.0F,1.0F,1.0F);
}
Program: 21939
Project: 21939
Buggy source:
/** 
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
 */
public void doRender(Entity par1Entity,double par2,double par4,double par6,float par8,float par9){
  this.renderThePainting((EntityPainting)par1Entity,par2,par4,par6,par8,par9);
}

Fixed version (ground truth):
/** 
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
 */
public void doRender(Entity par1Entity,double par2,double par4,double par6,float par8,float par9){
  this.renderThePainting((EntityTableOfElements)par1Entity,par2,par4,par6,par8,par9);
}
Program: 21941
Project: 21941
Buggy source:
public void renderThePainting(EntityPainting par1EntityPainting,double par2,double par4,double par6,float par8,float par9){
  GL11.glPushMatrix();
  GL11.glTranslatef((float)par2,(float)par4,(float)par6);
  GL11.glRotatef(par8,0.0F,1.0F,0.0F);
  GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  this.loadTexture(ConstantValue.table_HEX);
  EnumArt enumart=par1EntityPainting.art;
  float f2=0.0625F;
  GL11.glScalef(f2,f2,f2);
  this.func_77010_a(par1EntityPainting,enumart.sizeX,enumart.sizeY,enumart.offsetX,enumart.offsetY);
  GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  GL11.glPopMatrix();
}

Fixed version (ground truth):
public void renderThePainting(EntityTableOfElements par1EntityPainting,double par2,double par4,double par6,float par8,float par9){
  GL11.glPushMatrix();
  GL11.glTranslatef((float)par2,(float)par4,(float)par6);
  GL11.glRotatef(par8,0.0F,1.0F,0.0F);
  GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  this.loadTexture(ConstantValue.table_HEX);
  EnumArt enumart=par1EntityPainting.art;
  float f2=0.0625F;
  GL11.glScalef(f2,f2,f2);
  this.func_77010_a(par1EntityPainting,enumart.sizeX,enumart.sizeY,enumart.offsetX,enumart.offsetY);
  GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  GL11.glPopMatrix();
}
Program: 21943
Project: 21943
Buggy source:
/** 
 * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer,java.lang.Object,java.lang.Object)
 */
public int compare(Viewer viewer,Object e1,Object e2){
  int result=comparator.compare((Rule)e1,(Rule)e2);
  return sortDescending ? 0 - result : result;
}

Fixed version (ground truth):
@Override public int compare(Viewer viewer,Object e1,Object e2){
  int result=comparator.compare((Rule)e1,(Rule)e2);
  return sortDescending ? 0 - result : result;
}
Program: 21944
Project: 21944
Buggy source:
/** 
 * @return Returns the comparator.
 */
public Comparator<Rule> getComparator(){
  return comparator;
}

Fixed version (ground truth):
@Override protected Comparator<? super String> getComparator(){
  throw new UnsupportedOperationException("String_Node_Str" + "String_Node_Str");
}
Program: 21947
Project: 21947
Buggy source:
public void start(BundleContext context) throws Exception {
  super.start(context);
  plugin=this;
  registerStandardRuleSets();
  IPreferences prefs=loadPreferences();
  configureLogs(prefs);
  registerAdditionalRuleSets();
  fileChangeListenerEnabled(prefs.isCheckAfterSaveEnabled());
  ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener(){
    public void resourceChanged(    IResourceChangeEvent arg0){
      if (arg0.getType() == IResourceChangeEvent.PRE_DELETE && arg0.getResource() instanceof IProject) {
        getPropertiesManager().removeProjectProperties((IProject)arg0.getResource());
      }
    }
  }
);
  VERSION=context.getBundle().getHeaders().get((Object)"String_Node_Str");
}

Fixed version (ground truth):
public void start(BundleContext context) throws Exception {
  super.start(context);
  plugin=this;
  registerStandardRuleSets();
  IPreferences prefs=loadPreferences();
  configureLogs(prefs);
  registerAdditionalRuleSets();
  fileChangeListenerEnabled(prefs.isCheckAfterSaveEnabled());
  ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener(){
    public void resourceChanged(    IResourceChangeEvent arg0){
      if (arg0.getType() == IResourceChangeEvent.PRE_DELETE && arg0.getResource() instanceof IProject) {
        getPropertiesManager().removeProjectProperties((IProject)arg0.getResource());
      }
    }
  }
);
  VERSION=context.getBundle().getHeaders().get("String_Node_Str");
}
Program: 21949
Project: 21949
Buggy source:
public void widgetSelected(SelectionEvent e){
  Rule rule=soleRule();
  int selectionIdx=xpathVersionField.getSelectionIndex();
  Object newValue=ep.choices()[selectionIdx][1];
  if (newValue.equals(rule.getProperty(ep)))   return;
  rule.setProperty(ep,newValue);
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent e){
  Rule rule=soleRule();
  int selectionIdx=xpathVersionField.getSelectionIndex();
  String newValue=(String)ep.choices()[selectionIdx][1];
  if (newValue.equals(rule.getProperty(ep)))   return;
  rule.setProperty(ep,newValue);
}
Program: 21951
Project: 21951
Buggy source:
public void widgetSelected(SelectionEvent e){
  Rule rule=soleRule();
  int selectionIdx=xpathVersionField.getSelectionIndex();
  Object newValue=ep.choices()[selectionIdx][1];
  if (newValue.equals(rule.getProperty(ep)))   return;
  rule.setProperty(ep,newValue);
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent e){
  Rule rule=soleRule();
  int selectionIdx=xpathVersionField.getSelectionIndex();
  String newValue=(String)ep.choices()[selectionIdx][1];
  if (newValue.equals(rule.getProperty(ep)))   return;
  rule.setProperty(ep,newValue);
}
Program: 21952
Project: 21952
Buggy source:
public String[] names(){
  if (rulesByFilterName == null)   return StringUtil.EMPTY_STRINGS;
  return rulesByFilterName.keySet().toArray(new String[rulesByFilterName.size()]);
}

Fixed version (ground truth):
public String[] names(){
  if (rulesByFilterName == null)   return StringUtil.getEmptyStrings();
  return rulesByFilterName.keySet().toArray(new String[rulesByFilterName.size()]);
}
Program: 21953
Project: 21953
Buggy source:
protected String[] textWidgetValues(Text textWidget){
  String values=textWidget.getText().trim();
  if (StringUtil.isEmpty(values))   return StringUtil.EMPTY_STRINGS;
  String[] valueSet=values.split(delimiter);
  List<String> valueList=new ArrayList<String>(valueSet.length);
  for (  String value : valueSet) {
    String str=value.trim();
    if (str.length() > 0)     valueList.add(str);
  }
  return valueList.toArray(new String[valueList.size()]);
}

Fixed version (ground truth):
protected String[] textWidgetValues(Text textWidget){
  String values=textWidget.getText().trim();
  if (StringUtil.isEmpty(values))   return StringUtil.getEmptyStrings();
  String[] valueSet=values.split(delimiter);
  List<String> valueList=new ArrayList<String>(valueSet.length);
  for (  String value : valueSet) {
    String str=value.trim();
    if (str.length() > 0)     valueList.add(str);
  }
  return valueList.toArray(new String[valueList.size()]);
}
Program: 21954
Project: 21954
Buggy source:
public MethodPicker(Composite parent,int style,String[] theUnwantedPrefixes){
  super(parent,SWT.None);
  unwantedPrefixes=theUnwantedPrefixes == null ? StringUtil.EMPTY_STRINGS : theUnwantedPrefixes;
  GridLayout layout=new GridLayout(2,true);
  layout.verticalSpacing=0;
  layout.horizontalSpacing=0;
  layout.marginHeight=0;
  layout.marginWidth=0;
  this.setLayout(layout);
  typeText=new TypeText(this,style,false,"String_Node_Str");
  typeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  typeText.addListener(SWT.FocusOut,new Listener(){
    public void handleEvent(    Event event){
      reviseMethodListFor(typeText.getType(true));
    }
  }
);
  typeText.addListener(SWT.Modify,new Listener(){
    public void handleEvent(    Event event){
      reviseMethodListFor(typeText.getType(false));
    }
  }
);
  methodList=new Combo(this,style);
  methodList.setLayoutData(new GridData(GridData.FILL_BOTH));
}

Fixed version (ground truth):
public MethodPicker(Composite parent,int style,String[] theUnwantedPrefixes){
  super(parent,SWT.None);
  unwantedPrefixes=theUnwantedPrefixes == null ? StringUtil.getEmptyStrings() : theUnwantedPrefixes;
  GridLayout layout=new GridLayout(2,true);
  layout.verticalSpacing=0;
  layout.horizontalSpacing=0;
  layout.marginHeight=0;
  layout.marginWidth=0;
  this.setLayout(layout);
  typeText=new TypeText(this,style,false,"String_Node_Str");
  typeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  typeText.addListener(SWT.FocusOut,new Listener(){
    public void handleEvent(    Event event){
      reviseMethodListFor(typeText.getType(true));
    }
  }
);
  typeText.addListener(SWT.Modify,new Listener(){
    public void handleEvent(    Event event){
      reviseMethodListFor(typeText.getType(false));
    }
  }
);
  methodList=new Combo(this,style);
  methodList.setLayoutData(new GridData(GridData.FILL_BOTH));
}
Program: 21955
Project: 21955
Buggy source:
private Integer[] currentIntegers(Text textWidget){
  String[] numberStrings=textWidgetValues(textWidget);
  if (numberStrings.length == 0)   return emptyIntSet;
  List<Integer> ints=new ArrayList<Integer>(numberStrings.length);
  Integer intrg;
  for (  String numString : numberStrings) {
    try {
      intrg=Integer.parseInt(numString);
    }
 catch (    Exception e) {
    }
    if (intrg != null)     ints.add(intrg);
  }
  return ints.toArray(new Integer[ints.size()]);
}

Fixed version (ground truth):
private Integer[] currentIntegers(Text textWidget){
  String[] numberStrings=textWidgetValues(textWidget);
  if (numberStrings.length == 0)   return emptyIntSet;
  List<Integer> ints=new ArrayList<Integer>(numberStrings.length);
  for (  String numString : numberStrings) {
    try {
      Integer intrg=Integer.parseInt(numString);
      ints.add(intrg);
    }
 catch (    Exception e) {
    }
  }
  return ints.toArray(new Integer[ints.size()]);
}
Program: 21956
Project: 21956
Buggy source:
public void showOn(StyledText widget){
}

Fixed version (ground truth):
public void showOn(StyledText widget){
  String text=buffer.toString();
  widget.setText(text);
  List<StyleRange> ranges=new ArrayList<StyleRange>();
  int[] span;
  for (int i=0; i < headingSpans.size(); i++) {
    span=headingSpans.get(i);
    ranges.add(new StyleRange(span[0],span[1] - span[0],headingColor,BACKGROUND,SWT.BOLD));
  }
  for (  int[] spn : linksBySpan.keySet()) {
    StyleRange style=new StyleRange(spn[0],spn[1] - spn[0],headingColor,BACKGROUND,SWT.UNDERLINE_LINK);
    style.underline=true;
    ranges.add(style);
  }
  String crStr=Character.toString(CR);
  StyleRange sr;
  for (int i=0; i < codeSpans.size(); i++) {
    span=codeSpans.get(i);
    sr=new StyleRange(codeStyle);
    sr.start=span[0];
    sr.length=span[1] - span[0];
    List<StyleRange> colorRanges=codeStyleExtractor.stylesFor(text,sr.start,sr.length,crStr);
    for (    StyleRange range : colorRanges) {
      ranges.add(range);
    }
  }
  StyleRange[] styles=sort(ranges);
  widget.setStyleRanges(styles);
}
Program: 21957
Project: 21957
Buggy source:
/** 
 * @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
 */
@Override public IResource getResource(){
  IResource resource=null;
  try {
    resource=((IJavaElement)folder).getCorrespondingResource();
  }
 catch (  JavaModelException jme) {
    PMDPlugin.getDefault().logError(StringKeys.ERROR_JAVAMODEL_EXCEPTION + this.toString(),jme);
  }
  return resource;
}

Fixed version (ground truth):
/** 
 * @see net.sourceforge.pmd.eclipse.ui.model.AbstractPMDRecord#getResource()
 */
@Override public IResource getResource(){
  return (IResource)folder;
}
Program: 21958
Project: 21958
Buggy source:
private void checkNonDupes(){
  RuleSet rs=selectedRuleset();
  if (rs == null) {
    ruleTable.setCheckedElements(new Object[0]);
    return;
  }
  List<Rule> nonDupes=new ArrayList<Rule>();
  for (  Rule rule : rs.getRules()) {
    if (dupeChecker.isDuplicate(rule))     continue;
    nonDupes.add(rule);
  }
  ruleTable.setCheckedElements(nonDupes.toArray());
}

Fixed version (ground truth):
private void checkNonDupes(){
  List<Rule> nonDupes=new ArrayList<Rule>();
  for (  TableItem item : ruleTable.getTable().getItems()) {
    Rule rule=(Rule)item.getData();
    if (dupeChecker.isDuplicate(rule)) {
      continue;
    }
    nonDupes.add(rule);
  }
  ruleTable.setCheckedElements(nonDupes.toArray());
}
Program: 21959
Project: 21959
Buggy source:
/** 
 * @param event
 */
public void resourceChanged(IResourceChangeEvent event){
  Set<ResourceChange> itemsChanged=new HashSet<ResourceChange>();
switch (event.getType()) {
case IResourceChangeEvent.POST_CHANGE:
    changed(itemsChanged,event.getDelta(),new NullProgressMonitor());
}
if (itemsChanged.isEmpty()) return;
ReviewCodeCmd cmd=new ReviewCodeCmd();
cmd.reset();
for (ResourceChange chg : itemsChanged) cmd.addResource(chg.file);
try {
  cmd.performExecute();
}
 catch (CommandException e) {
  PMDPlugin.getDefault().log(IStatus.ERROR,"String_Node_Str",e);
}
}

Fixed version (ground truth):
/** 
 * @param event
 */
public void resourceChanged(IResourceChangeEvent event){
  Set<ResourceChange> itemsChanged=new HashSet<ResourceChange>();
switch (event.getType()) {
case IResourceChangeEvent.POST_CHANGE:
    changed(itemsChanged,event.getDelta(),new NullProgressMonitor());
}
if (itemsChanged.isEmpty()) return;
ReviewCodeCmd cmd=new ReviewCodeCmd();
cmd.clearExistingMarkersBeforeApplying(true);
cmd.reset();
for (ResourceChange chg : itemsChanged) cmd.addResource(chg.file);
try {
  cmd.performExecute();
}
 catch (CommandException e) {
  PMDPlugin.getDefault().log(IStatus.ERROR,"String_Node_Str",e);
}
}
Program: 21960
Project: 21960
Buggy source:
/** 
 * Apply PMD markers after the review
 */
private void applyMarkers(){
  log.info("String_Node_Str");
  int violationCount=0;
  final Timer timer=new Timer();
  String currentFile="String_Node_Str";
  beginTask("String_Node_Str",markersByFile.size());
  try {
    for (    IFile file : markersByFile.keySet()) {
      if (isCanceled())       break;
      currentFile=file.getName();
      Set<MarkerInfo2> markerInfoSet=markersByFile.get(file);
      for (      MarkerInfo2 markerInfo : markerInfoSet) {
        markerInfo.addAsMarkerTo(file);
        violationCount++;
      }
      worked(1);
    }
  }
 catch (  CoreException e) {
    log.warn("String_Node_Str" + currentFile + "String_Node_Str"+ e.getMessage());
  }
 finally {
    timer.stop();
    int count=markersByFile.size();
    logInfo("String_Node_Str" + violationCount + "String_Node_Str"+ count+ "String_Node_Str"+ timer.getDuration()+ "String_Node_Str");
    log.info("String_Node_Str" + violationCount + "String_Node_Str"+ count+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Apply PMD markers after the review
 */
private void applyMarkers(){
  log.info("String_Node_Str");
  int violationCount=0;
  final Timer timer=new Timer();
  String currentFile="String_Node_Str";
  beginTask("String_Node_Str",markersByFile.size());
  try {
    for (    IFile file : markersByFile.keySet()) {
      if (isCanceled())       break;
      currentFile=file.getName();
      Set<MarkerInfo2> markerInfoSet=markersByFile.get(file);
      if (clearExistingMarkersBeforeApplying) {
        MarkerUtil.deleteAllMarkersIn(file);
      }
      for (      MarkerInfo2 markerInfo : markerInfoSet) {
        markerInfo.addAsMarkerTo(file);
        violationCount++;
      }
      worked(1);
    }
  }
 catch (  CoreException e) {
    log.warn("String_Node_Str" + currentFile + "String_Node_Str"+ e.getMessage());
  }
 finally {
    timer.stop();
    int count=markersByFile.size();
    logInfo("String_Node_Str" + violationCount + "String_Node_Str"+ count+ "String_Node_Str"+ timer.getDuration()+ "String_Node_Str");
    log.info("String_Node_Str" + violationCount + "String_Node_Str"+ count+ "String_Node_Str");
  }
}
Program: 21961
Project: 21961
Buggy source:
private CPD newCPD(){
  CPDConfiguration config=new CPDConfiguration(minTileSize,language,System.getProperty("String_Node_Str"));
  return new CPD(config);
}

Fixed version (ground truth):
private CPD newCPD(){
  CPDConfiguration config=new CPDConfiguration();
  config.setMinimumTileSize(minTileSize);
  config.setLanguage(language);
  config.setEncoding(System.getProperty("String_Node_Str"));
  return new CPD(config);
}
Program: 21962
Project: 21962
Buggy source:
/** 
 * Save the properties of all renderers to the specified filename.
 * @param propertyFilename String
 */
private static void saveReportProperties(String propertyFilename){
  Properties props=new Properties();
  for (  Renderer renderer : ReportManager.instance.allRenderers()) {
    Map<PropertyDescriptor<?>,Object> valuesByProp=renderer.getPropertiesByPropertyDescriptor();
    for (    Map.Entry<PropertyDescriptor<?>,Object> entry : valuesByProp.entrySet()) {
      PropertyDescriptor desc=entry.getKey();
      props.put(keyOf(renderer,desc),desc.asDelimitedString(entry.getValue()));
    }
  }
  FileOutputStream fos=null;
  try {
    fos=new FileOutputStream(propertyFilename);
    props.storeToXML(fos,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    IOUtil.closeQuietly(fos);
  }
}

Fixed version (ground truth):
/** 
 * Save the properties of all renderers to the specified filename.
 * @param propertyFilename String
 */
private static void saveReportProperties(String propertyFilename){
  Properties props=new Properties();
  for (  Renderer renderer : ReportManager.instance.allRenderers()) {
    Map<PropertyDescriptor<?>,Object> valuesByProp=renderer.getPropertiesByPropertyDescriptor();
    for (    Map.Entry<PropertyDescriptor<?>,Object> entry : valuesByProp.entrySet()) {
      PropertyDescriptor desc=entry.getKey();
      props.put(keyOf(renderer,desc),desc.asDelimitedString(entry.getValue()));
    }
  }
  FileOutputStream fos=null;
  try {
    fos=new FileOutputStream(propertyFilename);
    props.storeToXML(fos,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (fos != null) {
        fos.close();
      }
    }
 catch (    Exception e) {
    }
  }
}
Program: 21963
Project: 21963
Buggy source:
/** 
 * Load the properties for all renderers from the specified filename. Return whether we succeeded or not.
 * @param propertyFilename String
 * @return boolean
 */
private static boolean loadReportProperties(String propertyFilename){
  Properties props=new Properties();
  FileInputStream fis=null;
  try {
    fis=new FileInputStream(propertyFilename);
    props.loadFromXML(fis);
  }
 catch (  Exception e) {
    return false;
  }
 finally {
    IOUtil.closeQuietly(fis);
  }
  for (  Renderer renderer : ReportManager.instance.allRenderers()) {
    for (    PropertyDescriptor pDesc : renderer.getPropertyDescriptors()) {
      String key=keyOf(renderer,pDesc);
      if (props.containsKey(key)) {
        Object value=pDesc.valueFrom((String)props.get(key));
        renderer.setProperty(pDesc,value);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Load the properties for all renderers from the specified filename. Return whether we succeeded or not.
 * @param propertyFilename String
 * @return boolean
 */
private static boolean loadReportProperties(String propertyFilename){
  Properties props=new Properties();
  FileInputStream fis=null;
  try {
    fis=new FileInputStream(propertyFilename);
    props.loadFromXML(fis);
  }
 catch (  Exception e) {
    return false;
  }
 finally {
    try {
      if (fis != null) {
        fis.close();
      }
    }
 catch (    Exception e) {
    }
  }
  for (  Renderer renderer : ReportManager.instance.allRenderers()) {
    for (    PropertyDescriptor pDesc : renderer.getPropertyDescriptors()) {
      String key=keyOf(renderer,pDesc);
      if (props.containsKey(key)) {
        Object value=pDesc.valueFrom((String)props.get(key));
        renderer.setProperty(pDesc,value);
      }
    }
  }
  return true;
}
Program: 21964
Project: 21964
Buggy source:
/** 
 * Test the basic usage of the report rendering command
 */
@Test public void testRenderReportCmdBasic() throws CommandException, CoreException {
  final ReviewCodeCmd reviewCmd=new ReviewCodeCmd();
  reviewCmd.addResource(this.testProject);
  reviewCmd.performExecute();
  final RenderReportsCmd cmd=new RenderReportsCmd();
  cmd.setProject(this.testProject);
  cmd.registerRenderer(new HTMLRenderer(new Properties()),PMDRuntimeConstants.HTML_REPORT_NAME);
  cmd.performExecute();
  cmd.join();
  final IFolder reportFolder=this.testProject.getFolder(PMDRuntimeConstants.REPORT_FOLDER);
  Assert.assertTrue(reportFolder.exists());
  final IFile reportFile=reportFolder.getFile(PMDRuntimeConstants.HTML_REPORT_NAME);
  Assert.assertTrue(reportFile.exists());
  this.testProject.deleteMarkers(PMDRuntimeConstants.PMD_MARKER,true,IResource.DEPTH_INFINITE);
  if (reportFile.exists()) {
    reportFile.delete(true,false,null);
  }
  if (reportFolder.exists()) {
    reportFolder.delete(true,false,null);
  }
}

Fixed version (ground truth):
/** 
 * Test the basic usage of the report rendering command
 */
@Test public void testRenderReportCmdBasic() throws CommandException, CoreException {
  final ReviewCodeCmd reviewCmd=new ReviewCodeCmd();
  reviewCmd.addResource(this.testProject);
  reviewCmd.performExecute();
  final RenderReportsCmd cmd=new RenderReportsCmd();
  cmd.setProject(this.testProject);
  cmd.registerRenderer(new HTMLRenderer(),PMDRuntimeConstants.HTML_REPORT_NAME);
  cmd.performExecute();
  cmd.join();
  final IFolder reportFolder=this.testProject.getFolder(PMDRuntimeConstants.REPORT_FOLDER);
  Assert.assertTrue(reportFolder.exists());
  final IFile reportFile=reportFolder.getFile(PMDRuntimeConstants.HTML_REPORT_NAME);
  Assert.assertTrue(reportFile.exists());
  this.testProject.deleteMarkers(PMDRuntimeConstants.PMD_MARKER,true,IResource.DEPTH_INFINITE);
  if (reportFile.exists()) {
    reportFile.delete(true,false,null);
  }
  if (reportFolder.exists()) {
    reportFolder.delete(true,false,null);
  }
}
Program: 21965
Project: 21965
Buggy source:
/** 
 * Test robustness #1
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg1() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(null);
    cmd.registerRenderer(new HTMLRenderer(new Properties()),PMDRuntimeConstants.HTML_REPORT_NAME);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}

Fixed version (ground truth):
/** 
 * Test robustness #1
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg1() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(null);
    cmd.registerRenderer(new HTMLRenderer(),PMDRuntimeConstants.HTML_REPORT_NAME);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}
Program: 21966
Project: 21966
Buggy source:
/** 
 * Test robustness #3
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg3() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(this.testProject);
    cmd.registerRenderer(new HTMLRenderer(new Properties()),null);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}

Fixed version (ground truth):
/** 
 * Test robustness #3
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg3() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(this.testProject);
    cmd.registerRenderer(new HTMLRenderer(),null);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}
Program: 21967
Project: 21967
Buggy source:
/** 
 * Test robustness #5
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg5() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(null);
    cmd.registerRenderer(new HTMLRenderer(new Properties()),null);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}

Fixed version (ground truth):
/** 
 * Test robustness #5
 * @throws CommandException
 */
@Test public void testRenderReportCmdNullArg5() throws CommandException {
  try {
    final RenderReportsCmd cmd=new RenderReportsCmd();
    cmd.setProject(null);
    cmd.registerRenderer(new HTMLRenderer(),null);
    cmd.performExecute();
    Assert.fail();
  }
 catch (  final UnsetInputPropertiesException e) {
  }
}
Program: 21968
Project: 21968
Buggy source:
public boolean equals(Object other){
  if (other == this)   return true;
  if (other.getClass() == getClass()) {
    ResourceChange chg=(ResourceChange)other;
    return chg.file.equals(file) && resourceDeltaType == chg.resourceDeltaType && flags == chg.flags;
  }
  return false;
}

Fixed version (ground truth):
public boolean equals(Object other){
  if (other == null)   return false;
  if (other == this)   return true;
  if (other.getClass() == getClass()) {
    ResourceChange chg=(ResourceChange)other;
    return chg.file.equals(file) && resourceDeltaType == chg.resourceDeltaType && flags == chg.flags;
  }
  return false;
}
Program: 21969
Project: 21969
Buggy source:
private void addFilesTo(IResource resource,Collection<IResource> allKids){
  if (resource instanceof IFile) {
    allKids.add(resource);
    return;
  }
  if (resource instanceof IFolder) {
    IFolder folder=(IFolder)resource;
    IResource[] kids=null;
    try {
      kids=folder.members();
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
    for (    IResource irc : kids) {
      if (irc instanceof IFile) {
        allKids.add(irc);
        continue;
      }
      if (irc instanceof IFolder) {
        addFilesTo(irc,allKids);
      }
    }
    allKids.add(folder);
    return;
  }
  if (resource instanceof IProject) {
    IProject project=(IProject)resource;
    IResource[] kids=null;
    try {
      kids=project.members();
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
    for (    IResource irc : kids) {
      if (irc instanceof IFile) {
        allKids.add(irc);
        continue;
      }
      if (irc instanceof IFolder) {
        addFilesTo(irc,allKids);
      }
    }
    allKids.add(project);
    return;
  }
}

Fixed version (ground truth):
private void addFilesTo(IResource resource,Collection<IResource> allKids){
  if (resource instanceof IFile) {
    allKids.add(resource);
    return;
  }
  if (resource instanceof IFolder) {
    IFolder folder=(IFolder)resource;
    IResource[] kids=null;
    try {
      kids=folder.members();
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
    addKids(allKids,kids);
    allKids.add(folder);
    return;
  }
  if (resource instanceof IProject) {
    IProject project=(IProject)resource;
    IResource[] kids=null;
    try {
      kids=project.members();
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
    addKids(allKids,kids);
    allKids.add(project);
    return;
  }
}
Program: 21970
Project: 21970
Buggy source:
public static boolean hasAnyRuleMarkers(IResource resource) throws CoreException {
  final boolean[] foundOne=new boolean[]{false};
  IResourceVisitor ruleMarkerFinder=new IResourceVisitor(){
    public boolean visit(    IResource resource){
      if (foundOne[0])       return false;
      if (resource instanceof IFile) {
        for (        String markerType : PMDRuntimeConstants.RULE_MARKER_TYPES) {
          IMarker[] ruleMarkers=null;
          try {
            ruleMarkers=resource.findMarkers(markerType,true,IResource.DEPTH_INFINITE);
          }
 catch (          CoreException ex) {
          }
          if (ruleMarkers.length > 0) {
            foundOne[0]=true;
            return false;
          }
        }
      }
      return true;
    }
  }
;
  try {
    resource.accept(ruleMarkerFinder);
  }
 catch (  CoreException e) {
    e.printStackTrace();
  }
  return foundOne[0];
}

Fixed version (ground truth):
public static boolean hasAnyRuleMarkers(IResource resource) throws CoreException {
  final boolean[] foundOne=new boolean[]{false};
  IResourceVisitor ruleMarkerFinder=new IResourceVisitor(){
    public boolean visit(    IResource resource){
      if (foundOne[0])       return false;
      if (resource instanceof IFile) {
        for (        String markerType : PMDRuntimeConstants.RULE_MARKER_TYPES) {
          IMarker[] ruleMarkers=null;
          try {
            ruleMarkers=resource.findMarkers(markerType,true,IResource.DEPTH_INFINITE);
          }
 catch (          CoreException ex) {
          }
          if (ruleMarkers != null && ruleMarkers.length > 0) {
            foundOne[0]=true;
            return false;
          }
        }
      }
      return true;
    }
  }
;
  try {
    resource.accept(ruleMarkerFinder);
  }
 catch (  CoreException e) {
    e.printStackTrace();
  }
  return foundOne[0];
}
Program: 21971
Project: 21971
Buggy source:
public boolean visit(IResource resource){
  if (foundOne[0])   return false;
  if (resource instanceof IFile) {
    for (    String markerType : PMDRuntimeConstants.RULE_MARKER_TYPES) {
      IMarker[] ruleMarkers=null;
      try {
        ruleMarkers=resource.findMarkers(markerType,true,IResource.DEPTH_INFINITE);
      }
 catch (      CoreException ex) {
      }
      if (ruleMarkers.length > 0) {
        foundOne[0]=true;
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean visit(IResource resource){
  if (foundOne[0])   return false;
  if (resource instanceof IFile) {
    for (    String markerType : PMDRuntimeConstants.RULE_MARKER_TYPES) {
      IMarker[] ruleMarkers=null;
      try {
        ruleMarkers=resource.findMarkers(markerType,true,IResource.DEPTH_INFINITE);
      }
 catch (      CoreException ex) {
      }
      if (ruleMarkers != null && ruleMarkers.length > 0) {
        foundOne[0]=true;
        return false;
      }
    }
  }
  return true;
}
Program: 21972
Project: 21972
Buggy source:
/** 
 * @see net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties#setRuleSetFile(String)
 */
public void setRuleSetFile(String ruleSetFile) throws PropertiesException {
  log.debug("String_Node_Str" + this.project.getName() + "String_Node_Str"+ ruleSetFile);
  this.needRebuild|=this.ruleSetFile == null || !ruleSetFile.equals(ruleSetFile);
  this.ruleSetFile=ruleSetFile;
  if (this.ruleSetStoredInProject && !isRuleSetFileExist()) {
    throw new PropertiesException("String_Node_Str" + this.project.getName());
  }
}

Fixed version (ground truth):
/** 
 * @see net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties#setRuleSetFile(String)
 */
public void setRuleSetFile(String ruleSetFile) throws PropertiesException {
  log.debug("String_Node_Str" + project.getName() + "String_Node_Str"+ ruleSetFile);
  needRebuild|=this.ruleSetFile == null || !this.ruleSetFile.equals(ruleSetFile);
  this.ruleSetFile=ruleSetFile;
  if (ruleSetStoredInProject && !isRuleSetFileExist()) {
    throw new PropertiesException("String_Node_Str" + project.getName());
  }
}
Program: 21973
Project: 21973
Buggy source:
public boolean equals(Object other){
  if (this == other)   return true;
  if (other.getClass() != getClass())   return false;
  ShapeDescriptor otherOne=(ShapeDescriptor)other;
  return shape.equals(otherOne.shape) && rgbColor.equals(otherOne.rgbColor) && size == otherOne.size;
}

Fixed version (ground truth):
public boolean equals(Object other){
  if (other == null)   return false;
  if (this == other)   return true;
  if (other.getClass() != getClass())   return false;
  ShapeDescriptor otherOne=(ShapeDescriptor)other;
  return shape.equals(otherOne.shape) && rgbColor.equals(otherOne.rgbColor) && size == otherOne.size;
}
Program: 21974
Project: 21974
Buggy source:
private T itemAt(int xIn,int yIn){
  if (items == null)   return null;
  int width=getSize().x;
  int xBoundary=3;
  for (int i=0; i < items.length; i++) {
    int xOffset=0;
    int step=(itemWidth + gap) * i;
switch (SWT.LEFT) {
case SWT.CENTER:
      xOffset=(width / 2) - (itemWidth / 2) - xBoundary + step;
    break;
case SWT.RIGHT:
  xOffset=width - width - xBoundary;
break;
case SWT.LEFT:
xOffset=xBoundary + step;
}
if (xIn < xOffset) {
return items[i == 0 ? 0 : i - 1];
}
if (xIn < xOffset + itemWidth) return items[i];
}
return null;
}

Fixed version (ground truth):
private T itemAt(int xIn,int yIn){
  if (items == null)   return null;
  int width=getSize().x;
  int xBoundary=3;
  for (int i=0; i < items.length; i++) {
    int xOffset=0;
    int step=(itemWidth + gap) * i;
switch (SWT.LEFT) {
case SWT.CENTER:
      xOffset=(width / 2) - (itemWidth / 2) - xBoundary + step;
    break;
case SWT.RIGHT:
  xOffset=0 - xBoundary;
break;
case SWT.LEFT:
xOffset=xBoundary + step;
}
if (xIn < xOffset) {
return items[i == 0 ? 0 : i - 1];
}
if (xIn < xOffset + itemWidth) return items[i];
}
return null;
}
Program: 21975
Project: 21975
Buggy source:
private void doPaint(PaintEvent pe){
  if (items == null)   return;
  GC gc=pe.gc;
  int width=getSize().x;
  int xBoundary=3;
  if (isFocusControl()) {
    gc.drawFocus(0,0,getSize().x,getSize().y);
  }
  for (int i=0; i < items.length; i++) {
    gc.setBackground(selectedItem == items[i] ? selectedItemFillColor : colourFor(i));
    int xOffset=0;
    int step=(itemWidth + gap) * i;
switch (SWT.LEFT) {
case SWT.CENTER:
      xOffset=(width / 2) - (itemWidth / 2) - xBoundary + step;
    break;
case SWT.RIGHT:
  xOffset=width - width - xBoundary;
break;
case SWT.LEFT:
xOffset=xBoundary + step;
}
gc.setLineWidth(showHighlightOn(items[i]) ? 3 : 1);
ShapePainter.drawShape(itemWidth,itemWidth,shapeFor(i),gc,pe.x + xOffset,pe.y + gap,null);
}
}

Fixed version (ground truth):
private void doPaint(PaintEvent pe){
  if (items == null)   return;
  GC gc=pe.gc;
  int width=getSize().x;
  int xBoundary=3;
  if (isFocusControl()) {
    gc.drawFocus(0,0,getSize().x,getSize().y);
  }
  for (int i=0; i < items.length; i++) {
    gc.setBackground(selectedItem == items[i] ? selectedItemFillColor : colourFor(i));
    int xOffset=0;
    int step=(itemWidth + gap) * i;
switch (SWT.LEFT) {
case SWT.CENTER:
      xOffset=(width / 2) - (itemWidth / 2) - xBoundary + step;
    break;
case SWT.RIGHT:
  xOffset=0 - xBoundary;
break;
case SWT.LEFT:
xOffset=xBoundary + step;
}
gc.setLineWidth(showHighlightOn(items[i]) ? 3 : 1);
ShapePainter.drawShape(itemWidth,itemWidth,shapeFor(i),gc,pe.x + xOffset,pe.y + gap,null);
}
}
Program: 21977
Project: 21977
Buggy source:
/** 
 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
 */
public boolean performOk(){
  updateMarkerIcons();
  if (additionalCommentText != null) {
    preferences.setReviewAdditionalComment(additionalCommentText.getText());
  }
  if (showPerspectiveBox != null) {
    preferences.setPmdPerspectiveEnabled(showPerspectiveBox.getSelection());
  }
  if (checkCodeOnSave != null) {
    preferences.isCheckAfterSaveEnabled(checkCodeOnSave.getSelection());
  }
  if (useCustomPriorityNames != null) {
    preferences.useCustomPriorityNames(useCustomPriorityNames.getSelection());
  }
  if (useProjectBuildPath != null) {
    preferences.setProjectBuildPathEnabled(useProjectBuildPath.getSelection());
  }
  if (maxViolationsPerFilePerRule != null) {
    preferences.setMaxViolationsPerFilePerRule(Integer.valueOf(maxViolationsPerFilePerRule.getText()).intValue());
  }
  if (reviewPmdStyleBox != null) {
    preferences.setReviewPmdStyleEnabled(reviewPmdStyleBox.getSelection());
  }
  if (logFileNameText != null) {
    preferences.setLogFileName(logFileNameText.getText());
  }
  if (logLevelScale != null) {
    preferences.setLogLevel(Level.toLevel(LOG_LEVELS[logLevelScale.getSelection()]));
  }
  preferences.sync();
  PMDPlugin.getDefault().fileChangeListenerEnabled(checkCodeOnSave.getSelection());
  PMDPlugin.getDefault().applyLogPreferences(preferences);
  return true;
}

Fixed version (ground truth):
/** 
 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
 */
public boolean performOk(){
  updateMarkerIcons();
  if (additionalCommentText != null) {
    preferences.setReviewAdditionalComment(additionalCommentText.getText());
  }
  if (showPerspectiveBox != null) {
    preferences.setPmdPerspectiveEnabled(showPerspectiveBox.getSelection());
  }
  if (checkCodeOnSave != null) {
    boolean doCheck=checkCodeOnSave.getSelection();
    preferences.isCheckAfterSaveEnabled(doCheck);
    PMDPlugin.getDefault().fileChangeListenerEnabled(doCheck);
  }
  if (useCustomPriorityNames != null) {
    preferences.useCustomPriorityNames(useCustomPriorityNames.getSelection());
  }
  if (useProjectBuildPath != null) {
    preferences.setProjectBuildPathEnabled(useProjectBuildPath.getSelection());
  }
  if (maxViolationsPerFilePerRule != null) {
    preferences.setMaxViolationsPerFilePerRule(Integer.valueOf(maxViolationsPerFilePerRule.getText()).intValue());
  }
  if (reviewPmdStyleBox != null) {
    preferences.setReviewPmdStyleEnabled(reviewPmdStyleBox.getSelection());
  }
  if (logFileNameText != null) {
    preferences.setLogFileName(logFileNameText.getText());
  }
  if (logLevelScale != null) {
    preferences.setLogLevel(Level.toLevel(LOG_LEVELS[logLevelScale.getSelection()]));
  }
  preferences.sync();
  PMDPlugin.getDefault().applyLogPreferences(preferences);
  return true;
}