Module OcamlgrepSource

Type-aware search for OCaml expression patterns.

Sourcetype position = {
  1. row : int;
  2. column : int;
}
Sourcetype location = {
  1. file : string;
  2. start : position;
  3. end_ : position;
}
Sourcetype finding = {
  1. location : location;
  2. lines : string list;
    (*

    Source lines spanned by loc, from loc_start.pos_lnum to loc_end.pos_lnum inclusive. Always non-empty.

    *)
}

A region of source code that matched a query pattern.

Sourcetype search_results = {
  1. findings : finding list;
  2. warnings : string list;
  3. error : string option;
}
Sourcetype event =
  1. | Scan_module of string
    (*

    a source file is about to be scanned

    *)
  2. | Finding of finding
    (*

    a matching region was found

    *)
  3. | Warning of string
    (*

    non-fatal diagnostic (e.g. missing cmt files)

    *)
Sourceval show_finding : ?use_color:bool -> finding -> string

Format a finding into human-readable text.

  • parameter use_color

    whether to emit ansiterm colors. Defaults to true.

search query searches the project containing the current directory for OCaml expressions matching the pattern query.

  • parameter dune_root

    forces the use of this folder as Dune's root folder.

  • parameter scan_root

    only scan this subtree which must be a folder or or a source file from which the OCaml module name can be derived by removing extensions and capitalization. Must be a relative path.

Same as search but lets the caller report findings and warnings as they come rather than waiting for the end of the scan.

Sourceval to_json : search_results -> string

JSON export