Move module validation to own function
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
51ca4f7659
commit
3667db05fc
|
@ -43,27 +43,8 @@ end = struct
|
||||||
, modules
|
, modules
|
||||||
)
|
)
|
||||||
|
|
||||||
let eval ~modules:(all_modules : Module.t Module.Name.Map.t)
|
let check_invalid_module_listing ~(buildable : Buildable.t) ~intf_only
|
||||||
~buildable:(conf : Buildable.t) =
|
~real_intf_only ~modules_without_implementation_locs =
|
||||||
let (fake_modules, modules, _) =
|
|
||||||
eval ~standard:all_modules ~all_modules conf.modules in
|
|
||||||
let (fake_modules, intf_only, modules_without_implementation_locs) =
|
|
||||||
let (fake_modules', intf_only, locs) =
|
|
||||||
eval ~standard:Module.Name.Map.empty ~all_modules
|
|
||||||
conf.modules_without_implementation in
|
|
||||||
( Module.Name.Map.superpose fake_modules' fake_modules
|
|
||||||
, intf_only
|
|
||||||
, locs
|
|
||||||
)
|
|
||||||
in
|
|
||||||
Module.Name.Map.iteri fake_modules ~f:(fun m loc ->
|
|
||||||
Loc.warn loc "Module %a is excluded but it doesn't exist."
|
|
||||||
Module.Name.pp m
|
|
||||||
);
|
|
||||||
let real_intf_only =
|
|
||||||
Module.Name.Map.filter modules
|
|
||||||
~f:(fun (m : Module.t) -> Option.is_none m.impl)
|
|
||||||
in
|
|
||||||
if not (Module.Name.Map.equal intf_only real_intf_only
|
if not (Module.Name.Map.equal intf_only real_intf_only
|
||||||
~equal:(fun a b -> Module.name a = Module.name b)) then begin
|
~equal:(fun a b -> Module.name a = Module.name b)) then begin
|
||||||
let should_be_listed, shouldn't_be_listed =
|
let should_be_listed, shouldn't_be_listed =
|
||||||
|
@ -78,9 +59,9 @@ end = struct
|
||||||
in
|
in
|
||||||
let uncapitalized = List.map ~f:Module.Name.uncapitalize in
|
let uncapitalized = List.map ~f:Module.Name.uncapitalize in
|
||||||
if should_be_listed <> [] then begin
|
if should_be_listed <> [] then begin
|
||||||
match Ordered_set_lang.loc conf.modules_without_implementation with
|
match Ordered_set_lang.loc buildable.modules_without_implementation with
|
||||||
| None ->
|
| None ->
|
||||||
Loc.warn conf.loc
|
Loc.warn buildable.loc
|
||||||
"Some modules don't have an implementation.\
|
"Some modules don't have an implementation.\
|
||||||
\nYou need to add the following field to this stanza:\
|
\nYou need to add the following field to this stanza:\
|
||||||
\n\
|
\n\
|
||||||
|
@ -119,7 +100,30 @@ end = struct
|
||||||
"Module %a has an implementation, it cannot be listed here"
|
"Module %a has an implementation, it cannot be listed here"
|
||||||
Module.Name.pp module_name
|
Module.Name.pp module_name
|
||||||
end
|
end
|
||||||
end;
|
end
|
||||||
|
|
||||||
|
let eval ~modules:(all_modules : Module.t Module.Name.Map.t)
|
||||||
|
~buildable:(conf : Buildable.t) =
|
||||||
|
let (fake_modules, modules, _) =
|
||||||
|
eval ~standard:all_modules ~all_modules conf.modules in
|
||||||
|
let (fake_modules, intf_only, modules_without_implementation_locs) =
|
||||||
|
let (fake_modules', intf_only, locs) =
|
||||||
|
eval ~standard:Module.Name.Map.empty ~all_modules
|
||||||
|
conf.modules_without_implementation in
|
||||||
|
( Module.Name.Map.superpose fake_modules' fake_modules
|
||||||
|
, intf_only
|
||||||
|
, locs
|
||||||
|
)
|
||||||
|
in
|
||||||
|
Module.Name.Map.iteri fake_modules ~f:(fun m loc ->
|
||||||
|
Loc.warn loc "Module %a is excluded but it doesn't exist."
|
||||||
|
Module.Name.pp m
|
||||||
|
);
|
||||||
|
let real_intf_only =
|
||||||
|
Module.Name.Map.filter modules
|
||||||
|
~f:(fun (m : Module.t) -> Option.is_none m.impl) in
|
||||||
|
check_invalid_module_listing ~buildable:conf ~intf_only ~real_intf_only
|
||||||
|
~modules_without_implementation_locs;
|
||||||
modules
|
modules
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue