### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.workbench Index: Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java,v retrieving revision 1.16 diff -u -r1.16 SearchPattern.java --- Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java 9 May 2007 14:51:35 -0000 1.16 +++ Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java 24 May 2007 18:54:20 -0000 @@ -17,7 +17,7 @@ * *

* This class is intended to be subclassed by clients. A default behavior is - * provided for each of the methods above, that clients can override if they + * provided for each of the methods above, that clients can ovveride if they * wish. *

* @@ -207,17 +207,17 @@ return; } - if (last == END_SYMBOL || last == BLANK) { - matchRule = RULE_EXACT_MATCH; - stringPattern = pattern.substring(0, length - 1); - return; - } - if (validateMatchRule(pattern, RULE_CAMELCASE_MATCH) == RULE_CAMELCASE_MATCH) { matchRule = RULE_CAMELCASE_MATCH; stringPattern = pattern; return; } + + if (last == END_SYMBOL || last == BLANK) { + matchRule = RULE_EXACT_MATCH; + stringPattern = pattern.substring(0, length - 1); + return; + } matchRule = RULE_PREFIX_MATCH; stringPattern = pattern; @@ -437,6 +437,12 @@ return false; } + int patternLength = patternEnd; + + if (pattern.charAt(patternEnd - 1) == END_SYMBOL || pattern.charAt(patternEnd - 1) == BLANK ) + patternLength = patternEnd - 1; + + char patternChar, nameChar; int iPattern = patternStart; int iName = nameStart; @@ -453,6 +459,8 @@ } if (iName == nameEnd) { + if (iPattern == patternLength) + return true; // We have exhausted name (and not pattern), so it's not a match return false; } @@ -472,13 +480,21 @@ // name while (true) { if (iName == nameEnd) { - // We have exhausted name (and not pattern), so it's not a - // match + if ((iPattern == patternLength) && (patternChar == END_SYMBOL || patternChar == BLANK)) + return true; return false; } nameChar = name.charAt(iName); + if ((iPattern == patternLength) && (patternChar == END_SYMBOL || patternChar == BLANK)) { + if (isNameCharAllowed(nameChar)) { + return false; + } + iName++; + continue; + } + if (!isNameCharAllowed(nameChar)) { // nameChar is lowercase iName++; @@ -505,7 +521,8 @@ * @return true if patternChar is in set of allowed characters for pattern */ protected boolean isPatternCharAllowed(char patternChar) { - return Character.isUpperCase(patternChar); + return Character.isUpperCase(patternChar) || patternChar == END_SYMBOL + || patternChar == BLANK; } /** #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java,v retrieving revision 1.25 diff -u -r1.25 FilteredTypesSelectionDialog.java --- ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java 30 Apr 2007 14:47:11 -0000 1.25 +++ ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java 24 May 2007 18:54:24 -0000 @@ -110,8 +110,8 @@ import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.TypeNameMatchLabelProvider; import org.eclipse.jdt.internal.ui.viewsupport.ColoredJavaElementLabels; -import org.eclipse.jdt.internal.ui.viewsupport.ColoredViewersManager; import org.eclipse.jdt.internal.ui.viewsupport.ColoredString; +import org.eclipse.jdt.internal.ui.viewsupport.ColoredViewersManager; import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; import org.eclipse.jdt.internal.ui.viewsupport.OwnerDrawSupport; import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup; @@ -566,15 +566,40 @@ SearchEngine engine= new SearchEngine((WorkingCopyOwner) null); String packPattern= typeSearchFilter.getPackagePattern(); progressMonitor.setTaskName(JavaUIMessages.FilteredTypesSelectionDialog_searchJob_taskName); + /* - * Setting the filter into match everything mode avoids filtering twice by the same pattern - * (the search engine only provides filtered matches). + * Setting the filter into match everything mode avoids filtering twice + * by the same pattern (the search engine only provides filtered + * matches). For the case when the pattern is a camel case pattern with + * a terminator, the filter is not set to match everything mode because + * it handles this case wrong. */ - typeSearchFilter.setMatchEverythingMode(true); + String tempPatternString = itemsFilter.getPattern(); + SearchPattern searchPattern = new SearchPattern(); + searchPattern.setPattern(tempPatternString); + + if (searchPattern.getMatchRule() == SearchPattern.RULE_CAMELCASE_MATCH) { + /* + * If the pattern is empty, the RULE_BLANK_MATCH will be chose, so + * we don't have to check the pattern length + */ + String lastChar = tempPatternString.substring(tempPatternString + .length() - 1); + + if (lastChar.equals("<") || lastChar.equals(" ")) { //$NON-NLS-1$//$NON-NLS-2$ + tempPatternString = tempPatternString.substring(0, + tempPatternString.length() - 1); + } else { + typeSearchFilter.setMatchEverythingMode(true); + } + } else { + typeSearchFilter.setMatchEverythingMode(true); + } + try { engine.searchAllTypeNames(packPattern == null ? null : packPattern.toCharArray(), typeSearchFilter.getPackageFlags(), //TODO: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176017 - typeSearchFilter.getPattern().toCharArray(), + tempPatternString.toCharArray(), typeSearchFilter.getMatchRule(), //TODO: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176017 typeSearchFilter.getElementKind(), typeSearchFilter.getSearchScope(),