mirror of
https://github.com/correl/rebar.git
synced 2024-11-30 11:09:56 +00:00
Make sure to cover all edge cases when parsing module names
This commit is contained in:
parent
1def586e39
commit
a0732e9e78
1 changed files with 13 additions and 6 deletions
|
@ -106,13 +106,20 @@ inspect(Source, IncludePath) ->
|
||||||
-spec inspect_epp(Epp::pid(), Module::string(), Includes::[string()]) -> {string(), [string()]}.
|
-spec inspect_epp(Epp::pid(), Module::string(), Includes::[string()]) -> {string(), [string()]}.
|
||||||
inspect_epp(Epp, Module, Includes) ->
|
inspect_epp(Epp, Module, Includes) ->
|
||||||
case epp:parse_erl_form(Epp) of
|
case epp:parse_erl_form(Epp) of
|
||||||
{ok, {attribute, _, module, ActualModule}} ->
|
{ok, {attribute, _, module, ModInfo}} ->
|
||||||
%% If the module name includes package info, we get a list of atoms...
|
case ModInfo of
|
||||||
case is_list(ActualModule) of
|
%% Typical module name, single atom
|
||||||
true ->
|
ActualModule when is_atom(ActualModule) ->
|
||||||
|
ActualModuleStr = atom_to_list(ActualModule);
|
||||||
|
%% Packag-ized module name, list of atoms
|
||||||
|
ActualModule when is_list(ActualModule) ->
|
||||||
ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".");
|
ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".");
|
||||||
false ->
|
%% Parameterized module name, single atom
|
||||||
ActualModuleStr = atom_to_list(ActualModule)
|
{ActualModule, _} when is_atom(ActualModule) ->
|
||||||
|
ActualModuleStr = atom_to_list(ActualModule);
|
||||||
|
%% Parameterized and packagized module name, list of atoms
|
||||||
|
{ActualModule, _} when is_list(ActualModule) ->
|
||||||
|
ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".")
|
||||||
end,
|
end,
|
||||||
inspect_epp(Epp, ActualModuleStr, Includes);
|
inspect_epp(Epp, ActualModuleStr, Includes);
|
||||||
{ok, {attribute, 1, file, {Module, 1}}} ->
|
{ok, {attribute, 1, file, {Module, 1}}} ->
|
||||||
|
|
Loading…
Reference in a new issue