Skip to content

Adding project-wide type-aware search for ocaml code patterns (ocamlgrep) #2063

@mjambon

Description

@mjambon

Dear project maintainers,

LexiFi created a tool called ocamlgrep (formerly known as grep_cmt) and has been using it internally for a while. For example, it allows a query such as (__ : int list) to locate all expressions of type int list in a project. We would like to make this tool more widely available and easy to use by the OCaml community. I'm looking into the possibility of integrating it into merlin and eventually in IDEs. I would try to do most of the work and would make it easy to maintain.

Ocamlgrep's development would benefit from being part of the merlin code base in the following ways:

  • locating the project's cmt files reliably (ocamlgrep currently assumes a dune build using the default context)
  • managing compiler-libs variations across OCaml versions (ocamlgrep currently works with a single OCaml version)

One approach would be to move ocamlgrep's matching code to the merlin project. It would be part of merlin-lib and a new merlin command would function like ocamlgrep (takes a user-specified pattern and returns matches in various files). A standalone ocamlgrep command could still be provided but it would be a thin wrapper around the merlin command.

Please let me know if this looks like a good idea and if you see any challenges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Unhandled

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions