public abstract class ReferenceMatch extends SearchMatch
A_ACCURATE, A_INACCURATE
Constructor and Description |
---|
ReferenceMatch(IJavaElement enclosingElement,
int accuracy,
int offset,
int length,
boolean insideDocComment,
SearchParticipant participant,
IResource resource)
Creates a new reference match.
|
Modifier and Type | Method and Description |
---|---|
IJavaElement |
getLocalElement()
Returns the local element of this search match, or
null if none. |
void |
setLocalElement(IJavaElement element)
Store the local element in the match.
|
getAccuracy, getElement, getLength, getOffset, getParticipant, getResource, getRule, isEquivalent, isErasure, isExact, isImplicit, isInsideDocComment, isRaw, setAccuracy, setElement, setImplicit, setInsideDocComment, setLength, setOffset, setParticipant, setRaw, setResource, setRule, toString
public ReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource)
enclosingElement
- the inner-most enclosing member that references this java elementaccuracy
- one of SearchMatch.A_ACCURATE
or SearchMatch.A_INACCURATE
offset
- the offset the match starts at, or -1 if unknownlength
- the length of the match, or -1 if unknowninsideDocComment
- true
if this search match is inside a doc
comment, and false
otherwiseparticipant
- the search participant that created the matchresource
- the resource of the elementpublic final IJavaElement getLocalElement()
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
parent
chain of this local element eventually
leads to the element from SearchMatch.getElement()
.
The local element being an IAnnotation
is the most usual case. For example,
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
'.Deprecated
in
public class Test { @Deprecated void method() {} }will return one
TypeReferenceMatch
match whose local element
is the IAnnotation
'Deprecated
'.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,
Test
in
public class Test { void foo() { Test local; } }will return one
TypeReferenceMatch
match whose local element
is the ILocalVariable
'local
'.ITypeParameter
that extends the referenced
type. For example,
Test
in
public class X< T extends Test> { }will return one
TypeReferenceMatch
match whose local element
is the ITypeParameter
'T
'.null
if none.public final void setLocalElement(IJavaElement element)
element
- The local element to be stored
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.