Created
August 16, 2018 08:24
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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