Merge "Convert a member to a local variable (A1)"

main
Jean Chalard 2012-06-26 02:46:39 -07:00 committed by Android (Google) Code Review
commit 0f455ae2a6
1 changed files with 17 additions and 17 deletions

View File

@ -86,7 +86,6 @@ public class Suggest {
private float mAutoCorrectionThreshold; private float mAutoCorrectionThreshold;
private ArrayList<SuggestedWordInfo> mSuggestions = new ArrayList<SuggestedWordInfo>();
private CharSequence mConsideredWord; private CharSequence mConsideredWord;
// TODO: Remove these member variables by passing more context to addWord() callback method // TODO: Remove these member variables by passing more context to addWord() callback method
@ -220,7 +219,8 @@ public class Suggest {
mIsFirstCharCapitalized = !isPrediction && wordComposer.isFirstCharCapitalized(); mIsFirstCharCapitalized = !isPrediction && wordComposer.isFirstCharCapitalized();
mIsAllUpperCase = !isPrediction && wordComposer.isAllUpperCase(); mIsAllUpperCase = !isPrediction && wordComposer.isAllUpperCase();
mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount(); mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
mSuggestions = new ArrayList<SuggestedWordInfo>(MAX_SUGGESTIONS); final ArrayList<SuggestedWordInfo> suggestions =
new ArrayList<SuggestedWordInfo>(MAX_SUGGESTIONS);
final String typedWord = wordComposer.getTypedWord(); final String typedWord = wordComposer.getTypedWord();
final String consideredWord = mTrailingSingleQuotesCount > 0 final String consideredWord = mTrailingSingleQuotesCount > 0
@ -243,15 +243,15 @@ public class Suggest {
for (final String key : mDictionaries.keySet()) { for (final String key : mDictionaries.keySet()) {
final int dicTypeId = sDictKeyToDictIndex.get(key); final int dicTypeId = sDictKeyToDictIndex.get(key);
final Dictionary dictionary = mDictionaries.get(key); final Dictionary dictionary = mDictionaries.get(key);
final ArrayList<SuggestedWordInfo> suggestions = final ArrayList<SuggestedWordInfo> localSuggestions =
dictionary.getBigrams(wordComposer, prevWordForBigram); dictionary.getBigrams(wordComposer, prevWordForBigram);
if (null != lowerPrevWord) { if (null != lowerPrevWord) {
suggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord)); localSuggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord));
} }
for (final SuggestedWordInfo suggestion : suggestions) { for (final SuggestedWordInfo suggestion : localSuggestions) {
final String suggestionStr = suggestion.mWord.toString(); final String suggestionStr = suggestion.mWord.toString();
addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(),
suggestion.mScore, dicTypeId, Dictionary.BIGRAM, mSuggestions); suggestion.mScore, dicTypeId, Dictionary.BIGRAM, suggestions);
} }
} }
} }
@ -272,12 +272,12 @@ public class Suggest {
continue; continue;
final int dicTypeId = sDictKeyToDictIndex.get(key); final int dicTypeId = sDictKeyToDictIndex.get(key);
final Dictionary dictionary = mDictionaries.get(key); final Dictionary dictionary = mDictionaries.get(key);
final ArrayList<SuggestedWordInfo> suggestions = dictionary.getWords( final ArrayList<SuggestedWordInfo> localSuggestions = dictionary.getWords(
wordComposerForLookup, prevWordForBigram, proximityInfo); wordComposerForLookup, prevWordForBigram, proximityInfo);
for (final SuggestedWordInfo suggestion : suggestions) { for (final SuggestedWordInfo suggestion : localSuggestions) {
final String suggestionStr = suggestion.mWord.toString(); final String suggestionStr = suggestion.mWord.toString();
addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(), addWord(suggestionStr.toCharArray(), null, 0, suggestionStr.length(),
suggestion.mScore, dicTypeId, Dictionary.UNIGRAM, mSuggestions); suggestion.mScore, dicTypeId, Dictionary.UNIGRAM, suggestions);
} }
} }
} }
@ -289,7 +289,7 @@ public class Suggest {
if (isCorrectionEnabled) { if (isCorrectionEnabled) {
final CharSequence autoCorrection = final CharSequence autoCorrection =
AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer, AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer,
mSuggestions, consideredWord, mAutoCorrectionThreshold, suggestions, consideredWord, mAutoCorrectionThreshold,
whitelistedWord); whitelistedWord);
hasAutoCorrection = (null != autoCorrection); hasAutoCorrection = (null != autoCorrection);
} else { } else {
@ -302,25 +302,25 @@ public class Suggest {
for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) { for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) {
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE); sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
} }
mSuggestions.add(0, new SuggestedWordInfo(sb.toString(), suggestions.add(0, new SuggestedWordInfo(sb.toString(),
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST)); SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
} else { } else {
mSuggestions.add(0, new SuggestedWordInfo(whitelistedWord, suggestions.add(0, new SuggestedWordInfo(whitelistedWord,
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST)); SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
} }
} }
if (!isPrediction) { if (!isPrediction) {
mSuggestions.add(0, new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE, suggestions.add(0, new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
SuggestedWordInfo.KIND_TYPED)); SuggestedWordInfo.KIND_TYPED));
} }
SuggestedWordInfo.removeDups(mSuggestions); SuggestedWordInfo.removeDups(suggestions);
final ArrayList<SuggestedWordInfo> suggestionsList; final ArrayList<SuggestedWordInfo> suggestionsList;
if (DBG && !mSuggestions.isEmpty()) { if (DBG && !suggestions.isEmpty()) {
suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, mSuggestions); suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, suggestions);
} else { } else {
suggestionsList = mSuggestions; suggestionsList = suggestions;
} }
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid" // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"