diff options
Diffstat (limited to 'lib/syntax_tools')
-rw-r--r-- | lib/syntax_tools/doc/src/notes.xml | 32 | ||||
-rw-r--r-- | lib/syntax_tools/src/erl_syntax.erl | 14 | ||||
-rw-r--r-- | lib/syntax_tools/src/erl_tidy.erl | 23 | ||||
-rw-r--r-- | lib/syntax_tools/test/syntax_tools_SUITE.erl | 31 | ||||
-rw-r--r-- | lib/syntax_tools/vsn.mk | 2 |
5 files changed, 91 insertions, 11 deletions
diff --git a/lib/syntax_tools/doc/src/notes.xml b/lib/syntax_tools/doc/src/notes.xml index 4b3d578c78..a9d3f68d1d 100644 --- a/lib/syntax_tools/doc/src/notes.xml +++ b/lib/syntax_tools/doc/src/notes.xml @@ -31,6 +31,38 @@ <p>This document describes the changes made to the Syntax_Tools application.</p> +<section><title>Syntax_Tools 1.6.13</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + In syntax_tools-1.6.12 (OTP R16B03) a bug was introduced + which broke reverting of local implicit funs. Implicit + funs were mistakenly thought to be using abstract terms + for their name and arity. This has now been corrected. + (Thanks to Anthony Ramine)</p> + <p> + Own Id: OTP-11576</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> The default encoding of Erlang files has been changed + from ISO-8859-1 to UTF-8. </p> <p> The encoding of XML + files has also been changed to UTF-8. </p> + <p> + Own Id: OTP-10907</p> + </item> + </list> + </section> + +</section> + <section><title>Syntax_Tools 1.6.12</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index 5911502960..4f7f9e83ac 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -512,7 +512,7 @@ %% @see macro/2 %% @see match_expr/2 %% @see module_qualifier/2 -%% @see named_fun_expr/1 +%% @see named_fun_expr/2 %% @see nil/0 %% @see operator/1 %% @see parentheses/1 @@ -5493,7 +5493,13 @@ revert_implicit_fun(Node) -> arity_qualifier -> F = arity_qualifier_body(Name), A = arity_qualifier_argument(Name), - {'fun', Pos, {function, F, A}}; + case {type(F), type(A)} of + {atom, integer} -> + {'fun', Pos, + {function, concrete(F), concrete(A)}}; + _ -> + Node + end; module_qualifier -> M = module_qualifier_argument(Name), Name1 = module_qualifier_body(Name), @@ -5693,7 +5699,7 @@ named_fun_expr_name(Node) -> %% ===================================================================== %% @doc Returns the list of clause subtrees of a `named_fun_expr' node. %% -%% @see named_fun_expr/1 +%% @see named_fun_expr/2 -spec named_fun_expr_clauses(syntaxTree()) -> [syntaxTree()]. @@ -5716,7 +5722,7 @@ named_fun_expr_clauses(Node) -> %% syntax tree `C' of type `clause' such that %% `clause_patterns(C)' is a nonempty list. %% -%% @see named_fun_expr/1 +%% @see named_fun_expr/2 %% @see named_fun_expr_clauses/1 %% @see clause/3 %% @see clause_patterns/1 diff --git a/lib/syntax_tools/src/erl_tidy.erl b/lib/syntax_tools/src/erl_tidy.erl index 0c149634f6..7444d8dc67 100644 --- a/lib/syntax_tools/src/erl_tidy.erl +++ b/lib/syntax_tools/src/erl_tidy.erl @@ -269,6 +269,13 @@ file(Name) -> %% is typically most useful if the `verbose' flag is enabled, to %% generate reports about the program files without affecting %% them. The default value is `false'.</dd> +%% +%% <dt>{stdout, boolean()}</dt> +%% +%% <dd>If the value is `true', instead of the file being written +%% to disk it will be printed to stdout. The default value is +%% `false'.</dd> +%% %% </dl> %% %% See the function `module/2' for further options. @@ -309,9 +316,15 @@ file_2(Name, Opts) -> true -> ok; false -> - write_module(Tree, Name, Opts1), - ok - end. + case proplists:get_bool(stdout, Opts1) of + true -> + print_module(Tree, Opts1), + ok; + false -> + write_module(Tree, Name, Opts1), + ok + end + end. read_module(Name, Opts) -> verbose("reading module `~ts'.", [filename(Name)], Opts), @@ -399,6 +412,10 @@ write_module(Tree, Name, Opts) -> throw(R) end. +print_module(Tree, Opts) -> + Printer = proplists:get_value(printer, Opts), + io:format(Printer(Tree, Opts)). + output(FD, Printer, Tree, Opts) -> io:put_chars(FD, Printer(Tree, Opts)), io:nl(FD). diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl index fd381f0b25..b673b70a95 100644 --- a/lib/syntax_tools/test/syntax_tools_SUITE.erl +++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl @@ -24,12 +24,12 @@ init_per_group/2,end_per_group/2]). %% Test cases --export([smoke_test/1]). +-export([smoke_test/1,revert/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [smoke_test]. + [smoke_test,revert]. groups() -> []. @@ -73,12 +73,37 @@ print_error_markers(F, File) -> case erl_syntax:type(F) of error_marker -> {L,M,Info} = erl_syntax:error_marker_info(F), - io:format("~s:~p: ~s", [File,L,M:format_error(Info)]); + io:format("~ts:~p: ~s", [File,L,M:format_error(Info)]); _ -> ok end. +%% Read with erl_parse, wrap and revert with erl_syntax and check for equality. +revert(Config) when is_list(Config) -> + Dog = ?t:timetrap(?t:minutes(12)), + Wc = filename:join([code:lib_dir("stdlib"),"src","*.erl"]), + Fs = filelib:wildcard(Wc), + Path = [filename:join(code:lib_dir(stdlib), "include"), + filename:join(code:lib_dir(kernel), "include")], + io:format("~p files\n", [length(Fs)]), + case p_run(fun (File) -> revert_file(File, Path) end, Fs) of + 0 -> ok; + N -> ?line ?t:fail({N,errors}) + end, + ?line ?t:timetrap_cancel(Dog). + +revert_file(File, Path) -> + case epp:parse_file(File, Path, []) of + {ok,Fs0} -> + Fs1 = erl_syntax:form_list(Fs0), + Fs2 = erl_syntax_lib:map(fun (Node) -> Node end, Fs1), + Fs3 = erl_syntax:form_list_elements(Fs2), + Fs4 = [ erl_syntax:revert(Form) || Form <- Fs3 ], + {ok,_} = compile:forms(Fs4, [report,strong_validation]), + ok + end. + p_run(Test, List) -> N = erlang:system_info(schedulers), p_run_loop(Test, List, N, [], 0). diff --git a/lib/syntax_tools/vsn.mk b/lib/syntax_tools/vsn.mk index 6cafc4dd55..26153a55f1 100644 --- a/lib/syntax_tools/vsn.mk +++ b/lib/syntax_tools/vsn.mk @@ -1 +1 @@ -SYNTAX_TOOLS_VSN = 1.6.12 +SYNTAX_TOOLS_VSN = 1.6.13 |