Crate grepdef

Source
Expand description

Quick search for symbol definitions in various programming languages

Currently this supports Rust, JS (or TypeScript), and PHP.

This can be used like “Go to definition” in an IDE, except that instead of using a language server, it just searches for the definition using text parsing. This is less accurate but often faster in projects with lots of files or where a language server won’t work or hasn’t yet started.

grepdef since 3.0 is written in Rust and is designed to be extremely fast.

This can also be used as a library crate for other Rust programs.

§Example

The syntax of the CLI is similar to that of grep or ripgrep: first put the symbol you want to search for (eg: a function name, class name, etc.) and then list the file(s) or directories over which you want to search.

$ grepdef parseQuery ./src
./src/queries.js:function parseQuery {

Just like grep, you can add the -n option to include line numbers.

$ grepdef -n parseQuery ./src
./src/queries.js:17:function parseQuery {

The search will be faster if you specify what type of file you are searching for using the --type option.

$ grepdef --type js -n parseQuery ./src
./src/queries.js:17:function parseQuery {

To use the crate from other Rust code, use Searcher.

use grepdef::{Args, Searcher};

for result in Searcher::new(Args::from_query("parseQuery")).unwrap().search().unwrap() {
    println!("{}", result.to_grep());
}

Structs§

Args
The command-line arguments to be used by Searcher
SearchResult
A result from calling Searcher::search or Searcher::search_and_format
Searcher
A struct that can perform a search

Enums§

ColorOption
The supported arguments to the color option
FileType
The supported file types to search
SearchEventType
The type of a search event
SearchMethod
(Advanced) The type of underlying search algorithm to use
SearchResultFormat
The output format of SearchResult