
* Fix stdlib warnings * Mark unused includes when used from non-included files * Do not mark indirectly included files as unused * Show unused include warning only for files that are never used * Remove unused include from Option.aes * Consider functions passed as args as used * Return warnings as a sorted list * Fix failing tests * Fix dialyzer warning * Fix warning in Func.aes
32 lines
736 B
Erlang
32 lines
736 B
Erlang
-module(aeso_warnings).
|
|
|
|
-record(warn, { pos :: aeso_errors:pos()
|
|
, message :: iolist()
|
|
}).
|
|
|
|
-opaque warning() :: #warn{}.
|
|
|
|
-export_type([warning/0]).
|
|
|
|
-export([ new/1
|
|
, new/2
|
|
, warn_to_err/2
|
|
, sort_warnings/1
|
|
, pp/1
|
|
]).
|
|
|
|
new(Msg) ->
|
|
new(aeso_errors:pos(0, 0), Msg).
|
|
|
|
new(Pos, Msg) ->
|
|
#warn{ pos = Pos, message = Msg }.
|
|
|
|
warn_to_err(Kind, #warn{ pos = Pos, message = Msg }) ->
|
|
aeso_errors:new(Kind, Pos, lists:flatten(Msg)).
|
|
|
|
sort_warnings(Warnings) ->
|
|
lists:sort(fun(W1, W2) -> W1#warn.pos =< W2#warn.pos end, Warnings).
|
|
|
|
pp(#warn{ pos = Pos, message = Msg }) ->
|
|
lists:flatten(io_lib:format("Warning~s:\n~s", [aeso_errors:pp_pos(Pos), Msg])).
|