igniter/lib/debug.ex

28 lines
614 B
Elixir
Raw Normal View History

2024-06-13 10:22:08 +12:00
defmodule Igniter.Debug do
@moduledoc "Tools for debugging zippers."
alias Sourceror.Zipper
@doc "Puts the formatted code at the node of the zipper to the console"
def puts_code_at_node(zipper) do
zipper
|> Zipper.subtree()
|> Zipper.root()
|> Sourceror.to_string()
|> then(&"==code==\n#{&1}\n==code==\n")
|> IO.puts()
zipper
end
@doc "Puts the ast at the node of the zipper to the console"
def puts_ast_at_node(zipper) do
zipper
|> Zipper.subtree()
|> Zipper.root()
|> then(&"==ast==\n#{inspect(&1)}\n==ast==\n")
|> IO.puts()
zipper
end
end