MinusculeMatcher: relax digit matching

This commit is contained in:
peter
2015-07-20 17:20:57 +02:00
parent a524c37c2c
commit 14be56ee7c
2 changed files with 11 additions and 2 deletions
@@ -430,6 +430,8 @@ public class NameUtilMatchingTest extends UsefulTestCase {
assertMatches("*TEST-* ", "TEST-001");
assertMatches("*TEST-0* ", "TEST-001");
assertMatches("*v2 ", "VARCHAR2");
assertMatches("smart8co", "SmartType18CompletionTest");
assertMatches("smart8co", "smart18completion");
}
public void testSpecialSymbols() {
@@ -117,6 +117,13 @@ public class MinusculeMatcher implements Matcher {
return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1));
}
private static int nextWord(@NotNull String name, int start) {
if (start < name.length() && Character.isDigit(name.charAt(start))) {
return start + 1; //treat each digit as a separate hump
}
return NameUtil.nextWord(name, start);
}
private boolean hasWildCards() {
for (int i = 0; i < myPattern.length; i++) {
if (isWildcard(i)) {
@@ -177,7 +184,7 @@ public class MinusculeMatcher implements Matcher {
if (nextHumpStart == i) {
isHumpStart = true;
}
nextHumpStart = NameUtil.nextWord(name, nextHumpStart);
nextHumpStart = nextWord(name, nextHumpStart);
if (first != range) {
humpIndex++;
}
@@ -457,7 +464,7 @@ public class MinusculeMatcher implements Matcher {
}
int nextWordStart = startFrom;
while (true) {
nextWordStart = NameUtil.nextWord(name, nextWordStart);
nextWordStart = nextWord(name, nextWordStart);
if (nextWordStart >= name.length()) {
return -1;
}