diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java index 5fc411f7df22..a9f50f8423a7 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java @@ -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"); diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index a9e8e2a27794..b87274759290 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -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; diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java index d6a3fbd2b20a..c45f3a1e26ce 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java @@ -211,7 +211,16 @@ public class MinusculeMatcher implements Matcher { return i >= minFragment ? FList.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 ranges = matchWildcards(name, patternIndex + i, nextWordStart); if (ranges != null) { return prependRange(ranges, nameIndex, i);