public class LocalVariable extends SourceRefElement implements ILocalVariable
| Modifier and Type | Field and Description |
|---|---|
IAnnotation[] |
annotations |
IAnnotation[][] |
annotationsOnDimensions |
int |
declarationSourceEnd |
int |
declarationSourceStart |
int |
nameEnd |
int |
nameStart |
static ILocalVariable[] |
NO_LOCAL_VARIABLES |
occurrenceCountJEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_DELIMITER_ESCAPE, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LAMBDA_EXPRESSION, JEM_LAMBDA_METHOD, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_STRING, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, parentANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER| Constructor and Description |
|---|
LocalVariable(JavaElement parent,
java.lang.String name,
int declarationSourceStart,
int declarationSourceEnd,
int nameStart,
int nameEnd,
java.lang.String typeSignature,
Annotation[] astAnnotations,
int flags,
boolean isParameter) |
LocalVariable(JavaElement parent,
java.lang.String name,
int declarationSourceStart,
int declarationSourceEnd,
int nameStart,
int nameEnd,
java.lang.String typeSignature,
Annotation[] astAnnotations,
int flags,
boolean isParameter,
Annotation[][] astAnnotationsOnDimensions) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closing(java.lang.Object info)
This element is being closed.
|
protected java.lang.Object |
createElementInfo()
Returns a new element info for this element.
|
boolean |
equals(java.lang.Object o)
Returns true if this handle represents the same Java element
as the given handle.
|
boolean |
exists()
Returns whether this Java element exists in the model.
|
protected void |
generateInfos(java.lang.Object info,
java.util.HashMap newElements,
IProgressMonitor pm)
Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable).
|
IAnnotation |
getAnnotation(java.lang.String annotationName)
Returns the annotation with the given name declared on this element.
|
IAnnotation[] |
getAnnotations()
Returns the annotations for this element.
|
IClassFile |
getClassFile() |
IResource |
getCorrespondingResource()
Elements within compilation units and class files have no
corresponding resource.
|
IMember |
getDeclaringMember()
Returns the declaring member of this local variable.
|
java.lang.String |
getElementName()
Returns the name of this element.
|
int |
getElementType()
Returns this element's kind encoded as an integer.
|
int |
getFlags()
Returns the modifier flags for this local variable.
|
IJavaElement |
getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner owner) |
protected void |
getHandleMemento(java.lang.StringBuffer buff) |
protected void |
getHandleMemento(java.lang.StringBuffer buff,
boolean memoizeParent) |
protected char |
getHandleMementoDelimiter()
Returns the
char that marks the start of this handles
contribution to a memento. |
java.lang.String |
getKey(boolean forceOpen) |
ISourceRange |
getNameRange()
Returns the source range of this local variable's name.
|
IPath |
getPath()
Returns the path to the innermost resource enclosing this element.
|
java.lang.String |
getSource()
Returns the source code associated with this element.
|
ISourceRange |
getSourceRange()
Returns the source range associated with this element.
|
ITypeRoot |
getTypeRoot()
Returns the Java type root in which this local variable is declared.
|
java.lang.String |
getTypeSignature()
Returns the type signature of this local variable.
|
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains
this element, or
null if this element is not contained
in a resource. |
int |
hashCode()
Returns the hash code for this Java element.
|
boolean |
isParameter()
Returns
true if this local variable is a method parameter, false otherwise. |
boolean |
isStructureKnown()
Returns whether the structure of this element is known.
|
IResource |
resource() |
protected void |
toStringInfo(int tab,
java.lang.StringBuffer buffer,
java.lang.Object info,
boolean showResolvedInfo)
Debugging purposes
|
copy, delete, findNode, getCompilationUnit, getHandleUpdatingCountFromMemento, getOccurrenceCount, getOpenableParent, hasChildren, move, rename, toStringNameappendEscapedDelimiter, close, escapeMementoName, getAncestor, getAttachedJavadoc, getChildren, getChildrenOfType, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavadocBaseLocation, getJavaModel, getJavaProject, getLibraryJavadocLocation, getOpenable, getParent, getPrimaryElement, getPrimaryElement, getResource, getSchedulingRule, getSourceElementAt, getSourceMapper, getURLContents, isAncestorOf, isReadOnly, newDoesNotExistStatus, newJavaModelException, newNotPresentException, openWhenClosed, readableName, resolved, tabString, toDebugString, toString, toString, toStringAncestors, toStringChildren, toStringInfo, toStringWithAncestors, toStringWithAncestors, unresolved, validateAndCacheclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetAncestor, getAttachedJavadoc, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, isReadOnlypublic static final ILocalVariable[] NO_LOCAL_VARIABLES
public int declarationSourceStart
public int declarationSourceEnd
public int nameStart
public int nameEnd
public IAnnotation[] annotations
public IAnnotation[][] annotationsOnDimensions
public LocalVariable(JavaElement parent, java.lang.String name, int declarationSourceStart, int declarationSourceEnd, int nameStart, int nameEnd, java.lang.String typeSignature, Annotation[] astAnnotations, int flags, boolean isParameter)
public LocalVariable(JavaElement parent, java.lang.String name, int declarationSourceStart, int declarationSourceEnd, int nameStart, int nameEnd, java.lang.String typeSignature, Annotation[] astAnnotations, int flags, boolean isParameter, Annotation[][] astAnnotationsOnDimensions)
protected void closing(java.lang.Object info)
SourceRefElementclosing in class SourceRefElementprotected java.lang.Object createElementInfo()
SourceRefElementcreateElementInfo in class SourceRefElementpublic boolean equals(java.lang.Object o)
JavaElementIf a subclass has other requirements for equality, this method must be overridden.
equals in class SourceRefElementObject.equals(java.lang.Object)public boolean exists()
IJavaElement
Java elements are handle objects that may or may not be backed by an
actual element. Java elements that are backed by an actual element are
said to "exist", and this method returns true. For Java
elements that are not working copies, it is always the case that if the
element exists, then its parent also exists (provided it has one) and
includes the element as one of its children. It is therefore possible
to navigated to any existing Java element from the root of the Java model
along a chain of existing Java elements. On the other hand, working
copies are said to exist until they are destroyed (with
IWorkingCopy.destroy). Unlike regular Java elements, a
working copy never shows up among the children of its parent element
(which may or may not exist).
exists in interface IJavaElementexists in interface ISourceReferenceexists in class JavaElementtrue if this element exists in the Java model, and
false if this element does not existIJavaElementprotected void generateInfos(java.lang.Object info,
java.util.HashMap newElements,
IProgressMonitor pm)
JavaElementgenerateInfos in class SourceRefElementpublic IAnnotation getAnnotation(java.lang.String annotationName)
IAnnotatablegetAnnotation in interface IAnnotatablegetAnnotation in class SourceRefElementannotationName - the given simple namepublic IAnnotation[] getAnnotations() throws JavaModelException
IAnnotatablegetAnnotations in interface IAnnotatablegetAnnotations in class SourceRefElementJavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resource.public IJavaElement getHandleFromMemento(java.lang.String token, MementoTokenizer memento, WorkingCopyOwner owner)
getHandleFromMemento in class SourceRefElementprotected void getHandleMemento(java.lang.StringBuffer buff)
getHandleMemento in class SourceRefElementprotected void getHandleMemento(java.lang.StringBuffer buff,
boolean memoizeParent)
protected char getHandleMementoDelimiter()
JavaElementchar that marks the start of this handles
contribution to a memento.getHandleMementoDelimiter in class JavaElementpublic IResource getCorrespondingResource()
SourceRefElementgetCorrespondingResource in interface IJavaElementgetCorrespondingResource in class SourceRefElementnull if noneIJavaElementpublic IMember getDeclaringMember()
This is a handle-only method.
getDeclaringMember in interface ILocalVariablepublic java.lang.String getElementName()
IJavaElementgetElementName in interface IJavaElementgetElementName in interface ILocalVariablegetElementName in class JavaElementIAdaptablepublic int getElementType()
IJavaElementgetElementType in interface IJavaElementIJavaElementIJavaElementpublic int getFlags()
Flags.
Note that only flags as indicated in the source are returned.
getFlags in interface ILocalVariableFlagspublic IClassFile getClassFile()
getClassFile in class JavaElementIMember.getClassFile()public ISourceRange getNameRange()
getNameRange in interface ILocalVariablegetNameRange in interface ISourceReferencepublic IPath getPath()
IJavaElementgetPath in interface IJavaElementgetPath in class SourceRefElementpublic IResource resource()
resource in class SourceRefElementpublic java.lang.String getSource()
throws JavaModelException
ISourceReferencegetSourceRange.
For class files, this returns the source of the entire compilation unit associated with the class file (if there is one).
getSource in interface ISourceReferencegetSource in class SourceRefElementnull if this element has no
associated source codeJavaModelException - if an exception occurs while accessing its corresponding resourceISourceReferencepublic ISourceRange getSourceRange() throws JavaModelException
For class files, this returns the range of the entire compilation unit associated with the class file (if there is one).
If this element has no associated source code, either null is returned,
or a source range with a -1 offset and a 0 length. SourceRange.isAvailable(ISourceRange)
can be used to detect that case.
getSourceRange in interface ISourceReferencegetSourceRange in class SourceRefElementnull or [-1, 0] if this element has no
associated source codeJavaModelException - if an exception occurs while accessing its corresponding resourceISourceReferencepublic ITypeRoot getTypeRoot()
This is a handle-only method.
getTypeRoot in interface ILocalVariablepublic java.lang.String getTypeSignature()
ILocalVariable
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.
getTypeSignature in interface ILocalVariableSignaturepublic IResource getUnderlyingResource()
throws JavaModelException
IJavaElementnull if this element is not contained
in a resource.getUnderlyingResource in interface IJavaElementgetUnderlyingResource in class SourceRefElementnull if noneJavaModelException - if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElementpublic int hashCode()
JavaElementhashCode in class JavaElementpublic boolean isParameter()
true if this local variable is a method parameter, false otherwise.isParameter in interface ILocalVariabletrue if this local variable is a method parameter, false otherwisepublic boolean isStructureKnown()
throws JavaModelException
IJavaElementfalse is returned.
If the structure of an element is unknown, navigations will return reasonable
defaults. For example, getChildren for a compilation unit with
syntax errors will return a collection of the children that could be parsed.
Note: This does not imply anything about consistency with the underlying resource/buffer contents.
isStructureKnown in interface IJavaElementisStructureKnown in class SourceRefElementtrue if the structure of this element is knownJavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElementpublic java.lang.String getKey(boolean forceOpen)
throws JavaModelException
JavaModelExceptionBinding.computeUniqueKey()protected void toStringInfo(int tab,
java.lang.StringBuffer buffer,
java.lang.Object info,
boolean showResolvedInfo)
JavaElementtoStringInfo in class JavaElementshowResolvedInfo - TODO