Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jdt.core.search
Class SearchParticipant

    java.lang.Object
      org.eclipse.jdt.core.search.SearchParticipant

public abstract class SearchParticipant
extends Object

A search participant describes a particular extension to a generic search mechanism, permitting combined search actions which will involve all required participants.

A search participant is involved in the indexing phase and in the search phase. The indexing phase consists in taking one or more search documents, parse them, and add index entries in an index chosen by the participant. An index is identified by a path on disk. The search phase consists in selecting the indexes corresponding to a search pattern and a search scope, from these indexes the search infrastructure extracts the document paths that match the search pattern asking the search participant for the corresponding document, finally the search participant is asked to locate the matches precisely in these search documents.

This class is intended to be subclassed by clients. During the indexing phase, a subclass will be called with the following requests in order:

- `scheduleDocumentIndexing(SearchDocument, IPath)`
- `indexDocument(SearchDocument, IPath)`

During the search phase, a subclass will be called with the following requests in order:

- `selectIndexes(SearchPattern, IJavaSearchScope)`
- one or more `getDocument(String)`
- `locateMatches(SearchDocument[], SearchPattern, IJavaSearchScope, SearchRequestor, IProgressMonitor)`

Since:
  3.0

Constructor Summary
`protected` | `SearchParticipant()` Creates a new search participant.

Method Summary
`void` | `beginSearching()` Notification that this participant's help is needed in a search.
`void` | `doneSearching()` Notification that this participant's help is no longer needed.
`String` | `getDescription()` Returns a displayable name of this search participant.
`abstract SearchDocument` | `getDocument(String documentPath)` Returns a search document for the given path.
`abstract void` | `indexDocument(SearchDocument document, IPath indexLocation)` Indexes the given document in the given index.
`abstract void` | `locateMatches(SearchDocument[] documents, SearchPattern pattern, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor)` Locates the matches in the given documents using the given search pattern and search scope, and reports them to the givenn search requestor.
`void` | `scheduleDocumentIndexing(SearchDocument document, IPath indexLocation)` Schedules the indexing of the given document.
`abstract IPath[]` | `selectIndexes(SearchPattern query, IJavaSearchScope scope)` Returns the collection of index locations to consider when performing the given search query in the given scope.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SearchParticipant

    protected SearchParticipant()

  Creates a new search participant.

Method Detail

### beginSearching

    public void beginSearching()

  Notification that this participant's help is needed in a search.

  This method should be re-implemented in subclasses that need to do something when the participant is needed in a search.

### doneSearching

    public void doneSearching()

  Notification that this participant's help is no longer needed.

  This method should be re-implemented in subclasses that need to do something when the participant is no longer needed in a search.

### getDescription

    public String getDescription()

  Returns a displayable name of this search participant.

  This method should be re-implemented in subclasses that need to display a meaningfull name.

  Returns:
    the displayable name of this search participant

### getDocument

    public abstract SearchDocument getDocument(String documentPath)

  Returns a search document for the given path. The given document path is a string that uniquely identifies the document. Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.

  Implementors of this method can either create an instance of their own subclass of `SearchDocument` or return an existing instance of such a subclass.

  Parameters:
    `documentPath` - the path of the document.
  Returns:
    a search document

### indexDocument

    public abstract void indexDocument(SearchDocument document,
                                       IPath indexLocation)

  Indexes the given document in the given index. A search participant asked to index a document should parse it and call `SearchDocument.addIndexEntry(char[], char[])` as many times as needed to add index entries to the index. If delegating to another participant, it should use the original index location (and not the delegatee's one). In the particular case of delegating to the default search participant (see `SearchEngine.getDefaultSearchParticipant()`), the provided document's path must be a path ending with '.java' or a '.class'.

  The given index location must represent a path in the file system to a file that either already exists or is going to be created. If it exists, it must be an index file, otherwise its data might be overwritten.

  Clients are not expected to call this method.

  Parameters:
    `document` - the document to index
    `indexLocation` - the location in the file system to the index

### locateMatches

    public abstract void locateMatches(SearchDocument[] documents,
                                       SearchPattern pattern,
                                       IJavaSearchScope scope,
                                       SearchRequestor requestor,
                                       IProgressMonitor monitor)
                                throws CoreException

  Locates the matches in the given documents using the given search pattern and search scope, and reports them to the givenn search requestor. This method is called by the search engine once it has search documents matching the given pattern in the given search scope.

  Note that a participant (e.g. a JSP participant) can pre-process the contents of the given documents, create its own documents whose contents are Java compilation units and delegate the match location to the default participant (see `SearchEngine.getDefaultSearchParticipant()`). Passing its own `SearchRequestor` this particpant can then map the match positions back to the original contents, create its own matches and report them to the original requestor.

  Implementors of this method should check the progress monitor for cancelation when it is safe and appropriate to do so. The cancelation request should be propagated to the caller by throwing `OperationCanceledException`.

  Parameters:
    `documents` - the documents to locate matches in
    `pattern` - the search pattern to use when locating matches
    `scope` - the scope to limit the search to
    `requestor` - the requestor to report matches to
    `monitor` - the progress monitor to report progress to, or `null` if no progress should be reported
  Throws:
    `CoreException` - if the requestor had problem accepting one of the matches

### scheduleDocumentIndexing

    public final void scheduleDocumentIndexing(SearchDocument document,
                                               IPath indexLocation)

  Schedules the indexing of the given document. Once the document is ready to be indexed, `indexDocument(document, indexPath)` will be called in a different thread than the caller's thread.

  The given index location must represent a path in the file system to a file that either already exists or is going to be created. If it exists, it must be an index file, otherwise its data might be overwritten.

  Parameters:
    `document` - the document to index
    `indexLocation` - the location on the file system of the index

### selectIndexes

    public abstract IPath[] selectIndexes(SearchPattern query,
                                          IJavaSearchScope scope)

  Returns the collection of index locations to consider when performing the given search query in the given scope. The search engine calls this method before locating matches.

  An index location represents a path in the file system to a file that holds index information.

  Clients are not expected to call this method.

  Parameters:
    `query` - the search pattern to consider
    `scope` - the given search scope
  Returns:
    the collection of index paths to consider

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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