Java: don't generate past participle name suggestion when the word contains anything other than an ascii letter

GitOrigin-RevId: e0271568a5b61d073b344c200c1ebf3490840930
This commit is contained in:
Bas Leijdekkers
2023-02-05 14:06:11 +00:00
committed by intellij-monorepo-bot
parent 8ee2687772
commit 272585bf3c
2 changed files with 10 additions and 2 deletions
@@ -115,6 +115,7 @@ public class PastParticipleTest {
assertEquals("matches", pastParticiple("matches"));
assertEquals("equals", pastParticiple("equals"));
assertEquals("of", pastParticiple("of"));
//assertEquals("running", generatePastParticiple("running"));
assertEquals("проблем", pastParticiple("проблем"));
assertEquals("string1", pastParticiple("string1"));
}
}
@@ -105,9 +105,16 @@ public class PastParticiple {
char c1 = toLowerCase(verb.charAt(length - 1));
char c2 = toLowerCase(verb.charAt(length - 2));
if (c1 == 's' && (c2 == 'e' || c2 == 'l')) return true;
for (int i = 0; i < length; i++) {
if (!isAsciiLetter(verb.charAt(i))) return true;
}
return false;
}
private static boolean isAsciiLetter(char c) {
return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z';
}
private static char toLowerCase(char c) {
return (char)(c | 0x20); // cheap hack
}