nus-yam/ex-repair huggingface dataset:
Program: 88275
Project: 88275
Buggy source:
public LatinKeyboard(Context context,int xmlLayoutResId,int mode){
  super(context,xmlLayoutResId,mode);
  final Resources res=context.getResources();
  mContext=context;
  mRes=res;
  mShiftLockIcon=res.getDrawable(R.drawable.sym_keyboard_shift_locked);
  mShiftLockPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
  mShiftLockPreviewIcon.setBounds(0,0,mShiftLockPreviewIcon.getIntrinsicWidth(),mShiftLockPreviewIcon.getIntrinsicHeight());
  mSpaceIcon=res.getDrawable(R.drawable.sym_keyboard_space);
  mSpaceAutoCompletionIndicator=res.getDrawable(R.drawable.sym_keyboard_space_led);
  mSpacePreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_space);
  mMicIcon=res.getDrawable(R.drawable.sym_keyboard_mic);
  mMicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_mic);
  setDefaultBounds(mMicPreviewIcon);
  mButtonArrowLeftIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
  mButtonArrowRightIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
  m123MicIcon=res.getDrawable(R.drawable.sym_keyboard_123_mic);
  m123MicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic);
  setDefaultBounds(m123MicPreviewIcon);
  sSpacebarVerticalCorrection=res.getDimensionPixelOffset(R.dimen.spacebar_vertical_correction);
  mIsAlphaKeyboard=xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black;
  mSpaceKeyIndex=indexOf(' ');
  initializeNumberHintResources(context);
}

Fixed version (ground truth):
public LatinKeyboard(Context context,int xmlLayoutResId,int mode){
  super(context,xmlLayoutResId,mode);
  final Resources res=context.getResources();
  mContext=context;
  mRes=res;
  mShiftLockIcon=res.getDrawable(R.drawable.sym_keyboard_shift_locked);
  mShiftLockPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
  mShiftLockPreviewIcon.setBounds(0,0,mShiftLockPreviewIcon.getIntrinsicWidth(),mShiftLockPreviewIcon.getIntrinsicHeight());
  mSpaceIcon=res.getDrawable(R.drawable.sym_keyboard_space);
  mSpaceAutoCompletionIndicator=res.getDrawable(R.drawable.sym_keyboard_space_led);
  mSpacePreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_space);
  mMicIcon=res.getDrawable(R.drawable.sym_keyboard_mic);
  mMicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_mic);
  setDefaultBounds(mMicPreviewIcon);
  mButtonArrowLeftIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
  mButtonArrowRightIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
  m123MicIcon=res.getDrawable(R.drawable.sym_keyboard_123_mic);
  m123MicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic);
  setDefaultBounds(m123MicPreviewIcon);
  sSpacebarVerticalCorrection=res.getDimensionPixelOffset(R.dimen.spacebar_vertical_correction);
  mIsAlphaKeyboard=xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black;
  mSpaceKeyIndex=indexOf(LatinIME.KEYCODE_SPACE);
  initializeNumberHintResources(context);
}
Program: 88276
Project: 88276
Buggy source:
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  if (oldKeyIndex != keyIndex && mShowPreview) {
    if (keyIndex == NOT_A_KEY) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(DELAY_AFTER_PREVIEW);
    }
 else     if (tracker != null) {
      mHandler.popupPreview(DELAY_BEFORE_PREVIEW,keyIndex,tracker);
    }
  }
}

Fixed version (ground truth):
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  final boolean isLanguageSwitchEnabled=(mKeyboard instanceof LatinKeyboard) && ((LatinKeyboard)mKeyboard).isLanguageSwitchEnabled();
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null) || tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex);
  if (oldKeyIndex != keyIndex && (mShowPreview || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) {
    if (keyIndex == NOT_A_KEY) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(DELAY_AFTER_PREVIEW);
    }
 else     if (tracker != null) {
      mHandler.popupPreview(DELAY_BEFORE_PREVIEW,keyIndex,tracker);
    }
  }
}
Program: 88277
Project: 88277
Buggy source:
void setKeyboardMode(int mode,int imeOptions,boolean enableVoice,boolean isSymbols){
  if (mInputView == null)   return;
  mMode=mode;
  mImeOptions=imeOptions;
  if (enableVoice != mHasVoice) {
    setVoiceMode(mHasVoice,mVoiceOnPrimary);
  }
  mIsSymbols=isSymbols;
  mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
  KeyboardId id=getKeyboardId(mode,imeOptions,isSymbols);
  LatinKeyboard keyboard=null;
  keyboard=getKeyboard(id);
  if (mode == MODE_PHONE) {
    mInputView.setPhoneKeyboard(keyboard);
    mInputView.setPreviewEnabled(false);
  }
  mCurrentId=id;
  mInputView.setKeyboard(keyboard);
  keyboard.setShifted(false);
  keyboard.setShiftLocked(keyboard.isShiftLocked());
  keyboard.setImeOptions(mInputMethodService.getResources(),mMode,imeOptions);
  keyboard.setColorOfSymbolIcons(mIsAutoCompletionActive,isBlackSym());
  updateSettingsKeyState(PreferenceManager.getDefaultSharedPreferences(mInputMethodService));
}

Fixed version (ground truth):
private void setKeyboardMode(int mode,int imeOptions,boolean enableVoice,boolean isSymbols){
  if (mInputView == null)   return;
  mMode=mode;
  mImeOptions=imeOptions;
  if (enableVoice != mHasVoice) {
    setVoiceMode(mHasVoice,mVoiceOnPrimary);
  }
  mIsSymbols=isSymbols;
  mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
  KeyboardId id=getKeyboardId(mode,imeOptions,isSymbols);
  LatinKeyboard keyboard=null;
  keyboard=getKeyboard(id);
  if (mode == MODE_PHONE) {
    mInputView.setPhoneKeyboard(keyboard);
  }
  mCurrentId=id;
  mInputView.setKeyboard(keyboard);
  keyboard.setShifted(false);
  keyboard.setShiftLocked(keyboard.isShiftLocked());
  keyboard.setImeOptions(mInputMethodService.getResources(),mMode,imeOptions);
  keyboard.setColorOfSymbolIcons(mIsAutoCompletionActive,isBlackSym());
  updateSettingsKeyState(PreferenceManager.getDefaultSharedPreferences(mInputMethodService));
}
Program: 88278
Project: 88278
Buggy source:
int getKeyboardMode(){
  return mMode;
}

Fixed version (ground truth):
public int getKeyboardMode(){
  return mMode;
}
Program: 88279
Project: 88279
Buggy source:
void setShifted(boolean shifted){
  if (mInputView != null) {
    mInputView.setShifted(shifted);
  }
}

Fixed version (ground truth):
public void setShifted(boolean shifted){
  if (mInputView != null) {
    mInputView.setShifted(shifted);
  }
}
Program: 88280
Project: 88280
Buggy source:
void setShiftLocked(boolean shiftLocked){
  if (mInputView != null) {
    mInputView.setShiftLocked(shiftLocked);
  }
}

Fixed version (ground truth):
public void setShiftLocked(boolean shiftLocked){
  if (mInputView != null) {
    mInputView.setShiftLocked(shiftLocked);
  }
}
Program: 88281
Project: 88281
Buggy source:
/** 
 * Updates state machine to figure out when to automatically switch back to alpha mode. Returns true if the keyboard needs to switch back 
 */
boolean onKey(int key){
switch (mSymbolsModeState) {
case SYMBOLS_MODE_STATE_BEGIN:
    if (key != LatinIME.KEYCODE_SPACE && key != LatinIME.KEYCODE_ENTER && key > 0) {
      mSymbolsModeState=SYMBOLS_MODE_STATE_SYMBOL;
    }
  break;
case SYMBOLS_MODE_STATE_SYMBOL:
if (key == LatinIME.KEYCODE_ENTER || key == LatinIME.KEYCODE_SPACE) return true;
break;
}
return false;
}

Fixed version (ground truth):
/** 
 * Updates state machine to figure out when to automatically switch back to alpha mode. Returns true if the keyboard needs to switch back 
 */
public boolean onKey(int key){
switch (mSymbolsModeState) {
case SYMBOLS_MODE_STATE_BEGIN:
    if (key != LatinIME.KEYCODE_SPACE && key != LatinIME.KEYCODE_ENTER && key > 0) {
      mSymbolsModeState=SYMBOLS_MODE_STATE_SYMBOL;
    }
  break;
case SYMBOLS_MODE_STATE_SYMBOL:
if (key == LatinIME.KEYCODE_ENTER || key == LatinIME.KEYCODE_SPACE) return true;
break;
}
return false;
}
Program: 88282
Project: 88282
Buggy source:
void toggleShift(){
  if (mCurrentId.equals(mSymbolsId)) {
    LatinKeyboard symbolsShiftedKeyboard=getKeyboard(mSymbolsShiftedId);
    mCurrentId=mSymbolsShiftedId;
    mInputView.setKeyboard(symbolsShiftedKeyboard);
    symbolsShiftedKeyboard.enableShiftLock();
    symbolsShiftedKeyboard.setShiftLocked(true);
    symbolsShiftedKeyboard.setImeOptions(mInputMethodService.getResources(),mMode,mImeOptions);
  }
 else   if (mCurrentId.equals(mSymbolsShiftedId)) {
    LatinKeyboard symbolsKeyboard=getKeyboard(mSymbolsId);
    mCurrentId=mSymbolsId;
    mInputView.setKeyboard(symbolsKeyboard);
    symbolsKeyboard.enableShiftLock();
    symbolsKeyboard.setShifted(false);
    symbolsKeyboard.setImeOptions(mInputMethodService.getResources(),mMode,mImeOptions);
  }
}

Fixed version (ground truth):
public void toggleShift(){
  if (mCurrentId.equals(mSymbolsId)) {
    LatinKeyboard symbolsShiftedKeyboard=getKeyboard(mSymbolsShiftedId);
    mCurrentId=mSymbolsShiftedId;
    mInputView.setKeyboard(symbolsShiftedKeyboard);
    symbolsShiftedKeyboard.enableShiftLock();
    symbolsShiftedKeyboard.setShiftLocked(true);
    symbolsShiftedKeyboard.setImeOptions(mInputMethodService.getResources(),mMode,mImeOptions);
  }
 else   if (mCurrentId.equals(mSymbolsShiftedId)) {
    LatinKeyboard symbolsKeyboard=getKeyboard(mSymbolsId);
    mCurrentId=mSymbolsId;
    mInputView.setKeyboard(symbolsKeyboard);
    symbolsKeyboard.enableShiftLock();
    symbolsKeyboard.setShifted(false);
    symbolsKeyboard.setImeOptions(mInputMethodService.getResources(),mMode,mImeOptions);
  }
}
Program: 88283
Project: 88283
Buggy source:
void toggleSymbols(){
  setKeyboardMode(mMode,mImeOptions,mHasVoice,!mIsSymbols);
  if (mIsSymbols && !mPreferSymbols) {
    mSymbolsModeState=SYMBOLS_MODE_STATE_BEGIN;
  }
 else {
    mSymbolsModeState=SYMBOLS_MODE_STATE_NONE;
  }
}

Fixed version (ground truth):
public void toggleSymbols(){
  setKeyboardMode(mMode,mImeOptions,mHasVoice,!mIsSymbols);
  if (mIsSymbols && !mPreferSymbols) {
    mSymbolsModeState=SYMBOLS_MODE_STATE_BEGIN;
  }
 else {
    mSymbolsModeState=SYMBOLS_MODE_STATE_NONE;
  }
}
Program: 88284
Project: 88284
Buggy source:
KeyboardSwitcher(LatinIME ims){
  mInputMethodService=ims;
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(ims);
  mLayoutId=Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT,DEFAULT_LAYOUT_ID));
  updateSettingsKeyState(prefs);
  prefs.registerOnSharedPreferenceChangeListener(this);
  mKeyboards=new HashMap<KeyboardId,SoftReference<LatinKeyboard>>();
  mSymbolsId=makeSymbolsId(false);
  mSymbolsShiftedId=makeSymbolsShiftedId(false);
}

Fixed version (ground truth):
public KeyboardSwitcher(LatinIME ims){
  mInputMethodService=ims;
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(ims);
  mLayoutId=Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT,DEFAULT_LAYOUT_ID));
  updateSettingsKeyState(prefs);
  prefs.registerOnSharedPreferenceChangeListener(this);
  mKeyboards=new HashMap<KeyboardId,SoftReference<LatinKeyboard>>();
  mSymbolsId=makeSymbolsId(false);
  mSymbolsShiftedId=makeSymbolsShiftedId(false);
}
Program: 88285
Project: 88285
Buggy source:
boolean isAlphabetMode(){
  if (mCurrentId == null) {
    return false;
  }
  int currentMode=mCurrentId.mKeyboardMode;
  for (  Integer mode : ALPHABET_MODES) {
    if (currentMode == mode) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean isAlphabetMode(){
  if (mCurrentId == null) {
    return false;
  }
  int currentMode=mCurrentId.mKeyboardMode;
  for (  Integer mode : ALPHABET_MODES) {
    if (currentMode == mode) {
      return true;
    }
  }
  return false;
}
Program: 88286
Project: 88286
Buggy source:
boolean hasVoiceButton(boolean isSymbols){
  return mHasVoice && (isSymbols != mVoiceOnPrimary);
}

Fixed version (ground truth):
private boolean hasVoiceButton(boolean isSymbols){
  return mHasVoice && (isSymbols != mVoiceOnPrimary);
}
Program: 88287
Project: 88287
Buggy source:
void setVoiceMode(boolean enableVoice,boolean voiceOnPrimary){
  if (enableVoice != mHasVoice || voiceOnPrimary != mVoiceOnPrimary) {
    mKeyboards.clear();
  }
  mHasVoice=enableVoice;
  mVoiceOnPrimary=voiceOnPrimary;
  setKeyboardMode(mMode,mImeOptions,mHasVoice,mIsSymbols);
}

Fixed version (ground truth):
public void setVoiceMode(boolean enableVoice,boolean voiceOnPrimary){
  if (enableVoice != mHasVoice || voiceOnPrimary != mVoiceOnPrimary) {
    mKeyboards.clear();
  }
  mHasVoice=enableVoice;
  mVoiceOnPrimary=voiceOnPrimary;
  setKeyboardMode(mMode,mImeOptions,mHasVoice,mIsSymbols);
}
Program: 88288
Project: 88288
Buggy source:
/** 
 * Sets the input locale, when there are multiple locales for input. If no locale switching is required, then the locale should be set to null.
 * @param locale the current input locale, or null for default locale with no locale button.
 */
void setLanguageSwitcher(LanguageSwitcher languageSwitcher){
  mLanguageSwitcher=languageSwitcher;
  mInputLocale=mLanguageSwitcher.getInputLocale();
}

Fixed version (ground truth):
/** 
 * Sets the input locale, when there are multiple locales for input. If no locale switching is required, then the locale should be set to null.
 * @param locale the current input locale, or null for default locale with no locale button.
 */
public void setLanguageSwitcher(LanguageSwitcher languageSwitcher){
  mLanguageSwitcher=languageSwitcher;
  mInputLocale=mLanguageSwitcher.getInputLocale();
}
Program: 88289
Project: 88289
Buggy source:
void makeKeyboards(boolean forceCreate){
  mSymbolsId=makeSymbolsId(mHasVoice && !mVoiceOnPrimary);
  mSymbolsShiftedId=makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary);
  if (forceCreate)   mKeyboards.clear();
  int displayWidth=mInputMethodService.getMaxWidth();
  if (displayWidth == mLastDisplayWidth)   return;
  mLastDisplayWidth=displayWidth;
  if (!forceCreate)   mKeyboards.clear();
}

Fixed version (ground truth):
public void makeKeyboards(boolean forceCreate){
  mSymbolsId=makeSymbolsId(mHasVoice && !mVoiceOnPrimary);
  mSymbolsShiftedId=makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary);
  if (forceCreate)   mKeyboards.clear();
  int displayWidth=mInputMethodService.getMaxWidth();
  if (displayWidth == mLastDisplayWidth)   return;
  mLastDisplayWidth=displayWidth;
  if (!forceCreate)   mKeyboards.clear();
}
Program: 88290
Project: 88290
Buggy source:
public LatinKeyboard(Context context,int xmlLayoutResId,int mode){
  super(context,xmlLayoutResId,mode);
  final Resources res=context.getResources();
  mContext=context;
  mRes=res;
  mShiftLockIcon=res.getDrawable(R.drawable.sym_keyboard_shift_locked);
  mShiftLockPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
  mShiftLockPreviewIcon.setBounds(0,0,mShiftLockPreviewIcon.getIntrinsicWidth(),mShiftLockPreviewIcon.getIntrinsicHeight());
  mSpaceIcon=res.getDrawable(R.drawable.sym_keyboard_space);
  mSpaceAutoCompletionIndicator=res.getDrawable(R.drawable.sym_keyboard_space_led);
  mSpacePreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_space);
  mMicIcon=res.getDrawable(R.drawable.sym_keyboard_mic);
  mMicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_mic);
  setDefaultBounds(mMicPreviewIcon);
  mButtonArrowLeftIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
  mButtonArrowRightIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
  m123MicIcon=res.getDrawable(R.drawable.sym_keyboard_123_mic);
  m123MicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic);
  setDefaultBounds(m123MicPreviewIcon);
  sSpacebarVerticalCorrection=res.getDimensionPixelOffset(R.dimen.spacebar_vertical_correction);
  mIsAlphaKeyboard=xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black;
  mSpaceKeyIndex=indexOf(' ');
  initializeNumberHintResources(context);
}

Fixed version (ground truth):
public LatinKeyboard(Context context,int xmlLayoutResId,int mode){
  super(context,xmlLayoutResId,mode);
  final Resources res=context.getResources();
  mContext=context;
  mRes=res;
  mShiftLockIcon=res.getDrawable(R.drawable.sym_keyboard_shift_locked);
  mShiftLockPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
  mShiftLockPreviewIcon.setBounds(0,0,mShiftLockPreviewIcon.getIntrinsicWidth(),mShiftLockPreviewIcon.getIntrinsicHeight());
  mSpaceIcon=res.getDrawable(R.drawable.sym_keyboard_space);
  mSpaceAutoCompletionIndicator=res.getDrawable(R.drawable.sym_keyboard_space_led);
  mSpacePreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_space);
  mMicIcon=res.getDrawable(R.drawable.sym_keyboard_mic);
  mMicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_mic);
  setDefaultBounds(mMicPreviewIcon);
  mButtonArrowLeftIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
  mButtonArrowRightIcon=res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
  m123MicIcon=res.getDrawable(R.drawable.sym_keyboard_123_mic);
  m123MicPreviewIcon=res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic);
  setDefaultBounds(m123MicPreviewIcon);
  sSpacebarVerticalCorrection=res.getDimensionPixelOffset(R.dimen.spacebar_vertical_correction);
  mIsAlphaKeyboard=xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black;
  mSpaceKeyIndex=indexOf(LatinIME.KEYCODE_SPACE);
  initializeNumberHintResources(context);
}
Program: 88291
Project: 88291
Buggy source:
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  if (oldKeyIndex != keyIndex && mShowPreview) {
    if (keyIndex == NOT_A_KEY) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(DELAY_AFTER_PREVIEW);
    }
 else     if (tracker != null) {
      mHandler.popupPreview(DELAY_BEFORE_PREVIEW,keyIndex,tracker);
    }
  }
}

Fixed version (ground truth):
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  final boolean isLanguageSwitchEnabled=(mKeyboard instanceof LatinKeyboard) && ((LatinKeyboard)mKeyboard).isLanguageSwitchEnabled();
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null) || tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex);
  if (oldKeyIndex != keyIndex && (mShowPreview || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) {
    if (keyIndex == NOT_A_KEY) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(DELAY_AFTER_PREVIEW);
    }
 else     if (tracker != null) {
      mHandler.popupPreview(DELAY_BEFORE_PREVIEW,keyIndex,tracker);
    }
  }
}
Program: 88292
Project: 88292
Buggy source:
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKey=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKey=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKey != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=closestKey;
  return closestKey;
}

Fixed version (ground truth):
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKeyIndex=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKeyIndex=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKeyIndex != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=keys[closestKeyIndex].codes[0];
  return closestKeyIndex;
}
Program: 88293
Project: 88293
Buggy source:
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKey=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKey=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKey != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=closestKey;
  return closestKey;
}

Fixed version (ground truth):
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKeyIndex=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKeyIndex=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKeyIndex != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=keys[closestKeyIndex].codes[0];
  return closestKeyIndex;
}
Program: 88294
Project: 88294
Buggy source:
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKey=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKey=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKey != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=closestKey;
  return closestKey;
}

Fixed version (ground truth):
@Override public int getKeyIndexAndNearbyCodes(int x,int y,int[] allKeys){
  final Key[] keys=getKeys();
  final int touchX=getTouchX(x);
  final int touchY=getTouchY(y);
  int closestKeyIndex=LatinKeyboardBaseView.NOT_A_KEY;
  int closestKeyDist=(y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
  final int keyCount=keys.length;
  for (int i=0; i < keyCount; i++) {
    final Key key=keys[i];
    int dist=key.squaredDistanceFrom(touchX,touchY);
    if (dist < closestKeyDist) {
      closestKeyIndex=i;
      closestKeyDist=dist;
    }
  }
  if (allKeys != null && closestKeyIndex != LatinKeyboardBaseView.NOT_A_KEY)   allKeys[0]=keys[closestKeyIndex].codes[0];
  return closestKeyIndex;
}
Program: 88301
Project: 88301
Buggy source:
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  return true;
}

Fixed version (ground truth):
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  postUpdateSuggestions();
  return true;
}
Program: 88305
Project: 88305
Buggy source:
void setKeyboardMode(int mode,int imeOptions,boolean enableVoice,boolean isSymbols){
  if (mInputView == null)   return;
  mMode=mode;
  mImeOptions=imeOptions;
  if (enableVoice != mHasVoice) {
    setVoiceMode(mHasVoice,mVoiceOnPrimary);
  }
  mIsSymbols=isSymbols;
  mInputView.setPreviewEnabled(true);
  KeyboardId id=getKeyboardId(mode,imeOptions,isSymbols);
  LatinKeyboard keyboard=null;
  keyboard=getKeyboard(id);
  if (mode == MODE_PHONE) {
    mInputView.setPhoneKeyboard(keyboard);
    mInputView.setPreviewEnabled(false);
  }
  mCurrentId=id;
  mInputView.setKeyboard(keyboard);
  keyboard.setShifted(false);
  keyboard.setShiftLocked(keyboard.isShiftLocked());
  keyboard.setImeOptions(mContext.getResources(),mMode,imeOptions);
  keyboard.setBlackFlag(isBlackSym());
}

Fixed version (ground truth):
void setKeyboardMode(int mode,int imeOptions,boolean enableVoice,boolean isSymbols){
  if (mInputView == null)   return;
  mMode=mode;
  mImeOptions=imeOptions;
  if (enableVoice != mHasVoice) {
    setVoiceMode(mHasVoice,mVoiceOnPrimary);
  }
  mIsSymbols=isSymbols;
  mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
  KeyboardId id=getKeyboardId(mode,imeOptions,isSymbols);
  LatinKeyboard keyboard=null;
  keyboard=getKeyboard(id);
  if (mode == MODE_PHONE) {
    mInputView.setPhoneKeyboard(keyboard);
    mInputView.setPreviewEnabled(false);
  }
  mCurrentId=id;
  mInputView.setKeyboard(keyboard);
  keyboard.setShifted(false);
  keyboard.setShiftLocked(keyboard.isShiftLocked());
  keyboard.setImeOptions(mContext.getResources(),mMode,imeOptions);
  keyboard.setBlackFlag(isBlackSym());
}
Program: 88308
Project: 88308
Buggy source:
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  return true;
}

Fixed version (ground truth):
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  postUpdateSuggestions();
  return true;
}
Program: 88311
Project: 88311
Buggy source:
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  return true;
}

Fixed version (ground truth):
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  postUpdateSuggestions();
  return true;
}
Program: 88314
Project: 88314
Buggy source:
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  return true;
}

Fixed version (ground truth):
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  postUpdateSuggestions();
  return true;
}
Program: 88317
Project: 88317
Buggy source:
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  return true;
}

Fixed version (ground truth):
public boolean addWordToDictionary(String word){
  mUserDictionary.addWord(word,128);
  postUpdateSuggestions();
  return true;
}
Program: 88320
Project: 88320
Buggy source:
private void underlineWord(CharSequence word,int left,int right){
  InputConnection ic=getCurrentInputConnection();
  if (ic == null)   return;
  ic.deleteSurroundingText(left,right);
  ic.setComposingText(word,1);
  ic.setSelection(mLastSelectionStart,mLastSelectionStart);
}

Fixed version (ground truth):
private void underlineWord(CharSequence word,int left,int right){
  InputConnection ic=getCurrentInputConnection();
  if (ic == null)   return;
  ic.finishComposingText();
  ic.deleteSurroundingText(left,right);
  ic.setComposingText(word,1);
  ic.setSelection(mLastSelectionStart,mLastSelectionStart);
}
Program: 88321
Project: 88321
Buggy source:
private void pickSuggestion(CharSequence suggestion){
  if (mCapsLock) {
    suggestion=suggestion.toString().toUpperCase();
  }
 else   if (preferCapitalization() || (mKeyboardSwitcher.isAlphabetMode() && mInputView.isShifted())) {
    suggestion=suggestion.toString().toUpperCase().charAt(0) + suggestion.subSequence(1,suggestion.length()).toString();
  }
  InputConnection ic=getCurrentInputConnection();
  if (ic != null) {
    rememberReplacedWord(suggestion);
    if (mSuggestionShouldReplaceCurrentWord) {
      EditingUtil.deleteWordAtCursor(ic,getWordSeparators());
    }
    if (!VoiceInput.DELETE_SYMBOL.equals(suggestion)) {
      ic.commitText(suggestion,1);
    }
  }
  saveWordInHistory(suggestion);
  mPredicting=false;
  mCommittedLength=suggestion.length();
  ((LatinKeyboard)mInputView.getKeyboard()).setPreferredLetters(null);
  setNextSuggestions();
  updateShiftKeyState(getCurrentInputEditorInfo());
}

Fixed version (ground truth):
private void pickSuggestion(CharSequence suggestion){
  if (mCapsLock) {
    suggestion=suggestion.toString().toUpperCase();
  }
 else   if (preferCapitalization() || (mKeyboardSwitcher.isAlphabetMode() && mInputView.isShifted())) {
    suggestion=suggestion.toString().toUpperCase().charAt(0) + suggestion.subSequence(1,suggestion.length()).toString();
  }
  InputConnection ic=getCurrentInputConnection();
  if (ic != null) {
    rememberReplacedWord(suggestion);
    if (!VoiceInput.DELETE_SYMBOL.equals(suggestion)) {
      ic.commitText(suggestion,1);
    }
  }
  saveWordInHistory(suggestion);
  mPredicting=false;
  mCommittedLength=suggestion.length();
  ((LatinKeyboard)mInputView.getKeyboard()).setPreferredLetters(null);
  setNextSuggestions();
  updateShiftKeyState(getCurrentInputEditorInfo());
}
Program: 88322
Project: 88322
Buggy source:
private void saveWordInHistory(CharSequence result){
  if (mWord.size() <= 1) {
    mWord.reset();
    return;
  }
  TypedWordAlternatives entry=new TypedWordAlternatives(result,mWord);
  mWord=new WordComposer(mWord);
  mWordHistory.add(entry);
}

Fixed version (ground truth):
private void saveWordInHistory(CharSequence result){
  if (mWord.size() <= 1) {
    mWord.reset();
    return;
  }
  final String resultCopy=result.toString();
  TypedWordAlternatives entry=new TypedWordAlternatives(resultCopy,new WordComposer(mWord));
  mWordHistory.add(entry);
}
Program: 88323
Project: 88323
Buggy source:
private void handleBackspace(){
  if (VOICE_INSTALLED && mVoiceInputHighlighted) {
    mVoiceInput.incrementTextModificationDeleteCount(mVoiceResults.candidates.get(0).toString().length());
    revertVoiceInput();
    return;
  }
  boolean deleteChar=false;
  InputConnection ic=getCurrentInputConnection();
  if (ic == null)   return;
  if (mAfterVoiceInput) {
    if (mVoiceInput.getCursorPos() > 0) {
      int deleteLen=mVoiceInput.getSelectionSpan() > 0 ? mVoiceInput.getSelectionSpan() : 1;
      mVoiceInput.incrementTextModificationDeleteCount(deleteLen);
    }
  }
  if (mPredicting) {
    final int length=mComposing.length();
    if (length > 0) {
      mComposing.delete(length - 1,length);
      mWord.deleteLast();
      ic.setComposingText(mComposing,1);
      if (mComposing.length() == 0) {
        mPredicting=false;
      }
      postUpdateSuggestions();
    }
 else {
      ic.deleteSurroundingText(1,0);
    }
  }
 else {
    deleteChar=true;
  }
  postUpdateShiftKeyState();
  TextEntryState.backspace();
  if (TextEntryState.getState() == TextEntryState.STATE_UNDO_COMMIT) {
    revertLastWord(deleteChar);
    return;
  }
 else   if (mEnteredText != null && sameAsTextBeforeCursor(ic,mEnteredText)) {
    ic.deleteSurroundingText(mEnteredText.length(),0);
  }
 else   if (deleteChar) {
    sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    if (mDeleteCount > DELETE_ACCELERATE_AT) {
      sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    }
  }
  mJustRevertedSeparator=null;
}

Fixed version (ground truth):
private void handleBackspace(){
  if (VOICE_INSTALLED && mVoiceInputHighlighted) {
    mVoiceInput.incrementTextModificationDeleteCount(mVoiceResults.candidates.get(0).toString().length());
    revertVoiceInput();
    return;
  }
  boolean deleteChar=false;
  InputConnection ic=getCurrentInputConnection();
  if (ic == null)   return;
  ic.beginBatchEdit();
  if (mAfterVoiceInput) {
    if (mVoiceInput.getCursorPos() > 0) {
      int deleteLen=mVoiceInput.getSelectionSpan() > 0 ? mVoiceInput.getSelectionSpan() : 1;
      mVoiceInput.incrementTextModificationDeleteCount(deleteLen);
    }
  }
  if (mPredicting) {
    final int length=mComposing.length();
    if (length > 0) {
      mComposing.delete(length - 1,length);
      mWord.deleteLast();
      ic.setComposingText(mComposing,1);
      if (mComposing.length() == 0) {
        mPredicting=false;
      }
      postUpdateSuggestions();
    }
 else {
      ic.deleteSurroundingText(1,0);
    }
  }
 else {
    deleteChar=true;
  }
  postUpdateShiftKeyState();
  TextEntryState.backspace();
  if (TextEntryState.getState() == TextEntryState.STATE_UNDO_COMMIT) {
    revertLastWord(deleteChar);
    ic.endBatchEdit();
    return;
  }
 else   if (mEnteredText != null && sameAsTextBeforeCursor(ic,mEnteredText)) {
    ic.deleteSurroundingText(mEnteredText.length(),0);
  }
 else   if (deleteChar) {
    sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    if (mDeleteCount > DELETE_ACCELERATE_AT) {
      sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    }
  }
  mJustRevertedSeparator=null;
  ic.endBatchEdit();
}
Program: 88324
Project: 88324
Buggy source:
private void rememberReplacedWord(CharSequence suggestion){
  if (mShowingVoiceSuggestions) {
    InputConnection ic=getCurrentInputConnection();
    EditingUtil.Range range=new EditingUtil.Range();
    String wordToBeReplaced=EditingUtil.getWordAtCursor(getCurrentInputConnection(),mWordSeparators,range).trim();
    if (!mWordToSuggestions.containsKey(wordToBeReplaced)) {
      wordToBeReplaced=wordToBeReplaced.toLowerCase();
    }
    if (mWordToSuggestions.containsKey(wordToBeReplaced)) {
      List<CharSequence> suggestions=mWordToSuggestions.get(wordToBeReplaced);
      if (suggestions.contains(suggestion)) {
        suggestions.remove(suggestion);
      }
      suggestions.add(wordToBeReplaced);
      mWordToSuggestions.remove(wordToBeReplaced);
      mWordToSuggestions.put(suggestion.toString(),suggestions);
    }
  }
}

Fixed version (ground truth):
private void rememberReplacedWord(CharSequence suggestion){
  if (mShowingVoiceSuggestions) {
    InputConnection ic=getCurrentInputConnection();
    EditingUtil.Range range=new EditingUtil.Range();
    String wordToBeReplaced=EditingUtil.getWordAtCursor(getCurrentInputConnection(),mWordSeparators,range);
    if (!mWordToSuggestions.containsKey(wordToBeReplaced)) {
      wordToBeReplaced=wordToBeReplaced.toLowerCase();
    }
    if (mWordToSuggestions.containsKey(wordToBeReplaced)) {
      List<CharSequence> suggestions=mWordToSuggestions.get(wordToBeReplaced);
      if (suggestions.contains(suggestion)) {
        suggestions.remove(suggestion);
      }
      suggestions.add(wordToBeReplaced);
      mWordToSuggestions.remove(wordToBeReplaced);
      mWordToSuggestions.put(suggestion.toString(),suggestions);
    }
  }
}
Program: 88328
Project: 88328
Buggy source:
public void revertLastWord(boolean deleteChar){
  final int length=mComposing.length();
  if (!mPredicting && length > 0) {
    final InputConnection ic=getCurrentInputConnection();
    mPredicting=true;
    ic.beginBatchEdit();
    mJustRevertedSeparator=ic.getTextBeforeCursor(1,0);
    if (deleteChar)     ic.deleteSurroundingText(1,0);
    int toDelete=mCommittedLength;
    CharSequence toTheLeft=ic.getTextBeforeCursor(mCommittedLength,0);
    if (toTheLeft != null && toTheLeft.length() > 0 && isWordSeparator(toTheLeft.charAt(0))) {
      toDelete--;
    }
    ic.deleteSurroundingText(toDelete,0);
    ic.setComposingText(mComposing,1);
    TextEntryState.backspace();
    ic.endBatchEdit();
    postUpdateSuggestions();
  }
 else {
    sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    mJustRevertedSeparator=null;
  }
}

Fixed version (ground truth):
public void revertLastWord(boolean deleteChar){
  final int length=mComposing.length();
  if (!mPredicting && length > 0) {
    final InputConnection ic=getCurrentInputConnection();
    mPredicting=true;
    mJustRevertedSeparator=ic.getTextBeforeCursor(1,0);
    if (deleteChar)     ic.deleteSurroundingText(1,0);
    int toDelete=mCommittedLength;
    CharSequence toTheLeft=ic.getTextBeforeCursor(mCommittedLength,0);
    if (toTheLeft != null && toTheLeft.length() > 0 && isWordSeparator(toTheLeft.charAt(0))) {
      toDelete--;
    }
    ic.deleteSurroundingText(toDelete,0);
    ic.setComposingText(mComposing,1);
    TextEntryState.backspace();
    postUpdateSuggestions();
  }
 else {
    sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
    mJustRevertedSeparator=null;
  }
}
Program: 88329
Project: 88329
Buggy source:
WordComposer(WordComposer copy){
  mCodes=(ArrayList<int[]>)copy.mCodes.clone();
  mPreferredWord=copy.mPreferredWord;
  mTypedWord=new StringBuilder(copy.mTypedWord);
  mCapsCount=copy.mCapsCount;
  mAutoCapitalized=copy.mAutoCapitalized;
}

Fixed version (ground truth):
WordComposer(WordComposer copy){
  mCodes=(ArrayList<int[]>)copy.mCodes.clone();
  mPreferredWord=copy.mPreferredWord;
  mTypedWord=new StringBuilder(copy.mTypedWord);
  mCapsCount=copy.mCapsCount;
  mAutoCapitalized=copy.mAutoCapitalized;
  mIsCapitalized=copy.mIsCapitalized;
}
Program: 88330
Project: 88330
Buggy source:
public static void logOnAutoSuggestion(String before,String after){
  if (sLogEnabled) {
    if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
      return;
    }
    int dicId=sSuggestDicMap.get(after);
    sLatinImeLogger.mAutoSuggestCountPerDic[dicId]++;
    sSuggestDicMap.clear();
    if (dicId != Suggest.DIC_MAIN) {
      if (sDBG) {
        Log.d(TAG,"String_Node_Str");
      }
      return;
    }
    if (before.equals(after)) {
      before="String_Node_Str";
      after="String_Node_Str";
    }
    sLastAutoSuggestSeparator=String.valueOf(sLatinImeLogger.mRingCharBuffer.getLastChar());
    String[] strings=new String[]{before,after,sLastAutoSuggestSeparator};
synchronized (LatinImeLogger.class) {
      sLastAutoSuggestBefore=before;
      sLastAutoSuggestAfter=after;
    }
    sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTION,strings);
  }
}

Fixed version (ground truth):
public static void logOnAutoSuggestion(String before,String after){
  if (sLogEnabled) {
    if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
    }
 else {
      String separator=String.valueOf(sLatinImeLogger.mRingCharBuffer.getLastChar());
      sLastAutoSuggestDicTypeId=sSuggestDicMap.get(after);
      sLatinImeLogger.mAutoSuggestCountPerDic[sLastAutoSuggestDicTypeId]++;
      if (sLastAutoSuggestDicTypeId != Suggest.DIC_MAIN) {
        if (sDBG) {
          Log.d(TAG,"String_Node_Str");
        }
        before="String_Node_Str";
        after="String_Node_Str";
      }
{
        if (before.equals(after)) {
          before="String_Node_Str";
          after="String_Node_Str";
        }
        String[] strings=new String[]{before,after,separator};
        sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTION,strings);
      }
synchronized (LatinImeLogger.class) {
        sLastAutoSuggestBefore=before;
        sLastAutoSuggestAfter=after;
        sLastAutoSuggestSeparator=separator;
      }
    }
    sSuggestDicMap.clear();
  }
}
Program: 88331
Project: 88331
Buggy source:
public static void logOnAutoSuggestionCanceled(){
  if (sLogEnabled) {
    sLatinImeLogger.mAutoCancelledCount++;
    if (sLastAutoSuggestBefore != null && sLastAutoSuggestAfter != null) {
      String[] strings=new String[]{sLastAutoSuggestBefore,sLastAutoSuggestAfter,sLastAutoSuggestSeparator};
      sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTIONCANCELLED,strings);
    }
synchronized (LatinImeLogger.class) {
      sLastAutoSuggestBefore="String_Node_Str";
      sLastAutoSuggestAfter="String_Node_Str";
      sLastAutoSuggestSeparator="String_Node_Str";
    }
  }
}

Fixed version (ground truth):
public static void logOnAutoSuggestionCanceled(){
  if (sLogEnabled) {
    sLatinImeLogger.mAutoCancelledCountPerDic[sLastAutoSuggestDicTypeId]++;
    if (sLastAutoSuggestBefore != null && sLastAutoSuggestAfter != null) {
      String[] strings=new String[]{sLastAutoSuggestBefore,sLastAutoSuggestAfter,sLastAutoSuggestSeparator};
      sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTIONCANCELLED,strings);
    }
synchronized (LatinImeLogger.class) {
      sLastAutoSuggestBefore="String_Node_Str";
      sLastAutoSuggestAfter="String_Node_Str";
      sLastAutoSuggestSeparator="String_Node_Str";
    }
  }
}
Program: 88332
Project: 88332
Buggy source:
private void initInternal(Context context){
  mContext=context;
  mDropBox=(DropBoxManager)mContext.getSystemService(Context.DROPBOX_SERVICE);
  mLastTimeSend=System.currentTimeMillis();
  mLastTimeActive=mLastTimeSend;
  mLastTimeCountEntry=mLastTimeSend;
  mDeleteCount=0;
  mInputCount=0;
  mWordCount=0;
  mActualCharCount=0;
  Arrays.fill(mAutoSuggestCountPerDic,0);
  Arrays.fill(mManualSuggestCountPerDic,0);
  mAutoCancelledCount=0;
  mLogBuffer=new ArrayList<LogEntry>();
  mPrivacyLogBuffer=new ArrayList<LogEntry>();
  mRingCharBuffer=new RingCharBuffer(context);
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  sLogEnabled=prefs.getBoolean(PREF_ENABLE_LOG,DEFAULT_LOG_ENABLED);
  mThemeId=prefs.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,KeyboardSwitcher.DEFAULT_LAYOUT_ID);
  sLOGPRINT=prefs.getBoolean(PREF_DEBUG_MODE,sLOGPRINT);
  sDBG=sLOGPRINT;
  prefs.registerOnSharedPreferenceChangeListener(this);
}

Fixed version (ground truth):
private void initInternal(Context context){
  mContext=context;
  mDropBox=(DropBoxManager)mContext.getSystemService(Context.DROPBOX_SERVICE);
  mLastTimeSend=System.currentTimeMillis();
  mLastTimeActive=mLastTimeSend;
  mLastTimeCountEntry=mLastTimeSend;
  mDeleteCount=0;
  mInputCount=0;
  mWordCount=0;
  mActualCharCount=0;
  Arrays.fill(mAutoSuggestCountPerDic,0);
  Arrays.fill(mManualSuggestCountPerDic,0);
  Arrays.fill(mAutoCancelledCountPerDic,0);
  mLogBuffer=new ArrayList<LogEntry>();
  mPrivacyLogBuffer=new ArrayList<LogEntry>();
  mRingCharBuffer=new RingCharBuffer(context);
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  sLogEnabled=prefs.getBoolean(PREF_ENABLE_LOG,DEFAULT_LOG_ENABLED);
  mThemeId=prefs.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,KeyboardSwitcher.DEFAULT_LAYOUT_ID);
  sLOGPRINT=prefs.getBoolean(PREF_DEBUG_MODE,sLOGPRINT);
  sDBG=sLOGPRINT;
  prefs.registerOnSharedPreferenceChangeListener(this);
}
Program: 88333
Project: 88333
Buggy source:
private void addSuggestionCountEntry(long time){
  if (sLOGPRINT) {
    Log.d(TAG,"String_Node_Str");
  }
  String[] s=new String[mAutoSuggestCountPerDic.length];
  for (int i=0; i < s.length; ++i) {
    s[i]=String.valueOf(mAutoSuggestCountPerDic[i]);
  }
  mLogBuffer.add(new LogEntry(time,ID_AUTOSUGGESTIONCOUNT,s));
  mLogBuffer.add(new LogEntry(time,ID_AUTOSUGGESTIONCANCELLEDCOUNT,new String[]{String.valueOf(mAutoCancelledCount)}));
  s=new String[mManualSuggestCountPerDic.length];
  for (int i=0; i < s.length; ++i) {
    s[i]=String.valueOf(mManualSuggestCountPerDic[i]);
  }
  mLogBuffer.add(new LogEntry(time,ID_MANUALSUGGESTIONCOUNT,s));
  Arrays.fill(mAutoSuggestCountPerDic,0);
  Arrays.fill(mManualSuggestCountPerDic,0);
  mAutoCancelledCount=0;
}

Fixed version (ground truth):
private void addSuggestionCountEntry(long time){
  if (sLOGPRINT) {
    Log.d(TAG,"String_Node_Str");
  }
  String[] s=new String[mAutoSuggestCountPerDic.length];
  for (int i=0; i < s.length; ++i) {
    s[i]=String.valueOf(mAutoSuggestCountPerDic[i]);
  }
  mLogBuffer.add(new LogEntry(time,ID_AUTOSUGGESTIONCOUNT,s));
  s=new String[mAutoCancelledCountPerDic.length];
  for (int i=0; i < s.length; ++i) {
    s[i]=String.valueOf(mAutoCancelledCountPerDic[i]);
  }
  mLogBuffer.add(new LogEntry(time,ID_AUTOSUGGESTIONCANCELLEDCOUNT,s));
  s=new String[mManualSuggestCountPerDic.length];
  for (int i=0; i < s.length; ++i) {
    s[i]=String.valueOf(mManualSuggestCountPerDic[i]);
  }
  mLogBuffer.add(new LogEntry(time,ID_MANUALSUGGESTIONCOUNT,s));
  Arrays.fill(mAutoSuggestCountPerDic,0);
  Arrays.fill(mManualSuggestCountPerDic,0);
  Arrays.fill(mAutoCancelledCountPerDic,0);
}
Program: 88334
Project: 88334
Buggy source:
public static void logOnManualSuggestion(String before,String after,int position,List<CharSequence> suggestions){
  if (sLogEnabled) {
    if (before.length() == 0 && after.length() == 1) {
      sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION,new String[]{before,after,String.valueOf(position),"String_Node_Str"});
    }
 else     if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
    }
 else {
      int dicTypeId=sSuggestDicMap.get(after);
      sLatinImeLogger.mManualSuggestCountPerDic[dicTypeId]++;
      if (dicTypeId != Suggest.DIC_MAIN) {
        if (sDBG) {
          Log.d(TAG,"String_Node_Str");
        }
      }
 else {
        if (before.equals(after)) {
          before="String_Node_Str";
          after="String_Node_Str";
        }
        String[] strings=new String[3 + suggestions.size()];
        strings[0]=before;
        strings[1]=after;
        strings[2]=String.valueOf(position);
        for (int i=0; i < suggestions.size(); ++i) {
          String s=suggestions.get(i).toString();
          strings[i + 3]=sSuggestDicMap.containsKey(s) ? s : "String_Node_Str";
        }
        sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION,strings);
      }
    }
    sSuggestDicMap.clear();
  }
}

Fixed version (ground truth):
public static void logOnManualSuggestion(String before,String after,int position,List<CharSequence> suggestions){
  if (sLogEnabled) {
    if (before.length() == 0 && after.length() == 1) {
      sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION,new String[]{before,after,String.valueOf(position),"String_Node_Str"});
    }
 else     if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
    }
 else {
      int dicTypeId=sSuggestDicMap.get(after);
      sLatinImeLogger.mManualSuggestCountPerDic[dicTypeId]++;
      if (dicTypeId != Suggest.DIC_MAIN) {
        if (sDBG) {
          Log.d(TAG,"String_Node_Str");
        }
        before="String_Node_Str";
        after="String_Node_Str";
      }
{
        if (before.equals(after)) {
          before="String_Node_Str";
          after="String_Node_Str";
        }
        String[] strings=new String[3 + suggestions.size()];
        strings[0]=before;
        strings[1]=after;
        strings[2]=String.valueOf(position);
        for (int i=0; i < suggestions.size(); ++i) {
          String s=suggestions.get(i).toString();
          strings[i + 3]=sSuggestDicMap.containsKey(s) ? s : "String_Node_Str";
        }
        sLatinImeLogger.sendLogToDropBox(ID_MANUALSUGGESTION,strings);
      }
    }
    sSuggestDicMap.clear();
  }
}
Program: 88335
Project: 88335
Buggy source:
public static void logOnAutoSuggestion(String before,String after){
  if (sLogEnabled) {
    if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
      return;
    }
    int dicId=sSuggestDicMap.get(after);
    sLatinImeLogger.mAutoSuggestCountPerDic[dicId]++;
    sSuggestDicMap.clear();
    if (dicId != Suggest.DIC_MAIN) {
      if (sDBG) {
        Log.d(TAG,"String_Node_Str");
      }
      return;
    }
    if (before.equals(after)) {
      before="String_Node_Str";
      after="String_Node_Str";
    }
    sLastAutoSuggestSeparator=String.valueOf(sLatinImeLogger.mRingCharBuffer.getLastChar());
    String[] strings=new String[]{before,after,sLastAutoSuggestSeparator};
synchronized (LatinImeLogger.class) {
      sLastAutoSuggestBefore=before;
      sLastAutoSuggestAfter=after;
    }
    sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTION,strings);
  }
}

Fixed version (ground truth):
public static void logOnAutoSuggestion(String before,String after){
  if (sLogEnabled) {
    if (!sSuggestDicMap.containsKey(after)) {
      if (sDBG) {
        Log.e(TAG,"String_Node_Str");
      }
    }
 else {
      String separator=String.valueOf(sLatinImeLogger.mRingCharBuffer.getLastChar());
      sLastAutoSuggestDicTypeId=sSuggestDicMap.get(after);
      sLatinImeLogger.mAutoSuggestCountPerDic[sLastAutoSuggestDicTypeId]++;
      if (sLastAutoSuggestDicTypeId != Suggest.DIC_MAIN) {
        if (sDBG) {
          Log.d(TAG,"String_Node_Str");
        }
        before="String_Node_Str";
        after="String_Node_Str";
      }
{
        if (before.equals(after)) {
          before="String_Node_Str";
          after="String_Node_Str";
        }
        String[] strings=new String[]{before,after,separator};
        sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTION,strings);
      }
synchronized (LatinImeLogger.class) {
        sLastAutoSuggestBefore=before;
        sLastAutoSuggestAfter=after;
        sLastAutoSuggestSeparator=separator;
      }
    }
    sSuggestDicMap.clear();
  }
}