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

Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/SearchPattern.java (-38 / +59 lines)
Lines 746-756 Link Here
746
	return new AndPattern(leftPattern, rightPattern);
746
	return new AndPattern(leftPattern, rightPattern);
747
}
747
}
748
748
749
/**
750
 * Field pattern are formed by [declaringType.]name[ type]
751
 * e.g. java.lang.String.serialVersionUID long
752
 *		field*
753
 */
754
private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchRule) {
749
private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchRule) {
755
	
750
	
756
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 
751
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 
Lines 867-890 Link Here
867
			matchRule);
862
			matchRule);
868
}
863
}
869
864
870
/**
871
 * Method pattern are formed by:<br>
872
 * 	[declaringType '.'] ['&lt;' typeArguments '&gt;'] selector ['(' parameterTypes ')'] [returnType]
873
 *		<br>e.g.<ul>
874
 *			<li>java.lang.Runnable.run() void</li>
875
 *			<li>main(*)</li>
876
 *			<li>&lt;String&gt;toArray(String[])</li>
877
 *		</ul>
878
 * Constructor pattern are formed by:<br>
879
 *		[declaringQualification '.'] ['&lt;' typeArguments '&gt;'] type ['(' parameterTypes ')']
880
 *		<br>e.g.<ul>
881
 *			<li>java.lang.Object()</li>
882
 *			<li>Main(*)</li>
883
 *			<li>&lt;Exception&gt;Sample(Exception)</li>
884
 *		</ul>
885
 * Type arguments have the same pattern that for type patterns
886
 * @see #createTypePattern(String,int,int,char)
887
 */
888
private static SearchPattern createMethodOrConstructorPattern(String patternString, int limitTo, int matchRule, boolean isConstructor) {
865
private static SearchPattern createMethodOrConstructorPattern(String patternString, int limitTo, int matchRule, boolean isConstructor) {
889
	
866
	
890
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 
867
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 
Lines 918-924 Link Here
918
						case TerminalTokens.TokenNameLESS:
895
						case TerminalTokens.TokenNameLESS:
919
							argCount++;
896
							argCount++;
920
							if (selector == null || lastToken == TerminalTokens.TokenNameDOT) {
897
							if (selector == null || lastToken == TerminalTokens.TokenNameDOT) {
921
								if (typeArgumentsString != null) return null; // invalid syntax
922
								typeArgumentsString = scanner.getCurrentTokenString();
898
								typeArgumentsString = scanner.getCurrentTokenString();
923
								mode = InsideTypeArguments;
899
								mode = InsideTypeArguments;
924
								break;
900
								break;
Lines 932-938 Link Here
932
							selector = null;
908
							selector = null;
933
							break;
909
							break;
934
						case TerminalTokens.TokenNameDOT:
910
						case TerminalTokens.TokenNameDOT:
935
							if (typeArgumentsString != null) return null; // invalid syntax
911
							if (!isConstructor && typeArgumentsString != null) return null; // invalid syntax
936
							if (declaringType == null) {
912
							if (declaringType == null) {
937
								if (selector == null) return null; // invalid syntax
913
								if (selector == null) return null; // invalid syntax
938
								declaringType = selector;
914
								declaringType = selector;
Lines 1295-1300 Link Here
1295
 *			<code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code></li>
1271
 *			<code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code></li>
1296
 *  </ul>
1272
 *  </ul>
1297
 * @param stringPattern the given pattern
1273
 * @param stringPattern the given pattern
1274
 * <ul>
1275
 * 	<li>Type pattern can have the following syntax:
1276
 * 		<p><b><code>[qualification '.']type ['&lt;' typeArguments '&gt;']</code></b></p>
1277
 *			<p>Some samples:<code>
1278
 *			<ul>
1279
 * 			<li>java.lang.Object</li>
1280
 *				<li>Runnable</li>
1281
 *				<li>List&lt;String&gt;</li>
1282
 *			</ul>
1283
 *			</code>
1284
 *			</p><p>
1285
 *			Type arguments can be specified to search references to parameterized types
1286
 * 		using following syntax:</p><p>
1287
 * 		<b><code>'&lt;' { [ '?' {'extends'|'super'} ] type ( ',' [ '?' {'extends'|'super'} ] type )* | '?' } '&gt;'</code></b>
1288
 * 		</p><p><i>
1289
 * 		Note that:
1290
 * 		<ul>
1291
 * 			<li>'*' is not valid inside type arguments definition &lt;&gt;</li>
1292
 * 			<li>'?' is treated as a wildcard when it is inside &lt;&gt; (i.e. it must be put on first position of the type argument)</li>
1293
 * 		</ul>
1294
 * 		</i></p>
1295
 * 	</li>
1296
 * 	<li>Method pattern can have the following syntax:
1297
 * 		<p><b><code>[declaringType '.'] ['&lt;' typeArguments '&gt;'] selector ['(' parameterTypes ')'] [returnType]</code></b></p>
1298
 *			 <p>Type arguments have the same pattern that for type patterns</p>
1299
	 *		<p>Some samples:<code>
1300
 *			<ul>
1301
 *				<li>java.lang.Runnable.run() void</li>
1302
 *				<li>main(*)</li>
1303
 *				<li>&lt;String&gt;toArray(String[])</li>
1304
 *			</ul>
1305
 *			</code>
1306
 *			</p>
1307
 *		</li>
1308
 * 	<li>Constructor pattern can have the following syntax:
1309
 *			<p><b><code>['&lt;' typeArguments '&gt;'] [declaringQualification '.'] type ['(' parameterTypes ')']</code></b></p>
1310
 *			<p>Type arguments have the same pattern that for type patterns</p>
1311
 *			<p>Some samples:<code>
1312
 *			<ul>
1313
 *				<li>java.lang.Object()</li>
1314
 *				<li>Test(*)</li>
1315
 *				<li>&lt;Exception&gt;Sample(Exception)</li>
1316
 *			</ul>
1317
 *			</code>
1318
 *			 </p>
1319
 * 	</li>
1320
 * 	<li>Field pattern can have the following syntax:
1321
 *			<p><b><code>[declaringType.]name[ type]</code></b></p>
1322
 *			<p>Some samples:<code>
1323
 *			<ul>
1324
 *				<li>java.lang.String.serialVersionUID long</li>
1325
 *				<li>field*</li>
1326
 *			</ul>
1327
 *			</code>
1328
 *			</p>
1329
 * 	</li>
1330
 * </ul>
1298
 * @param searchFor determines the nature of the searched elements
1331
 * @param searchFor determines the nature of the searched elements
1299
 *	<ul>
1332
 *	<ul>
1300
 * 	<li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
1333
 * 	<li>{@link IJavaSearchConstants#CLASS}: only look for classes</li>
Lines 1808-1826 Link Here
1808
	}
1841
	}
1809
	return null;
1842
	return null;
1810
}
1843
}
1811
/**
1844
1812
 * Type pattern are formed by [qualification '.']type [typeArguments].
1813
 * e.g. java.lang.Object
1814
 *		Runnable
1815
 *		List&lt;String&gt;
1816
 *
1817
 * @since 3.1
1818
 *		Type arguments can be specified to search references to parameterized types.
1819
 * 	and look as follow: '&lt;' { [ '?' {'extends'|'super'} ] type ( ',' [ '?' {'extends'|'super'} ] type )* | '?' } '&gt;'
1820
 * 	Please note that:
1821
 * 		- '*' is not valid inside type arguments definition &lt;&gt;
1822
 * 		- '?' is treated as a wildcard when it is inside &lt;&gt; (i.e. it must be put on first position of the type argument)
1823
 */
1824
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
1845
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
1825
	
1846
	
1826
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 
1847
	Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); 

Return to bug 208260