From 0da9a7c094ed29f680f1ab9d4a27194a84c593c3 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 26 Jun 2012 18:36:00 +0900 Subject: [PATCH] Convert a member to a local variable (A1) Change-Id: I9eab910989443704f83711cf4fb0070c5987a13a --- .../android/inputmethod/latin/Suggest.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 03ed9d98c..6f7a23a15 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -86,7 +86,6 @@ public class Suggest { private float mAutoCorrectionThreshold; - private ArrayList mSuggestions = new ArrayList(); private CharSequence mConsideredWord; // TODO: Remove these member variables by passing more context to addWord() callback method @@ -220,7 +219,8 @@ public class Suggest { mIsFirstCharCapitalized = !isPrediction && wordComposer.isFirstCharCapitalized(); mIsAllUpperCase = !isPrediction && wordComposer.isAllUpperCase(); mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount(); - mSuggestions = new ArrayList(MAX_SUGGESTIONS); + final ArrayList suggestions = + new ArrayList(MAX_SUGGESTIONS); final String typedWord = wordComposer.getTypedWord(); final String consideredWord = mTrailingSingleQuotesCount > 0 @@ -243,15 +243,15 @@ public class Suggest { for (final String key : mDictionaries.keySet()) { final int dicTypeId = sDictKeyToDictIndex.get(key); final Dictionary dictionary = mDictionaries.get(key); - final ArrayList suggestions = + final ArrayList localSuggestions = dictionary.getBigrams(wordComposer, prevWordForBigram); 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(); 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; final int dicTypeId = sDictKeyToDictIndex.get(key); final Dictionary dictionary = mDictionaries.get(key); - final ArrayList suggestions = dictionary.getWords( + final ArrayList localSuggestions = dictionary.getWords( wordComposerForLookup, prevWordForBigram, proximityInfo); - for (final SuggestedWordInfo suggestion : suggestions) { + for (final SuggestedWordInfo suggestion : localSuggestions) { final String suggestionStr = suggestion.mWord.toString(); 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) { final CharSequence autoCorrection = AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer, - mSuggestions, consideredWord, mAutoCorrectionThreshold, + suggestions, consideredWord, mAutoCorrectionThreshold, whitelistedWord); hasAutoCorrection = (null != autoCorrection); } else { @@ -302,25 +302,25 @@ public class Suggest { for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) { 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)); } else { - mSuggestions.add(0, new SuggestedWordInfo(whitelistedWord, + suggestions.add(0, new SuggestedWordInfo(whitelistedWord, SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST)); } } if (!isPrediction) { - mSuggestions.add(0, new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE, + suggestions.add(0, new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED)); } - SuggestedWordInfo.removeDups(mSuggestions); + SuggestedWordInfo.removeDups(suggestions); final ArrayList suggestionsList; - if (DBG && !mSuggestions.isEmpty()) { - suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, mSuggestions); + if (DBG && !suggestions.isEmpty()) { + suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, suggestions); } else { - suggestionsList = mSuggestions; + suggestionsList = suggestions; } // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"