mirror of
https://github.com/ash-project/igniter.git
synced 2024-09-20 05:22:52 +12:00
067c4a6df0
improvement: use `Spitfire` to ensure that aliases are considered when comparing modules improvement: use `Spitfire` to *use* any existing aliases when inserting code improvement: use `Zipper.topmost` to power new `Spitfire`-related features
35 lines
827 B
Elixir
35 lines
827 B
Elixir
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 "Returns the formatted code at the node of the zipper to the console"
|
|
def code_at_node(zipper) do
|
|
zipper
|
|
|> Zipper.subtree()
|
|
|> Zipper.root()
|
|
|> Sourceror.to_string()
|
|
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, pretty: true)}\n==ast==\n")
|
|
|> IO.puts()
|
|
|
|
zipper
|
|
end
|
|
end
|