diff options
author | Kostis Sagonas <[email protected]> | 2011-01-20 19:12:01 +0200 |
---|---|---|
committer | Kostis Sagonas <[email protected]> | 2011-01-20 19:12:01 +0200 |
commit | b4c3711c6daa2f171f56b984235969e223ce8f9c (patch) | |
tree | 181f6ada7126a8e66ae0876578eb5af0c5346cce /lib/dialyzer/src/dialyzer.erl | |
parent | faef041a446314bb228e0e8c88a09241df2798f1 (diff) | |
download | otp-b4c3711c6daa2f171f56b984235969e223ce8f9c.tar.gz otp-b4c3711c6daa2f171f56b984235969e223ce8f9c.tar.bz2 otp-b4c3711c6daa2f171f56b984235969e223ce8f9c.zip |
Add a --fullpath option to Dialyzer
This change adds a --fullpath option to Dialyzer, which makes the
warning messages contain the full path of the corresponding file.
Original patch submitted by Magnus Henoch (legoscia) on 15/9/2010
and cooked to death in the 'pu' branch all this time.
The patch was essentially correct and most of it has been used as
is, but there have been some changes to make the code slightly
prettier, avoid some code duplication, and add documentation to
dialyzer's doc files and to its help message.
Diffstat (limited to 'lib/dialyzer/src/dialyzer.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer.erl | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl index 471f9fccd2..f4b3cff19c 100644 --- a/lib/dialyzer/src/dialyzer.erl +++ b/lib/dialyzer/src/dialyzer.erl @@ -2,7 +2,7 @@ %%----------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% Copyright Ericsson AB 2006-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -38,7 +38,8 @@ gui/0, gui/1, plt_info/1, - format_warning/1]). + format_warning/1, + format_warning/2]). -include("dialyzer.hrl"). @@ -48,6 +49,8 @@ %% - run/1: Erlang interface for a command line-like analysis %% - gui/0/1: Erlang interface for the gui. %% - format_warning/1: Get the string representation of a warning. +%% - format_warning/1: Likewise, but with an option whether +%% to display full path names or not %% - plt_info/1: Get information of the specified plt. %%-------------------------------------------------------------------- @@ -281,11 +284,19 @@ cl_check_log(Output) -> -spec format_warning(dial_warning()) -> string(). -format_warning({_Tag, {File, Line}, Msg}) when is_list(File), - is_integer(Line) -> - BaseName = filename:basename(File), +format_warning(W) -> + format_warning(W, basename). + +-spec format_warning(dial_warning(), fopt()) -> string(). + +format_warning({_Tag, {File, Line}, Msg}, FOpt) when is_list(File), + is_integer(Line) -> + F = case FOpt of + fullpath -> File; + basename -> filename:basename(File) + end, String = lists:flatten(message_to_string(Msg)), - lists:flatten(io_lib:format("~s:~w: ~s", [BaseName, Line, String])). + lists:flatten(io_lib:format("~s:~w: ~s", [F, Line, String])). %%----------------------------------------------------------------------------- |