Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse JDT
Release 3.5

org.eclipse.jdt.core.search
Class ReferenceMatch

java.lang.Object
  extended by 

org.eclipse.jdt.core.search.SearchMatch
      extended by 
org.eclipse.jdt.core.search.ReferenceMatch
Direct Known Subclasses:
FieldReferenceMatch, MethodReferenceMatch, PackageReferenceMatch, TypeReferenceMatch

public abstract class ReferenceMatch
extends SearchMatch

An abstract Java search match that represents a reference.

Since:
3.4

Field Summary
 
Fields inherited from class org.eclipse.jdt.core.search. SearchMatch
A_ACCURATE, A_INACCURATE
 
Constructor Summary
ReferenceMatch ( IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource)
          Creates a new reference match.
 
Method Summary
  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.
 
Methods inherited from class org.eclipse.jdt.core.search. SearchMatch
getAccuracy, getElement, getLength, getOffset, getParticipant, getResource, getRule, isEquivalent, isErasure, isExact, isImplicit, isInsideDocComment, isRaw, setAccuracy, setElement, setImplicit, setInsideDocComment, setLength, setOffset, setParticipant, setRaw, setResource, setRule, toString
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceMatch

public ReferenceMatch(
IJavaElement enclosingElement,
                      int accuracy,
                      int offset,
                      int length,
                      boolean insideDocComment,
                      
SearchParticipant participant,
                      
IResource resource)
Creates a new reference match.

Parameters:
enclosingElement - the inner-most enclosing member that references this java element
accuracy - one of SearchMatch.A_ACCURATE or SearchMatch.A_INACCURATE
offset - the offset the match starts at, or -1 if unknown
length - the length of the match, or -1 if unknown
insideDocComment - true if this search match is inside a doc comment, and false otherwise
participant - the search participant that created the match
resource - the resource of the element
Method Detail

getLocalElement

public final 
IJavaElement getLocalElement()
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 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,

  • 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,

  • searching for the references to the type Test in
             public class Test {
                 void foo() {
                    Test local;
                 }
             }
    will return one TypeReferenceMatch match whose local element is the ILocalVariable 'local'.

Or a local element may be an ITypeParameter that extends the referenced type. For example,
  • searching for the references to the type Test in
             public class X< T extends Test> {
             }
    will return one TypeReferenceMatch match whose local element is the ITypeParameter 'T'.

Returns:
the local element of this search match, or null if none.
Since:
3.4

setLocalElement

public final void setLocalElement(
IJavaElement element)
Store the local element in the match.

Parameters:
element - The local element to be stored
Since:
3.5

Eclipse JDT
Release 3.5

Copyright (c) IBM Corp. and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire