IDEA-63313 CamelHump immediately after digit is not taken into account

1. Corrected 'camel humps' selection when target work contains digit just before the 'hump';
2. Corresponding test is added;
This commit is contained in:
Denis Zhdanov
2011-01-25 15:51:45 +03:00
parent 96ec4da830
commit 3502c44e76
2 changed files with 14 additions and 2 deletions
@@ -165,9 +165,9 @@ public class EditorActionUtil {
if (isCamel) {
if (firstIsIdentifierPart && secondIsIdentifierPart &&
(Character.isLowerCase(prev) && Character.isUpperCase(current) ||
(isLowerCaseOrDigit(prev) && Character.isUpperCase(current) ||
prev == '_' && current != '_' ||
Character.isUpperCase(prev) && Character.isUpperCase(current) && Character.isLowerCase(next))) {
Character.isUpperCase(prev) && Character.isUpperCase(current) && isLowerCaseOrDigit(next))) {
return true;
}
}
@@ -175,6 +175,10 @@ public class EditorActionUtil {
return (Character.isWhitespace(prev) || firstIsIdentifierPart) &&
!Character.isWhitespace(current) && !secondIsIdentifierPart;
}
private static boolean isLowerCaseOrDigit(char c) {
return Character.isLowerCase(c) || Character.isDigit(c);
}
public static boolean isWordEnd(CharSequence text, int offset, boolean isCamel) {
char prev = offset > 0 ? text.charAt(offset - 1) : 0;
@@ -492,6 +492,14 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
doAction(IdeActions.ACTION_EDITOR_PASTE);
}
protected static void moveCaretToPreviousWordWithSelection() {
doAction("EditorPreviousWordWithSelection");
}
protected static void moveCaretToNextWordWithSelection() {
doAction("EditorNextWordWithSelection");
}
protected static void lineComment() {
new CommentByLineCommentHandler().invoke(getProject(), getEditor(), getFile());
}