1 /*******************************************************************************
2  * Copyright (c) 2000, 2019 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.core.search;
15 
16 import org.eclipse.jdt.internal.core.search.processing.*;
17 
18 /**
19  * <p>
20  * This interface defines the constants used by the search engine.
21  * </p>
22  * <p>
23  * This interface declares constants only.
24  * </p>
25  * @see org.eclipse.jdt.core.search.SearchEngine
26  * @noimplement This interface is not intended to be implemented by clients.
27  */
28 public interface IJavaSearchConstants {
29 
30 	/**
31 	 * The nature of searched element or the nature
32 	 * of match in unknown.
33 	 */
34 	int UNKNOWN = -1;
35 
36 	/* Nature of searched element */
37 
38 	/**
39 	 * The searched element is a type, which may include classes, interfaces,
40 	 * enums, and annotation types.
41 	 *
42 	 * @category searchFor
43 	 */
44 	int TYPE= 0;
45 
46 	/**
47 	 * The searched element is a method.
48 	 *
49 	 * @category searchFor
50 	 */
51 	int METHOD= 1;
52 
53 	/**
54 	 * The searched element is a package.
55 	 *
56 	 * @category searchFor
57 	 */
58 	int PACKAGE= 2;
59 
60 	/**
61 	 * The searched element is a constructor.
62 	 *
63 	 * @category searchFor
64 	 */
65 	int CONSTRUCTOR= 3;
66 
67 	/**
68 	 * The searched element is a field.
69 	 *
70 	 * @category searchFor
71 	 */
72 	int FIELD= 4;
73 
74 	/**
75 	 * The searched element is a class.
76 	 * More selective than using {@link #TYPE}.
77 	 *
78 	 * @category searchFor
79 	 */
80 	int CLASS= 5;
81 
82 	/**
83 	 * The searched element is an interface.
84 	 * More selective than using {@link #TYPE}.
85 	 *
86 	 * @category searchFor
87 	 */
88 	int INTERFACE= 6;
89 
90 	/**
91 	 * The searched element is an enum.
92 	 * More selective than using {@link #TYPE}.
93 	 *
94 	 * @since 3.1
95 	 * @category searchFor
96 	 */
97 	int ENUM= 7;
98 
99 	/**
100 	 * The searched element is an annotation type.
101 	 * More selective than using {@link #TYPE}.
102 	 *
103 	 * @since 3.1
104 	 * @category searchFor
105 	 */
106 	int ANNOTATION_TYPE= 8;
107 
108 	/**
109 	 * The searched element is a class or enum type.
110 	 * More selective than using {@link #TYPE}.
111 	 *
112 	 * @since 3.1
113 	 * @category searchFor
114 	 */
115 	int CLASS_AND_ENUM= 9;
116 
117 	/**
118 	 * The searched element is a class or interface type.
119 	 * More selective than using {@link #TYPE}.
120 	 *
121 	 * @since 3.1
122 	 * @category searchFor
123 	 */
124 	int CLASS_AND_INTERFACE= 10;
125 
126 	/**
127 	 * The searched element is an interface or annotation type.
128 	 * More selective than using {@link #TYPE}.
129 	 * @since 3.3
130 	 * @category searchFor
131 	 */
132 	int INTERFACE_AND_ANNOTATION= 11;
133 
134 	/**
135 	 * The searched element is a module.
136 	 * @since 3.14
137 	 * @category searchFor
138 	 */
139 	int MODULE= 12;
140 	/* Nature of match */
141 
142 	/**
143 	 * The search result is a declaration.
144 	 * Can be used in conjunction with any of the nature of searched elements
145 	 * so as to better narrow down the search.
146 	 *
147 	 * @category limitTo
148 	 */
149 	int DECLARATIONS= 0;
150 
151 	/**
152 	 * The search result is a type that implements an interface or extends a class.
153 	 * Used in conjunction with either TYPE or CLASS or INTERFACE, it will
154 	 * respectively search for any type implementing/extending a type,
155 	 * or rather exclusively search for classes implementing/extending the type, or
156 	 * interfaces extending the type.
157 	 *
158 	 * @category limitTo
159 	 */
160 	int IMPLEMENTORS= 1;
161 
162 	/**
163 	 * The search result is a reference.
164 	 * Can be used in conjunction with any of the nature of searched elements
165 	 * so as to better narrow down the search.
166 	 * References can contain implementers since they are more generic kind
167 	 * of matches.
168 	 *
169 	 * @category limitTo
170 	 */
171 	int REFERENCES= 2;
172 
173 	/**
174 	 * The search result is a declaration, a reference, or an implementer
175 	 * of an interface.
176 	 * Can be used in conjunction with any of the nature of searched elements
177 	 * so as to better narrow down the search.
178 	 *
179 	 * @category limitTo
180 	 */
181 	int ALL_OCCURRENCES= 3;
182 
183 	/**
184 	 * When searching for field matches, it will exclusively find read accesses, as
185 	 * opposed to write accesses. Note that some expressions are considered both
186 	 * as field read/write accesses: for example, x++; x+= 1;
187 	 *
188 	 * @since 2.0
189 	 * @category limitTo
190 	 */
191 	int READ_ACCESSES = 4;
192 
193 	/**
194 	 * When searching for field matches, it will exclusively find write accesses, as
195 	 * opposed to read accesses. Note that some expressions are considered both
196 	 * as field read/write accesses: for example,  x++; x+= 1;
197 	 *
198 	 * @since 2.0
199 	 * @category limitTo
200 	 */
201 	int WRITE_ACCESSES = 5;
202 
203 	/**
204 	 * When searching for Type Declaration matches, and if a module is given, this
205 	 * will find type declaration matches in this module as well as the dependent
206 	 * module graph of the given module.
207 	 *
208 	 * @since 3.14
209 	 * @category limitTo
210 	 */
211 	int MODULE_GRAPH = 6;
212 
213 	/**
214 	 * Ignore declaring type while searching result.
215 	 * Can be used in conjunction with any of the nature of match.
216 	 *
217 	 * @since 3.1
218 	 * @category limitTo
219 	 */
220 	int IGNORE_DECLARING_TYPE = 0x10;
221 
222 	/**
223 	 * Ignore return type while searching result.
224 	 * Can be used in conjunction with any other nature of match.
225 	 * Note that:
226 	 * <ul>
227 	 * 	<li>for fields search, pattern will ignore field type</li>
228 	 * 	<li>this flag will have no effect for types search</li>
229 	 *	</ul>
230 	 *
231 	 * @since 3.1
232 	 * @category limitTo
233 	 */
234 	int IGNORE_RETURN_TYPE = 0x20;
235 
236 	/**
237 	 * Return only type references used as the type of a field declaration.
238 	 * <p>
239 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
240 	 * returned.
241 	 *</p>
242 	 * @since 3.4
243 	 * @category limitTo
244 	 */
245 	int FIELD_DECLARATION_TYPE_REFERENCE = 0x40;
246 
247 	/**
248 	 * Return only type references used as the type of a local variable declaration.
249 	 * <p>
250 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
251 	 * returned.
252 	 *</p>
253 	 * @since 3.4
254 	 * @category limitTo
255 	 */
256 	int LOCAL_VARIABLE_DECLARATION_TYPE_REFERENCE = 0x80;
257 
258 	/**
259 	 * Return only type references used as the type of a method parameter
260 	 * declaration.
261 	 * <p>
262 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
263 	 * returned.
264 	 *</p>
265 	 * @since 3.4
266 	 * @category limitTo
267 	 */
268 	int PARAMETER_DECLARATION_TYPE_REFERENCE = 0x100;
269 
270 	/**
271 	 * Return only type references used as a super type or as a super interface.
272 	 * <p>
273 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
274 	 * returned.
275 	 *</p>
276 	 * @since 3.4
277 	 * @category limitTo
278 	 */
279 	int SUPERTYPE_TYPE_REFERENCE = 0x200;
280 
281 	/**
282 	 * Return only type references used in a throws clause.
283 	 * <p>
284 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
285 	 * returned.
286 	 *</p>
287 	 * @since 3.4
288 	 * @category limitTo
289 	 */
290 	int THROWS_CLAUSE_TYPE_REFERENCE = 0x400;
291 
292 	/**
293 	 * Return only type references used in a cast expression.
294 	 * <p>
295 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
296 	 * returned.
297 	 *</p>
298 	 * @since 3.4
299 	 * @category limitTo
300 	 */
301 	int CAST_TYPE_REFERENCE = 0x800;
302 
303 	/**
304 	 * Return only type references used in a catch header.
305 	 * <p>
306 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
307 	 * returned.
308 	 *</p>
309 	 * @since 3.4
310 	 * @category limitTo
311 	 */
312 	int CATCH_TYPE_REFERENCE = 0x1000;
313 
314 	/**
315 	 * Return only type references used in class instance creation.
316 	 * <p>
317 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
318 	 * returned.
319 	 *</p><p>
320 	 *	Example:
321 	 *<pre>
322 	 * public class Test {
323 	 * 	Test() {}
324 	 * 	static Test bar()  {
325 	 * 		return new <i>Test</i>();
326 	 * 	}
327 	 * }
328 	 *</pre>
329 	 * Searching references to the type <code>Test</code> using this flag in the
330 	 * above snippet will match only the reference in italic.
331 	 * <p>
332 	 * Note that array creations are not returned when using this flag.
333 	 * </p>
334 	 * @since 3.4
335 	 * @category limitTo
336 	 */
337 	int CLASS_INSTANCE_CREATION_TYPE_REFERENCE = 0x2000;
338 
339 	/**
340 	 * Return only type references used as a method return type.
341 	 * <p>
342 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
343 	 * returned.
344 	 *</p>
345 	 * @since 3.4
346 	 * @category limitTo
347 	 */
348 	int RETURN_TYPE_REFERENCE = 0x4000;
349 
350 	/**
351 	 * Return only type references used in an import declaration.
352 	 * <p>
353 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
354 	 * returned.
355 	 *</p>
356 	 * @since 3.4
357 	 * @category limitTo
358 	 */
359 	int IMPORT_DECLARATION_TYPE_REFERENCE = 0x8000;
360 
361 	/**
362 	 * Return only type references used as an annotation.
363 	 * <p>
364 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
365 	 * returned.
366 	 *</p>
367 	 * @since 3.4
368 	 * @category limitTo
369 	 */
370 	int ANNOTATION_TYPE_REFERENCE = 0x10000;
371 
372 	/**
373 	 * Return only type references used as a type argument in a parameterized
374 	 * type or a parameterized method.
375 	 * <p>
376 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
377 	 * returned.
378 	 *</p>
379 	 * @since 3.4
380 	 * @category limitTo
381 	 */
382 	int TYPE_ARGUMENT_TYPE_REFERENCE = 0x20000;
383 
384 	/**
385 	 * Return only type references used as a type variable bound.
386 	 * <p>
387 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
388 	 * returned.
389 	 *</p>
390 	 * @since 3.4
391 	 * @category limitTo
392 	 */
393 	int TYPE_VARIABLE_BOUND_TYPE_REFERENCE = 0x40000;
394 
395 	/**
396 	 * Return only type references used as a wildcard bound.
397 	 * <p>
398 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
399 	 * returned.
400 	 *</p>
401 	 * @since 3.4
402 	 * @category limitTo
403 	 */
404 	int WILDCARD_BOUND_TYPE_REFERENCE = 0x80000;
405 
406 	/**
407 	 * Return only type references used as a type of an <code>instanceof</code>
408 	 * expression.
409 	 * <p>
410 	 * When this flag is set, only {@link TypeReferenceMatch} matches will be
411 	 * returned.
412 	 *</p>
413 	 * @since 3.4
414 	 * @category limitTo
415 	 */
416 	int INSTANCEOF_TYPE_REFERENCE = 0x100000;
417 
418 	/**
419 	 * Return only super field accesses or super method invocations (e.g. using the
420 	 * <code>super</code> qualifier).
421 	 * <p>
422 	 * When this flag is set, the kind of returned matches will depend on the
423 	 * specified nature of the searched element:
424 	 * <ul>
425 	 * 	<li>for the {@link #FIELD} nature, only {@link FieldReferenceMatch}
426 	 * 		matches will be returned,</li>
427 	 * 	<li>for the {@link #METHOD} nature, only {@link MethodReferenceMatch}
428 	 * 		matches will be returned.</li>
429 	 * </ul>
430 	 * @since 3.4
431 	 * @category limitTo
432 	 */
433 	int SUPER_REFERENCE = 0x1000000;
434 
435 	/**
436 	 * Return only qualified field accesses or qualified method invocations.
437 	 * <p>
438 	 * When this flag is set, the kind of returned matches will depend on the
439 	 * specified nature of the searched element:
440 	 * <ul>
441 	 * 	<li>for the {@link #FIELD} nature, only {@link FieldReferenceMatch}
442 	 * 		matches will be returned,</li>
443 	 * 	<li>for the {@link #METHOD} nature, only {@link MethodReferenceMatch}
444 	 * 		matches will be returned.</li>
445 	 * </ul>
446 	 * @since 3.4
447 	 * @category limitTo
448 	 */
449 	int QUALIFIED_REFERENCE = 0x2000000;
450 
451 	/**
452 	 * Return only primary field accesses or primary method invocations (e.g. using
453 	 * the <code>this</code> qualifier).
454 	 * <p>
455 	 * When this flag is set, the kind of returned matches will depend on the
456 	 * specified nature of the searched element:
457 	 * <ul>
458 	 * 	<li>for the {@link #FIELD} nature, only {@link FieldReferenceMatch}
459 	 * 		matches will be returned,</li>
460 	 * 	<li>for the {@link #METHOD} nature, only {@link MethodReferenceMatch}
461 	 * 		matches will be returned.</li>
462 	 * </ul>
463 	 * @since 3.4
464 	 * @category limitTo
465 	 */
466 	int THIS_REFERENCE = 0x4000000;
467 
468 	/**
469 	 * Return only field accesses or method invocations without any qualification.
470 	 * <p>
471 	 * When this flag is set, the kind of returned matches will depend on the
472 	 * specified nature of the searched element:
473 	 * <ul>
474 	 * 	<li>for the {@link #FIELD} nature, only {@link FieldReferenceMatch}
475 	 * 		matches will be returned,</li>
476 	 * 	<li>for the {@link #METHOD} nature, only {@link MethodReferenceMatch}
477 	 * 		matches will be returned.</li>
478 	 * </ul>
479 	 * @since 3.4
480 	 * @category limitTo
481 	 */
482 	int IMPLICIT_THIS_REFERENCE = 0x8000000;
483 
484 	/**
485 	 * Return only method reference expressions, e.g. <code>A::foo</code>.
486 	 * <p>
487 	 * When this flag is set, only {@link MethodReferenceMatch} matches will be
488 	 * returned.
489 	 *</p>
490 	 * @since 3.10
491 	 * @category limitTo
492 	 */
493 	int METHOD_REFERENCE_EXPRESSION = 0x10000000;
494 
495 	/* Syntactic match modes */
496 
497 	/**
498 	 * The search pattern matches exactly the search result,
499 	 * that is, the source of the search result equals the search pattern.
500 	 *
501 	 * @deprecated Use {@link SearchPattern#R_EXACT_MATCH} instead.
502 	 * @category matchRule
503 	 */
504 	int EXACT_MATCH = 0;
505 	/**
506 	 * The search pattern is a prefix of the search result.
507 	 *
508 	 * @deprecated Use {@link SearchPattern#R_PREFIX_MATCH} instead.
509 	 * @category matchRule
510 	 */
511 	int PREFIX_MATCH = 1;
512 	/**
513 	 * The search pattern contains one or more wild cards ('*') where a
514 	 * wild-card can replace 0 or more characters in the search result.
515 	 *
516 	 * @deprecated Use {@link SearchPattern#R_PATTERN_MATCH} instead.
517 	 * @category matchRule
518 	 */
519 	int PATTERN_MATCH = 2;
520 
521 
522 	/* Case sensitivity */
523 
524 	/**
525 	 * The search pattern matches the search result only
526 	 * if cases are the same.
527 	 *
528 	 * @deprecated Use the methods that take the matchMode
529 	 *   with {@link SearchPattern#R_CASE_SENSITIVE} as a matchRule instead.
530 	 * @category matchRule
531 	 */
532 	boolean CASE_SENSITIVE = true;
533 	/**
534 	 * The search pattern ignores cases in the search result.
535 	 *
536 	 * @deprecated Use the methods that take the matchMode
537 	 *   without {@link SearchPattern#R_CASE_SENSITIVE} as a matchRule instead.
538 	 * @category matchRule
539 	 */
540 	boolean CASE_INSENSITIVE = false;
541 
542 
543 	/* Waiting policies */
544 
545 	/**
546 	 * The search operation starts immediately, even if the underlying indexer
547 	 * has not finished indexing the workspace. Results will more likely
548 	 * not contain all the matches.
549 	 */
550 	int FORCE_IMMEDIATE_SEARCH = IJob.ForceImmediate;
551 	/**
552 	 * The search operation throws an <code>org.eclipse.core.runtime.OperationCanceledException</code>
553 	 * if the underlying indexer has not finished indexing the workspace.
554 	 */
555 	int CANCEL_IF_NOT_READY_TO_SEARCH = IJob.CancelIfNotReady;
556 	/**
557 	 * The search operation waits for the underlying indexer to finish indexing
558 	 * the workspace before starting the search.
559 	 */
560 	int WAIT_UNTIL_READY_TO_SEARCH = IJob.WaitUntilReady;
561 
562 	/* Special Constant for module search */
563 
564 	/**
565 	 * The unnamed module is represented by this constant for making the intent explicit
566 	 * in searches involving modules
567 	 * @since 3.14
568 	 */
569 	char[] ALL_UNNAMED = "ALL-UNNAMED".toCharArray(); ////$NON-NLS-1$
570 
571 }
572