瀏覽代碼

Add support for behaviors, and not just behaviours

pull/1339/head
Brujo Benavides 8 年之前
父節點
當前提交
3f0e56d9c8
共有 3 個檔案被更改,包括 5 行新增2 行删除
  1. +2
    -0
      src/rebar_erlc_compiler.erl
  2. +2
    -1
      src/rebar_prv_xref.erl
  3. +1
    -1
      test/rebar_xref_SUITE.erl

+ 2
- 0
src/rebar_erlc_compiler.erl 查看文件

@ -668,6 +668,8 @@ process_attr(include_lib, Form, Includes, Dir) ->
[FileNode] = erl_syntax:attribute_arguments(Form), [FileNode] = erl_syntax:attribute_arguments(Form),
RawFile = erl_syntax:string_value(FileNode), RawFile = erl_syntax:string_value(FileNode),
maybe_expand_include_lib_path(RawFile, Dir) ++ Includes; maybe_expand_include_lib_path(RawFile, Dir) ++ Includes;
process_attr(behavior, Form, Includes, _Dir) ->
process_attr(behaviour, Form, Includes, _Dir);
process_attr(behaviour, Form, Includes, _Dir) -> process_attr(behaviour, Form, Includes, _Dir) ->
[FileNode] = erl_syntax:attribute_arguments(Form), [FileNode] = erl_syntax:attribute_arguments(Form),
File = module_to_erl(erl_syntax:atom_value(FileNode)), File = module_to_erl(erl_syntax:atom_value(FileNode)),

+ 2
- 1
src/rebar_prv_xref.erl 查看文件

@ -165,7 +165,8 @@ keyall(Key, List) ->
lists:flatmap(fun({K, L}) when Key =:= K -> L; (_) -> [] end, List). lists:flatmap(fun({K, L}) when Key =:= K -> L; (_) -> [] end, List).
get_behaviour_callbacks(exports_not_used, Attributes) -> get_behaviour_callbacks(exports_not_used, Attributes) ->
[B:behaviour_info(callbacks) || B <- keyall(behaviour, Attributes)];
[B:behaviour_info(callbacks) || B <- keyall(behaviour, Attributes) ++
keyall(behavior, Attributes)];
get_behaviour_callbacks(_XrefCheck, _Attributes) -> get_behaviour_callbacks(_XrefCheck, _Attributes) ->
[]. [].

+ 1
- 1
test/rebar_xref_SUITE.erl 查看文件

@ -150,7 +150,7 @@ get_module_body(mymod, AppName, IgnoreXref) ->
["-ignore_xref([{other2,1},{localfunc2,0},{fdeprecated,0}]).\n" ["-ignore_xref([{other2,1},{localfunc2,0},{fdeprecated,0}]).\n"
|| X <- [IgnoreXref], X =:= true], || X <- [IgnoreXref], X =:= true],
"-behaviour(", AppName, "_behaviour1).\n", % 2 behaviours "-behaviour(", AppName, "_behaviour1).\n", % 2 behaviours
"-behaviour(", AppName, "_behaviour2).\n",
"-behavior(", AppName, "_behaviour2).\n",
"-deprecated({fdeprecated,0}).\n", % deprecated function "-deprecated({fdeprecated,0}).\n", % deprecated function
"bh1_a(A) -> localfunc1(bh1_a, A).\n", % behaviour functions "bh1_a(A) -> localfunc1(bh1_a, A).\n", % behaviour functions
"bh1_b(A) -> localfunc1(bh1_b, A).\n", "bh1_b(A) -> localfunc1(bh1_b, A).\n",

Loading…
取消
儲存