only cross space/parenthesis border in matcher when the pattern has those characters

This commit is contained in:
peter
2012-07-27 17:42:59 +02:00
parent a8843ed4a0
commit 9b430f7f2d
3 changed files with 35 additions and 6 deletions
@@ -227,9 +227,21 @@ public class NameUtilTest extends UsefulTestCase {
}
public void testFileStructure() {
assertMatches("hint", "height:int");
assertDoesntMatch("hint", "height: int");
assertDoesntMatch("Hint", "Height:int");
assertMatches("getColor", "getBackground():Color");
assertMatches("getColor", "getBackground(): Color");
assertMatches("get color", "getBackground(): Color");
assertDoesntMatch("getcolor", "getBackground(): Color");
assertMatches("get()", "getBackground(): Color");
assertMatches("setColor", "setBackground(Color): void");
assertMatches("set color", "setBackground(Color): void");
assertMatches("set Color", "setBackground(Color): void");
assertMatches("set(color", "setBackground(Color): void");
assertMatches("set(color)", "setBackground(Color): void");
assertDoesntMatch("setcolor", "setBackground(Color): void");
}
public void testMiddleMatchingMinimumTwoConsecutiveLettersInWordMiddle() {
@@ -317,7 +329,7 @@ public class NameUtilTest extends UsefulTestCase {
assertMatches("ncdfoe", "NoClassDefFoundException");
assertMatches("fob", "FOO_BAR");
assertMatches("fo_b", "FOO_BAR");
assertMatches("fob", "FOO BAR");
assertDoesntMatch("fob", "FOO BAR");
assertMatches("fo b", "FOO BAR");
assertMatches("AACl", "AAClass");
assertMatches("ZZZ", "ZZZZZZZZZZ");
@@ -1331,8 +1331,16 @@ public class StringUtil extends StringUtilRt {
}
public static boolean containsAnyChar(@NotNull final String value, @NotNull final String chars) {
for (int i = 0; i < chars.length(); i++) {
if (containsChar(value, chars.charAt(i))) return true;
return containsAnyChar(value, chars, 0, value.length());
}
public static boolean containsAnyChar(@NotNull final String value,
@NotNull final String chars,
final int start, final int end) {
for (int i = start; i < end; i++) {
if (chars.indexOf(value.charAt(i)) >= 0) {
return true;
}
}
return false;
@@ -211,7 +211,16 @@ public class MinusculeMatcher implements Matcher {
return i >= minFragment ? FList.<TextRange>emptyList().prepend(TextRange.from(nameIndex, i)) : null;
}
while (i >= minFragment) {
int nextWordStart = isWildcard(patternIndex + i) ? nameIndex + i : indexOfWordStart(name, patternIndex + i, nameIndex + i);
int nextWordStart;
if (isWildcard(patternIndex + i)) {
nextWordStart = nameIndex + i;
}
else {
nextWordStart = indexOfWordStart(name, patternIndex + i, nameIndex + i);
if (!myHasHumps && StringUtil.containsAnyChar(name, " ()", nameIndex + i, nextWordStart)) {
nextWordStart = -1;
}
}
FList<TextRange> ranges = matchWildcards(name, patternIndex + i, nextWordStart);
if (ranges != null) {
return prependRange(ranges, nameIndex, i);