Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.

1 /*******************************************************************************2 * Copyright (c) 2000, 2006 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 *8 * Contributors:9 * IBM Corporation - initial API and implementation10 * IBM Corporation - added J2SE 1.5 support11 *******************************************************************************/12 package org.eclipse.jdt.core;13 14 importjava.io.InputStream;15 16 importorg.eclipse.core.runtime.IProgressMonitor;17 18 /**19 * Represents either a source type in a compilation unit (either a top-level20 * type, a member type, a local type or an anonymous type) 21 * or a binary type in a class file. Enumeration classes and annotation22 * types are subkinds of classes and interfaces, respectively.23 * <p>24 * Note that the element name of an anonymous source type is always empty.25 * </p><p>26 * If a binary type cannot be parsed, its structure remains unknown.27 * Use <code>IJavaElement.isStructureKnown</code> to determine whether this28 * is the case.29 * </p>30 * <p>31 * The children are of type <code>IMember</code>, which includes <code>IField</code>,32 * <code>IMethod</code>, <code>IInitializer</code> and <code>IType</code>.33 * The children are listed in the order in which they appear in the source or class file.34 * </p>35 * <p>36 * This interface is not intended to be implemented by clients.37 * </p>38 */39 publicinterface IType extendsIMember {40 /**41 * Do code completion inside a code snippet in the context of the current type.42 * 43 * If the type can access to his source code and the insertion position is valid,44 * then completion is performed against source. Otherwise the completion is performed45 * against type structure and given locals variables.46 * 47 * @param snippet the code snippet48 * @param insertion the position with in source where the snippet49 * is inserted. This position must not be in comments.50 * A possible value is -1, if the position is not known.51 * @param position the position within snippet where the user 52 * is performing code assist.53 * @param localVariableTypeNames an array (possibly empty) of fully qualified 54 * type names of local variables visible at the current scope55 * @param localVariableNames an array (possibly empty) of local variable names 56 * that are visible at the current scope57 * @param localVariableModifiers an array (possible empty) of modifiers for 58 * local variables59 * @param isStatic whether the current scope is in a static context60 * @param requestor the completion requestor61 * @exception JavaModelException if this element does not exist or if an62 * exception occurs while accessing its corresponding resource.63 * @since 2.064 * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor)} instead.65 */66 void codeComplete(67 char[] snippet,68 int insertion,69 int position,70 char[][] localVariableTypeNames,71 char[][] localVariableNames,72 int[] localVariableModifiers,73 boolean isStatic,74 ICompletionRequestor requestor)75 throwsJavaModelException;76 77 /**78 * Do code completion inside a code snippet in the context of the current type.79 * It considers types in the working copies with the given owner first. In other words, 80 * the owner's working copies will take precedence over their original compilation units81 * in the workspace.82 * <p>83 * Note that if a working copy is empty, it will be as if the original compilation84 * unit had been deleted.85 * </p><p>86 * If the type can access to his source code and the insertion position is valid,87 * then completion is performed against source. Otherwise the completion is performed88 * against type structure and given locals variables.89 * </p>90 * 91 * @param snippet the code snippet92 * @param insertion the position with in source where the snippet93 * is inserted. This position must not be in comments.94 * A possible value is -1, if the position is not known.95 * @param position the position with in snippet where the user 96 * is performing code assist.97 * @param localVariableTypeNames an array (possibly empty) of fully qualified 98 * type names of local variables visible at the current scope99 * @param localVariableNames an array (possibly empty) of local variable names 100 * that are visible at the current scope101 * @param localVariableModifiers an array (possible empty) of modifiers for 102 * local variables103 * @param isStatic whether the current scope is in a static context104 * @param requestor the completion requestor105 * @param owner the owner of working copies that take precedence over their original compilation units106 * @exception JavaModelException if this element does not exist or if an107 * exception occurs while accessing its corresponding resource.108 * @since 3.0109 * @deprecated Use {@link #codeComplete(char[],int,int,char[][],char[][],int[],boolean,CompletionRequestor,WorkingCopyOwner)} instead.110 */111 void codeComplete(112 char[] snippet,113 int insertion,114 int position,115 char[][] localVariableTypeNames,116 char[][] localVariableNames,117 int[] localVariableModifiers,118 boolean isStatic,119 ICompletionRequestor requestor,120 WorkingCopyOwner owner)121 throwsJavaModelException;122 123 /**124 * Do code completion inside a code snippet in the context of the current type.125 * 126 * If the type can access to his source code and the insertion position is valid,127 * then completion is performed against source. Otherwise the completion is performed128 * against type structure and given locals variables.129 * 130 * @param snippet the code snippet131 * @param insertion the position with in source where the snippet132 * is inserted. This position must not be in comments.133 * A possible value is -1, if the position is not known.134 * @param position the position within snippet where the user 135 * is performing code assist.136 * @param localVariableTypeNames an array (possibly empty) of fully qualified 137 * type names of local variables visible at the current scope138 * @param localVariableNames an array (possibly empty) of local variable names 139 * that are visible at the current scope140 * @param localVariableModifiers an array (possible empty) of modifiers for 141 * local variables142 * @param isStatic whether the current scope is in a static context143 * @param requestor the completion requestor144 * @exception JavaModelException if this element does not exist or if an145 * exception occurs while accessing its corresponding resource.146 * @since 3.1147 */148 void codeComplete(149 char[] snippet,150 int insertion,151 int position,152 char[][] localVariableTypeNames,153 char[][] localVariableNames,154 int[] localVariableModifiers,155 boolean isStatic,156 CompletionRequestor requestor)157 throwsJavaModelException;158 159 /**160 * Do code completion inside a code snippet in the context of the current type.161 * It considers types in the working copies with the given owner first. In other words, 162 * the owner's working copies will take precedence over their original compilation units163 * in the workspace.164 * <p>165 * Note that if a working copy is empty, it will be as if the original compilation166 * unit had been deleted.167 * </p><p>168 * If the type can access to his source code and the insertion position is valid,169 * then completion is performed against source. Otherwise the completion is performed170 * against type structure and given locals variables.171 * </p>172 * 173 * @param snippet the code snippet174 * @param insertion the position with in source where the snippet175 * is inserted. This position must not be in comments.176 * A possible value is -1, if the position is not known.177 * @param position the position with in snippet where the user 178 * is performing code assist.179 * @param localVariableTypeNames an array (possibly empty) of fully qualified 180 * type names of local variables visible at the current scope181 * @param localVariableNames an array (possibly empty) of local variable names 182 * that are visible at the current scope183 * @param localVariableModifiers an array (possible empty) of modifiers for 184 * local variables185 * @param isStatic whether the current scope is in a static context186 * @param requestor the completion requestor187 * @param owner the owner of working copies that take precedence over their original compilation units188 * @exception JavaModelException if this element does not exist or if an189 * exception occurs while accessing its corresponding resource.190 * @since 3.1191 */192 void codeComplete(193 char[] snippet,194 int insertion,195 int position,196 char[][] localVariableTypeNames,197 char[][] localVariableNames,198 int[] localVariableModifiers,199 boolean isStatic,200 CompletionRequestor requestor,201 WorkingCopyOwner owner)202 throwsJavaModelException;203 204 205 /**206 * Creates and returns a field in this type with the207 * given contents.208 * <p>209 * Optionally, the new element can be positioned before the specified210 * sibling. If no sibling is specified, the element will be inserted211 * as the last field declaration in this type.</p>212 *213 * <p>It is possible that a field with the same name already exists in this type.214 * The value of the <code>force</code> parameter effects the resolution of215 * such a conflict:<ul>216 * <li> <code>true</code> - in this case the field is created with the new contents</li>217 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>218 * </ul></p>219 *220 * @param contents the given contents221 * @param sibling the given sibling222 * @param force a flag in case the same name already exists in this type223 * @param monitor the given progress monitor224 * @exception JavaModelException if the element could not be created. Reasons include:225 * <ul>226 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>227 * <li> A <code>CoreException</code> occurred while updating an underlying resource228 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)229 * <li> The contents could not be recognized as a field declaration (INVALID_CONTENTS)230 * <li> This type is read-only (binary) (READ_ONLY)231 * <li> There was a naming collision with an existing field (NAME_COLLISION)232 * </ul>233 * @return a field in this type with the given contents234 */235 IField createField(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)236 throwsJavaModelException;237 238 /**239 * Creates and returns a static initializer in this type with the240 * given contents.241 * <p>242 * Optionally, the new element can be positioned before the specified243 * sibling. If no sibling is specified, the new initializer is positioned244 * after the last existing initializer declaration, or as the first member245 * in the type if there are no initializers.</p>246 *247 * @param contents the given contents248 * @param sibling the given sibling249 * @param monitor the given progress monitor250 * @exception JavaModelException if the element could not be created. Reasons include:251 * <ul>252 * <li> This element does not exist253 * <li> A <code>CoreException</code> occurred while updating an underlying resource254 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)255 * <li> The contents could not be recognized as an initializer declaration (INVALID_CONTENTS)256 * <li> This type is read-only (binary) (READ_ONLY)257 * </ul>258 * @return a static initializer in this type with the given contents259 */260 IInitializer createInitializer(String contents, IJavaElement sibling, IProgressMonitor monitor)261 throwsJavaModelException;262 263 /**264 * Creates and returns a method or constructor in this type with the265 * given contents.266 * <p>267 * Optionally, the new element can be positioned before the specified268 * sibling. If no sibling is specified, the element will be appended269 * to this type.270 *271 * <p>It is possible that a method with the same signature already exists in this type.272 * The value of the <code>force</code> parameter effects the resolution of273 * such a conflict:<ul>274 * <li> <code>true</code> - in this case the method is created with the new contents</li>275 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>276 * </ul></p>277 *278 * @param contents the given contents279 * @param sibling the given sibling280 * @param force a flag in case the same name already exists in this type281 * @param monitor the given progress monitor282 * @exception JavaModelException if the element could not be created. Reasons include:283 * <ul>284 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>285 * <li> A <code>CoreException</code> occurred while updating an underlying resource286 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)287 * <li> The contents could not be recognized as a method or constructor288 * declaration (INVALID_CONTENTS)289 * <li> This type is read-only (binary) (READ_ONLY)290 * <li> There was a naming collision with an existing method (NAME_COLLISION)291 * </ul>292 * @return a method or constructor in this type with the given contents293 */294 IMethod createMethod(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)295 throwsJavaModelException;296 297 /**298 * Creates and returns a type in this type with the299 * given contents.300 * <p>301 * Optionally, the new type can be positioned before the specified302 * sibling. If no sibling is specified, the type will be appended303 * to this type.</p>304 *305 * <p>It is possible that a type with the same name already exists in this type.306 * The value of the <code>force</code> parameter effects the resolution of307 * such a conflict:<ul>308 * <li> <code>true</code> - in this case the type is created with the new contents</li>309 * <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>310 * </ul></p>311 *312 * @param contents the given contents313 * @param sibling the given sibling314 * @param force a flag in case the same name already exists in this type315 * @param monitor the given progress monitor316 * @exception JavaModelException if the element could not be created. Reasons include:317 * <ul>318 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>319 * <li> A <code>CoreException</code> occurred while updating an underlying resource320 * <li> The specified sibling is not a child of this type (INVALID_SIBLING)321 * <li> The contents could not be recognized as a type declaration (INVALID_CONTENTS)322 * <li> This type is read-only (binary) (READ_ONLY)323 * <li> There was a naming collision with an existing field (NAME_COLLISION)324 * </ul>325 * @return a type in this type with the given contents326 */327 IType createType(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor)328 throwsJavaModelException;329 330 /** 331 * Finds the methods in this type that correspond to332 * the given method.333 * A method m1 corresponds to another method m2 if:334 * <ul>335 * <li>m1 has the same element name as m2.336 * <li>m1 has the same number of arguments as m2 and337 * the simple names of the argument types must be equals.338 * <li>m1 exists.339 * </ul>340 * @param method the given method341 * @return the found method or <code>null</code> if no such methods can be found.342 * 343 * @since 2.0 344 */345 IMethod[] findMethods(IMethod method);346 347 /**348 * Returns the children of this type that have the given category as a <code>@category</code> tag.349 * Returns an empty array if no children with this category exist.350 * 351 * @return the children for the given category.352 * @exception JavaModelException if this element does not exist or if an353 * exception occurs while accessing its corresponding resource.354 * @since 3.2355 */356 IJavaElement[] getChildrenForCategory(String category) throwsJavaModelException;357 358 /**359 * Returns the simple name of this type, unqualified by package or enclosing type.360 * This is a handle-only method.361 * 362 * @return the simple name of this type363 */364 String getElementName();365 366 /**367 * Returns the field with the specified name368 * in this type (for example, <code>"bar"</code>).369 * This is a handle-only method. The field may or may not exist.370 * 371 * @param name the given name372 * @return the field with the specified name in this type373 */374 IField getField(String name);375 376 /**377 * Returns the fields declared by this type.378 * If this is a source type, the results are listed in the order379 * in which they appear in the source, otherwise, the results are380 * in no particular order. For binary types, this includes synthetic fields.381 *382 * @exception JavaModelException if this element does not exist or if an383 * exception occurs while accessing its corresponding resource.384 * @return the fields declared by this type385 */386 IField[] getFields() throwsJavaModelException;387 388 /**389 * Returns the fully qualified name of this type, 390 * including qualification for any containing types and packages.391 * This is the name of the package, followed by <code>'.'</code>,392 * followed by the type-qualified name.393 * This is a handle-only method.394 *395 * @see IType#getTypeQualifiedName()396 * @return the fully qualified name of this type397 */398 String getFullyQualifiedName();399 400 /**401 * Returns the fully qualified name of this type, 402 * including qualification for any containing types and packages.403 * This is the name of the package, followed by <code>'.'</code>,404 * followed by the type-qualified name using the <code>enclosingTypeSeparator</code>.405 * 406 * For example:407 * <ul>408 * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java 409 * in a package x.y using the '.' separator is "x.y.A.B"</li>410 * <li>the fully qualified name of a class B defined as a member of a class A in a compilation unit A.java 411 * in a package x.y using the '$' separator is "x.y.A$B"</li>412 * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class413 * using the '.' separator is "x.y.A.B"</li>414 * <li>the fully qualified name of a binary type whose class file is x/y/A$B.class415 * using the '$' separator is "x.y.A$B"</li>416 * <li>the fully qualified name of an anonymous binary type whose class file is x/y/A$1.class417 * using the '.' separator is "x.y.A$1"</li>418 * </ul>419 * 420 * This is a handle-only method.421 *422 * @param enclosingTypeSeparator the given enclosing type separator423 * @return the fully qualified name of this type, including qualification for any containing types and packages424 * @see IType#getTypeQualifiedName(char)425 * @since 2.0426 */427 String getFullyQualifiedName(char enclosingTypeSeparator);428 429 /**430 * Returns this type's fully qualified name followed by its type parameters between angle brakets if it is a generic type.431 * For example, "p.X&lt;T&gt;", "java.util.Map&lt;java.lang.String, p.X&gt;"432 * 433 * @exception JavaModelException if this element does not exist or if an434 * exception occurs while accessing its corresponding resource.435 * @return the fully qualified parameterized representation of this type436 * @since 3.1437 */438 String getFullyQualifiedParameterizedName() throwsJavaModelException;439 440 /**441 * Returns the initializer with the specified position relative to442 * the order they are defined in the source.443 * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).444 * This is a handle-only method. The initializer may or may not be present.445 * 446 * @param occurrenceCount the specified position447 * @return the initializer with the specified position relative to the order they are defined in the source448 */449 IInitializer getInitializer(int occurrenceCount);450 451 /**452 * Returns the initializers declared by this type.453 * For binary types this is an empty collection.454 * If this is a source type, the results are listed in the order455 * in which they appear in the source.456 *457 * @exception JavaModelException if this element does not exist or if an458 * exception occurs while accessing its corresponding resource.459 * @return the initializers declared by this type460 */461 IInitializer[] getInitializers() throwsJavaModelException;462 463 /**464 * Returns the binding key for this type. A binding key is a key that uniquely465 * identifies this type. It allows access to generic info for parameterized466 * types.467 * 468 * @return the binding key for this type469 * @see org.eclipse.jdt.core.dom.IBinding#getKey()470 * @see BindingKey471 * @since 3.1472 */473 String getKey();474 475 /**476 * Returns the method with the specified name and parameter types477 * in this type (for example, <code>"foo", {"I", "QString;"}</code>).478 * To get the handle for a constructor, the name specified must be the479 * simple name of the enclosing type.480 * This is a handle-only method. The method may or may not be present.481 * <p>482 * The type signatures may be either unresolved (for source types)483 * or resolved (for binary types), and either basic (for basic types)484 * or rich (for parameterized types). See {@link Signature} for details.485 * </p>486 * 487 * @param name the given name488 * @param parameterTypeSignatures the given parameter types489 * @return the method with the specified name and parameter types in this type490 */491 IMethod getMethod(String name, String[] parameterTypeSignatures);492 493 /**494 * Returns the methods and constructors declared by this type.495 * For binary types, this may include the special <code>&lt;clinit&gt;</code>; method 496 * and synthetic methods.497 * If this is a source type, the results are listed in the order498 * in which they appear in the source, otherwise, the results are499 * in no particular order.500 *501 * @exception JavaModelException if this element does not exist or if an502 * exception occurs while accessing its corresponding resource.503 * @return the methods and constructors declared by this type504 */505 IMethod[] getMethods() throwsJavaModelException;506 507 /**508 * Returns the package fragment in which this element is defined.509 * This is a handle-only method.510 * 511 * @return the package fragment in which this element is defined512 */513 IPackageFragment getPackageFragment();514 515 /**516 * Returns the name of this type's superclass, or <code>null</code>517 * for source types that do not specify a superclass.518 * <p>519 * For interfaces, the superclass name is always <code>"java.lang.Object"</code>.520 * For source types, the name as declared is returned, for binary types,521 * the resolved, qualified name is returned.522 * For anonymous types, the superclass name is the name appearing after the 'new' keyword'.523 * If the superclass is a parameterized type, the string524 * may include its type arguments enclosed in "&lt;&gt;".525 * If the returned string is needed for anything other than display526 * purposes, use {@link #getSuperclassTypeSignature()} which returns527 * a structured type signature string containing more precise information.528 * </p>529 *530 * @exception JavaModelException if this element does not exist or if an531 * exception occurs while accessing its corresponding resource.532 * @return the name of this type's superclass, or <code>null</code> for source types that do not specify a superclass533 */534 String getSuperclassName() throwsJavaModelException;535 536 /**537 * Returns the type signature of this type's superclass, or 538 * <code>null</code> if none.539 * <p>540 * The type signature may be either unresolved (for source types)541 * or resolved (for binary types), and either basic (for basic types)542 * or rich (for parameterized types). See {@link Signature} for details.543 * </p>544 *545 * @exception JavaModelException if this element does not exist or if an546 * exception occurs while accessing its corresponding resource.547 * @return the type signature of this type's superclass, or548 * <code>null</code> if none549 * @since 3.0550 */551 String getSuperclassTypeSignature() throwsJavaModelException;552 553 /**554 * Returns the type signatures of the interfaces that this type555 * implements or extends, in the order in which they are listed in the556 * source.557 * <p>558 * For classes and enum types, this gives the interfaces that this559 * class implements. For interfaces and annotation types,560 * this gives the interfaces that this interface extends.561 * An empty collection is returned if this type does not implement or562 * extend any interfaces. For anonymous types, an empty collection is563 * always returned.564 * </p>565 * <p>566 * The type signatures may be either unresolved (for source types)567 * or resolved (for binary types), and either basic (for basic types)568 * or rich (for parameterized types). See {@link Signature} for details.569 * </p>570 *571 * @exception JavaModelException if this element does not exist or if an572 * exception occurs while accessing its corresponding resource.573 * @return the type signatures of interfaces that this type implements574 * or extends, in the order in which they are listed in the source, 575 * an empty collection if none576 * @since 3.0577 */578 String[] getSuperInterfaceTypeSignatures() throwsJavaModelException;579 580 /**581 * Returns the names of interfaces that this type implements or extends,582 * in the order in which they are listed in the source.583 * <p>584 * For classes, this gives the interfaces that this class implements.585 * For interfaces, this gives the interfaces that this interface extends.586 * An empty collection is returned if this type does not implement or587 * extend any interfaces. For source types, simple names are returned,588 * for binary types, qualified names are returned.589 * For anonymous types, an empty collection is always returned.590 * If the list of supertypes includes parameterized types,591 * the string may include type arguments enclosed in "&lt;&gt;".592 * If the result is needed for anything other than display593 * purposes, use {@link #getSuperInterfaceTypeSignatures()} which returns594 * structured signature strings containing more precise information.595 * </p>596 *597 * @exception JavaModelException if this element does not exist or if an598 * exception occurs while accessing its corresponding resource.599 * @return the names of interfaces that this type implements or extends, in the order in which they are listed in the source, 600 * an empty collection if none601 */602 String[] getSuperInterfaceNames() throwsJavaModelException;603 604 /**605 * Returns the formal type parameter signatures for this type.606 * Returns an empty array if this type has no formal type parameters.607 * <p>608 * The formal type parameter signatures may be either unresolved (for source609 * types) or resolved (for binary types). See {@link Signature} for details.610 * </p>611 *612 * @exception JavaModelException if this element does not exist or if an613 * exception occurs while accessing its corresponding resource.614 * @return the formal type parameter signatures of this type,615 * in the order declared in the source, an empty array if none616 * @see Signature617 * @since 3.0618 */619 String[] getTypeParameterSignatures() throwsJavaModelException;620 621 /**622 * Returns the formal type parameters for this type.623 * Returns an empty array if this type has no formal type parameters.624 *625 * @exception JavaModelException if this element does not exist or if an626 * exception occurs while accessing its corresponding resource.627 * @return the formal type parameters of this type,628 * in the order declared in the source, an empty array if none629 * @since 3.1630 */631 ITypeParameter[] getTypeParameters() throwsJavaModelException;632 633 /**634 * Returns the member type declared in this type with the given simple name.635 * This is a handle-only method. The type may or may not exist.636 * 637 * @param name the given simple name638 * @return the member type declared in this type with the given simple name639 */640 IType getType(String name);641 642 /**643 * Returns the type parameter declared in this type with the given name.644 * This is a handle-only method. The type parameter may or may not exist.645 * 646 * @param name the given simple name647 * @return the type parameter declared in this type with the given name648 * @since 3.1649 */650 ITypeParameter getTypeParameter(String name);651 652 /**653 * Returns the type-qualified name of this type, 654 * including qualification for any enclosing types,655 * but not including package qualification.656 * For source types, this consists of the simple names of any enclosing types, 657 * separated by <code>'$'</code>, followed by the simple name of this type658 * or the occurence count of this type if it is anonymous.659 * For binary types, this is the name of the class file without the ".class" suffix.660 * This is a handle-only method.661 * 662 * @return the type-qualified name of this type663 */664 String getTypeQualifiedName();665 666 /**667 * Returns the type-qualified name of this type, 668 * including qualification for any enclosing types,669 * but not including package qualification.670 * For source types, this consists of the simple names of any enclosing types, 671 * separated by <code>enclosingTypeSeparator</code>, followed by the 672 * simple name of this type or the occurence count of this type if it is anonymous.673 * For binary types, this is the name of the class file without the ".class" suffix.674 * 675 * For example:676 * <ul>677 * <li>the type qualified name of a class B defined as a member of a class A678 * using the '.' separator is "A.B"</li>679 * <li>the type qualified name of a class B defined as a member of a class A680 * using the '$' separator is "A$B"</li>681 * <li>the type qualified name of a binary type whose class file is A$B.class682 * using the '.' separator is "A$B"</li>683 * <li>the type qualified name of a binary type whose class file is A$B.class684 * using the '$' separator is "A$B"</li>685 * <li>the type qualified name of an anonymous binary type whose class file is A$1.class686 * using the '.' separator is "A$1"</li>687 * </ul>688 *689 * This is a handle-only method.690 * 691 * @param enclosingTypeSeparator the specified enclosing type separator692 * @return the type-qualified name of this type693 * @since 2.0694 */695 String getTypeQualifiedName(char enclosingTypeSeparator);696 697 /**698 * Returns the immediate member types declared by this type.699 * The results are listed in the order in which they appear in the source or class file.700 *701 * @exception JavaModelException if this element does not exist or if an702 * exception occurs while accessing its corresponding resource.703 * @return the immediate member types declared by this type704 */705 IType[] getTypes() throwsJavaModelException;706 707 /**708 * Returns whether this type represents an anonymous type.709 *710 * @exception JavaModelException if this element does not exist or if an711 * exception occurs while accessing its corresponding resource.712 * @return true if this type represents an anonymous type, false otherwise713 * @since 2.0714 */715 boolean isAnonymous() throwsJavaModelException;716 717 /**718 * Returns whether this type represents a class.719 * <p>720 * Note that a class can neither be an interface, an enumeration class, nor an annotation type.721 * </p>722 *723 * @exception JavaModelException if this element does not exist or if an724 * exception occurs while accessing its corresponding resource.725 * @return true if this type represents a class, false otherwise726 */727 boolean isClass() throwsJavaModelException;728 729 /**730 * Returns whether this type represents an enumeration class.731 * <p>732 * Note that an enumeration class can neither be a class, an interface, nor an annotation type.733 * </p>734 * 735 * @exception JavaModelException if this element does not exist or if an736 * exception occurs while accessing its corresponding resource.737 * @return true if this type represents an enumeration class,738 * false otherwise739 * @since 3.0740 */741 boolean isEnum() throwsJavaModelException;742 743 /**744 * Returns whether this type represents an interface.745 * <p>746 * Note that an interface can also be an annotation type, but it can neither be a class nor an enumeration class.747 * </p>748 *749 * @exception JavaModelException if this element does not exist or if an750 * exception occurs while accessing its corresponding resource.751 * @return true if this type represents an interface, false otherwise752 */753 boolean isInterface() throwsJavaModelException;754 755 /**756 * Returns whether this type represents an annotation type.757 * <p>758 * Note that an annotation type is also an interface, but it can neither be a class nor an enumeration class. 759 * </p>760 *761 * @exception JavaModelException if this element does not exist or if an762 * exception occurs while accessing its corresponding resource.763 * @return true if this type represents an annotation type,764 * false otherwise765 * @since 3.0766 */767 boolean isAnnotation() throwsJavaModelException;768 769 /**770 * Returns whether this type represents a local type.771 *772 * @exception JavaModelException if this element does not exist or if an773 * exception occurs while accessing its corresponding resource.774 * @return true if this type represents a local type, false otherwise775 * @since 2.0776 */777 boolean isLocal() throwsJavaModelException;778 779 /**780 * Returns whether this type represents a member type.781 *782 * @exception JavaModelException if this element does not exist or if an783 * exception occurs while accessing its corresponding resource.784 * @return true if this type represents a member type, false otherwise785 * @since 2.0786 */787 boolean isMember() throwsJavaModelException;788 /**789 * Returns whether this type represents a resolved type.790 * If a type is resolved, its key contains resolved information.791 * 792 * @return whether this type represents a resolved type.793 * @since 3.1794 */795 boolean isResolved();796 /**797 * Loads a previously saved ITypeHierarchy from an input stream. A type hierarchy can798 * be stored using ITypeHierachy#store(OutputStream).799 * 800 * Only hierarchies originally created by the following methods can be loaded:801 * <ul>802 * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>803 * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>804 * <li>IType#newTypeHierarchy(IProgressMonitor)</li>805 * </ul>806 * 807 * @param input stream where hierarchy will be read808 * @param monitor the given progress monitor809 * @return the stored hierarchy810 * @exception JavaModelException if the hierarchy could not be restored, reasons include:811 * - type is not the focus of the hierarchy or 812 * - unable to read the input stream (wrong format, IOException during reading, ...)813 * @see ITypeHierarchy#store(java.io.OutputStream, IProgressMonitor)814 * @since 2.1815 */816 ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throwsJavaModelException;817 /**818 * Creates and returns a type hierarchy for this type containing819 * this type and all of its supertypes.820 *821 * @param monitor the given progress monitor822 * @exception JavaModelException if this element does not exist or if an823 * exception occurs while accessing its corresponding resource.824 * @return a type hierarchy for this type containing this type and all of its supertypes825 */826 ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throwsJavaModelException;827 828 /**829 * Creates and returns a type hierarchy for this type containing830 * this type and all of its supertypes, considering types in the given 831 * working copies. In other words, the list of working copies will take 832 * precedence over their original compilation units in the workspace.833 * <p>834 * Note that passing an empty working copy will be as if the original compilation835 * unit had been deleted.836 * </p>837 *838 * @param workingCopies the working copies that take precedence over their original compilation units839 * @param monitor the given progress monitor840 * @return a type hierarchy for this type containing this type and all of its supertypes841 * @exception JavaModelException if this element does not exist or if an842 * exception occurs while accessing its corresponding resource.843 * @since 3.0844 */845 ITypeHierarchy newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor)846 throwsJavaModelException;847 848 /**849 * Creates and returns a type hierarchy for this type containing850 * this type and all of its supertypes, considering types in the given 851 * working copies. In other words, the list of working copies will take 852 * precedence over their original compilation units in the workspace.853 * <p>854 * Note that passing an empty working copy will be as if the original compilation855 * unit had been deleted.856 * </p>857 *858 * @param workingCopies the working copies that take precedence over their original compilation units859 * @param monitor the given progress monitor860 * @return a type hierarchy for this type containing this type and all of its supertypes861 * @exception JavaModelException if this element does not exist or if an862 * exception occurs while accessing its corresponding resource.863 * @since 2.0864 * @deprecated Use {@link #newSupertypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead865 */866 ITypeHierarchy newSupertypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor)867 throwsJavaModelException;868 869 /**870 * Creates and returns a type hierarchy for this type containing871 * this type and all of its supertypes, considering types in the 872 * working copies with the given owner. 873 * In other words, the owner's working copies will take 874 * precedence over their original compilation units in the workspace.875 * <p>876 * Note that if a working copy is empty, it will be as if the original compilation877 * unit had been deleted.878 * <p>879 *880 * @param owner the owner of working copies that take precedence over their original compilation units881 * @param monitor the given progress monitor882 * @return a type hierarchy for this type containing this type and all of its supertypes883 * @exception JavaModelException if this element does not exist or if an884 * exception occurs while accessing its corresponding resource.885 * @since 3.0886 */887 ITypeHierarchy newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)888 throwsJavaModelException;889 890 /**891 * Creates and returns a type hierarchy for this type containing892 * this type, all of its supertypes, and all its subtypes 893 * in the context of the given project.894 *895 * @param project the given project896 * @param monitor the given progress monitor897 * @exception JavaModelException if this element does not exist or if an898 * exception occurs while accessing its corresponding resource.899 * @return a type hierarchy for this type containing900 * this type, all of its supertypes, and all its subtypes 901 * in the context of the given project902 */903 ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throwsJavaModelException;904 905 /**906 * Creates and returns a type hierarchy for this type containing907 * this type, all of its supertypes, and all its subtypes 908 * in the context of the given project, considering types in the 909 * working copies with the given owner. 910 * In other words, the owner's working copies will take 911 * precedence over their original compilation units in the workspace.912 * <p>913 * Note that if a working copy is empty, it will be as if the original compilation914 * unit had been deleted.915 * <p>916 *917 * @param project the given project918 * @param owner the owner of working copies that take precedence over their original compilation units919 * @param monitor the given progress monitor920 * @exception JavaModelException if this element does not exist or if an921 * exception occurs while accessing its corresponding resource.922 * @return a type hierarchy for this type containing923 * this type, all of its supertypes, and all its subtypes 924 * in the context of the given project925 * @since 3.0926 */927 ITypeHierarchy newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throwsJavaModelException;928 929 /**930 * Creates and returns a type hierarchy for this type containing931 * this type, all of its supertypes, and all its subtypes in the workspace.932 *933 * @param monitor the given progress monitor934 * @exception JavaModelException if this element does not exist or if an935 * exception occurs while accessing its corresponding resource.936 * @return a type hierarchy for this type containing937 * this type, all of its supertypes, and all its subtypes in the workspace938 */939 ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throwsJavaModelException;940 941 /**942 * Creates and returns a type hierarchy for this type containing943 * this type, all of its supertypes, and all its subtypes in the workspace, 944 * considering types in the given working copies. In other words, the list of working 945 * copies that will take precedence over their original compilation units in the workspace.946 * <p>947 * Note that passing an empty working copy will be as if the original compilation948 * unit had been deleted.949 *950 * @param workingCopies the working copies that take precedence over their original compilation units951 * @param monitor the given progress monitor952 * @return a type hierarchy for this type containing953 * this type, all of its supertypes, and all its subtypes in the workspace954 * @exception JavaModelException if this element does not exist or if an955 * exception occurs while accessing its corresponding resource.956 * @since 3.0957 */958 ITypeHierarchy newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throwsJavaModelException;959 960 /**961 * Creates and returns a type hierarchy for this type containing962 * this type, all of its supertypes, and all its subtypes in the workspace, 963 * considering types in the given working copies. In other words, the list of working 964 * copies that will take precedence over their original compilation units in the workspace.965 * <p>966 * Note that passing an empty working copy will be as if the original compilation967 * unit had been deleted.968 *969 * @param workingCopies the working copies that take precedence over their original compilation units970 * @param monitor the given progress monitor971 * @return a type hierarchy for this type containing972 * this type, all of its supertypes, and all its subtypes in the workspace973 * @exception JavaModelException if this element does not exist or if an974 * exception occurs while accessing its corresponding resource.975 * @since 2.0976 * @deprecated Use {@link #newTypeHierarchy(ICompilationUnit[], IProgressMonitor)} instead977 */978 ITypeHierarchy newTypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor) throwsJavaModelException;979 980 /**981 * Creates and returns a type hierarchy for this type containing982 * this type, all of its supertypes, and all its subtypes in the workspace, 983 * considering types in the working copies with the given owner. 984 * In other words, the owner's working copies will take 985 * precedence over their original compilation units in the workspace.986 * <p>987 * Note that if a working copy is empty, it will be as if the original compilation988 * unit had been deleted.989 * <p>990 *991 * @param owner the owner of working copies that take precedence over their original compilation units992 * @param monitor the given progress monitor993 * @return a type hierarchy for this type containing994 * this type, all of its supertypes, and all its subtypes in the workspace995 * @exception JavaModelException if this element does not exist or if an996 * exception occurs while accessing its corresponding resource.997 * @since 3.0998 */999 ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throwsJavaModelException;10001001/**1002 * Resolves the given type name within the context of this type (depending on the type hierarchy 1003 * and its imports). 1004 * <p>1005 * Multiple answers might be found in case there are ambiguous matches.1006 * </p>1007 * <p>1008 * Each matching type name is decomposed as an array of two strings, the first denoting the package1009 * name (dot-separated) and the second being the type name. The package name is empty if it is the1010 * default package. The type name is the type qualified name using a '.' enclosing type separator.1011 * </p>1012 * <p>1013 * Returns <code>null</code> if unable to find any matching type.1014 * </p>1015 *<p>1016 * For example, resolution of <code>"Object"</code> would typically return1017 * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns1018 * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the 1019 * default package.1020 * </p>1021 * 1022 * @param typeName the given type name1023 * @exception JavaModelException if code resolve could not be performed. 1024 * @return the resolved type names or <code>null</code> if unable to find any matching type1025 * @see #getTypeQualifiedName(char)1026 */1027String[][] resolveType(String typeName) throwsJavaModelException;10281029/**1030 * Resolves the given type name within the context of this type (depending on the type hierarchy 1031 * and its imports) and using the given owner's working copies, considering types in the 1032 * working copies with the given owner. In other words, the owner's working copies will take 1033 * precedence over their original compilation units in the workspace.1034 * <p>1035 * Note that if a working copy is empty, it will be as if the original compilation1036 * unit had been deleted.1037 * </p>1038 * <p>Multiple answers might be found in case there are ambiguous matches.1039 * </p>1040 * <p>1041 * Each matching type name is decomposed as an array of two strings, the first denoting the package1042 * name (dot-separated) and the second being the type name. The package name is empty if it is the1043 * default package. The type name is the type qualified name using a '.' enclosing type separator.1044 * </p>1045 * <p>1046 * Returns <code>null</code> if unable to find any matching type.1047 *</p>1048 *<p>1049 * For example, resolution of <code>"Object"</code> would typically return1050 * <code>{{"java.lang", "Object"}}</code>. Another resolution that returns1051 * <code>{{"", "X.Inner"}}</code> represents the inner type Inner defined in type X in the 1052 * default package.1053 * </p>1054 * 1055 * @param typeName the given type name1056 * @param owner the owner of working copies that take precedence over their original compilation units1057 * @exception JavaModelException if code resolve could not be performed. 1058 * @return the resolved type names or <code>null</code> if unable to find any matching type1059 * @see #getTypeQualifiedName(char)1060 * @since 3.01061 */1062String[][] resolveType(String typeName, WorkingCopyOwner owner) throwsJavaModelException;1063}1064