nus-yam/ex-repair huggingface dataset:
Program: 87415
Project: 87415
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  mEditText=new MyEditText(getContext());
  final int inputType=InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
  mEditText.setInputType(inputType);
  mEditText.setEnabled(true);
  setupService();
  mLatinIME=getService();
  mPreviousDebugSetting=setDebugMode(true);
  mPreviousBigramPredictionSettings=setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,true,true);
  mPreviousAutoCorrectSetting=setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD,DEFAULT_AUTO_CORRECTION_THRESHOLD,DEFAULT_AUTO_CORRECTION_THRESHOLD);
  mLatinIME.onCreate();
  EditorInfo ei=new EditorInfo();
  final InputConnection ic=mEditText.onCreateInputConnection(ei);
  final LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  final ViewGroup vg=new FrameLayout(getContext());
  mInputView=inflater.inflate(R.layout.input_view,vg);
  ei=enrichEditorInfo(ei);
  mLatinIME.onCreateInputMethodInterface().startInput(ic,ei);
  mLatinIME.setInputView(mInputView);
  mLatinIME.onBindInput();
  mLatinIME.onCreateInputView();
  mLatinIME.onStartInputView(ei,false);
  mInputConnection=ic;
  changeLanguage("String_Node_Str");
  sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
  runMessages();
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  mEditText=new MyEditText(getContext());
  final int inputType=InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
  mEditText.setInputType(inputType);
  mEditText.setEnabled(true);
  setupService();
  mLatinIME=getService();
  setDebugMode(true);
  mPreviousBigramPredictionSettings=setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,true,true);
  mPreviousAutoCorrectSetting=setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD,DEFAULT_AUTO_CORRECTION_THRESHOLD,DEFAULT_AUTO_CORRECTION_THRESHOLD);
  mLatinIME.onCreate();
  EditorInfo ei=new EditorInfo();
  final InputConnection ic=mEditText.onCreateInputConnection(ei);
  final LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  final ViewGroup vg=new FrameLayout(getContext());
  mInputView=inflater.inflate(R.layout.input_view,vg);
  ei=enrichEditorInfo(ei);
  mLatinIME.onCreateInputMethodInterface().startInput(ic,ei);
  mLatinIME.setInputView(mInputView);
  mLatinIME.onBindInput();
  mLatinIME.onCreateInputView();
  mLatinIME.onStartInputView(ei,false);
  mInputConnection=ic;
  changeLanguage("String_Node_Str");
  sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
  runMessages();
}
Program: 87416
Project: 87416
Buggy source:
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo){
  mEnteredText=null;
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
}

Fixed version (ground truth):
/** 
 * Initializes the input logic for input in an editor. Call this when input starts or restarts in some editor (typically, in onStartInputView). If the input is starting in the same field as before, set `restarting' to true. This allows the input logic to reset only necessary stuff and save performance. Also, when restarting some things must not be done (for example, the keyboard should not be reset to the alphabetic layout), so do not send false to this just in case.
 * @param restarting whether input is starting in the same field as before. Unused for now.
 * @param editorInfo the editorInfo associated with the editor.
 */
public void startInput(final boolean restarting,final EditorInfo editorInfo){
  mEnteredText=null;
  resetComposingState(true);
  mDeleteCount=0;
  mSpaceState=SpaceState.NONE;
  mRecapitalizeStatus.deactivate();
  mCurrentlyPressedHardwareKeys.clear();
  mSuggestedWords=SuggestedWords.EMPTY;
  mConnection.tryFixLyingCursorPosition();
  cancelDoubleSpacePeriodCountdown();
  mInputLogicHandler.destroy();
  mInputLogicHandler=new InputLogicHandler(mLatinIME,this);
}
Program: 87417
Project: 87417
Buggy source:
/** 
 * Create an event interpreter according to a specification. The specification contains information about what to do with events. Typically, it will contain information about the type of keyboards - for example, if hardware keyboard(s) is/are attached, their type will be included here so that the decoder knows what to do with each keypress (a 10-key keyboard is not handled like a qwerty-ish keyboard). It also contains information for combining characters. For example, if the input language is Japanese, the specification will typically request kana conversion. Also note that the specification can be null. This means that we need to create a default interpreter that does no specific combining, and assumes the most common cases.
 * @param specification the specification for event interpretation. null for default.
 * @param latinIme a reference to the ime.
 */
public EventInterpreter(final EventDecoderSpec specification,final LatinIME latinIme){
  mDecoderSpec=null != specification ? specification : new EventDecoderSpec();
  mHardwareEventDecoders=new SparseArray<HardwareEventDecoder>(1);
  mSoftwareEventDecoder=new SoftwareKeyboardEventDecoder();
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
  mLatinIme=latinIme;
}

Fixed version (ground truth):
/** 
 * Create an event interpreter according to a specification. The specification contains information about what to do with events. Typically, it will contain information about the type of keyboards - for example, if hardware keyboard(s) is/are attached, their type will be included here so that the decoder knows what to do with each keypress (a 10-key keyboard is not handled like a qwerty-ish keyboard). It also contains information for combining characters. For example, if the input language is Japanese, the specification will typically request kana conversion. Also note that the specification can be null. This means that we need to create a default interpreter that does no specific combining, and assumes the most common cases.
 * @param specification the specification for event interpretation. null for default.
 */
public EventInterpreter(final EventDecoderSpec specification){
  mDecoderSpec=null != specification ? specification : new EventDecoderSpec();
  mCombiners=CollectionUtils.newArrayList();
  mCombiners.add(new DeadKeyCombiner());
}
Program: 87418
Project: 87418
Buggy source:
@Override public boolean onKeyDown(final int keyCode,final KeyEvent event){
  if (!ProductionFlag.IS_HARDWARE_KEYBOARD_SUPPORTED)   return super.onKeyDown(keyCode,event);
  if (mInputLogic.mEventInterpreter.onHardwareKeyEvent(event)) {
    final long keyIdentifier=event.getDeviceId() << 32 + event.getKeyCode();
    mInputLogic.mCurrentlyPressedHardwareKeys.add(keyIdentifier);
    return true;
  }
  return super.onKeyDown(keyCode,event);
}

Fixed version (ground truth):
@Override public boolean onKeyDown(final int keyCode,final KeyEvent keyEvent){
  if (!ProductionFlag.IS_HARDWARE_KEYBOARD_SUPPORTED) {
    return super.onKeyDown(keyCode,keyEvent);
  }
  final Event event=getHardwareKeyEventDecoder(keyEvent.getDeviceId()).decodeHardwareKey(keyEvent);
  if (event.isHandled()) {
    mInputLogic.onCodeInput(mSettings.getCurrent(),event,mKeyboardSwitcher.getKeyboardShiftMode(),mHandler);
    return true;
  }
  return super.onKeyDown(keyCode,keyEvent);
}
Program: 87419
Project: 87419
Buggy source:
public InputLogic(final LatinIME latinIME,final SuggestionStripViewAccessor suggestionStripViewAccessor){
  mLatinIME=latinIME;
  mSuggestionStripViewAccessor=suggestionStripViewAccessor;
  mWordComposer=new WordComposer();
  mEventInterpreter=new EventInterpreter(latinIME);
  mConnection=new RichInputConnection(latinIME);
  mInputLogicHandler=InputLogicHandler.NULL_HANDLER;
}

Fixed version (ground truth):
public InputLogic(final LatinIME latinIME,final SuggestionStripViewAccessor suggestionStripViewAccessor){
  mLatinIME=latinIME;
  mSuggestionStripViewAccessor=suggestionStripViewAccessor;
  mWordComposer=new WordComposer();
  mConnection=new RichInputConnection(latinIME);
  mInputLogicHandler=InputLogicHandler.NULL_HANDLER;
}
Program: 87422
Project: 87422
Buggy source:
private void setupWordViewsTextAndColor(final SuggestedWords suggestedWords,final int countInStrip){
  for (int positionInStrip=0; positionInStrip < countInStrip; ++positionInStrip) {
    mWordViews.get(positionInStrip).setText(null);
    if (SuggestionStripView.DBG) {
      mDebugInfoViews.get(positionInStrip).setText(null);
    }
  }
  final int count=Math.min(suggestedWords.size(),countInStrip);
  for (int indexInSuggestedWords=0; indexInSuggestedWords < count; indexInSuggestedWords++) {
    final int positionInStrip=getPositionInSuggestionStrip(indexInSuggestedWords,suggestedWords);
    final TextView wordView=mWordViews.get(positionInStrip);
    wordView.setTag(indexInSuggestedWords);
    wordView.setText(getStyledSuggestedWord(suggestedWords,indexInSuggestedWords));
    wordView.setTextColor(getSuggestionTextColor(positionInStrip,suggestedWords));
    if (SuggestionStripView.DBG) {
      mDebugInfoViews.get(positionInStrip).setText(suggestedWords.getDebugString(indexInSuggestedWords));
    }
  }
}

Fixed version (ground truth):
private void setupWordViewsTextAndColor(final SuggestedWords suggestedWords,final int countInStrip){
  for (int positionInStrip=0; positionInStrip < countInStrip; ++positionInStrip) {
    mWordViews.get(positionInStrip).setText(null);
    if (SuggestionStripView.DBG) {
      mDebugInfoViews.get(positionInStrip).setText(null);
    }
  }
  final int count=Math.min(suggestedWords.size(),countInStrip);
  for (int indexInSuggestedWords=0; indexInSuggestedWords < count; indexInSuggestedWords++) {
    final int positionInStrip=getPositionInSuggestionStrip(indexInSuggestedWords,suggestedWords);
    final TextView wordView=mWordViews.get(positionInStrip);
    wordView.setTag(indexInSuggestedWords);
    wordView.setText(getStyledSuggestedWord(suggestedWords,indexInSuggestedWords));
    wordView.setTextColor(getSuggestionTextColor(suggestedWords,indexInSuggestedWords));
    if (SuggestionStripView.DBG) {
      mDebugInfoViews.get(positionInStrip).setText(suggestedWords.getDebugString(indexInSuggestedWords));
    }
  }
}
Program: 87423
Project: 87423
Buggy source:
private int getSuggestionTextColor(final int indexInSuggestedWords,final SuggestedWords suggestedWords){
  final int positionInStrip=getPositionInSuggestionStrip(indexInSuggestedWords,suggestedWords);
  final boolean isSuggested=(indexInSuggestedWords != SuggestedWords.INDEX_OF_TYPED_WORD);
  final int color;
  if (positionInStrip == mCenterPositionInStrip && suggestedWords.mWillAutoCorrect) {
    color=mColorAutoCorrect;
  }
 else   if (positionInStrip == mCenterPositionInStrip && suggestedWords.mTypedWordValid) {
    color=mColorValidTypedWord;
  }
 else   if (isSuggested) {
    color=mColorSuggested;
  }
 else {
    color=mColorTypedWord;
  }
  if (LatinImeLogger.sDBG && suggestedWords.size() > 1) {
    if (positionInStrip == mCenterPositionInStrip && AutoCorrectionUtils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords.getLabel(SuggestedWords.INDEX_OF_AUTO_CORRECTION),suggestedWords.getLabel(SuggestedWords.INDEX_OF_TYPED_WORD))) {
      return 0xFFFF0000;
    }
  }
  if (suggestedWords.mIsObsoleteSuggestions && isSuggested) {
    return applyAlpha(color,mAlphaObsoleted);
  }
  return color;
}

Fixed version (ground truth):
private int getSuggestionTextColor(final SuggestedWords suggestedWords,final int indexInSuggestedWords){
  final int positionInStrip=getPositionInSuggestionStrip(indexInSuggestedWords,suggestedWords);
  final boolean isSuggested=(indexInSuggestedWords != SuggestedWords.INDEX_OF_TYPED_WORD);
  final int color;
  if (positionInStrip == mCenterPositionInStrip && suggestedWords.mWillAutoCorrect) {
    color=mColorAutoCorrect;
  }
 else   if (positionInStrip == mCenterPositionInStrip && suggestedWords.mTypedWordValid) {
    color=mColorValidTypedWord;
  }
 else   if (isSuggested) {
    color=mColorSuggested;
  }
 else {
    color=mColorTypedWord;
  }
  if (LatinImeLogger.sDBG && suggestedWords.size() > 1) {
    if (positionInStrip == mCenterPositionInStrip && AutoCorrectionUtils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords.getLabel(SuggestedWords.INDEX_OF_AUTO_CORRECTION),suggestedWords.getLabel(SuggestedWords.INDEX_OF_TYPED_WORD))) {
      return 0xFFFF0000;
    }
  }
  if (suggestedWords.mIsObsoleteSuggestions && isSuggested) {
    return applyAlpha(color,mAlphaObsoleted);
  }
  return color;
}
Program: 87425
Project: 87425
Buggy source:
/** 
 * Resets the whole input state to the starting state. This will clear the composing word, reset the last composed word, clear the suggestion strip and tell the input connection about it so that it can refresh its caches.
 * @param settingsValues the current values of the settings.
 * @param newSelStart the new selection start, in java characters.
 * @param newSelEnd the new selection end, in java characters.
 */
public void resetEntireInputState(final SettingsValues settingsValues,final int newSelStart,final int newSelEnd){
  final boolean shouldFinishComposition=mWordComposer.isComposingWord();
  resetComposingState(true);
  mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
  mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,shouldFinishComposition);
}

Fixed version (ground truth):
/** 
 * Resets the whole input state to the starting state. This will clear the composing word, reset the last composed word, clear the suggestion strip and tell the input connection about it so that it can refresh its caches.
 * @param settingsValues the current values of the settings.
 * @param newSelStart the new selection start, in java characters.
 * @param newSelEnd the new selection end, in java characters.
 * @param clearSuggestionStrip whether this method should clear the suggestion strip.
 */
public void resetEntireInputState(final SettingsValues settingsValues,final int newSelStart,final int newSelEnd,final boolean clearSuggestionStrip){
  final boolean shouldFinishComposition=mWordComposer.isComposingWord();
  resetComposingState(true);
  if (clearSuggestionStrip) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
  }
  mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,shouldFinishComposition);
}
Program: 87433
Project: 87433
Buggy source:
/** 
 * Resets the whole input state to the starting state. This will clear the composing word, reset the last composed word, clear the suggestion strip and tell the input connection about it so that it can refresh its caches.
 * @param settingsValues the current values of the settings.
 * @param newSelStart the new selection start, in java characters.
 * @param newSelEnd the new selection end, in java characters.
 */
public void resetEntireInputState(final SettingsValues settingsValues,final int newSelStart,final int newSelEnd){
  final boolean shouldFinishComposition=mWordComposer.isComposingWord();
  resetComposingState(true);
  mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
  mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,shouldFinishComposition);
}

Fixed version (ground truth):
/** 
 * Resets the whole input state to the starting state. This will clear the composing word, reset the last composed word, clear the suggestion strip and tell the input connection about it so that it can refresh its caches.
 * @param settingsValues the current values of the settings.
 * @param newSelStart the new selection start, in java characters.
 * @param newSelEnd the new selection end, in java characters.
 * @param clearSuggestionStrip whether this method should clear the suggestion strip.
 */
public void resetEntireInputState(final SettingsValues settingsValues,final int newSelStart,final int newSelEnd,final boolean clearSuggestionStrip){
  final boolean shouldFinishComposition=mWordComposer.isComposingWord();
  resetComposingState(true);
  if (clearSuggestionStrip) {
    mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
  }
  mConnection.resetCachesUponCursorMoveAndReturnSuccess(newSelStart,newSelEnd,shouldFinishComposition);
}
Program: 87440
Project: 87440
Buggy source:
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}

Fixed version (ground truth):
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (mExpectedSelStart - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}
Program: 87441
Project: 87441
Buggy source:
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}

Fixed version (ground truth):
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(Constants.EDITOR_CONTENTS_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (mExpectedSelStart - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}
Program: 87442
Project: 87442
Buggy source:
public void dismissKeyPreview(final Key key,final boolean withAnimation){
  if (key == null) {
    return;
  }
  final TextView previewTextView=mShowingKeyPreviewTextViews.get(key);
  if (previewTextView == null) {
    return;
  }
  final Object tag=previewTextView.getTag();
  if (withAnimation) {
    if (tag instanceof KeyPreviewAnimations) {
      final KeyPreviewAnimations animation=(KeyPreviewAnimations)tag;
      animation.startDismiss();
    }
    return;
  }
  if (tag instanceof Animator) {
    ((Animator)tag).cancel();
  }
  previewTextView.setTag(null);
  previewTextView.setVisibility(View.INVISIBLE);
  mFreeKeyPreviewTextViews.add(previewTextView);
}

Fixed version (ground truth):
public void dismissKeyPreview(final Key key,final boolean withAnimation){
  if (key == null) {
    return;
  }
  final TextView previewTextView=mShowingKeyPreviewTextViews.get(key);
  if (previewTextView == null) {
    return;
  }
  final Object tag=previewTextView.getTag();
  if (withAnimation) {
    if (tag instanceof KeyPreviewAnimations) {
      final KeyPreviewAnimations animation=(KeyPreviewAnimations)tag;
      animation.startDismiss();
      return;
    }
  }
  mShowingKeyPreviewTextViews.remove(key);
  if (tag instanceof Animator) {
    ((Animator)tag).cancel();
  }
  previewTextView.setTag(null);
  previewTextView.setVisibility(View.INVISIBLE);
  mFreeKeyPreviewTextViews.add(previewTextView);
}
Program: 87443
Project: 87443
Buggy source:
public void dismissKeyPreview(final Key key,final boolean withAnimation){
  if (key == null) {
    return;
  }
  final TextView previewTextView=mShowingKeyPreviewTextViews.get(key);
  if (previewTextView == null) {
    return;
  }
  final Object tag=previewTextView.getTag();
  if (withAnimation) {
    if (tag instanceof KeyPreviewAnimations) {
      final KeyPreviewAnimations animation=(KeyPreviewAnimations)tag;
      animation.startDismiss();
    }
    return;
  }
  if (tag instanceof Animator) {
    ((Animator)tag).cancel();
  }
  previewTextView.setTag(null);
  previewTextView.setVisibility(View.INVISIBLE);
  mFreeKeyPreviewTextViews.add(previewTextView);
}

Fixed version (ground truth):
public void dismissKeyPreview(final Key key,final boolean withAnimation){
  if (key == null) {
    return;
  }
  final TextView previewTextView=mShowingKeyPreviewTextViews.get(key);
  if (previewTextView == null) {
    return;
  }
  final Object tag=previewTextView.getTag();
  if (withAnimation) {
    if (tag instanceof KeyPreviewAnimations) {
      final KeyPreviewAnimations animation=(KeyPreviewAnimations)tag;
      animation.startDismiss();
      return;
    }
  }
  mShowingKeyPreviewTextViews.remove(key);
  if (tag instanceof Animator) {
    ((Animator)tag).cancel();
  }
  previewTextView.setTag(null);
  previewTextView.setVisibility(View.INVISIBLE);
  mFreeKeyPreviewTextViews.add(previewTextView);
}
Program: 87444
Project: 87444
Buggy source:
public SpacingAndPunctuations(final Resources res){
  mSymbolsPrecededBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_preceded_by_space));
  Arrays.sort(mSymbolsPrecededBySpace);
  mSymbolsFollowedBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_followed_by_space));
  Arrays.sort(mSymbolsFollowedBySpace);
  mWordConnectors=StringUtils.toCodePointArray(res.getString(R.string.symbols_word_connectors));
  Arrays.sort(mWordConnectors);
  final String[] suggestPuncsSpec=KeySpecParser.splitKeySpecs(res.getString(R.string.suggested_punctuations));
  mSuggestPuncList=createSuggestPuncList(suggestPuncsSpec);
  mWordSeparators=res.getString(R.string.symbols_word_separators);
  mSentenceSeparator=res.getInteger(R.integer.sentence_separator);
  mSentenceSeparatorAndSpace=new String(new int[]{mSentenceSeparator,Constants.CODE_SPACE},0,2);
  mCurrentLanguageHasSpaces=res.getBoolean(R.bool.current_language_has_spaces);
  final Locale locale=res.getConfiguration().locale;
  mUsesAmericanTypography=Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
}

Fixed version (ground truth):
public SpacingAndPunctuations(final Resources res){
  mSymbolsPrecededBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_preceded_by_space));
  Arrays.sort(mSymbolsPrecededBySpace);
  mSymbolsFollowedBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_followed_by_space));
  Arrays.sort(mSymbolsFollowedBySpace);
  mWordConnectors=StringUtils.toCodePointArray(res.getString(R.string.symbols_word_connectors));
  Arrays.sort(mWordConnectors);
  final String[] suggestPuncsSpec=KeySpecParser.splitKeySpecs(res.getString(R.string.suggested_punctuations));
  mSuggestPuncList=createSuggestPuncList(suggestPuncsSpec);
  mWordSeparators=res.getString(R.string.symbols_word_separators);
  mSentenceSeparator=res.getInteger(R.integer.sentence_separator);
  mSentenceSeparatorAndSpace=new String(new int[]{mSentenceSeparator,Constants.CODE_SPACE},0,2);
  mCurrentLanguageHasSpaces=res.getBoolean(R.bool.current_language_has_spaces);
  final Locale locale=res.getConfiguration().locale;
  mUsesAmericanTypography=Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
  mUsesGermanRules=Locale.GERMAN.getLanguage().equals(locale.getLanguage());
}
Program: 87447
Project: 87447
Buggy source:
public SpacingAndPunctuations(final Resources res){
  mSymbolsPrecededBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_preceded_by_space));
  Arrays.sort(mSymbolsPrecededBySpace);
  mSymbolsFollowedBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_followed_by_space));
  Arrays.sort(mSymbolsFollowedBySpace);
  mWordConnectors=StringUtils.toCodePointArray(res.getString(R.string.symbols_word_connectors));
  Arrays.sort(mWordConnectors);
  final String[] suggestPuncsSpec=KeySpecParser.splitKeySpecs(res.getString(R.string.suggested_punctuations));
  mSuggestPuncList=createSuggestPuncList(suggestPuncsSpec);
  mWordSeparators=res.getString(R.string.symbols_word_separators);
  mSentenceSeparator=res.getInteger(R.integer.sentence_separator);
  mSentenceSeparatorAndSpace=new String(new int[]{mSentenceSeparator,Constants.CODE_SPACE},0,2);
  mCurrentLanguageHasSpaces=res.getBoolean(R.bool.current_language_has_spaces);
  final Locale locale=res.getConfiguration().locale;
  mUsesAmericanTypography=Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
}

Fixed version (ground truth):
public SpacingAndPunctuations(final Resources res){
  mSymbolsPrecededBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_preceded_by_space));
  Arrays.sort(mSymbolsPrecededBySpace);
  mSymbolsFollowedBySpace=StringUtils.toCodePointArray(res.getString(R.string.symbols_followed_by_space));
  Arrays.sort(mSymbolsFollowedBySpace);
  mWordConnectors=StringUtils.toCodePointArray(res.getString(R.string.symbols_word_connectors));
  Arrays.sort(mWordConnectors);
  final String[] suggestPuncsSpec=KeySpecParser.splitKeySpecs(res.getString(R.string.suggested_punctuations));
  mSuggestPuncList=createSuggestPuncList(suggestPuncsSpec);
  mWordSeparators=res.getString(R.string.symbols_word_separators);
  mSentenceSeparator=res.getInteger(R.integer.sentence_separator);
  mSentenceSeparatorAndSpace=new String(new int[]{mSentenceSeparator,Constants.CODE_SPACE},0,2);
  mCurrentLanguageHasSpaces=res.getBoolean(R.bool.current_language_has_spaces);
  final Locale locale=res.getConfiguration().locale;
  mUsesAmericanTypography=Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
  mUsesGermanRules=Locale.GERMAN.getLanguage().equals(locale.getLanguage());
}
Program: 87451
Project: 87451
Buggy source:
/** 
 * Attaches a keyboard to this view. The keyboard can be switched at any time and the view will re-layout itself to accommodate the keyboard.
 * @see Keyboard
 * @see #getKeyboard()
 * @param keyboard the keyboard to display in this view
 */
@Override public void setKeyboard(final Keyboard keyboard){
  mKeyTimerHandler.cancelAllKeyTimers();
  super.setKeyboard(keyboard);
  mKeyDetector.setKeyboard(keyboard,-getPaddingLeft(),-getPaddingTop() + getVerticalCorrection());
  PointerTracker.setKeyDetector(mKeyDetector);
  mMoreKeysKeyboardCache.clear();
  mSpaceKey=keyboard.getKey(Constants.CODE_SPACE);
  mSpacebarIcon=(mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet,Constants.Color.ALPHA_OPAQUE) : null;
  final int keyHeight=keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
  mLanguageOnSpacebarTextSize=keyHeight * mLanguageOnSpacebarTextRatio;
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    final int orientation=getContext().getResources().getConfiguration().orientation;
    ResearchLogger.mainKeyboardView_setKeyboard(keyboard,orientation);
  }
  AccessibleKeyboardViewProxy.getInstance().setKeyboard();
}

Fixed version (ground truth):
/** 
 * Attaches a keyboard to this view. The keyboard can be switched at any time and the view will re-layout itself to accommodate the keyboard.
 * @see Keyboard
 * @see #getKeyboard()
 * @param keyboard the keyboard to display in this view
 */
@Override public void setKeyboard(final Keyboard keyboard){
  mKeyTimerHandler.cancelLongPressTimers();
  super.setKeyboard(keyboard);
  mKeyDetector.setKeyboard(keyboard,-getPaddingLeft(),-getPaddingTop() + getVerticalCorrection());
  PointerTracker.setKeyDetector(mKeyDetector);
  mMoreKeysKeyboardCache.clear();
  mSpaceKey=keyboard.getKey(Constants.CODE_SPACE);
  mSpacebarIcon=(mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet,Constants.Color.ALPHA_OPAQUE) : null;
  final int keyHeight=keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
  mLanguageOnSpacebarTextSize=keyHeight * mLanguageOnSpacebarTextRatio;
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    final int orientation=getContext().getResources().getConfiguration().orientation;
    ResearchLogger.mainKeyboardView_setKeyboard(keyboard,orientation);
  }
  AccessibleKeyboardViewProxy.getInstance().setKeyboard();
}
Program: 87452
Project: 87452
Buggy source:
private void cancelLongPressTimers(){
  removeMessages(MSG_LONGPRESS_KEY);
  removeMessages(MSG_LONGPRESS_SHIFT_KEY);
}

Fixed version (ground truth):
public void cancelLongPressTimers(){
  removeMessages(MSG_LONGPRESS_KEY);
  removeMessages(MSG_LONGPRESS_SHIFT_KEY);
}
Program: 87453
Project: 87453
Buggy source:
/** 
 * Attaches a keyboard to this view. The keyboard can be switched at any time and the view will re-layout itself to accommodate the keyboard.
 * @see Keyboard
 * @see #getKeyboard()
 * @param keyboard the keyboard to display in this view
 */
@Override public void setKeyboard(final Keyboard keyboard){
  mKeyTimerHandler.cancelAllKeyTimers();
  super.setKeyboard(keyboard);
  mKeyDetector.setKeyboard(keyboard,-getPaddingLeft(),-getPaddingTop() + getVerticalCorrection());
  PointerTracker.setKeyDetector(mKeyDetector);
  mMoreKeysKeyboardCache.clear();
  mSpaceKey=keyboard.getKey(Constants.CODE_SPACE);
  mSpacebarIcon=(mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet,Constants.Color.ALPHA_OPAQUE) : null;
  final int keyHeight=keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
  mLanguageOnSpacebarTextSize=keyHeight * mLanguageOnSpacebarTextRatio;
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    final int orientation=getContext().getResources().getConfiguration().orientation;
    ResearchLogger.mainKeyboardView_setKeyboard(keyboard,orientation);
  }
  AccessibleKeyboardViewProxy.getInstance().setKeyboard();
}

Fixed version (ground truth):
/** 
 * Attaches a keyboard to this view. The keyboard can be switched at any time and the view will re-layout itself to accommodate the keyboard.
 * @see Keyboard
 * @see #getKeyboard()
 * @param keyboard the keyboard to display in this view
 */
@Override public void setKeyboard(final Keyboard keyboard){
  mKeyTimerHandler.cancelLongPressTimers();
  super.setKeyboard(keyboard);
  mKeyDetector.setKeyboard(keyboard,-getPaddingLeft(),-getPaddingTop() + getVerticalCorrection());
  PointerTracker.setKeyDetector(mKeyDetector);
  mMoreKeysKeyboardCache.clear();
  mSpaceKey=keyboard.getKey(Constants.CODE_SPACE);
  mSpacebarIcon=(mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet,Constants.Color.ALPHA_OPAQUE) : null;
  final int keyHeight=keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
  mLanguageOnSpacebarTextSize=keyHeight * mLanguageOnSpacebarTextRatio;
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    final int orientation=getContext().getResources().getConfiguration().orientation;
    ResearchLogger.mainKeyboardView_setKeyboard(keyboard,orientation);
  }
  AccessibleKeyboardViewProxy.getInstance().setKeyboard();
}
Program: 87454
Project: 87454
Buggy source:
private void cancelLongPressTimers(){
  removeMessages(MSG_LONGPRESS_KEY);
  removeMessages(MSG_LONGPRESS_SHIFT_KEY);
}

Fixed version (ground truth):
public void cancelLongPressTimers(){
  removeMessages(MSG_LONGPRESS_KEY);
  removeMessages(MSG_LONGPRESS_SHIFT_KEY);
}
Program: 87455
Project: 87455
Buggy source:
public LastComposedWord commitWord(final int type,final String committedWord,final String separatorString,final String prevWord){
  final int[] primaryKeyCodes=mPrimaryKeyCodes;
  mPrimaryKeyCodes=new int[MAX_WORD_LENGTH];
  final LastComposedWord lastComposedWord=new LastComposedWord(primaryKeyCodes,mInputPointers,mTypedWord.toString(),committedWord,separatorString,prevWord,mCapitalizedMode);
  mInputPointers.reset();
  if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD && type != LastComposedWord.COMMIT_TYPE_MANUAL_PICK) {
    lastComposedWord.deactivate();
  }
  mCapsCount=0;
  mDigitsCount=0;
  mIsBatchMode=false;
  mPreviousWordForSuggestion=mTypedWord.toString();
  mTypedWord.setLength(0);
  mCodePointSize=0;
  mTrailingSingleQuotesCount=0;
  mIsFirstCharCapitalized=false;
  mCapitalizedMode=CAPS_MODE_OFF;
  refreshSize();
  mAutoCorrection=null;
  mCursorPositionWithinWord=0;
  mIsResumed=false;
  mRejectedBatchModeSuggestion=null;
  return lastComposedWord;
}

Fixed version (ground truth):
public LastComposedWord commitWord(final int type,final String committedWord,final String separatorString,final String prevWord){
  final int[] primaryKeyCodes=mPrimaryKeyCodes;
  mPrimaryKeyCodes=new int[MAX_WORD_LENGTH];
  final LastComposedWord lastComposedWord=new LastComposedWord(primaryKeyCodes,mInputPointers,mTypedWord.toString(),committedWord,separatorString,prevWord,mCapitalizedMode);
  mInputPointers.reset();
  if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD && type != LastComposedWord.COMMIT_TYPE_MANUAL_PICK) {
    lastComposedWord.deactivate();
  }
  mCapsCount=0;
  mDigitsCount=0;
  mIsBatchMode=false;
  mPreviousWordForSuggestion=committedWord;
  mTypedWord.setLength(0);
  mCodePointSize=0;
  mTrailingSingleQuotesCount=0;
  mIsFirstCharCapitalized=false;
  mCapitalizedMode=CAPS_MODE_OFF;
  refreshSize();
  mAutoCorrection=null;
  mCursorPositionWithinWord=0;
  mIsResumed=false;
  mRejectedBatchModeSuggestion=null;
  return lastComposedWord;
}
Program: 87456
Project: 87456
Buggy source:
/** 
 * Commits the chosen word to the text field and saves it for later retrieval.
 * @param settingsValues the current values of the settings.
 * @param chosenWord the word we want to commit.
 * @param commitType the type of the commit, as one of LastComposedWord.COMMIT_TYPE_
 * @param separatorString the separator that's causing the commit, or NOT_A_SEPARATOR if none.
 */
public void commitChosenWord(final SettingsValues settingsValues,final String chosenWord,final int commitType,final String separatorString){
  final SuggestedWords suggestedWords=mSuggestedWords;
  mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(mLatinIME,chosenWord,suggestedWords),1);
  final String prevWord=mConnection.getNthPreviousWord(settingsValues,2);
  performAdditionToUserHistoryDictionary(settingsValues,chosenWord,prevWord);
  mLastComposedWord=mWordComposer.commitWord(commitType,chosenWord,separatorString,prevWord);
  final boolean shouldDiscardPreviousWordForSuggestion;
  if (0 == StringUtils.codePointCount(separatorString)) {
    shouldDiscardPreviousWordForSuggestion=settingsValues.mCurrentLanguageHasSpaces;
  }
 else {
    shouldDiscardPreviousWordForSuggestion=!StringUtils.containsOnlyWhitespace(separatorString);
  }
  if (shouldDiscardPreviousWordForSuggestion) {
    mWordComposer.discardPreviousWordForSuggestion();
  }
}

Fixed version (ground truth):
/** 
 * Commits the chosen word to the text field and saves it for later retrieval.
 * @param settingsValues the current values of the settings.
 * @param chosenWord the word we want to commit.
 * @param commitType the type of the commit, as one of LastComposedWord.COMMIT_TYPE_
 * @param separatorString the separator that's causing the commit, or NOT_A_SEPARATOR if none.
 */
public void commitChosenWord(final SettingsValues settingsValues,final String chosenWord,final int commitType,final String separatorString){
  final SuggestedWords suggestedWords=mSuggestedWords;
  mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(mLatinIME,chosenWord,suggestedWords),1);
  final String prevWord=mConnection.getNthPreviousWord(settingsValues,2);
  performAdditionToUserHistoryDictionary(settingsValues,chosenWord,prevWord);
  mLastComposedWord=mWordComposer.commitWord(commitType,chosenWord,separatorString,prevWord);
  final boolean shouldDiscardPreviousWordForSuggestion;
  if (0 == StringUtils.codePointCount(separatorString)) {
    shouldDiscardPreviousWordForSuggestion=false;
  }
 else {
    shouldDiscardPreviousWordForSuggestion=!StringUtils.containsOnlyWhitespace(separatorString);
  }
  if (shouldDiscardPreviousWordForSuggestion) {
    mWordComposer.discardPreviousWordForSuggestion();
  }
}
Program: 87457
Project: 87457
Buggy source:
private boolean maybeDoubleSpacePeriod(){
  final SettingsValues currentSettingsValues=mSettings.getCurrent();
  if (!currentSettingsValues.mUseDoubleSpacePeriod)   return false;
  if (!mHandler.isAcceptingDoubleSpacePeriod())   return false;
  final CharSequence lastThree=mConnection.getTextBeforeCursor(4,0);
  if (null == lastThree)   return false;
  final int length=lastThree.length();
  if (length < 3)   return false;
  if (lastThree.charAt(length - 1) != Constants.CODE_SPACE)   return false;
  if (lastThree.charAt(length - 2) != Constants.CODE_SPACE)   return false;
  final int firstCodePoint=Character.isSurrogatePair(lastThree.charAt(0),lastThree.charAt(1)) ? Character.codePointAt(lastThree,0) : lastThree.charAt(length - 3);
  if (canBeFollowedByDoubleSpacePeriod(firstCodePoint)) {
    mHandler.cancelDoubleSpacePeriodTimer();
    mConnection.deleteSurroundingText(2,0);
    final String textToInsert=new String(new int[]{currentSettingsValues.mSentenceSeparator,Constants.CODE_SPACE},0,2);
    mConnection.commitText(textToInsert,1);
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,false);
    }
    mWordComposer.doubleSpacePeriod();
    mKeyboardSwitcher.updateShiftState();
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean maybeDoubleSpacePeriod(){
  final SettingsValues currentSettingsValues=mSettings.getCurrent();
  if (!currentSettingsValues.mUseDoubleSpacePeriod)   return false;
  if (!mHandler.isAcceptingDoubleSpacePeriod())   return false;
  final CharSequence lastThree=mConnection.getTextBeforeCursor(4,0);
  if (null == lastThree)   return false;
  final int length=lastThree.length();
  if (length < 3)   return false;
  if (lastThree.charAt(length - 1) != Constants.CODE_SPACE)   return false;
  if (lastThree.charAt(length - 2) != Constants.CODE_SPACE)   return false;
  final int firstCodePoint=Character.isSurrogatePair(lastThree.charAt(0),lastThree.charAt(1)) ? Character.codePointAt(lastThree,0) : lastThree.charAt(length - 3);
  if (canBeFollowedByDoubleSpacePeriod(firstCodePoint)) {
    mHandler.cancelDoubleSpacePeriodTimer();
    mConnection.deleteSurroundingText(2,0);
    final String textToInsert=new String(new int[]{currentSettingsValues.mSentenceSeparator,Constants.CODE_SPACE},0,2);
    mConnection.commitText(textToInsert,1);
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,false);
    }
    mWordComposer.discardPreviousWordForSuggestion();
    mKeyboardSwitcher.updateShiftState();
    return true;
  }
  return false;
}
Program: 87458
Project: 87458
Buggy source:
/** 
 * Commits the chosen word to the text field and saves it for later retrieval.
 */
private void commitChosenWord(final String chosenWord,final int commitType,final String separatorString){
  final SuggestedWords suggestedWords=mSuggestedWords;
  mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(this,chosenWord,suggestedWords,mIsMainDictionaryAvailable),1);
  final String prevWord=addToUserHistoryDictionary(chosenWord);
  mLastComposedWord=mWordComposer.commitWord(commitType,chosenWord,separatorString,prevWord);
}

Fixed version (ground truth):
/** 
 * Commits the chosen word to the text field and saves it for later retrieval.
 */
private void commitChosenWord(final String chosenWord,final int commitType,final String separatorString){
  final SuggestedWords suggestedWords=mSuggestedWords;
  mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(this,chosenWord,suggestedWords,mIsMainDictionaryAvailable),1);
  final String prevWord=addToUserHistoryDictionary(chosenWord);
  mLastComposedWord=mWordComposer.commitWord(commitType,chosenWord,separatorString,prevWord);
  final boolean shouldDiscardPreviousWordForSuggestion;
  if (0 == StringUtils.codePointCount(separatorString)) {
    shouldDiscardPreviousWordForSuggestion=mSettings.getCurrent().mCurrentLanguageHasSpaces;
  }
 else {
    shouldDiscardPreviousWordForSuggestion=!StringUtils.containsOnlyWhitespace(separatorString);
  }
  if (shouldDiscardPreviousWordForSuggestion) {
    mWordComposer.discardPreviousWordForSuggestion();
  }
}
Program: 87459
Project: 87459
Buggy source:
private void getSuggestedWords(final int sessionId,final int sequenceNumber,final OnGetSuggestedWordsCallback callback){
  final Keyboard keyboard=mKeyboardSwitcher.getKeyboard();
  final Suggest suggest=mSuggest;
  if (keyboard == null || suggest == null) {
    callback.onGetSuggestedWords(SuggestedWords.EMPTY);
    return;
  }
  final SettingsValues currentSettings=mSettings.getCurrent();
  final int[] additionalFeaturesOptions=currentSettings.mAdditionalFeaturesSettingValues;
  if (DEBUG) {
    if (mWordComposer.isComposingWord() || mWordComposer.isBatchMode()) {
      final String previousWord=mWordComposer.getPreviousWord();
      final String rereadPrevWord=getNthPreviousWordForSuggestion(currentSettings,mWordComposer.isComposingWord() ? 2 : 1);
      if (!TextUtils.equals(previousWord,rereadPrevWord)) {
        throw new RuntimeException("String_Node_Str" + previousWord + "String_Node_Str"+ rereadPrevWord);
      }
    }
  }
  suggest.getSuggestedWords(mWordComposer,mWordComposer.getPreviousWord(),keyboard.getProximityInfo(),currentSettings.mBlockPotentiallyOffensive,currentSettings.mCorrectionEnabled,additionalFeaturesOptions,sessionId,sequenceNumber,callback);
}

Fixed version (ground truth):
private void getSuggestedWords(final int sessionId,final int sequenceNumber,final OnGetSuggestedWordsCallback callback){
  final Keyboard keyboard=mKeyboardSwitcher.getKeyboard();
  final Suggest suggest=mSuggest;
  if (keyboard == null || suggest == null) {
    callback.onGetSuggestedWords(SuggestedWords.EMPTY);
    return;
  }
  final SettingsValues currentSettings=mSettings.getCurrent();
  final int[] additionalFeaturesOptions=currentSettings.mAdditionalFeaturesSettingValues;
  if (DEBUG) {
    if (mWordComposer.isComposingWord() || mWordComposer.isBatchMode()) {
      final String previousWord=mWordComposer.getPreviousWordForSuggestion();
      final String rereadPrevWord=getNthPreviousWordForSuggestion(currentSettings,mWordComposer.isComposingWord() ? 2 : 1);
      if (!TextUtils.equals(previousWord,rereadPrevWord)) {
        throw new RuntimeException("String_Node_Str" + previousWord + "String_Node_Str"+ rereadPrevWord);
      }
    }
  }
  suggest.getSuggestedWords(mWordComposer,mWordComposer.getPreviousWordForSuggestion(),keyboard.getProximityInfo(),currentSettings.mBlockPotentiallyOffensive,currentSettings.mCorrectionEnabled,additionalFeaturesOptions,sessionId,sequenceNumber,callback);
}
Program: 87460
Project: 87460
Buggy source:
/** 
 * Set the currently composing word to the one passed as an argument. This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
 * @param word the char sequence to set as the composing word.
 * @param previousWord the previous word, to use as context for suggestions. Can be null ifthe context is nil (typically, at start of text).
 * @param keyboard the keyboard this is typed on, for coordinate info/proximity.
 */
public void setComposingWord(final CharSequence word,final String previousWord,final Keyboard keyboard){
  reset();
  final int length=word.length();
  for (int i=0; i < length; i=Character.offsetByCodePoints(word,i,1)) {
    final int codePoint=Character.codePointAt(word,i);
    addKeyInfo(codePoint,keyboard);
  }
  mIsResumed=true;
  mPreviousWord=previousWord;
}

Fixed version (ground truth):
/** 
 * Set the currently composing word to the one passed as an argument. This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
 * @param word the char sequence to set as the composing word.
 * @param previousWord the previous word, to use as context for suggestions. Can be null ifthe context is nil (typically, at start of text).
 * @param keyboard the keyboard this is typed on, for coordinate info/proximity.
 */
public void setComposingWord(final CharSequence word,final String previousWord,final Keyboard keyboard){
  reset();
  final int length=word.length();
  for (int i=0; i < length; i=Character.offsetByCodePoints(word,i,1)) {
    final int codePoint=Character.codePointAt(word,i);
    addKeyInfo(codePoint,keyboard);
  }
  mIsResumed=true;
  mPreviousWordForSuggestion=previousWord;
}
Program: 87461
Project: 87461
Buggy source:
public LastComposedWord commitWord(final int type,final String committedWord,final String separatorString,final String prevWord){
  final int[] primaryKeyCodes=mPrimaryKeyCodes;
  mPrimaryKeyCodes=new int[MAX_WORD_LENGTH];
  final LastComposedWord lastComposedWord=new LastComposedWord(primaryKeyCodes,mInputPointers,mTypedWord.toString(),committedWord,separatorString,prevWord,mCapitalizedMode);
  mInputPointers.reset();
  if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD && type != LastComposedWord.COMMIT_TYPE_MANUAL_PICK) {
    lastComposedWord.deactivate();
  }
  mCapsCount=0;
  mDigitsCount=0;
  mIsBatchMode=false;
  final boolean isWhitespace=1 == StringUtils.codePointCount(separatorString) && Character.isWhitespace(separatorString.codePointAt(0));
  mPreviousWord=isWhitespace ? mTypedWord.toString() : null;
  mTypedWord.setLength(0);
  mCodePointSize=0;
  mTrailingSingleQuotesCount=0;
  mIsFirstCharCapitalized=false;
  mCapitalizedMode=CAPS_MODE_OFF;
  refreshSize();
  mAutoCorrection=null;
  mCursorPositionWithinWord=0;
  mIsResumed=false;
  mRejectedBatchModeSuggestion=null;
  return lastComposedWord;
}

Fixed version (ground truth):
public LastComposedWord commitWord(final int type,final String committedWord,final String separatorString,final String prevWord){
  final int[] primaryKeyCodes=mPrimaryKeyCodes;
  mPrimaryKeyCodes=new int[MAX_WORD_LENGTH];
  final LastComposedWord lastComposedWord=new LastComposedWord(primaryKeyCodes,mInputPointers,mTypedWord.toString(),committedWord,separatorString,prevWord,mCapitalizedMode);
  mInputPointers.reset();
  if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD && type != LastComposedWord.COMMIT_TYPE_MANUAL_PICK) {
    lastComposedWord.deactivate();
  }
  mCapsCount=0;
  mDigitsCount=0;
  mIsBatchMode=false;
  mPreviousWordForSuggestion=mTypedWord.toString();
  mTypedWord.setLength(0);
  mCodePointSize=0;
  mTrailingSingleQuotesCount=0;
  mIsFirstCharCapitalized=false;
  mCapitalizedMode=CAPS_MODE_OFF;
  refreshSize();
  mAutoCorrection=null;
  mCursorPositionWithinWord=0;
  mIsResumed=false;
  mRejectedBatchModeSuggestion=null;
  return lastComposedWord;
}