Returns the local element of this search match, or
null
if none.
A local element is the inner-most element that contains the reference and that is
not reachable by navigating from the root of the
IJavaModel using
IParent#getChildren().
Known element types for local elements are
IJavaElement#ANNOTATION,
IJavaElement#LOCAL_VARIABLE and
IJavaElement#TYPE_PARAMETER.
However clients should not assume that this set of element types is closed as
other types of elements may be returned in the future, e.g. if new types
of elements are added in the Java model. Clients can only assume that the
IJavaElement#getParent() chain of this local element eventually
leads to the element from
#getElement().
The local element being an
IAnnotation is the most usual case. For example,
- searching for the references to the method
Annot.clazz()
in
public class Test {
void method() {
@Annot(clazz=Test.class) int x;
}
}
will return one
MethodReferenceMatch match whose local element
is the
IAnnotation 'Annot
'.
- searching for the references to the type
Deprecated
in
public class Test {
@Deprecated void method() {}
}
will return one
TypeReferenceMatch match whose local element
is the
IAnnotation 'Deprecated
'.
- searching for the references to the field
CONST
in
@Num(number= Num.CONST)
@interface Num {
public static final int CONST= 42;
int number();
}
will return one
FieldReferenceMatch match whose local element
is the
IAnnotation 'Num
'.
A local element may also be a
ILocalVariable whose type is the referenced
type. For example,
Or a local element may be an
ITypeParameter that extends the referenced
type. For example,