Refactor a bit some code in workspace.ml
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
6a9c32dcb4
commit
2913d3e501
|
@ -167,28 +167,22 @@ let t ?x ?profile:cmdline_profile () =
|
||||||
multi_field "context" (Context.t ~profile ~x)
|
multi_field "context" (Context.t ~profile ~x)
|
||||||
>>| fun contexts ->
|
>>| fun contexts ->
|
||||||
let defined_names = ref String.Set.empty in
|
let defined_names = ref String.Set.empty in
|
||||||
let { merlin_context; contexts; env } =
|
let merlin_context =
|
||||||
let init =
|
List.fold_left contexts ~init:None ~f:(fun acc ctx ->
|
||||||
{ merlin_context = None
|
|
||||||
; contexts = []
|
|
||||||
; env
|
|
||||||
}
|
|
||||||
in
|
|
||||||
List.fold_left contexts ~init ~f:(fun t ctx ->
|
|
||||||
let name = Context.name ctx in
|
let name = Context.name ctx in
|
||||||
if String.Set.mem !defined_names name then
|
if String.Set.mem !defined_names name then
|
||||||
Loc.fail (Context.loc ctx)
|
Loc.fail (Context.loc ctx)
|
||||||
"second definition of build context %S" name;
|
"second definition of build context %S" name;
|
||||||
defined_names := String.Set.union !defined_names
|
defined_names := String.Set.union !defined_names
|
||||||
(String.Set.of_list (Context.all_names ctx));
|
(String.Set.of_list (Context.all_names ctx));
|
||||||
match ctx, t.merlin_context with
|
match ctx, acc with
|
||||||
| Opam { merlin = true; _ }, Some _ ->
|
| Opam { merlin = true; _ }, Some _ ->
|
||||||
Loc.fail (Context.loc ctx)
|
Loc.fail (Context.loc ctx)
|
||||||
"you can only have one context for merlin"
|
"you can only have one context for merlin"
|
||||||
| Opam { merlin = true; _ }, None ->
|
| Opam { merlin = true; _ }, None ->
|
||||||
{ t with contexts = ctx :: t.contexts; merlin_context = Some name }
|
Some name
|
||||||
| _ ->
|
| _ ->
|
||||||
{ t with contexts = ctx :: t.contexts })
|
acc)
|
||||||
in
|
in
|
||||||
let contexts =
|
let contexts =
|
||||||
match contexts with
|
match contexts with
|
||||||
|
|
Loading…
Reference in New Issue