### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/search/StringOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/StringOperation.java,v retrieving revision 1.1 diff -u -r1.1 StringOperation.java --- search/org/eclipse/jdt/internal/core/search/StringOperation.java 12 Feb 2009 15:27:02 -0000 1.1 +++ search/org/eclipse/jdt/internal/core/search/StringOperation.java 13 Feb 2009 12:26:30 -0000 @@ -18,6 +18,8 @@ */ public final class StringOperation { + private final static int[] EMPTY_REGIONS = new int[0]; + /** * Answers all the regions in a given name matching a given camel case pattern. *

@@ -85,8 +87,11 @@ if (name == null) return null; // null name cannot match - if (pattern == null) - return new int[] { patternStart, patternEnd-patternStart }; // null pattern is equivalent to '*' + if (pattern == null) { + // null pattern cannot match any region + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816 + return EMPTY_REGIONS; + } if (patternEnd < 0) patternEnd = pattern.length(); if (nameEnd < 0) nameEnd = name.length(); @@ -293,9 +298,10 @@ */ if (name == null) return null; // null name cannot match - if (pattern == null || pattern.equals("*")) { //$NON-NLS-1$ - // null and '*' patterns match the entire name - return new int[] { nameStart, nameEnd-nameStart }; + if (pattern == null) { + // null pattern cannot match any region + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816 + return EMPTY_REGIONS; } int iPattern = patternStart; int iName = nameStart; @@ -330,6 +336,10 @@ previous = ch; } int[] segments = new int[parts*2]; + if (parts == 0) { + if (questions <= (nameEnd - nameStart)) return segments; + return null; + } /* check first segment */ int count = 0; Index: search/org/eclipse/jdt/core/search/SearchPattern.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java,v retrieving revision 1.80 diff -u -r1.80 SearchPattern.java --- search/org/eclipse/jdt/core/search/SearchPattern.java 12 Feb 2009 15:27:02 -0000 1.80 +++ search/org/eclipse/jdt/core/search/SearchPattern.java 13 Feb 2009 12:26:30 -0000 @@ -732,7 +732,9 @@ * pattern match behavior * * @param pattern the given pattern. If null, - * then the returned region will be the entire given name. + * then an empty region (new int[0]) will be returned to let + * the client know that the name matches the pattern but no common + * character has been found. * @param name the given name * @param matchRule the rule to apply for the comparison.
* The following values are accepted: @@ -762,15 +764,16 @@ *

  • etc.
  • * * @return an array of int having two slots per returned - * regions: the first one is the region starting index and the second one - * is the region length. + * regions (the first one is the region starting index and the second one + * is the region length or null if the given name does not + * match the given pattern). *

    - * The returned region may be the entire given name if the given pattern - * is either null (whatever the match rule is) or - * '*' with a pattern match rule. - *

    - * May also be null if the given name does not match - * the given pattern. + * The returned regions may be empty (new int[0]) if the + * pattern is null (whatever the match rule is). The returned + * regions will also be empty if the pattern is only made of '?' + * and/or '*' character(s) (e.g. '*', + * '?*', '???', etc.) when using a pattern + * match rule. *

    * * @since 3.5 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java,v retrieving revision 1.1 diff -u -r1.1 MatchingRegionsTest.java Binary files /tmp/cvsgUiQHZ and MatchingRegionsTest.java differ