Skip to content

Instantly share code, notes, and snippets.

@bjorng
Created August 16, 2018 08:24
Show Gist options
  • Save bjorng/d44ce521571b8fc3119aa89e8420bf90 to your computer and use it in GitHub Desktop.
Save bjorng/d44ce521571b8fc3119aa89e8420bf90 to your computer and use it in GitHub Desktop.
Core transform to set all line numbers to the same value (42). Useful for simulating huge Elixir macros.
-module(same_line).
-export([core_transform/2]).
%%
%% erlc -pa . '+{core_transform,same_line}' <filename>.erl
%%
core_transform(Core, _Options) ->
F = fun(Node) ->
case cerl:get_ann(Node) of
[Line|Ann] when is_integer(Line) ->
cerl:set_ann(Node, [42|Ann]);
_Ann ->
Node
end
end,
cerl_trees:map(F, Core).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment