Program: 87420
Project: 87420
Buggy source:
private void getSuggestedWordsForTypingInput(final WordComposer wordComposer,final String prevWordForBigram,final ProximityInfo proximityInfo,final boolean blockOffensiveWords,final boolean isCorrectionEnabled,final int[] additionalFeaturesOptions,final int sequenceNumber,final OnGetSuggestedWordsCallback callback){
  final int trailingSingleQuotesCount=wordComposer.trailingSingleQuotesCount();
  final BoundedTreeSet suggestionsSet=new BoundedTreeSet(sSuggestedWordInfoComparator,SuggestedWords.MAX_SUGGESTIONS);
  final String typedWord=wordComposer.getTypedWord();
  final String consideredWord=trailingSingleQuotesCount > 0 ? typedWord.substring(0,typedWord.length() - trailingSingleQuotesCount) : typedWord;
  LatinImeLogger.onAddSuggestedWord(typedWord,Dictionary.TYPE_USER_TYPED);
  final WordComposer wordComposerForLookup;
  if (trailingSingleQuotesCount > 0) {
    wordComposerForLookup=new WordComposer(wordComposer);
    for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
      wordComposerForLookup.deleteLast();
    }
  }
 else {
    wordComposerForLookup=wordComposer;
  }
  final ArrayList<SuggestedWordInfo> rawSuggestions;
  if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
    rawSuggestions=CollectionUtils.newArrayList();
  }
 else {
    rawSuggestions=null;
  }
  mDictionaryFacilitator.getSuggestions(wordComposerForLookup,prevWordForBigram,proximityInfo,blockOffensiveWords,additionalFeaturesOptions,SESSION_TYPING,suggestionsSet,rawSuggestions);
  final String firstSuggestion;
  final String whitelistedWord;
  if (suggestionsSet.isEmpty()) {
    whitelistedWord=firstSuggestion=null;
  }
 else {
    final SuggestedWordInfo firstSuggestedWordInfo=suggestionsSet.first();
    firstSuggestion=firstSuggestedWordInfo.mWord;
    if (SuggestedWordInfo.KIND_WHITELIST != firstSuggestedWordInfo.mKind) {
      whitelistedWord=null;
    }
 else {
      whitelistedWord=firstSuggestion;
    }
  }
  final boolean isPrediction=!wordComposer.isComposingWord();
  final boolean allowsToBeAutoCorrected=(null != whitelistedWord && !whitelistedWord.equals(consideredWord)) || (consideredWord.length() > 1 && !mDictionaryFacilitator.isValidWord(consideredWord,wordComposer.isFirstCharCapitalized()) && !consideredWord.equals(firstSuggestion));
  final boolean hasAutoCorrection;
  if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction|| suggestionsSet.isEmpty()|| wordComposer.hasDigits()|| wordComposer.isMostlyCaps()|| wordComposer.isResumed()|| !mDictionaryFacilitator.hasMainDictionary()|| SuggestedWordInfo.KIND_SHORTCUT == suggestionsSet.first().mKind) {
    hasAutoCorrection=false;
  }
 else {
    hasAutoCorrection=AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(suggestionsSet.first(),consideredWord,mAutoCorrectionThreshold);
  }
  final ArrayList<SuggestedWordInfo> suggestionsContainer=CollectionUtils.newArrayList(suggestionsSet);
  final int suggestionsCount=suggestionsContainer.size();
  final boolean isFirstCharCapitalized=wordComposer.isFirstCharCapitalized();
  final boolean isAllUpperCase=wordComposer.isAllUpperCase();
  if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) {
    for (int i=0; i < suggestionsCount; ++i) {
      final SuggestedWordInfo wordInfo=suggestionsContainer.get(i);
      final SuggestedWordInfo transformedWordInfo=getTransformedSuggestedWordInfo(wordInfo,mLocale,isAllUpperCase,isFirstCharCapitalized,trailingSingleQuotesCount);
      suggestionsContainer.set(i,transformedWordInfo);
    }
  }
  for (int i=0; i < suggestionsCount; ++i) {
    final SuggestedWordInfo wordInfo=suggestionsContainer.get(i);
    LatinImeLogger.onAddSuggestedWord(wordInfo.mWord.toString(),wordInfo.mSourceDict.mDictType);
  }
  if (!TextUtils.isEmpty(typedWord)) {
    suggestionsContainer.add(0,new SuggestedWordInfo(typedWord,SuggestedWordInfo.MAX_SCORE,SuggestedWordInfo.KIND_TYPED,Dictionary.DICTIONARY_USER_TYPED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
  }
  SuggestedWordInfo.removeDups(suggestionsContainer);
  final ArrayList<SuggestedWordInfo> suggestionsList;
  if (DBG && !suggestionsContainer.isEmpty()) {
    suggestionsList=getSuggestionsInfoListWithDebugInfo(typedWord,suggestionsContainer);
  }
 else {
    suggestionsList=suggestionsContainer;
  }
  callback.onGetSuggestedWords(new SuggestedWords(suggestionsList,rawSuggestions,!isPrediction && !allowsToBeAutoCorrected,hasAutoCorrection,false,isPrediction,sequenceNumber));
}

Fixed version (ground truth):
private void getSuggestedWordsForTypingInput(final WordComposer wordComposer,final String prevWordForBigram,final ProximityInfo proximityInfo,final boolean blockOffensiveWords,final boolean isCorrectionEnabled,final int[] additionalFeaturesOptions,final int sequenceNumber,final OnGetSuggestedWordsCallback callback){
  final int trailingSingleQuotesCount=wordComposer.trailingSingleQuotesCount();
  final BoundedTreeSet suggestionsSet=new BoundedTreeSet(sSuggestedWordInfoComparator,SuggestedWords.MAX_SUGGESTIONS);
  final String typedWord=wordComposer.getTypedWord();
  final String consideredWord=trailingSingleQuotesCount > 0 ? typedWord.substring(0,typedWord.length() - trailingSingleQuotesCount) : typedWord;
  LatinImeLogger.onAddSuggestedWord(typedWord,Dictionary.TYPE_USER_TYPED);
  final WordComposer wordComposerForLookup;
  if (trailingSingleQuotesCount > 0) {
    wordComposerForLookup=new WordComposer(wordComposer);
    for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
      wordComposerForLookup.deleteLast();
    }
  }
 else {
    wordComposerForLookup=wordComposer;
  }
  final ArrayList<SuggestedWordInfo> rawSuggestions;
  if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
    rawSuggestions=CollectionUtils.newArrayList();
  }
 else {
    rawSuggestions=null;
  }
  mDictionaryFacilitator.getSuggestions(wordComposerForLookup,prevWordForBigram,proximityInfo,blockOffensiveWords,additionalFeaturesOptions,SESSION_TYPING,suggestionsSet,rawSuggestions);
  final boolean isFirstCharCapitalized=wordComposer.isFirstCharCapitalized();
  final boolean isAllUpperCase=wordComposer.isAllUpperCase();
  final String firstSuggestion;
  final String whitelistedWord;
  if (suggestionsSet.isEmpty()) {
    whitelistedWord=firstSuggestion=null;
  }
 else {
    final SuggestedWordInfo firstSuggestedWordInfo=getTransformedSuggestedWordInfo(suggestionsSet.first(),mLocale,isAllUpperCase,isFirstCharCapitalized,trailingSingleQuotesCount);
    firstSuggestion=firstSuggestedWordInfo.mWord;
    if (SuggestedWordInfo.KIND_WHITELIST != firstSuggestedWordInfo.mKind) {
      whitelistedWord=null;
    }
 else {
      whitelistedWord=firstSuggestion;
    }
  }
  final boolean isPrediction=!wordComposer.isComposingWord();
  final boolean allowsToBeAutoCorrected=(null != whitelistedWord && !whitelistedWord.equals(consideredWord)) || (consideredWord.length() > 1 && !mDictionaryFacilitator.isValidWord(consideredWord,wordComposer.isFirstCharCapitalized()) && !consideredWord.equals(firstSuggestion));
  final boolean hasAutoCorrection;
  if (!isCorrectionEnabled || !allowsToBeAutoCorrected || isPrediction|| suggestionsSet.isEmpty()|| wordComposer.hasDigits()|| wordComposer.isMostlyCaps()|| wordComposer.isResumed()|| !mDictionaryFacilitator.hasMainDictionary()|| SuggestedWordInfo.KIND_SHORTCUT == suggestionsSet.first().mKind) {
    hasAutoCorrection=false;
  }
 else {
    hasAutoCorrection=AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(suggestionsSet.first(),consideredWord,mAutoCorrectionThreshold);
  }
  final ArrayList<SuggestedWordInfo> suggestionsContainer=CollectionUtils.newArrayList(suggestionsSet);
  final int suggestionsCount=suggestionsContainer.size();
  if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) {
    for (int i=0; i < suggestionsCount; ++i) {
      final SuggestedWordInfo wordInfo=suggestionsContainer.get(i);
      final SuggestedWordInfo transformedWordInfo=getTransformedSuggestedWordInfo(wordInfo,mLocale,isAllUpperCase,isFirstCharCapitalized,trailingSingleQuotesCount);
      suggestionsContainer.set(i,transformedWordInfo);
    }
  }
  for (int i=0; i < suggestionsCount; ++i) {
    final SuggestedWordInfo wordInfo=suggestionsContainer.get(i);
    LatinImeLogger.onAddSuggestedWord(wordInfo.mWord.toString(),wordInfo.mSourceDict.mDictType);
  }
  if (!TextUtils.isEmpty(typedWord)) {
    suggestionsContainer.add(0,new SuggestedWordInfo(typedWord,SuggestedWordInfo.MAX_SCORE,SuggestedWordInfo.KIND_TYPED,Dictionary.DICTIONARY_USER_TYPED,SuggestedWordInfo.NOT_AN_INDEX,SuggestedWordInfo.NOT_A_CONFIDENCE));
  }
  SuggestedWordInfo.removeDups(suggestionsContainer);
  final ArrayList<SuggestedWordInfo> suggestionsList;
  if (DBG && !suggestionsContainer.isEmpty()) {
    suggestionsList=getSuggestionsInfoListWithDebugInfo(typedWord,suggestionsContainer);
  }
 else {
    suggestionsList=suggestionsContainer;
  }
  callback.onGetSuggestedWords(new SuggestedWords(suggestionsList,rawSuggestions,!isPrediction && !allowsToBeAutoCorrected,hasAutoCorrection,false,isPrediction,sequenceNumber));
}