Creating custom search

Search system

Searches in ReSharper are represented by types derived from SearchRequest. These types do actual searches and provide found occurences as instances of IOccurence to the caller. Usually caller is type derived from SearchDescriptor which is in turn called by TreeModelBrowser. See Utilizing standard tool windows for more details.

Creating search request

When inheriting SearchRequest the most important member you have to provide is

public override ICollection<IOccurence> Search(IProgressIndicator progressIndicator)

This override will do actual search each time it is asked to do so.

Other members to implement will provide title, search targets and solution for search request consumers. Solution object is usually accepted as constructor parameter, stored and returned. Most requests will be created in the action handlers and will have immediate access to solution object.

Creating search descriptor

Most search descriptors merely inherit SearchDescriptor and implement single abstract member GetResultsTitle(), which is displayed on the tab in Search Results Window. The rest is done by base types and search requests.

Some can override ActionBarID to provide additional actions for toolbar, or override GetDefaultNode to provide initial selection better suited for the particular kind of search.

References

To.Be.Specified.dll – description

Samples and power toys

Labels

 
(None)