1 /*******************************************************************************
2  * Copyright (c) 2000, 2020 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  *     IBM Corporation - added J2SE 1.5 support
14  *******************************************************************************/
15 package org.eclipse.jdt.core;
16 
17 import java.io.InputStream;
18 
19 import org.eclipse.core.runtime.IProgressMonitor;
20 
21 /**
22  * Represents either a source type in a compilation unit (either a top-level
23  * type, a member type, a local type, an anonymous type or a lambda expression)
24  * or a binary type in a class file. Enumeration classes and annotation
25  * types are subkinds of classes and interfaces, respectively.
26  * <p>
27  * Note that the element name of an anonymous source type and lambda expressions
28  * is always empty. Types representing lambda expressions are pseudo-elements
29  * and not included in the children of their parent. Lambda expressions are created
30  * as the result of a <code>ICodeAssist.codeSelect(...)</code>. For more information
31  * on such pseudo-elements, see <code>ILocalVariable</code>.
32  * </p><p>
33  * If a binary type cannot be parsed, its structure remains unknown.
34  * Use <code>IJavaElement.isStructureKnown</code> to determine whether this
35  * is the case.
36  * </p>
37  * <p>
38  * The children are of type <code>IMember</code>, which includes <code>IField</code>,
39  * <code>IMethod</code>, <code>IInitializer</code> and <code>IType</code>.
40  * The children are listed in the order in which they appear in the source or class file.
41  * </p>
42  * <p>
43  * Caveat: The {@link #getChildren() children} of a {@link #isBinary() binary} type include
44  * nested types. However, the {@link #getParent() parent} of such a nested binary type is
45  * <em>not</em> the enclosing type, but that nested type's {@link IClassFile}!
46  * </p>
47  *
48  * @noimplement This interface is not intended to be implemented by clients.
49  */
50 public interface IType extends IMember, IAnnotatable {
51 	/**
52 	 * Do code completion inside a code snippet in the context of the current type.
53 	 *
54 	 * If the type has access to its source code and the insertion position is valid,
55 	 * then completion is performed against the source. Otherwise the completion is performed
56 	 * against the type structure and the given locals variables.
57 	 *
58 	 * @param snippet the code snippet
59 	 * @param insertion the position with in source where the snippet
60 	 * is inserted. This position must not be in comments.
61 	 * A possible value is -1, if the position is not known.
62 	 * @param position the position within snippet where the user
63 	 * is performing code assist.
64 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
65 	 * type names of local variables visible at the current scope
66 	 * @param localVariableNames an array (possibly empty) of local variable names
67 	 * that are visible at the current scope
68 	 * @param localVariableModifiers an array (possible empty) of modifiers for
69 	 * local variables
70 	 * @param isStatic whether the current scope is in a static context
71 	 * @param requestor the completion requestor
72 	 * @exception JavaModelException if this element does not exist or if an
73 	 *		exception occurs while accessing its corresponding resource.
74 	 * @since 2.0
75 	 * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor)} instead.
76 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, ICompletionRequestor requestor)77 	void codeComplete(
78 		char[] snippet,
79 		int insertion,
80 		int position,
81 		char[][] localVariableTypeNames,
82 		char[][] localVariableNames,
83 		int[] localVariableModifiers,
84 		boolean isStatic,
85 		ICompletionRequestor requestor)
86 		throws JavaModelException;
87 
88 	/**
89 	 * Do code completion inside a code snippet in the context of the current type.
90 	 * It considers types in the working copies with the given owner first. In other words,
91 	 * the owner's working copies will take precedence over their original compilation units
92 	 * in the workspace.
93 	 * <p>
94 	 * Note that if a working copy is empty, it will be as if the original compilation
95 	 * unit had been deleted.
96 	 * </p><p>
97 	 * If the type has access to its source code and the insertion position is valid,
98 	 * then completion is performed against the source. Otherwise the completion is performed
99 	 * against the type structure and the given locals variables.
100 	 * </p>
101 	 *
102 	 * @param snippet the code snippet
103 	 * @param insertion the position with in source where the snippet
104 	 * is inserted. This position must not be in comments.
105 	 * A possible value is -1, if the position is not known.
106 	 * @param position the position with in snippet where the user
107 	 * is performing code assist.
108 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
109 	 * type names of local variables visible at the current scope
110 	 * @param localVariableNames an array (possibly empty) of local variable names
111 	 * that are visible at the current scope
112 	 * @param localVariableModifiers an array (possible empty) of modifiers for
113 	 * local variables
114 	 * @param isStatic whether the current scope is in a static context
115 	 * @param requestor the completion requestor
116 	 * @param owner the owner of working copies that take precedence over their original compilation units
117 	 * @exception JavaModelException if this element does not exist or if an
118 	 *		exception occurs while accessing its corresponding resource.
119 	 * @since 3.0
120 	 * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor,WorkingCopyOwner)} instead.
121 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, ICompletionRequestor requestor, WorkingCopyOwner owner)122 	void codeComplete(
123 		char[] snippet,
124 		int insertion,
125 		int position,
126 		char[][] localVariableTypeNames,
127 		char[][] localVariableNames,
128 		int[] localVariableModifiers,
129 		boolean isStatic,
130 		ICompletionRequestor requestor,
131 		WorkingCopyOwner owner)
132 		throws JavaModelException;
133 
134 	/**
135 	 * Do code completion inside a code snippet in the context of the current type.
136 	 *
137 	 * If the type has access to its source code and the insertion position is valid,
138 	 * then completion is performed against the source. Otherwise the completion is performed
139 	 * against the type structure and the given locals variables.
140 	 *
141 	 * @param snippet the code snippet
142 	 * @param insertion the position with in source where the snippet
143 	 * is inserted. This position must not be in comments.
144 	 * A possible value is -1, if the position is not known.
145 	 * @param position the position within snippet where the user
146 	 * is performing code assist.
147 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
148 	 * type names of local variables visible at the current scope
149 	 * @param localVariableNames an array (possibly empty) of local variable names
150 	 * that are visible at the current scope
151 	 * @param localVariableModifiers an array (possible empty) of modifiers for
152 	 * local variables
153 	 * @param isStatic whether the current scope is in a static context
154 	 * @param requestor the completion requestor
155 	 * @exception JavaModelException if this element does not exist or if an
156 	 *		exception occurs while accessing its corresponding resource.
157 	 * @since 3.1
158 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor)159 	void codeComplete(
160 		char[] snippet,
161 		int insertion,
162 		int position,
163 		char[][] localVariableTypeNames,
164 		char[][] localVariableNames,
165 		int[] localVariableModifiers,
166 		boolean isStatic,
167 		CompletionRequestor requestor)
168 		throws JavaModelException;
169 
170 	/**
171 	 * Do code completion inside a code snippet in the context of the current type.
172 	 *
173 	 * If the type has access to its source code and the insertion position is valid,
174 	 * then completion is performed against the source. Otherwise the completion is performed
175 	 * against the type structure and the given locals variables.
176 	 * <p>
177 	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
178 	 * can be very long to compute are proposed. To avoid that the code assist operation
179 	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
180 	 * assist operation when a specified amount of time is reached could be used.
181 	 *
182 	 * <pre>
183 	 * new IProgressMonitor() {
184 	 *     private final static int TIMEOUT = 500; //ms
185 	 *     private long endTime;
186 	 *     public void beginTask(String name, int totalWork) {
187 	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
188 	 *     }
189 	 *     public boolean isCanceled() {
190 	 *         return endTime <= System.currentTimeMillis();
191 	 *     }
192 	 *     ...
193 	 * };
194 	 * </pre>
195 	 * <p>
196 	 *
197 	 * @param snippet the code snippet
198 	 * @param insertion the position with in source where the snippet
199 	 * is inserted. This position must not be in comments.
200 	 * A possible value is -1, if the position is not known.
201 	 * @param position the position within snippet where the user
202 	 * is performing code assist.
203 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
204 	 * type names of local variables visible at the current scope
205 	 * @param localVariableNames an array (possibly empty) of local variable names
206 	 * that are visible at the current scope
207 	 * @param localVariableModifiers an array (possible empty) of modifiers for
208 	 * local variables
209 	 * @param isStatic whether the current scope is in a static context
210 	 * @param requestor the completion requestor
211 	 * @param monitor the progress monitor used to report progress
212 	 * @exception JavaModelException if this element does not exist or if an
213 	 *		exception occurs while accessing its corresponding resource.
214 	 * @since 3.5
215 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, IProgressMonitor monitor)216 	void codeComplete(
217 		char[] snippet,
218 		int insertion,
219 		int position,
220 		char[][] localVariableTypeNames,
221 		char[][] localVariableNames,
222 		int[] localVariableModifiers,
223 		boolean isStatic,
224 		CompletionRequestor requestor,
225 		IProgressMonitor monitor)
226 		throws JavaModelException;
227 
228 	/**
229 	 * Do code completion inside a code snippet in the context of the current type.
230 	 * It considers types in the working copies with the given owner first. In other words,
231 	 * the owner's working copies will take precedence over their original compilation units
232 	 * in the workspace.
233 	 * <p>
234 	 * Note that if a working copy is empty, it will be as if the original compilation
235 	 * unit had been deleted.
236 	 * </p><p>
237 	 * If the type has access to its source code and the insertion position is valid,
238 	 * then completion is performed against the source. Otherwise the completion is performed
239 	 * against the type structure and the given locals variables.
240 	 * </p>
241 	 *
242 	 * @param snippet the code snippet
243 	 * @param insertion the position with in source where the snippet
244 	 * is inserted. This position must not be in comments.
245 	 * A possible value is -1, if the position is not known.
246 	 * @param position the position with in snippet where the user
247 	 * is performing code assist.
248 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
249 	 * type names of local variables visible at the current scope
250 	 * @param localVariableNames an array (possibly empty) of local variable names
251 	 * that are visible at the current scope
252 	 * @param localVariableModifiers an array (possible empty) of modifiers for
253 	 * local variables
254 	 * @param isStatic whether the current scope is in a static context
255 	 * @param requestor the completion requestor
256 	 * @param owner the owner of working copies that take precedence over their original compilation units
257 	 * @exception JavaModelException if this element does not exist or if an
258 	 *		exception occurs while accessing its corresponding resource.
259 	 * @since 3.1
260 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, WorkingCopyOwner owner)261 	void codeComplete(
262 		char[] snippet,
263 		int insertion,
264 		int position,
265 		char[][] localVariableTypeNames,
266 		char[][] localVariableNames,
267 		int[] localVariableModifiers,
268 		boolean isStatic,
269 		CompletionRequestor requestor,
270 		WorkingCopyOwner owner)
271 		throws JavaModelException;
272 
273 	/**
274 	 * Do code completion inside a code snippet in the context of the current type.
275 	 * It considers types in the working copies with the given owner first. In other words,
276 	 * the owner's working copies will take precedence over their original compilation units
277 	 * in the workspace.
278 	 * <p>
279 	 * Note that if a working copy is empty, it will be as if the original compilation
280 	 * unit had been deleted.
281 	 * </p><p>
282 	 * If the type has access to its source code and the insertion position is valid,
283 	 * then completion is performed against the source. Otherwise the completion is performed
284 	 * against the type structure and the given locals variables.
285 	 * </p>
286 	 * <p>
287 	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
288 	 * can be very long to compute are proposed. To avoid that the code assist operation
289 	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
290 	 * assist operation when a specified amount of time is reached could be used.
291 	 *
292 	 * <pre>
293 	 * new IProgressMonitor() {
294 	 *     private final static int TIMEOUT = 500; //ms
295 	 *     private long endTime;
296 	 *     public void beginTask(String name, int totalWork) {
297 	 *         endTime= System.currentTimeMillis() + TIMEOUT;
298 	 *     }
299 	 *     public boolean isCanceled() {
300 	 *         return endTime <= System.currentTimeMillis();
301 	 *     }
302 	 *     ...
303 	 * };
304 	 * </pre>
305 	 * <p>
306 	 *
307 	 * @param snippet the code snippet
308 	 * @param insertion the position with in source where the snippet
309 	 * is inserted. This position must not be in comments.
310 	 * A possible value is -1, if the position is not known.
311 	 * @param position the position with in snippet where the user
312 	 * is performing code assist.
313 	 * @param localVariableTypeNames an array (possibly empty) of fully qualified
314 	 * type names of local variables visible at the current scope
315 	 * @param localVariableNames an array (possibly empty) of local variable names
316 	 * that are visible at the current scope
317 	 * @param localVariableModifiers an array (possible empty) of modifiers for
318 	 * local variables
319 	 * @param isStatic whether the current scope is in a static context
320 	 * @param requestor the completion requestor
321 	 * @param owner the owner of working copies that take precedence over their original compilation units
322 	 * @param monitor the progress monitor used to report progress
323 	 * @exception JavaModelException if this element does not exist or if an
324 	 *		exception occurs while accessing its corresponding resource.
325 	 * @since 3.5
326 	 */
codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor)327 	void codeComplete(
328 		char[] snippet,
329 		int insertion,
330 		int position,
331 		char[][] localVariableTypeNames,
332 		char[][] localVariableNames,
333 		int[] localVariableModifiers,
334 		boolean isStatic,
335 		CompletionRequestor requestor,
336 		WorkingCopyOwner owner,
337 		IProgressMonitor monitor)
338 		throws JavaModelException;
339 
340 
341 	/**
342 	 * Creates and returns a field in this type with the
343 	 * given contents.
344 	 * <p>
345 	 * Optionally, the new element can be positioned before the specified
346 	 * sibling. If no sibling is specified, the element will be inserted
347 	 * as the last field declaration in this type.</p>
348 	 *
349 	 * <p>It is possible that a field with the same name already exists in this type.
350 	 * The value of the <code>force</code> parameter affects the resolution of
351 	 * such a conflict:
352 	 * <ul>
353 	 * <li> <code>true</code> - in this case the field is created with the new contents</li>
354 	 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
355 	 * </ul>
356 	 *
357 	 * @param contents the given contents
358 	 * @param sibling the given sibling
359 	 * @param force a flag in case the same name already exists in this type
360 	 * @param monitor the given progress monitor
361 	 * @exception JavaModelException if the element could not be created. Reasons include:
362 	 * <ul>
363 	 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
364 	 * <li> A <code>CoreException</code> occurred while updating an underlying resource
365 	 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
366 	 * <li> The contents could not be recognized as a field declaration (INVALID_CONTENTS)
367 	 * <li> This type is read-only (binary) (READ_ONLY)
368 	 * <li> There was a naming collision with an existing field (NAME_COLLISION)
369 	 * </ul>
370 	 * @return a field in this type with the given contents
371 	 */
createField(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)372 	IField createField(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
373 		throws JavaModelException;
374 
375 	/**
376 	 * Creates and returns a static initializer in this type with the
377 	 * given contents.
378 	 * <p>
379 	 * Optionally, the new element can be positioned before the specified
380 	 * sibling. If no sibling is specified, the new initializer is positioned
381 	 * after the last existing initializer declaration, or as the first member
382 	 * in the type if there are no initializers.</p>
383 	 *
384 	 * @param contents the given contents
385 	 * @param sibling the given sibling
386 	 * @param monitor the given progress monitor
387 	 * @exception JavaModelException if the element could not be created. Reasons include:
388 	 * <ul>
389 	 * <li> This element does not exist
390 	 * <li> A <code>CoreException</code> occurred while updating an underlying resource
391 	 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
392 	 * <li> The contents could not be recognized as an initializer declaration (INVALID_CONTENTS)
393 	 * <li> This type is read-only (binary) (READ_ONLY)
394 	 * </ul>
395 	 * @return a static initializer in this type with the given contents
396 	 */
createInitializer(String contents, IJavaElement sibling, IProgressMonitor monitor)397 	IInitializer createInitializer(String contents, IJavaElement sibling, IProgressMonitor monitor)
398 		throws JavaModelException;
399 
400 	/**
401 	 * Creates and returns a method or constructor in this type with the
402 	 * given contents.
403 	 * <p>
404 	 * Optionally, the new element can be positioned before the specified
405 	 * sibling. If no sibling is specified, the element will be appended
406 	 * to this type.
407 	 *
408 	 * <p>It is possible that a method with the same signature already exists in this type.
409 	 * The value of the <code>force</code> parameter affects the resolution of
410 	 * such a conflict:
411 	 * <ul>
412 	 * <li> <code>true</code> - in this case the method is created with the new contents</li>
413 	 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
414 	 * </ul>
415 	 *
416 	 * @param contents the given contents
417 	 * @param sibling the given sibling
418 	 * @param force a flag in case the same name already exists in this type
419 	 * @param monitor the given progress monitor
420 	 * @exception JavaModelException if the element could not be created. Reasons include:
421 	 * <ul>
422 	 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
423 	 * <li> A <code>CoreException</code> occurred while updating an underlying resource
424 	 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
425 	 * <li> The contents could not be recognized as a method or constructor
426 	 *		declaration (INVALID_CONTENTS)
427 	 * <li> This type is read-only (binary) (READ_ONLY)
428 	 * <li> There was a naming collision with an existing method (NAME_COLLISION)
429 	 * </ul>
430 	 * @return a method or constructor in this type with the given contents
431 	 */
createMethod(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)432 	IMethod createMethod(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
433 		throws JavaModelException;
434 
435 	/**
436 	 * Creates and returns a type in this type with the
437 	 * given contents.
438 	 * <p>
439 	 * Optionally, the new type can be positioned before the specified
440 	 * sibling. If no sibling is specified, the type will be appended
441 	 * to this type.</p>
442 	 *
443 	 * <p>It is possible that a type with the same name already exists in this type.
444 	 * The value of the <code>force</code> parameter affects the resolution of
445 	 * such a conflict:
446 	 * <ul>
447 	 * <li> <code>true</code> - in this case the type is created with the new contents</li>
448 	 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
449 	 * </ul>
450 	 *
451 	 * @param contents the given contents
452 	 * @param sibling the given sibling
453 	 * @param force a flag in case the same name already exists in this type
454 	 * @param monitor the given progress monitor
455 	 * @exception JavaModelException if the element could not be created. Reasons include:
456 	 * <ul>
457 	 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
458 	 * <li> A <code>CoreException</code> occurred while updating an underlying resource
459 	 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)
460 	 * <li> The contents could not be recognized as a type declaration (INVALID_CONTENTS)
461 	 * <li> This type is read-only (binary) (READ_ONLY)
462 	 * <li> There was a naming collision with an existing field (NAME_COLLISION)
463 	 * </ul>
464 	 * @return a type in this type with the given contents
465 	 */
createType(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)466 	IType createType(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)
467 		throws JavaModelException;
468 
469 	/**
470 	 * Finds the methods in this type that correspond to
471 	 * the given method.
472 	 * A method m1 corresponds to another method m2 if:
473 	 * <ul>
474 	 * <li>m1 has the same element name as m2.
475 	 * <li>m1 has the same number of arguments as m2 and
476 	 *     the simple names of the argument types must be equals.
477 	 * <li>m1 exists.
478 	 * </ul>
479 	 * @param method the given method
480 	 * @return the found method or <code>null</code> if no such methods can be found.
481 	 *
482 	 * @since 2.0
483 	 */
findMethods(IMethod method)484 	IMethod[] findMethods(IMethod method);
485 
486 	/**
487 	 * Returns the children of this type that have the given category as a <code>@category</code> tag.
488 	 * Returns an empty array if no children with this category exist.
489 	 *
490 	 * <p>
491 	 * The results are listed in the order in which they appear in the source or class file.
492 	 * </p>
493 	 *
494 	 * @return the children for the given category.
495 	 * @exception JavaModelException if this element does not exist or if an
496 	 *      exception occurs while accessing its corresponding resource.
497 	 *  @since 3.2
498 	 */
getChildrenForCategory(String category)499 	IJavaElement[] getChildrenForCategory(String category) throws JavaModelException;
500 
501 	/**
502 	 * Returns the simple name of this type, unqualified by package or enclosing type.
503 	 * This is a handle-only method.
504 	 *
505 	 * Note that the element name of an anonymous source type and lambda expressions
506 	 * is always empty.
507 	 *
508 	 * @return the simple name of this type
509 	 */
510 	@Override
getElementName()511 	String getElementName();
512 
513 	/**
514 	 * Returns the field with the specified name
515 	 * in this type (for example, <code>"bar"</code>).
516 	 * This is a handle-only method.  The field may or may not exist.
517 	 *
518 	 * @param name the given name
519 	 * @return the field with the specified name in this type
520 	 */
getField(String name)521 	IField getField(String name);
522 
523 	/**
524 	 * Returns the fields declared by this type in the order in which they appear
525 	 * in the source or class file. For binary types, this includes synthetic fields.
526 	 * This does not include the implicit fields representing record components.
527 	 *
528 	 * @exception JavaModelException if this element does not exist or if an
529 	 *		exception occurs while accessing its corresponding resource.
530 	 * @return the fields declared by this type
531 	 */
getFields()532 	IField[] getFields() throws JavaModelException;
533 
534 	/**
535 	 * Returns the fully qualified name of this type,
536 	 * including qualification for any containing types and packages.
537 	 * This is the name of the package, followed by <code>'.'</code>,
538 	 * followed by the type-qualified name.
539 	 * <p>
540 	 * <b>Note</b>: The enclosing type separator used in the type-qualified
541 	 * name is <code>'$'</code>, not <code>'.'</code>.
542 	 * </p>
543 	 * This method is fully equivalent to <code>getFullyQualifiedName('$')</code>.
544 	 * This is a handle-only method.
545 	 *
546 	 * @see IType#getTypeQualifiedName()
547 	 * @see IType#getFullyQualifiedName(char)
548 	 * @return the fully qualified name of this type
549 	 */
getFullyQualifiedName()550 	String getFullyQualifiedName();
551 
552 	/**
553 	 * Returns the fully qualified name of this type,
554 	 * including qualification for any containing types and packages.
555 	 * This is the name of the package, followed by <code>'.'</code>,
556 	 * followed by the type-qualified name using the <code>enclosingTypeSeparator</code>.
557 	 *
558 	 * For example:
559 	 * <ul>
560 	 * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java
561 	 *     in a package x.y using the '.' separator is "x.y.A.B"</li>
562 	 * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java
563 	 *     in a package x.y using the '$' separator is "x.y.A$B"</li>
564 	 * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class
565 	 *     using the '.' separator is "x.y.A.B"</li>
566 	 * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class
567 	 *     using the '$' separator is "x.y.A$B"</li>
568 	 * <li>the fully qualified name of an anonymous binary type whose class file is x/y/A$1.class
569 	 *     using the '.' separator is "x.y.A.1"</li>
570 	 * </ul>
571 	 *
572 	 * This is a handle-only method.
573 	 *
574 	 * @param enclosingTypeSeparator the given enclosing type separator
575 	 * @return the fully qualified name of this type, including qualification for any containing types and packages
576 	 * @see IType#getTypeQualifiedName(char)
577 	 * @since 2.0
578 	 */
getFullyQualifiedName(char enclosingTypeSeparator)579 	String getFullyQualifiedName(char enclosingTypeSeparator);
580 
581 	/**
582 	 * Returns this type's fully qualified name using a '.' enclosing type separator
583 	 * followed by its type parameters between angle brackets if it is a generic type.
584 	 * For example, "p.X&lt;T&gt;", "java.util.Map&lt;java.lang.String, p.X&gt;"
585 	 *
586 	 * @exception JavaModelException if this element does not exist or if an
587 	 *      exception occurs while accessing its corresponding resource.
588 	 * @return the fully qualified parameterized representation of this type
589 	 * @since 3.1
590 	 */
getFullyQualifiedParameterizedName()591 	String getFullyQualifiedParameterizedName() throws JavaModelException;
592 
593 	/**
594 	 * Returns the initializer with the specified position relative to
595 	 * the order they are defined in the source.
596 	 * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).
597 	 * This is a handle-only method.  The initializer may or may not be present.
598 	 *
599 	 * @param occurrenceCount the specified position
600 	 * @return the initializer with the specified position relative to the order they are defined in the source
601 	 */
getInitializer(int occurrenceCount)602 	IInitializer getInitializer(int occurrenceCount);
603 
604 	/**
605 	 * Returns the initializers declared by this type. For binary types this is an
606 	 * empty collection. For source types, the results are listed in the order in
607 	 * which they appear in the source.
608 	 *
609 	 * @exception JavaModelException if this element does not exist or if an
610 	 *		exception occurs while accessing its corresponding resource.
611 	 * @return the initializers declared by this type
612 	 */
getInitializers()613 	IInitializer[] getInitializers() throws JavaModelException;
614 
615 	/**
616 	 * Returns the binding key for this type only if the given type is {@link #isResolved() resolved}.
617 	 * A binding key is a key that uniquely identifies this type. It allows access
618 	 * to generic info for parameterized types.
619 	 *
620 	 * <p>If the given type is not resolved, the returned key is simply the java element's key.
621 	 * </p>
622 	 * @return the binding key for this type
623 	 * @see org.eclipse.jdt.core.dom.IBinding#getKey()
624 	 * @see BindingKey
625 	 * @since 3.1
626 	 * @see #isResolved()
627 	 */
getKey()628 	String getKey();
629 
630 	/**
631 	 * Returns the method with the specified name and parameter types
632 	 * in this type (for example, <code>"foo", {"I", "QString;"}</code>).
633 	 * To get the handle for a constructor, the name specified must be the
634 	 * simple name of the enclosing type.
635 	 * This is a handle-only method.  The method may or may not be present.
636 	 * <p>
637 	 * The type signatures may be either unresolved (for source types)
638 	 * or resolved (for binary types), and either basic (for basic types)
639 	 * or rich (for parameterized types). See {@link Signature} for details.
640 	 * Note that the parameter type signatures for binary methods are expected
641 	 * to be dot-based.
642 	 * </p>
643 	 *
644 	 * @param name the given name
645 	 * @param parameterTypeSignatures the given parameter types
646 	 * @return the method with the specified name and parameter types in this type
647 	 */
getMethod(String name, String[] parameterTypeSignatures)648 	IMethod getMethod(String name, String[] parameterTypeSignatures);
649 
650 	/**
651 	 * Returns the methods and constructors declared by this type.
652 	 * For binary types, this may include the special <code>&lt;clinit&gt;</code> method
653 	 * and synthetic methods.
654 	 * <p>
655 	 * The results are listed in the order in which they appear in the source or class file.
656 	 * </p>
657 	 *
658 	 * @exception JavaModelException if this element does not exist or if an
659 	 *		exception occurs while accessing its corresponding resource.
660 	 * @return the methods and constructors declared by this type
661 	 */
getMethods()662 	IMethod[] getMethods() throws JavaModelException;
663 
664 	/**
665 	 * Returns the package fragment in which this element is defined.
666 	 * This is a handle-only method.
667 	 *
668 	 * @return the package fragment in which this element is defined
669 	 */
getPackageFragment()670 	IPackageFragment getPackageFragment();
671 
672 	/**
673 	 * Returns the name of this type's superclass, or <code>null</code>
674 	 * for source types that do not specify a superclass.
675 	 * <p>
676 	 * For interfaces, the superclass name is always <code>"java.lang.Object"</code>.
677 	 * For source types, the name as declared is returned, for binary types,
678 	 * the resolved, qualified name is returned.
679 	 * For anonymous types, the superclass name is the name appearing after the 'new' keyword'.
680 	 * If the superclass is a parameterized type, the string
681 	 * may include its type arguments enclosed in "&lt;&gt;".
682 	 * If the returned string is needed for anything other than display
683 	 * purposes, use {@link #getSuperclassTypeSignature()} which returns
684 	 * a structured type signature string containing more precise information.
685 	 * </p>
686 	 *
687 	 * @exception JavaModelException if this element does not exist or if an
688 	 *		exception occurs while accessing its corresponding resource.
689 	 * @return the name of this type's superclass, or <code>null</code> for source types that do not specify a superclass
690 	 */
getSuperclassName()691 	String getSuperclassName() throws JavaModelException;
692 
693 	/**
694 	 * Returns the type signature of this type's superclass, or
695 	 * <code>null</code> if none.
696 	 * <p>
697 	 * The type signature may be either unresolved (for source types)
698 	 * or resolved (for binary types), and either basic (for basic types)
699 	 * or rich (for parameterized types). See {@link Signature} for details.
700 	 * </p>
701 	 *
702 	 * @exception JavaModelException if this element does not exist or if an
703 	 *		exception occurs while accessing its corresponding resource.
704 	 * @return the type signature of this type's superclass, or
705 	 * <code>null</code> if none
706 	 * @since 3.0
707 	 */
getSuperclassTypeSignature()708 	String getSuperclassTypeSignature() throws JavaModelException;
709 
710 	/**
711 	 * Returns the type signatures of the interfaces that this type
712 	 * implements or extends, in the order in which they are listed in the
713 	 * source.
714 	 * <p>
715 	 * For classes and enum types, this gives the interfaces that this
716 	 * class implements. For interfaces and annotation types,
717 	 * this gives the interfaces that this interface extends.
718 	 * An empty collection is returned if this type does not implement or
719 	 * extend any interfaces. For anonymous types, an empty collection is
720 	 * always returned.
721 	 * </p>
722 	 * <p>
723 	 * The type signatures may be either unresolved (for source types)
724 	 * or resolved (for binary types), and either basic (for basic types)
725 	 * or rich (for parameterized types). See {@link Signature} for details.
726 	 * </p>
727 	 *
728 	 * @exception JavaModelException if this element does not exist or if an
729 	 *		exception occurs while accessing its corresponding resource.
730 	 * @return  the type signatures of interfaces that this type implements
731 	 * or extends, in the order in which they are listed in the source,
732 	 * an empty collection if none
733 	 * @since 3.0
734 	 */
getSuperInterfaceTypeSignatures()735 	String[] getSuperInterfaceTypeSignatures() throws JavaModelException;
736 
737 	/**
738 	 * Returns the names of interfaces that this type implements or extends,
739 	 * in the order in which they are listed in the source.
740 	 * <p>
741 	 * For classes, this gives the interfaces that this class implements.
742 	 * For interfaces, this gives the interfaces that this interface extends.
743 	 * An empty collection is returned if this type does not implement or
744 	 * extend any interfaces. For source types, simple names are returned,
745 	 * for binary types, qualified names are returned.
746 	 * For anonymous types, an empty collection is always returned.
747 	 * If the list of supertypes includes parameterized types,
748 	 * the string may include type arguments enclosed in "&lt;&gt;".
749 	 * If the result is needed for anything other than display
750 	 * purposes, use {@link #getSuperInterfaceTypeSignatures()} which returns
751 	 * structured signature strings containing more precise information.
752 	 * </p>
753 	 *
754 	 * @exception JavaModelException if this element does not exist or if an
755 	 *		exception occurs while accessing its corresponding resource.
756 	 * @return  the names of interfaces that this type implements or extends, in the order in which they are listed in the source,
757 	 * an empty collection if none
758 	 */
getSuperInterfaceNames()759 	String[] getSuperInterfaceNames() throws JavaModelException;
760 
761 	/**
762 	 * Returns the formal type parameter signatures for this type.
763 	 * Returns an empty array if this type has no formal type parameters.
764 	 * <p>
765 	 * The formal type parameter signatures may be either unresolved (for source
766 	 * types) or resolved (for binary types). See {@link Signature} for details.
767 	 * </p>
768 	 *
769 	 * @exception JavaModelException if this element does not exist or if an
770 	 *      exception occurs while accessing its corresponding resource.
771 	 * @return the formal type parameter signatures of this type,
772 	 * in the order declared in the source, an empty array if none
773 	 * @see Signature
774 	 * @since 3.0
775 	 */
getTypeParameterSignatures()776 	String[] getTypeParameterSignatures() throws JavaModelException;
777 
778 	/**
779 	 * Returns the formal type parameters for this type.
780 	 * Returns an empty array if this type has no formal type parameters.
781 	 *
782 	 * @exception JavaModelException if this element does not exist or if an
783 	 *      exception occurs while accessing its corresponding resource.
784 	 * @return the formal type parameters of this type,
785 	 * in the order declared in the source, an empty array if none
786 	 * @since 3.1
787 	 */
getTypeParameters()788 	ITypeParameter[] getTypeParameters() throws JavaModelException;
789 
790 	/**
791 	 * Returns the member type declared in this type with the given simple name.
792 	 * This is a handle-only method. The type may or may not exist.
793 	 *
794 	 * @param name the given simple name
795 	 * @return the member type declared in this type with the given simple name
796 	 */
getType(String name)797 	IType getType(String name);
798 
799 	/**
800 	 * Returns the type parameter declared in this type with the given name.
801 	 * This is a handle-only method. The type parameter may or may not exist.
802 	 *
803 	 * @param name the given simple name
804 	 * @return the type parameter declared in this type with the given name
805 	 * @since 3.1
806 	 */
getTypeParameter(String name)807 	ITypeParameter getTypeParameter(String name);
808 
809 	/**
810 	 * Returns the type-qualified name of this type,
811 	 * including qualification for any enclosing types,
812 	 * but not including package qualification.
813 	 * For source types, this consists of the simple names of any enclosing types,
814 	 * separated by <code>'$'</code>, followed by the simple name of this type
815 	 * or the occurrence count of this type if it is anonymous.
816 	 * For binary types, this is the name of the class file without the ".class" suffix.
817 	 * This method is fully equivalent to <code>getTypeQualifiedName('$')</code>.
818 	 * This is a handle-only method.
819 	 *
820 	 * @see #getTypeQualifiedName(char)
821 	 * @return the type-qualified name of this type
822 	 */
getTypeQualifiedName()823 	String getTypeQualifiedName();
824 
825 	/**
826 	 * Returns the type-qualified name of this type,
827 	 * including qualification for any enclosing types,
828 	 * but not including package qualification.
829 	 * For source types, this consists of the simple names of any enclosing types,
830 	 * separated by <code>enclosingTypeSeparator</code>, followed by the
831 	 * simple name of this type  or the occurrence count of this type if it is anonymous.
832 	 * For binary types, this is the name of the class file without the ".class" suffix,
833 	 * and - since 3.4 - the '$' characters in the class file name are replaced with the
834 	 * <code>enclosingTypeSeparator</code> character.
835 	 *
836 	 * For example:
837 	 * <ul>
838 	 * <li>the type qualified name of a class B defined as a member of a class A
839 	 *     using the '.' separator is "A.B"</li>
840 	 * <li>the type qualified name of a class B defined as a member of a class A
841 	 *     using the '$' separator is "A$B"</li>
842 	 * <li>the type qualified name of a binary type whose class file is A$B.class
843 	 *     using the '.' separator is "A.B"</li>
844 	 * <li>the type qualified name of a binary type whose class file is A$B.class
845 	 *     using the '$' separator is "A$B"</li>
846 	 * <li>the type qualified name of an anonymous binary type whose class file is A$1.class
847 	 *     using the '.' separator is "A.1"</li>
848 	 * </ul>
849 	 *
850 	 * This is a handle-only method.
851 	 *
852 	 * @param enclosingTypeSeparator the specified enclosing type separator
853 	 * @return the type-qualified name of this type
854 	 * @since 2.0
855 	 */
getTypeQualifiedName(char enclosingTypeSeparator)856 	String getTypeQualifiedName(char enclosingTypeSeparator);
857 
858 	/**
859 	 * Returns the immediate member types declared by this type.
860 	 * The results are listed in the order in which they appear in the source or class file.
861 	 *
862 	 * @exception JavaModelException if this element does not exist or if an
863 	 *		exception occurs while accessing its corresponding resource.
864 	 * @return the immediate member types declared by this type
865 	 */
getTypes()866 	IType[] getTypes() throws JavaModelException;
867 
868 	/**
869 	 * Returns whether this type represents an anonymous type.
870 	 *
871 	 * @exception JavaModelException if this element does not exist or if an
872 	 *		exception occurs while accessing its corresponding resource.
873 	 * @return true if this type represents an anonymous type, false otherwise
874 	 * @since 2.0
875 	 */
isAnonymous()876 	boolean isAnonymous() throws JavaModelException;
877 
878 	/**
879 	 * Returns whether this type represents a class.
880 	 * <p>
881 	 * Note that a class can neither be an interface, an enumeration class, nor an annotation type.
882 	 * </p>
883 	 *
884 	 * @exception JavaModelException if this element does not exist or if an
885 	 *		exception occurs while accessing its corresponding resource.
886 	 * @return true if this type represents a class, false otherwise
887 	 */
isClass()888 	boolean isClass() throws JavaModelException;
889 
890 	/**
891 	 * Returns whether this type represents an enumeration class.
892 	 * <p>
893 	 * Note that an enumeration class can neither be a class, an interface, nor an annotation type.
894 	 * </p>
895 	 *
896 	 * @exception JavaModelException if this element does not exist or if an
897 	 *		exception occurs while accessing its corresponding resource.
898 	 * @return true if this type represents an enumeration class,
899 	 * false otherwise
900 	 * @since 3.0
901 	 */
isEnum()902 	boolean isEnum() throws JavaModelException;
903 
904 	/**
905 	 * Returns whether this type represents a record class.
906 	 * <p>
907 	 * Note that a record class can neither be an enumeration, an interface, nor an annotation type.
908 	 * </p>
909 	 *
910 	 * @exception JavaModelException if this element does not exist or if an
911 	 *		exception occurs while accessing its corresponding resource.
912 	 * @return true if this type represents a record class,
913 	 * false otherwise
914 	 * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
915 	 */
isRecord()916 	boolean isRecord() throws JavaModelException;
917 	/**
918 	 * Returns the record components declared by this record class, or an empty
919 	 * array if this is not a record.
920 	 *
921 	 * @exception JavaModelException if this element does not exist or if an
922 	 *		exception occurs while accessing its corresponding resource.
923 	 * @return record components declared by this record class
924 	 * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
925 	 */
getRecordComponents()926 	default IField[] getRecordComponents() throws JavaModelException {
927 		return null;
928 	}
929 	/**
930 	 * Returns the record component with the specified name
931 	 * in this type (for example, <code>"bar"</code>).
932 	 * This is a handle-only method. The record component may or may not exist.
933 	 *
934 	 * @param name the given name
935 	 * @return the record component with the specified name in this record
936 	 * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
937 	 */
getRecordComponent(String name)938 	IField getRecordComponent(String name);
939 
940 	/**
941 	 * Returns whether this type represents an interface.
942 	 * <p>
943 	 * Note that an interface can also be an annotation type, but it can neither be a class nor an enumeration class.
944 	 * </p>
945 	 *
946 	 * @exception JavaModelException if this element does not exist or if an
947 	 *		exception occurs while accessing its corresponding resource.
948 	 * @return true if this type represents an interface, false otherwise
949 	 */
isInterface()950 	boolean isInterface() throws JavaModelException;
951 
952 	/**
953 	 * Returns whether this type represents an annotation type.
954 	 * <p>
955 	 * Note that an annotation type is also an interface, but it can neither be a class nor an enumeration class.
956 	 * </p>
957 	 *
958 	 * @exception JavaModelException if this element does not exist or if an
959 	 *		exception occurs while accessing its corresponding resource.
960 	 * @return true if this type represents an annotation type,
961 	 * false otherwise
962 	 * @since 3.0
963 	 */
isAnnotation()964 	boolean isAnnotation() throws JavaModelException;
965 
966 	/**
967 	 * Returns whether this type represents a local type. For an anonymous type,
968 	 * this method returns true.
969 	 * <p>
970 	 * Note: This deviates from JLS3 14.3, which states that anonymous types are
971 	 * not local types since they do not have a name.
972 	 * </p>
973 	 *
974 	 * @exception JavaModelException if this element does not exist or if an
975 	 *		exception occurs while accessing its corresponding resource.
976 	 * @return true if this type represents a local type, false otherwise
977 	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isLocal()
978 	 * @since 2.0
979 	 */
isLocal()980 	boolean isLocal() throws JavaModelException;
981 
982 	/**
983 	 * Returns whether this type represents a member type.
984 	 *
985 	 * @exception JavaModelException if this element does not exist or if an
986 	 *		exception occurs while accessing its corresponding resource.
987 	 * @return true if this type represents a member type, false otherwise
988 	 * @since 2.0
989 	 */
isMember()990 	boolean isMember() throws JavaModelException;
991 	/**
992 	 * Returns whether this type represents a resolved type.
993 	 * If a type is resolved, its key contains resolved information.
994 	 *
995 	 * @return whether this type represents a resolved type.
996 	 * @since 3.1
997 	 */
isResolved()998 	boolean isResolved();
999 	/**
1000 	 * Loads a previously saved ITypeHierarchy from an input stream. A type hierarchy can
1001 	 * be stored using ITypeHierachy#store(OutputStream).
1002 	 *
1003 	 * Only hierarchies originally created by the following methods can be loaded:
1004 	 * <ul>
1005 	 * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>
1006 	 * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>
1007 	 * <li>IType#newTypeHierarchy(IProgressMonitor)</li>
1008 	 * </ul>
1009 	 *
1010 	 * @param input stream where hierarchy will be read
1011 	 * @param monitor the given progress monitor
1012 	 * @return the stored hierarchy
1013 	 * @exception JavaModelException if the hierarchy could not be restored, reasons include:
1014 	 *      - type is not the focus of the hierarchy or
1015 	 *		- unable to read the input stream (wrong format, IOException during reading, ...)
1016 	 * @see ITypeHierarchy#store(java.io.OutputStream, IProgressMonitor)
1017 	 * @since 2.1
1018 	 */
loadTypeHierachy(InputStream input, IProgressMonitor monitor)1019 	ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throws JavaModelException;
1020 	/**
1021 	 * Creates and returns a type hierarchy for this type containing
1022 	 * this type and all of its supertypes.
1023 	 *
1024 	 * @param monitor the given progress monitor
1025 	 * @exception JavaModelException if this element does not exist or if an
1026 	 *		exception occurs while accessing its corresponding resource.
1027 	 * @return a type hierarchy for this type containing this type and all of its supertypes
1028 	 */
newSupertypeHierarchy(IProgressMonitor monitor)1029 	ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws JavaModelException;
1030 
1031 	/**
1032 	 * Creates and returns a type hierarchy for this type containing
1033 	 * this type and all of its supertypes, considering types in the given
1034 	 * working copies. In other words, the list of working copies will take
1035 	 * precedence over their original compilation units in the workspace.
1036 	 * <p>
1037 	 * Note that passing an empty working copy will be as if the original compilation
1038 	 * unit had been deleted.
1039 	 * </p>
1040 	 *
1041 	 * @param workingCopies the working copies that take precedence over their original compilation units
1042 	 * @param monitor the given progress monitor
1043 	 * @return a type hierarchy for this type containing this type and all of its supertypes
1044 	 * @exception JavaModelException if this element does not exist or if an
1045 	 *		exception occurs while accessing its corresponding resource.
1046 	 * @since 3.0
1047 	 */
newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor)1048 	ITypeHierarchy newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor)
1049 		throws JavaModelException;
1050 
1051 	/**
1052 	 * Creates and returns a type hierarchy for this type containing
1053 	 * this type and all of its supertypes, considering types in the given
1054 	 * working copies. In other words, the list of working copies will take
1055 	 * precedence over their original compilation units in the workspace.
1056 	 * <p>
1057 	 * Note that passing an empty working copy will be as if the original compilation
1058 	 * unit had been deleted.
1059 	 * </p>
1060 	 *
1061 	 * @param workingCopies the working copies that take precedence over their original compilation units
1062 	 * @param monitor the given progress monitor
1063 	 * @return a type hierarchy for this type containing this type and all of its supertypes
1064 	 * @exception JavaModelException if this element does not exist or if an
1065 	 *		exception occurs while accessing its corresponding resource.
1066 	 * @since 2.0
1067 	 * @deprecated Use {@link #newSupertypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead
1068 	 */
newSupertypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor)1069 	ITypeHierarchy newSupertypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor)
1070 		throws JavaModelException;
1071 
1072 	/**
1073 	 * Creates and returns a type hierarchy for this type containing
1074 	 * this type and all of its supertypes, considering types in the
1075 	 * working copies with the given owner.
1076 	 * In other words, the owner's working copies will take
1077 	 * precedence over their original compilation units in the workspace.
1078 	 * <p>
1079 	 * Note that if a working copy is empty, it will be as if the original compilation
1080 	 * unit had been deleted.
1081 	 * <p>
1082 	 *
1083 	 * @param owner the owner of working copies that take precedence over their original compilation units
1084 	 * @param monitor the given progress monitor
1085 	 * @return a type hierarchy for this type containing this type and all of its supertypes
1086 	 * @exception JavaModelException if this element does not exist or if an
1087 	 *		exception occurs while accessing its corresponding resource.
1088 	 * @since 3.0
1089 	 */
newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)1090 	ITypeHierarchy newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)
1091 		throws JavaModelException;
1092 
1093 	/**
1094 	 * Creates and returns a type hierarchy for this type containing
1095 	 * this type, all of its supertypes, and all its subtypes
1096 	 * in the context of the given project.
1097 	 *
1098 	 * @param project the given project
1099 	 * @param monitor the given progress monitor
1100 	 * @exception JavaModelException if this element does not exist or if an
1101 	 *		exception occurs while accessing its corresponding resource.
1102 	 * @return a type hierarchy for this type containing
1103 	 * this type, all of its supertypes, and all its subtypes
1104 	 * in the context of the given project
1105 	 */
newTypeHierarchy(IJavaProject project, IProgressMonitor monitor)1106 	ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException;
1107 
1108 	/**
1109 	 * Creates and returns a type hierarchy for this type containing
1110 	 * this type, all of its supertypes, and all its subtypes
1111 	 * in the context of the given project, considering types in the
1112 	 * working copies with the given owner.
1113 	 * In other words, the owner's working copies will take
1114 	 * precedence over their original compilation units in the workspace.
1115 	 * <p>
1116 	 * Note that if a working copy is empty, it will be as if the original compilation
1117 	 * unit had been deleted.
1118 	 * <p>
1119 	 *
1120 	 * @param project the given project
1121 	 * @param owner the owner of working copies that take precedence over their original compilation units
1122 	 * @param monitor the given progress monitor
1123 	 * @exception JavaModelException if this element does not exist or if an
1124 	 *		exception occurs while accessing its corresponding resource.
1125 	 * @return a type hierarchy for this type containing
1126 	 * this type, all of its supertypes, and all its subtypes
1127 	 * in the context of the given project
1128 	 * @since 3.0
1129 	 */
newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor)1130 	ITypeHierarchy newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
1131 
1132 	/**
1133 	 * Creates and returns a type hierarchy for this type containing
1134 	 * this type, all of its supertypes, and all its subtypes in the workspace.
1135 	 *
1136 	 * @param monitor the given progress monitor
1137 	 * @exception JavaModelException if this element does not exist or if an
1138 	 *		exception occurs while accessing its corresponding resource.
1139 	 * @return a type hierarchy for this type containing
1140 	 * this type, all of its supertypes, and all its subtypes in the workspace
1141 	 */
newTypeHierarchy(IProgressMonitor monitor)1142 	ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException;
1143 
1144 	/**
1145 	 * Creates and returns a type hierarchy for this type containing
1146 	 * this type, all of its supertypes, and all its subtypes in the workspace,
1147 	 * considering types in the given working copies. In other words, the list of working
1148 	 * copies that will take precedence over their original compilation units in the workspace.
1149 	 * <p>
1150 	 * Note that passing an empty working copy will be as if the original compilation
1151 	 * unit had been deleted.
1152 	 *
1153 	 * @param workingCopies the working copies that take precedence over their original compilation units
1154 	 * @param monitor the given progress monitor
1155 	 * @return a type hierarchy for this type containing
1156 	 * this type, all of its supertypes, and all its subtypes in the workspace
1157 	 * @exception JavaModelException if this element does not exist or if an
1158 	 *		exception occurs while accessing its corresponding resource.
1159 	 * @since 3.0
1160 	 */
newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor)1161 	ITypeHierarchy newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException;
1162 
1163 	/**
1164 	 * Creates and returns a type hierarchy for this type containing
1165 	 * this type, all of its supertypes, and all its subtypes in the workspace,
1166 	 * considering types in the given working copies. In other words, the list of working
1167 	 * copies that will take precedence over their original compilation units in the workspace.
1168 	 * <p>
1169 	 * Note that passing an empty working copy will be as if the original compilation
1170 	 * unit had been deleted.
1171 	 *
1172 	 * @param workingCopies the working copies that take precedence over their original compilation units
1173 	 * @param monitor the given progress monitor
1174 	 * @return a type hierarchy for this type containing
1175 	 * this type, all of its supertypes, and all its subtypes in the workspace
1176 	 * @exception JavaModelException if this element does not exist or if an
1177 	 *		exception occurs while accessing its corresponding resource.
1178 	 * @since 2.0
1179 	 * @deprecated Use {@link #newTypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead
1180 	 */
newTypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor)1181 	ITypeHierarchy newTypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor) throws JavaModelException;
1182 
1183 	/**
1184 	 * Creates and returns a type hierarchy for this type containing
1185 	 * this type, all of its supertypes, and all its subtypes in the workspace,
1186 	 * considering types in the working copies with the given owner.
1187 	 * In other words, the owner's working copies will take
1188 	 * precedence over their original compilation units in the workspace.
1189 	 * <p>
1190 	 * Note that if a working copy is empty, it will be as if the original compilation
1191 	 * unit had been deleted.
1192 	 * <p>
1193 	 *
1194 	 * @param owner the owner of working copies that take precedence over their original compilation units
1195 	 * @param monitor the given progress monitor
1196 	 * @return a type hierarchy for this type containing
1197 	 * this type, all of its supertypes, and all its subtypes in the workspace
1198 	 * @exception JavaModelException if this element does not exist or if an
1199 	 *		exception occurs while accessing its corresponding resource.
1200 	 * @since 3.0
1201 	 */
newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)1202 	ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
1203 
1204 	/**
1205 	 * Resolves the given type name within the context of this type (depending on the type hierarchy
1206 	 * and its imports).
1207 	 * <p>
1208 	 * Multiple answers might be found in case there are ambiguous matches.
1209 	 * </p>
1210 	 * <p>
1211 	 * Each matching type name is decomposed as an array of two strings, the first denoting the package
1212 	 * name (dot-separated) and the second being the type name. The package name is empty if it is the
1213 	 * default package. The type name is the type qualified name using a '.' enclosing type separator.
1214 	 * </p>
1215 	 * <p>
1216 	 * Returns <code>null</code> if unable to find any matching type.
1217 	 * </p>
1218 	 *<p>
1219 	 * For example, resolution of <code>"Object"</code> would typically return
1220 	 * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns
1221 	 * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the
1222 	 * default package.
1223 	 * </p>
1224 	 *
1225 	 * @param typeName the given type name
1226 	 * @exception JavaModelException if code resolve could not be performed.
1227 	 * @return the resolved type names or <code>null</code> if unable to find any matching type
1228 	 * @see #getTypeQualifiedName(char)
1229 	 */
resolveType(String typeName)1230 	String[][] resolveType(String typeName) throws JavaModelException;
1231 
1232 	/**
1233 	 * Resolves the given type name within the context of this type (depending on the type hierarchy
1234 	 * and its imports) and using the given owner's working copies, considering types in the
1235 	 * working copies with the given owner. In other words, the owner's working copies will take
1236 	 * precedence over their original compilation units in the workspace.
1237 	 * <p>
1238 	 * Note that if a working copy is empty, it will be as if the original compilation
1239 	 * unit had been deleted.
1240 	 * </p>
1241 	 * <p>Multiple answers might be found in case there are ambiguous matches.
1242 	 * </p>
1243 	 * <p>
1244 	 * Each matching type name is decomposed as an array of two strings, the first denoting the package
1245 	 * name (dot-separated) and the second being the type name. The package name is empty if it is the
1246 	 * default package. The type name is the type qualified name using a '.' enclosing type separator.
1247 	 * </p>
1248 	 * <p>
1249 	 * Returns <code>null</code> if unable to find any matching type.
1250 	 *</p>
1251 	 *<p>
1252 	 * For example, resolution of <code>"Object"</code> would typically return
1253 	 * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns
1254 	 * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the
1255 	 * default package.
1256 	 * </p>
1257 	 *
1258 	 * @param typeName the given type name
1259 	 * @param owner the owner of working copies that take precedence over their original compilation units
1260 	 * @exception JavaModelException if code resolve could not be performed.
1261 	 * @return the resolved type names or <code>null</code> if unable to find any matching type
1262 	 * @see #getTypeQualifiedName(char)
1263 	 * @since 3.0
1264 	 */
resolveType(String typeName, WorkingCopyOwner owner)1265 	String[][] resolveType(String typeName, WorkingCopyOwner owner) throws JavaModelException;
1266 
1267 	/**
1268 	 * Returns whether this type represents a lambda expression.
1269 	 *
1270 	 * @return true if this type represents a lambda expression, false otherwise
1271 	 * @since 3.10
1272 	 */
isLambda()1273 	public boolean isLambda();
1274 
1275 	/**
1276 	 * Strengthen the contract of the inherited method to signal that the returned class file
1277 	 * is always an {@link IOrdinaryClassFile}.
1278 	 * @since 3.14
1279 	 */
1280 	@Override
getClassFile()1281 	IOrdinaryClassFile getClassFile();
1282 }
1283