diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java index e1d030f..ad4599d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssist.java @@ -476,9 +476,9 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor { String nsKeyword = nsPrefix == null ? keyword : (nsPrefix + keyword); - if (keyword.startsWith(wordPrefix) || - (nsPrefix != null && keyword.startsWith(nsPrefix)) || - (nsPrefix != null && nsKeyword.startsWith(wordPrefix))) { + if (startsWith(keyword, wordPrefix) || + (nsPrefix != null && startsWith(keyword, nsPrefix)) || + (nsPrefix != null && startsWith(nsKeyword, wordPrefix))) { if (nsPrefix != null) { keyword = nsPrefix + keyword; } @@ -535,6 +535,31 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor { } /** + * Returns true if the given word starts with the given prefix. The comparison is not + * case sensitive. + * + * @param word the word to test + * @param prefix the prefix the word should start with + * @return true if the given word starts with the given prefix + */ + static boolean startsWith(String word, String prefix) { + int prefixLength = prefix.length(); + int wordLength = word.length(); + if (wordLength < prefixLength) { + return false; + } + + for (int i = 0; i < prefixLength; i++) { + if (Character.toLowerCase(prefix.charAt(i)) + != Character.toLowerCase(word.charAt(i))) { + return false; + } + } + + return true; + } + + /** * Indicates whether this descriptor describes an element that can potentially * have children (either sub-elements or text value). If an element can have children, * we want to explicitly write an opening and a separate closing tag. |