### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/InternalNamingConventions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InternalNamingConventions.java,v retrieving revision 1.24 diff -u -r1.24 InternalNamingConventions.java --- model/org/eclipse/jdt/internal/core/InternalNamingConventions.java 20 Nov 2008 12:03:21 -0000 1.24 +++ model/org/eclipse/jdt/internal/core/InternalNamingConventions.java 5 Mar 2009 14:18:09 -0000 @@ -625,10 +625,27 @@ tempName[length+1] = 'S'; } } else if(tempName[length-1] == 'Y') { - System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length); - tempName[length-1] = 'I'; - tempName[length] = 'E'; - tempName[length+1] = 'S'; + boolean precededByAVowel = false; + if(tempName.length > 1) { + switch (tempName[length-2]) { + case 'A': + case 'E': + case 'I': + case 'O': + case 'U': + precededByAVowel = true; + break; + } + } + if (precededByAVowel) { + System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length); + tempName[length] = 'S'; + } else { + System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length); + tempName[length-1] = 'I'; + tempName[length] = 'E'; + tempName[length+1] = 'S'; + } } else { System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length); tempName[length] = 'S'; @@ -641,10 +658,27 @@ tempName[length+1] = 's'; } } else if(tempName[length-1] == 'y') { - System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length); - tempName[length-1] = 'i'; - tempName[length] = 'e'; - tempName[length+1] = 's'; + boolean precededByAVowel = false; + if(tempName.length > 1) { + switch (tempName[length-2]) { + case 'a': + case 'e': + case 'i': + case 'o': + case 'u': + precededByAVowel = true; + break; + } + } + if (precededByAVowel) { + System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length); + tempName[length] = 's'; + } else { + System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length); + tempName[length-1] = 'i'; + tempName[length] = 'e'; + tempName[length+1] = 's'; + } } else { System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length); tempName[length] = 's'; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java,v retrieving revision 1.25 diff -u -r1.25 NamingConventionTests.java --- src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java 20 Nov 2008 12:03:19 -0000 1.25 +++ src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java 5 Mar 2009 14:18:10 -0000 @@ -860,6 +860,40 @@ "INT", //$NON-NLS-1$ toString(suggestions)); } +/* + * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=260840 + */ +public void testSuggestFieldName041() { + String[] suggestions = NamingConventions.suggestVariableNames( + NamingConventions.VK_INSTANCE_FIELD, + NamingConventions.BK_TYPE_NAME, + "Key", //$NON-NLS-1$ + this.project, + 1, + new String[]{}, + true); + + assumeEquals( + "keys", //$NON-NLS-1$ + toString(suggestions)); +} +/* + * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=260840 + */ +public void testSuggestFieldName042() { + String[] suggestions = NamingConventions.suggestVariableNames( + NamingConventions.VK_STATIC_FINAL_FIELD, + NamingConventions.BK_TYPE_NAME, + "Key", //$NON-NLS-1$ + this.project, + 1, + new String[]{}, + true); + + assumeEquals( + "KEYS", //$NON-NLS-1$ + toString(suggestions)); +} /** @deprecated */ public void testRemovePrefixAndSuffixForFieldName001() { Hashtable options = JavaCore.getOptions();