View | Details | Raw Unified | Return to bug 264816 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/StringOperation.java (-5 / +15 lines)
Lines 18-23 Link Here
18
 */
18
 */
19
public final class StringOperation {
19
public final class StringOperation {
20
20
21
	private final static int[] EMPTY_REGIONS = new int[0];
22
21
/**
23
/**
22
 * Answers all the regions in a given name matching a given camel case pattern.
24
 * Answers all the regions in a given name matching a given camel case pattern.
23
 * </p><p>
25
 * </p><p>
Lines 85-92 Link Here
85
87
86
	if (name == null)
88
	if (name == null)
87
		return null; // null name cannot match
89
		return null; // null name cannot match
88
	if (pattern == null)
90
	if (pattern == null) {
89
		return new int[] { patternStart, patternEnd-patternStart }; // null pattern is equivalent to '*'
91
		// null pattern cannot match any region
92
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816
93
		return EMPTY_REGIONS;
94
	}
90
	if (patternEnd < 0) 	patternEnd = pattern.length();
95
	if (patternEnd < 0) 	patternEnd = pattern.length();
91
	if (nameEnd < 0) nameEnd = name.length();
96
	if (nameEnd < 0) nameEnd = name.length();
92
97
Lines 293-301 Link Here
293
	 */
298
	 */
294
299
295
	if (name == null) return null; // null name cannot match
300
	if (name == null) return null; // null name cannot match
296
	if (pattern == null || pattern.equals("*")) {	//$NON-NLS-1$
301
	if (pattern == null) {
297
		// null and '*' patterns match the entire name
302
		// null pattern cannot match any region
298
		return new int[] { nameStart, nameEnd-nameStart };
303
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816
304
		return EMPTY_REGIONS;
299
	}
305
	}
300
	int iPattern = patternStart;
306
	int iPattern = patternStart;
301
	int iName = nameStart;
307
	int iName = nameStart;
Lines 330-335 Link Here
330
		previous = ch;
336
		previous = ch;
331
	}
337
	}
332
	int[] segments = new int[parts*2];
338
	int[] segments = new int[parts*2];
339
	if (parts == 0) {
340
		if (questions <= (nameEnd - nameStart)) return segments;
341
		return null;
342
	}
333
343
334
	/* check first segment */
344
	/* check first segment */
335
	int count = 0;
345
	int count = 0;
(-)search/org/eclipse/jdt/core/search/SearchPattern.java (-9 / +12 lines)
Lines 732-738 Link Here
732
 * 	pattern match behavior
732
 * 	pattern match behavior
733
 *
733
 *
734
 * @param pattern the given pattern. If <code>null</code>,
734
 * @param pattern the given pattern. If <code>null</code>,
735
 * 	then the returned region will be the entire given name.
735
 * 	then an empty region (<code>new int[0]</code>) will be returned to let
736
 * 	the client know that the name matches the pattern but no common
737
 * 	character has been found.
736
 * @param name the given name
738
 * @param name the given name
737
 * @param matchRule the rule to apply for the comparison.<br>
739
 * @param matchRule the rule to apply for the comparison.<br>
738
 *     The following values are accepted:
740
 *     The following values are accepted:
Lines 762-776 Link Here
762
 *         <li>etc.</li>
764
 *         <li>etc.</li>
763
 *     </ul>
765
 *     </ul>
764
 * @return an array of <code>int</code> having two slots per returned
766
 * @return an array of <code>int</code> having two slots per returned
765
 *     regions: the first one is the region starting index and the second one
767
 *     regions (the first one is the region starting index and the second one
766
 *     is the region length.
768
 *     is the region length or <code>null</code> if the given name does not
769
 *     match the given pattern).
767
 *     <p>
770
 *     <p>
768
 *     The returned region may be the entire given name if the given pattern
771
 *     The returned regions may be empty (<code>new int[0]</code>) if the
769
 *     is either <code>null</code> (whatever the match rule is) or
772
 *     pattern is <code>null</code> (whatever the match rule is). The returned
770
 *     <code>'*'</code>  with a pattern match rule.
773
 *     regions will also be empty if the pattern is only made of <code>'?'</code>
771
 *     </p><p>
774
 *     and/or <code>'*'</code> character(s) (e.g. <code>'*'</code>,
772
 *     May also be <code>null</code> if the given name does not match
775
 *     <code>'?*'</code>, <code>'???'</code>, etc.) when using a pattern
773
 *     the given pattern.
776
 *     match rule.
774
 *     </p>
777
 *     </p>
775
 * 
778
 * 
776
 * @since 3.5
779
 * @since 3.5

Return to bug 264816