public interface IType extends IMember, IFunctionContainer
The children are of type IMember
, which includes IField
,
IFunction
, IInitializer
and IType
.
The children are listed in the order in which they appear in the source file.
This interface is not intended to be implemented by clients.
Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.CLASS_FILE, EXPORT_CONTAINER, EXPORT_DECLARATION, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVASCRIPT_MODEL, JAVASCRIPT_PROJECT, JAVASCRIPT_UNIT, LOCAL_VARIABLE, METHOD, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE
Modifier and Type | Method and Description |
---|---|
void |
codeComplete(char[] snippet,
int insertion,
int position,
char[][] localVariableTypeNames,
char[][] localVariableNames,
int[] localVariableModifiers,
boolean isStatic,
CompletionRequestor requestor)
Do code completion inside a code snippet in the context of the current type.
|
void |
codeComplete(char[] snippet,
int insertion,
int position,
char[][] localVariableTypeNames,
char[][] localVariableNames,
int[] localVariableModifiers,
boolean isStatic,
CompletionRequestor requestor,
WorkingCopyOwner owner)
Do code completion inside a code snippet in the context of the current type.
|
IField |
createField(java.lang.String contents,
IJavaScriptElement sibling,
boolean force,
IProgressMonitor monitor)
Creates and returns a field in this type with the
given contents.
|
IFunction |
createMethod(java.lang.String contents,
IJavaScriptElement sibling,
boolean force,
IProgressMonitor monitor)
Creates and returns a method or constructor in this type with the
given contents.
|
IType |
createType(java.lang.String contents,
IJavaScriptElement sibling,
boolean force,
IProgressMonitor monitor)
Creates and returns a type in this type with the
given contents.
|
IFunction[] |
findMethods(IFunction method)
Finds the methods in this type that correspond to
the given method.
|
IJavaScriptElement[] |
getChildrenForCategory(java.lang.String category)
Returns the children of this type that have the given category as a
@category tag. |
java.lang.String |
getElementName()
Returns the simple name of this type, unqualified by package or enclosing type.
|
IField |
getField(java.lang.String name)
Returns the field with the specified name
in this type (for example,
"bar" ). |
IField[] |
getFields()
Returns the fields declared by this type.
|
java.lang.String |
getFullyQualifiedName()
Returns the fully qualified name of this type,
including qualification for any containing types and packages.
|
java.lang.String |
getFullyQualifiedName(char enclosingTypeSeparator)
Returns the fully qualified name of this type,
including qualification for any containing types and packages.
|
java.lang.String |
getFullyQualifiedParameterizedName()
Returns this type's fully qualified name
|
IFunction |
getFunction(java.lang.String name,
java.lang.String[] parameterTypeSignatures)
Returns the method with the specified name and parameter types
in this type (for example,
"foo", {"I", "QString;"} ). |
IFunction[] |
getFunctions()
Returns the methods and constructors declared by this type.
|
IInitializer |
getInitializer(int occurrenceCount)
Returns the initializer with the specified position relative to
the order they are defined in the source.
|
IInitializer[] |
getInitializers()
Returns the initializers declared by this type.
|
java.lang.String |
getKey()
Returns the binding key for this type.
|
IPackageFragment |
getPackageFragment()
Returns the source folder (package fragment) in which this element is defined.
|
java.lang.String |
getSuperclassName()
Returns the name of this type's superclass, or
null
for source types that do not specify a superclass. |
java.lang.String |
getSuperclassTypeSignature()
Returns the type signature of this type's superclass, or
null if none. |
IType |
getType(java.lang.String name)
Returns the member type declared in this type with the given simple name.
|
java.lang.String |
getTypeQualifiedName()
Returns the type-qualified name of this type,
including qualification for any enclosing types,
but not including package qualification.
|
java.lang.String |
getTypeQualifiedName(char enclosingTypeSeparator)
Returns the type-qualified name of this type,
including qualification for any enclosing types,
but not including package qualification.
|
IType[] |
getTypes()
Returns the immediate member types declared by this type.
|
boolean |
isAnonymous()
Returns whether this type represents an anonymous type.
|
boolean |
isClass()
Returns whether this type is read-only.
|
boolean |
isLocal()
Returns whether this type represents a local type.
|
boolean |
isMember()
Returns whether this type represents a member type.
|
boolean |
isResolved()
Returns whether this type represents a resolved type.
|
ITypeHierarchy |
loadTypeHierachy(java.io.InputStream input,
IProgressMonitor monitor)
Loads a previously saved ITypeHierarchy from an input stream.
|
ITypeHierarchy |
newSupertypeHierarchy(IJavaScriptUnit[] workingCopies,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type and all of its supertypes, considering types in the given
working copies.
|
ITypeHierarchy |
newSupertypeHierarchy(IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type and all of its supertypes.
|
ITypeHierarchy |
newSupertypeHierarchy(WorkingCopyOwner owner,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type and all of its supertypes, considering types in the
working copies with the given owner.
|
ITypeHierarchy |
newTypeHierarchy(IJavaScriptProject project,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type, all of its supertypes, and all its subtypes
in the context of the given project.
|
ITypeHierarchy |
newTypeHierarchy(IJavaScriptProject project,
WorkingCopyOwner owner,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type, all of its supertypes, and all its subtypes
in the context of the given project, considering types in the
working copies with the given owner.
|
ITypeHierarchy |
newTypeHierarchy(IJavaScriptUnit[] workingCopies,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type, all of its supertypes, and all its subtypes in the workspace,
considering types in the given working copies.
|
ITypeHierarchy |
newTypeHierarchy(IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type, all of its supertypes, and all its subtypes in the workspace.
|
ITypeHierarchy |
newTypeHierarchy(WorkingCopyOwner owner,
IProgressMonitor monitor)
Creates and returns a type hierarchy for this type containing
this type, all of its supertypes, and all its subtypes in the workspace,
considering types in the working copies with the given owner.
|
java.lang.String[][] |
resolveType(java.lang.String typeName)
Resolves the given type name within the context of this type (depending on the type hierarchy
and its imports).
|
java.lang.String[][] |
resolveType(java.lang.String typeName,
WorkingCopyOwner owner)
Resolves the given type name within the context of this type (depending on the type hierarchy
and its imports) and using the given owner's working copies, considering types in the
working copies with the given owner.
|
getCategories, getClassFile, getDeclaringType, getFlags, getJavaScriptUnit, getJSdocRange, getNameRange, getOccurrenceCount, getType, getTypeRoot, isBinary
exists, getAncestor, getAttachedJavadoc, getCommonSuperType, getCorrespondingResource, getDisplayName, getElementType, getHandleIdentifier, getHostPath, getJavaScriptModel, getJavaScriptProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown, isVirtual
newNameLookup, newNameLookup, newSearchableNameEnvironment, newSearchableNameEnvironment
exists, getSource, getSourceRange
copy, delete, move, rename
getChildren, hasChildren
void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor) throws JavaScriptModelException
snippet
- the code snippetinsertion
- the position with in source where the snippet
is inserted. This position must not be in comments.
A possible value is -1, if the position is not known.position
- the position within snippet where the user
is performing code assist.localVariableTypeNames
- an array (possibly empty) of fully qualified
type names of local variables visible at the current scopelocalVariableNames
- an array (possibly empty) of local variable names
that are visible at the current scopelocalVariableModifiers
- an array (possible empty) of modifiers for
local variablesisStatic
- whether the current scope is in a static contextrequestor
- the completion requestorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, WorkingCopyOwner owner) throws JavaScriptModelException
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
If the type can access to his source code and the insertion position is valid, then completion is performed against source. Otherwise the completion is performed against type structure and given locals variables.
snippet
- the code snippetinsertion
- the position with in source where the snippet
is inserted. This position must not be in comments.
A possible value is -1, if the position is not known.position
- the position with in snippet where the user
is performing code assist.localVariableTypeNames
- an array (possibly empty) of fully qualified
type names of local variables visible at the current scopelocalVariableNames
- an array (possibly empty) of local variable names
that are visible at the current scopelocalVariableModifiers
- an array (possible empty) of modifiers for
local variablesisStatic
- whether the current scope is in a static contextrequestor
- the completion requestorowner
- the owner of working copies that take precedence over their original compilation unitsJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IField createField(java.lang.String contents, IJavaScriptElement sibling, boolean force, IProgressMonitor monitor) throws JavaScriptModelException
Optionally, the new element can be positioned before the specified sibling. If no sibling is specified, the element will be inserted as the last field declaration in this type.
It is possible that a field with the same name already exists in this type.
The value of the force
parameter effects the resolution of
such a conflict:
true
- in this case the field is created with the new contentsfalse
- in this case a JavaScriptModelException
is throwncontents
- the given contentssibling
- the given siblingforce
- a flag in case the same name already exists in this typemonitor
- the given progress monitorJavaScriptModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
IFunction createMethod(java.lang.String contents, IJavaScriptElement sibling, boolean force, IProgressMonitor monitor) throws JavaScriptModelException
Optionally, the new element can be positioned before the specified sibling. If no sibling is specified, the element will be appended to this type.
It is possible that a method with the same signature already exists in this type.
The value of the force
parameter effects the resolution of
such a conflict:
true
- in this case the method is created with the new contentsfalse
- in this case a JavaScriptModelException
is throwncontents
- the given contentssibling
- the given siblingforce
- a flag in case the same name already exists in this typemonitor
- the given progress monitorJavaScriptModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
IType createType(java.lang.String contents, IJavaScriptElement sibling, boolean force, IProgressMonitor monitor) throws JavaScriptModelException
Optionally, the new type can be positioned before the specified sibling. If no sibling is specified, the type will be appended to this type.
It is possible that a type with the same name already exists in this type.
The value of the force
parameter effects the resolution of
such a conflict:
true
- in this case the type is created with the new contentsfalse
- in this case a JavaScriptModelException
is throwncontents
- the given contentssibling
- the given siblingforce
- a flag in case the same name already exists in this typemonitor
- the given progress monitorJavaScriptModelException
- if the element could not be created. Reasons include:
CoreException
occurred while updating an underlying resource
IFunction[] findMethods(IFunction method)
method
- the given methodnull
if no such methods can be found.IJavaScriptElement[] getChildrenForCategory(java.lang.String category) throws JavaScriptModelException
@category
tag.
Returns an empty array if no children with this category exist.JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.java.lang.String getElementName()
getElementName
in interface IJavaScriptElement
IField getField(java.lang.String name)
"bar"
).
This is a handle-only method. The field may or may not exist.getField
in interface IFunctionContainer
name
- the given nameIField[] getFields() throws JavaScriptModelException
getFields
in interface IFunctionContainer
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.java.lang.String getFullyQualifiedName()
'.'
,
followed by the type-qualified name.
This is a handle-only method.getTypeQualifiedName()
java.lang.String getFullyQualifiedName(char enclosingTypeSeparator)
'.'
,
followed by the type-qualified name using the enclosingTypeSeparator
.
This is a handle-only method.enclosingTypeSeparator
- the given enclosing type separatorgetTypeQualifiedName(char)
java.lang.String getFullyQualifiedParameterizedName() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IInitializer getInitializer(int occurrenceCount)
occurrenceCount
- the specified positionIInitializer[] getInitializers() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.java.lang.String getKey()
IBinding.getKey()
,
BindingKey
IFunction getFunction(java.lang.String name, java.lang.String[] parameterTypeSignatures)
"foo", {"I", "QString;"}
).
To get the handle for a constructor, the name specified must be the
simple name of the enclosing type.
This is a handle-only method. The method may or may not be present.
The type signatures may be either unresolved (for source types)
or resolved (for binary types), and either basic (for basic types)
or rich (for parameterized types). See Signature
for details.
getFunction
in interface IFunctionContainer
name
- the given nameparameterTypeSignatures
- the given parameter typesIFunction[] getFunctions() throws JavaScriptModelException
<clinit>
; method
and synthetic methods.
If this is a source type, the results are listed in the order
in which they appear in the source, otherwise, the results are
in no particular order.getFunctions
in interface IFunctionContainer
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IPackageFragment getPackageFragment()
java.lang.String getSuperclassName() throws JavaScriptModelException
null
for source types that do not specify a superclass.
For interfaces, the superclass name is always "java.lang.Object"
.
For source types, the name as declared is returned, for binary types,
the resolved, qualified name is returned.
For anonymous types, the superclass name is the name appearing after the 'new' keyword'.
If the superclass is a parameterized type, the string
may include its type arguments enclosed in "<>".
If the returned string is needed for anything other than display
purposes, use getSuperclassTypeSignature()
which returns
a structured type signature string containing more precise information.
null
for source types that do not specify a superclassJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.java.lang.String getSuperclassTypeSignature() throws JavaScriptModelException
null
if none.
The type signature may be either unresolved (for source types)
or resolved (for binary types), and either basic (for basic types)
or rich (for parameterized types). See Signature
for details.
null
if noneJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IType getType(java.lang.String name)
getType
in interface IFunctionContainer
name
- the given simple namejava.lang.String getTypeQualifiedName()
java.lang.String getTypeQualifiedName(char enclosingTypeSeparator)
enclosingTypeSeparator
- the specified enclosing type separatorIType[] getTypes() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.boolean isAnonymous() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.boolean isClass() throws JavaScriptModelException
Note that a class can neither be an interface, an enumeration class, nor an annotation type.
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.boolean isLocal() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.boolean isMember() throws JavaScriptModelException
JavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.boolean isResolved()
ITypeHierarchy loadTypeHierachy(java.io.InputStream input, IProgressMonitor monitor) throws JavaScriptModelException
input
- stream where hierarchy will be readmonitor
- the given progress monitorJavaScriptModelException
- if the hierarchy could not be restored, reasons include:
- type is not the focus of the hierarchy or
- unable to read the input stream (wrong format, IOException during reading, ...)ITypeHierarchy.store(java.io.OutputStream, IProgressMonitor)
ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws JavaScriptModelException
monitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newSupertypeHierarchy(IJavaScriptUnit[] workingCopies, IProgressMonitor monitor) throws JavaScriptModelException
Note that passing an empty working copy will be as if the original compilation unit had been deleted.
workingCopies
- the working copies that take precedence over their original compilation unitsmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaScriptModelException
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
owner
- the owner of working copies that take precedence over their original compilation unitsmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newTypeHierarchy(IJavaScriptProject project, IProgressMonitor monitor) throws JavaScriptModelException
project
- the given projectmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newTypeHierarchy(IJavaScriptProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaScriptModelException
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
project
- the given projectowner
- the owner of working copies that take precedence over their original compilation unitsmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaScriptModelException
monitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newTypeHierarchy(IJavaScriptUnit[] workingCopies, IProgressMonitor monitor) throws JavaScriptModelException
Note that passing an empty working copy will be as if the original compilation unit had been deleted.
workingCopies
- the working copies that take precedence over their original compilation unitsmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaScriptModelException
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
owner
- the owner of working copies that take precedence over their original compilation unitsmonitor
- the given progress monitorJavaScriptModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.java.lang.String[][] resolveType(java.lang.String typeName) throws JavaScriptModelException
Multiple answers might be found in case there are ambiguous matches.
Each matching type name is decomposed as an array of two strings, the first denoting the package name (dot-separated) and the second being the type name. The package name is empty if it is the default package. The type name is the type qualified name using a '.' enclosing type separator.
Returns null
if unable to find any matching type.
typeName
- the given type namenull
if unable to find any matching typeJavaScriptModelException
- if code resolve could not be performed.getTypeQualifiedName(char)
java.lang.String[][] resolveType(java.lang.String typeName, WorkingCopyOwner owner) throws JavaScriptModelException
Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.
Multiple answers might be found in case there are ambiguous matches.
Each matching type name is decomposed as an array of two strings, the first denoting the package name (dot-separated) and the second being the type name. The package name is empty if it is the default package. The type name is the type qualified name using a '.' enclosing type separator.
Returns null
if unable to find any matching type.
typeName
- the given type nameowner
- the owner of working copies that take precedence over their original compilation unitsnull
if unable to find any matching typeJavaScriptModelException
- if code resolve could not be performed.getTypeQualifiedName(char)
Copyright (c) IBM Corp. and others 2000, 2010. All Rights Reserved.