Interface ILocalVariable
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable, IAnnotatable, IJavaElement, ISourceReference
- All Known Implementing Classes:
LocalVariable
Represents a local variable declared in a method or an initializer.
ILocalVariable are pseudo-elements created as the result of a ICodeAssist.codeSelect(...)
operation. They are not part of the Java model (exists() returns whether the parent exists rather than
whether the local variable exists in the parent) and they are not included in the children of an IMethod
or an IInitializer.
In particular such a pseudo-element should not be used as a handle. For example its name range won't be updated if the underlying source changes.
- Since:
- 3.0
-
Field Summary
Fields inherited from interface IJavaElement
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_MODULE, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETERModifier and TypeFieldDescriptionstatic final intConstant representing an annotation.static final intConstant representing a class file.static final intConstant representing a Java compilation unit.static final intConstant representing a field.static final intConstant representing all import declarations within a compilation unit.static final intConstant representing an import declaration within a compilation unit.static final intConstant representing a stand-alone instance or class initializer.static final intConstant representing a Java model (workspace level object).static final intConstant represents a module descriptor.static final intConstant representing a Java project.static final intConstant representing a local variable declaration.static final intConstant representing a method or constructor.static final intConstant representing a package declaration within a compilation unit.static final intConstant representing a package fragment.static final intConstant representing a package fragment root.static final intConstant representing a type (a class or interface).static final intConstant representing a type parameter declaration. -
Method Summary
Modifier and TypeMethodDescriptionReturns the declaring member of this local variable.Returns the name of this local variable.intgetFlags()Returns the modifier flags for this local variable.Returns the source range of this local variable's name.Returns the Java type root in which this local variable is declared.Returns the type signature of this local variable.booleanReturnstrueif this local variable is a method parameter,falseotherwise.Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods inherited from interface IAnnotatable
getAnnotation, getAnnotationsModifier and TypeMethodDescriptiongetAnnotation(String name) Returns the annotation with the given name declared on this element.Returns the annotations for this element.Methods inherited from interface IJavaElement
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnownModifier and TypeMethodDescriptionbooleanexists()Returns whether this Java element exists in the model.getAncestor(int ancestorType) Returns this Java element or the first ancestor of this element that has the given type.getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) Returns the Javadoc as HTML source if this element has attached Javadoc,nullotherwise.org.eclipse.core.resources.IResourceReturns the resource that corresponds directly to this element, ornullif there is no resource that corresponds to this element.intReturns this element's kind encoded as an integer.Returns a string representation of this element handle.Returns the Java model.Returns the Java project this element is contained in, ornullif this element is not contained in any Java project (for instance, theIJavaModelis not contained in any Java project).Returns the first openable parent.Returns the element directly containing this element, ornullif this element has no parent.org.eclipse.core.runtime.IPathgetPath()Returns the path to the innermost resource enclosing this element.Returns the primary element (whose compilation unit is the primary compilation unit) this working copy element was created from, or this element if it is a descendant of a primary compilation unit or if it is not a descendant of a working copy (e.g.org.eclipse.core.resources.IResourceReturns the innermost resource enclosing this element.org.eclipse.core.runtime.jobs.ISchedulingRuleReturns the scheduling rule associated with this Java element.org.eclipse.core.resources.IResourceReturns the smallest underlying resource that contains this element, ornullif this element is not contained in a resource.booleanReturns whether this Java element is read-only.booleanReturns whether the structure of this element is known.Methods inherited from interface ISourceReference
exists, getSource, getSourceRangeModifier and TypeMethodDescriptionbooleanexists()Returns whether this element exists in the model.Returns the source code associated with this element.Returns the source range associated with this element.
-
Method Details
-
getElementName
String getElementName()Returns the name of this local variable.- Specified by:
getElementNamein interfaceIJavaElement- Returns:
- the name of this local variable.
-
getNameRange
ISourceRange getNameRange()Returns the source range of this local variable's name.- Specified by:
getNameRangein interfaceISourceReference- Returns:
- the source range of this local variable's name
-
getTypeSignature
String getTypeSignature()Returns the type signature of this local variable.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
Signaturefor details.- Returns:
- the type signature of this local variable.
- See Also:
-
isParameter
boolean isParameter()Returnstrueif this local variable is a method parameter,falseotherwise.- Returns:
trueif this local variable is a method parameter,falseotherwise- Since:
- 3.7
-
getFlags
int getFlags()Returns the modifier flags for this local variable. The flags can be examined using classFlags.Note that only flags as indicated in the source are returned.
- Returns:
- the modifier flags for this local variable
- Since:
- 3.7
- See Also:
-
getDeclaringMember
IMember getDeclaringMember()Returns the declaring member of this local variable.This is a handle-only method.
- Returns:
- the declaring member of this local variable
- Since:
- 3.7
-
getTypeRoot
ITypeRoot getTypeRoot()Returns the Java type root in which this local variable is declared.This is a handle-only method.
- Returns:
- the Java type root in which this local variable is declared
- Since:
- 3.7
-