mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove plus-related hacks from MinusculeMatcher, move NameUtil.isWordStart closer to its usages
This commit is contained in:
@@ -73,7 +73,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
int i = 0;
|
||||
while (isWildcard(i)) i++;
|
||||
myHasHumps = hasFlag(i + 1, isUpperCase) && hasFlag(i, isLowerCase) || pattern.contains("+");
|
||||
myHasHumps = hasFlag(i + 1, isUpperCase) && hasFlag(i, isLowerCase);
|
||||
myHasSeparators = hasFlag(i, isWordSeparator);
|
||||
myHasDots = hasDots(i);
|
||||
myHasWildCards = hasWildCards();
|
||||
@@ -83,6 +83,24 @@ public class MinusculeMatcher implements Matcher {
|
||||
return Character.isWhitespace(c) || c == '_' || c == '-' || c == ':' || c == '+';
|
||||
}
|
||||
|
||||
private static boolean isWordStart(String text, int i) {
|
||||
char c = text.charAt(i);
|
||||
if (Character.isUpperCase(c)) {
|
||||
if (i > 0 && Character.isUpperCase(text.charAt(i - 1))) {
|
||||
// check that we're not in the middle of an all-caps word
|
||||
return i + 1 < text.length() && Character.isLowerCase(text.charAt(i + 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Character.isDigit(c)) {
|
||||
return true;
|
||||
}
|
||||
if (!Character.isLetter(c)) {
|
||||
return false;
|
||||
}
|
||||
return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1));
|
||||
}
|
||||
|
||||
private boolean hasWildCards() {
|
||||
for (int i = 0; i < myPattern.length; i++) {
|
||||
if (isWildcard(i)) {
|
||||
@@ -163,7 +181,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
|
||||
int startIndex = first.getStartOffset();
|
||||
boolean afterSeparator = StringUtil.indexOfAny(name, HARD_SEPARATORS, 0, startIndex) >= 0;
|
||||
boolean wordStart = startIndex == 0 || NameUtil.isWordStart(name, startIndex) && !NameUtil.isWordStart(name, startIndex - 1);
|
||||
boolean wordStart = startIndex == 0 || isWordStart(name, startIndex) && !isWordStart(name, startIndex - 1);
|
||||
|
||||
return (wordStart ? 1000 : 0) - integral * 10 + matchingCase + (afterSeparator ? 0 : 1);
|
||||
}
|
||||
@@ -275,7 +293,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
// uppercase should match either uppercase or a word start
|
||||
if (!isUpperCase[patternIndex] ||
|
||||
star && Character.isUpperCase(name.charAt(nextOccurrence)) ||
|
||||
NameUtil.isWordStart(name, nextOccurrence)) {
|
||||
isWordStart(name, nextOccurrence)) {
|
||||
FList<TextRange> ranges = matchFragment(name, patternIndex, nextOccurrence, matchingState);
|
||||
if (ranges != null) {
|
||||
return ranges;
|
||||
@@ -320,7 +338,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
|
||||
// middle matches have to be at least of length 3, to prevent too many irrelevant matches
|
||||
int minFragment = isPatternChar(patternIndex - 1, '*') && !isWildcard(patternIndex + 1) &&
|
||||
Character.isLetterOrDigit(name.charAt(nameIndex)) && !NameUtil.isWordStart(name, nameIndex)
|
||||
Character.isLetterOrDigit(name.charAt(nameIndex)) && !isWordStart(name, nameIndex)
|
||||
? 3 : 1;
|
||||
int i = 1;
|
||||
boolean ignoreCase = myOptions != NameUtil.MatchingCaseSensitivity.ALL;
|
||||
|
||||
@@ -326,24 +326,6 @@ public class NameUtil {
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
static boolean isWordStart(String text, int i) {
|
||||
char c = text.charAt(i);
|
||||
if (Character.isUpperCase(c)) {
|
||||
if (i > 0 && Character.isUpperCase(text.charAt(i - 1))) {
|
||||
// check that we're not in the middle of an all-caps word
|
||||
return i + 1 < text.length() && Character.isLowerCase(text.charAt(i + 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Character.isDigit(c) || c == '+') {
|
||||
return true;
|
||||
}
|
||||
if (!Character.isLetter(c)) {
|
||||
return false;
|
||||
}
|
||||
return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1));
|
||||
}
|
||||
|
||||
static boolean isWordStart(char p) {
|
||||
return Character.isUpperCase(p) || Character.isDigit(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user