Package org.eclipse.jdt.core.search
Class SearchMatch
- java.lang.Object
-
- org.eclipse.jdt.core.search.SearchMatch
-
- Direct Known Subclasses:
FieldDeclarationMatch,LocalVariableDeclarationMatch,LocalVariableReferenceMatch,MethodDeclarationMatch,ModuleDeclarationMatch,PackageDeclarationMatch,ReferenceMatch,TypeDeclarationMatch,TypeParameterDeclarationMatch,TypeParameterReferenceMatch
public class SearchMatch extends Object
A search match represents the result of a search query. Search matches may be accurate (A_ACCURATE) or they might be merely potential matches (A_INACCURATE). The latter occurs when a compile-time problem prevents the search engine from completely resolving the match.This class is intended to be instantiated and subclassed by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static intA_ACCURATEThe search result corresponds an exact match of the search pattern.static intA_INACCURATEThe search result is potentially a match for the search pattern, but the search engine is unable to fully check it (for example, because there are errors in the code or the classpath are not correctly set).
-
Constructor Summary
Constructors Constructor Description SearchMatch(IJavaElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource)Creates a new search match.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAccuracy()Returns the accuracy of this search match.ObjectgetElement()Returns the element of this search match.intgetLength()Returns the length of this search match.intgetOffset()Returns the offset of this search match.SearchParticipantgetParticipant()Returns the search participant which issued this search match.IResourcegetResource()Returns the resource containing this search match.intgetRule()Returns the rule used while creating the match.booleanisEquivalent()Returns whether match element is compatible with searched pattern or not.booleanisErasure()Returns whether match element only has same erasure than searched pattern or not.booleanisExact()Returns whether element matches exactly searched pattern or not.booleanisImplicit()Returns whether the associated element is implicit or not.booleanisInsideDocComment()Returns whether this search match is inside a doc comment of a Java source file.booleanisRaw()Returns whether the associated element is a raw type/method or not.voidsetAccuracy(int accuracy)Sets the accuracy of this match.voidsetElement(Object element)Sets the element of this search match.voidsetImplicit(boolean implicit)Sets whether the associated element is implicit or not.voidsetInsideDocComment(boolean insideDoc)Sets whether this search match is inside a doc comment of a Java source file.voidsetLength(int length)Sets the length of this search match.voidsetOffset(int offset)Sets the offset of this search match.voidsetParticipant(SearchParticipant participant)Sets the participant of this match.voidsetRaw(boolean raw)Set whether the associated element is a raw type/method or not.voidsetResource(IResource resource)Sets the resource of this match.voidsetRule(int rule)Set the rule used while reporting the match.StringtoString()
-
-
-
Field Detail
-
A_ACCURATE
public static final int A_ACCURATE
The search result corresponds an exact match of the search pattern.- See Also:
getAccuracy(), Constant Field Values
-
A_INACCURATE
public static final int A_INACCURATE
The search result is potentially a match for the search pattern, but the search engine is unable to fully check it (for example, because there are errors in the code or the classpath are not correctly set).- See Also:
getAccuracy(), Constant Field Values
-
-
Constructor Detail
-
SearchMatch
public SearchMatch(IJavaElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource)
Creates a new search match.Note that
isInsideDocComment()defaults to false.- Parameters:
element- the element that encloses or corresponds to the match, ornullif noneaccuracy- one ofA_ACCURATEorA_INACCURATEoffset- the offset the match starts at, or -1 if unknownlength- the length of the match, or -1 if unknownparticipant- the search participant that created the matchresource- the resource of the element, ornullif none
-
-
Method Detail
-
getAccuracy
public final int getAccuracy()
Returns the accuracy of this search match.- Returns:
- one of
A_ACCURATEorA_INACCURATE
-
getElement
public final Object getElement()
Returns the element of this search match. In case of a reference match, this is the inner-most enclosing element of the reference. In case of a declaration match, this is the declaration.- Returns:
- the element of the search match, or
nullif none
-
getLength
public final int getLength()
Returns the length of this search match.- Returns:
- the length of this search match, or -1 if unknown
-
getOffset
public final int getOffset()
Returns the offset of this search match.- Returns:
- the offset of this search match, or -1 if unknown
-
getParticipant
public final SearchParticipant getParticipant()
Returns the search participant which issued this search match.- Returns:
- the participant which issued this search match
-
getResource
public final IResource getResource()
Returns the resource containing this search match.- Returns:
- the resource of the match, or
nullif none
-
getRule
public final int getRule()
Returns the rule used while creating the match.- Returns:
- one of
SearchPattern.R_FULL_MATCH,SearchPattern.R_EQUIVALENT_MATCHorSearchPattern.R_ERASURE_MATCH - Since:
- 3.1
-
isEquivalent
public final boolean isEquivalent()
Returns whether match element is compatible with searched pattern or not. Note that equivalent matches are also erasure ones.- Returns:
trueif match element is compatiblefalseotherwise- Since:
- 3.1
-
isErasure
public final boolean isErasure()
Returns whether match element only has same erasure than searched pattern or not. Note that this is always true for both generic and non-generic element as soon as the accuracy is accurate.- Returns:
trueif match element has same erasurefalseotherwise- Since:
- 3.1
-
isExact
public final boolean isExact()
Returns whether element matches exactly searched pattern or not. Note that exact matches are also erasure and equivalent ones.- Returns:
trueif match is exactfalseotherwise- Since:
- 3.1
-
isImplicit
public final boolean isImplicit()
Returns whether the associated element is implicit or not. Note that this piece of information is currently only implemented for implicit member pair value in annotation.- Returns:
trueif this match is associated to an implicit element andfalseotherwise- Since:
- 3.1
-
isRaw
public final boolean isRaw()
Returns whether the associated element is a raw type/method or not.- Returns:
trueif this match is associated to a raw type or method andfalseotherwise- Since:
- 3.1
-
isInsideDocComment
public final boolean isInsideDocComment()
Returns whether this search match is inside a doc comment of a Java source file.- Returns:
trueif this search match is inside a doc comment, andfalseotherwise
-
setAccuracy
public final void setAccuracy(int accuracy)
Sets the accuracy of this match.- Parameters:
accuracy- one ofA_ACCURATEorA_INACCURATE
-
setElement
public final void setElement(Object element)
Sets the element of this search match.- Parameters:
element- the element that encloses or corresponds to the match, ornullif none
-
setInsideDocComment
public final void setInsideDocComment(boolean insideDoc)
Sets whether this search match is inside a doc comment of a Java source file.- Parameters:
insideDoc-trueif this search match is inside a doc comment, andfalseotherwise
-
setImplicit
public final void setImplicit(boolean implicit)
Sets whether the associated element is implicit or not. Typically, this is the case when match is on an implicit constructor or an implicit member pair value in annotation.- Parameters:
implicit-trueif this match is associated to an implicit element andfalseotherwise- Since:
- 3.1
-
setLength
public final void setLength(int length)
Sets the length of this search match.- Parameters:
length- the length of the match, or -1 if unknown
-
setOffset
public final void setOffset(int offset)
Sets the offset of this search match.- Parameters:
offset- the offset the match starts at, or -1 if unknown
-
setParticipant
public final void setParticipant(SearchParticipant participant)
Sets the participant of this match.- Parameters:
participant- the search participant that created this match
-
setResource
public final void setResource(IResource resource)
Sets the resource of this match.- Parameters:
resource- the resource of the match, ornullif none
-
setRule
public final void setRule(int rule)
Set the rule used while reporting the match.- Parameters:
rule- one ofSearchPattern.R_FULL_MATCH,SearchPattern.R_EQUIVALENT_MATCHorSearchPattern.R_ERASURE_MATCH- Since:
- 3.1
-
setRaw
public final void setRaw(boolean raw)
Set whether the associated element is a raw type/method or not.- Parameters:
raw-trueif this search match is associated to a raw type or method andfalseotherwise- Since:
- 3.1
-
-