org.eclipse.wst.jsdt.web.core.javascript.search
Class JsSearchParticipant

java.lang.Object
  extended by org.eclipse.wst.jsdt.core.search.SearchParticipant
      extended by org.eclipse.wst.jsdt.web.core.javascript.search.JsSearchParticipant

public class JsSearchParticipant
extends SearchParticipant

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves. (copied from JSP) Integration of JSP w/ java search.


Constructor Summary
JsSearchParticipant()
           
 
Method Summary
 java.lang.String getDescription()
          Returns a displayable name of this search participant.
 SearchDocument getDocument(java.lang.String documentPath)
          Important to never return null here or else Java search participation will break.
 void indexDocument(SearchDocument document, IPath indexPath)
          Indexes the given document in the given index.
 void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, IJavaScriptSearchScope 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.
 IPath[] selectIndexes(SearchPattern pattern, IJavaScriptSearchScope scope)
          Returns the collection of index locations to consider when performing the given search query in the given scope.
 
Methods inherited from class org.eclipse.wst.jsdt.core.search.SearchParticipant
beginSearching, doneSearching, removeIndex, scheduleDocumentIndexing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsSearchParticipant

public JsSearchParticipant()
Method Detail

getDocument

public SearchDocument getDocument(java.lang.String documentPath)
Important to never return null here or else Java search participation will break.

Specified by:
getDocument in class SearchParticipant
Parameters:
documentPath - the path of the document.
Returns:
a search document

getDescription

public java.lang.String getDescription()
Description copied from class: SearchParticipant
Returns a displayable name of this search participant.

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

Overrides:
getDescription in class SearchParticipant
Returns:
the displayable name of this search participant

selectIndexes

public IPath[] selectIndexes(SearchPattern pattern,
                             IJavaScriptSearchScope scope)
Description copied from class: SearchParticipant
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.

Specified by:
selectIndexes in class SearchParticipant
Parameters:
pattern - the search pattern to consider
scope - the given search scope
Returns:
the collection of index paths to consider

indexDocument

public void indexDocument(SearchDocument document,
                          IPath indexPath)
Description copied from class: SearchParticipant
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 one of the Java-like extensions or with '.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.

Specified by:
indexDocument in class SearchParticipant
Parameters:
document - the document to index
indexPath - the location in the file system to the index

locateMatches

public void locateMatches(SearchDocument[] indexMatches,
                          SearchPattern pattern,
                          IJavaScriptSearchScope scope,
                          SearchRequestor requestor,
                          IProgressMonitor monitor)
                   throws CoreException
Description copied from class: SearchParticipant
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 JavaScript javascript unit s 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.

Specified by:
locateMatches in class SearchParticipant
Parameters:
indexMatches - 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