Exograph (exograph v0.2.0)

Copy Markdown View Source

Local CodeQL-style code search for Elixir, backed by Postgres and ExAST.

Quick start

{:ok, index} = Exograph.index("lib", repo: MyApp.Repo, migrate?: true)
{:ok, hits} = Exograph.search(index, "Repo.get!(_, _)")

DSL queries

import Exograph.DSL
query = from(f in Fragment, where: matches(f, "def _ do ... end"))
{:ok, hits} = Exograph.all(index, query)

Call graph

{:ok, callers} = Exograph.search_callers(index, "Repo.transaction/1")
{:ok, callees} = Exograph.search_callees(index, "MyApp.create_user/1")

Summary

Functions

all(index, query, opts \\ [])

@spec all(Exograph.Index.t(), Exograph.DSL.Query.t(), keyword()) ::
  {:ok, [map()]} | {:error, term()}

index(paths, opts \\ [])

@spec index(
  String.t() | [String.t()],
  keyword()
) :: {:ok, Exograph.Index.t()} | {:error, term()}

search(index, pattern_or_selector, opts \\ [])

@spec search(
  Exograph.Index.t() | term(),
  ExAST.Pattern.pattern() | ExAST.Selector.t(),
  keyword()
) ::
  {:ok, [map()]} | {:error, term()}

search_callees(index, caller, opts \\ [])

@spec search_callees(Exograph.Index.t(), String.t(), keyword()) ::
  {:ok, [Exograph.CallEdge.t()]}

search_callers(index, callee, opts \\ [])

@spec search_callers(Exograph.Index.t(), String.t(), keyword()) ::
  {:ok, [Exograph.CallEdge.t()]}