Skip to content

Commit 93b71e6

Browse files
committed
Remove processDoc and all the resulting dead code.
1 parent f25b190 commit 93b71e6

File tree

7 files changed

+21
-58
lines changed

7 files changed

+21
-58
lines changed

analysis/src/Infix.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* You provide a function that turns an element into an optional of another element,
44
* and you get a list of all of the present results.
55
*)
6-
let optMap : ('a -> 'b option) -> 'a list -> 'b list = fun fn items ->
6+
let optMap : ('a -> 'b option) -> 'a list -> 'b list =
7+
fun fn items ->
78
List.fold_left
89
(fun result item ->
910
match fn item with None -> result | Some res -> res :: result)
@@ -19,8 +20,6 @@ let ( |?> ) o fn = match o with None -> None | Some v -> fn v
1920

2021
let ( |?>> ) o fn = match o with None -> None | Some v -> Some (fn v)
2122

22-
let fold o d f = match o with None -> d | Some v -> f v
23-
2423
let logIfAbsent message x =
2524
match x with
2625
| None ->

analysis/src/ProcessAttributes.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ let rec findDeprecatedAttribute attributes =
3434
| ({Asttypes.txt = "deprecated"}, _) :: _ -> Some ""
3535
| _ :: rest -> findDeprecatedAttribute rest
3636

37-
let newDeclared ~item ~scope ~extent ~name ~stamp ~modulePath ~processDoc
38-
exported attributes =
37+
let newDeclared ~item ~scope ~extent ~name ~stamp ~modulePath exported
38+
attributes =
3939
{
4040
name;
4141
stamp;
@@ -45,10 +45,6 @@ let newDeclared ~item ~scope ~extent ~name ~stamp ~modulePath ~processDoc
4545
modulePath;
4646
deprecated = findDeprecatedAttribute attributes;
4747
docstring =
48-
( match findDocAttribute attributes with
49-
| None -> []
50-
| Some d -> processDoc d );
48+
(match findDocAttribute attributes with None -> [] | Some d -> [d]);
5149
item;
52-
(* scopeType = Let; *)
53-
(* scopeStart = env.scopeStart; *)
5450
}

analysis/src/ProcessCmt.ml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ let sigItemsExtent items =
3131
loc_end = last.sig_loc.loc_end;
3232
}
3333

34-
type env = {
35-
stamps : stamps;
36-
processDoc : string -> string list;
37-
modulePath : visibilityPath;
38-
scope : Location.t;
39-
}
34+
type env = {stamps : stamps; modulePath : visibilityPath; scope : Location.t}
4035

4136
let addItem ~name ~extent ~stamp ~env ~item attributes exported stamps =
4237
let declared =
@@ -47,7 +42,7 @@ let addItem ~name ~extent ~stamp ~env ~item attributes exported stamps =
4742
loc_end = env.scope.loc_end;
4843
loc_ghost = false;
4944
}
50-
~extent ~name ~stamp ~modulePath:env.modulePath ~processDoc:env.processDoc
45+
~extent ~name ~stamp ~modulePath:env.modulePath
5146
(not (Hashtbl.mem exported name.txt))
5247
attributes
5348
in
@@ -117,8 +112,7 @@ let rec forSignatureTypeItem env (exported : SharedTypes.exported) item =
117112
}
118113
~name:(Location.mknoloc name)
119114
~stamp (* TODO maybe this needs another child *)
120-
~modulePath:env.modulePath
121-
~processDoc:env.processDoc true cd_attributes
115+
~modulePath:env.modulePath true cd_attributes
122116
in
123117
Hashtbl.add env.stamps.constructors stamp declared;
124118
item))
@@ -291,7 +285,7 @@ let forSignature ~env items =
291285
let docstring =
292286
match ProcessAttributes.findDocAttribute attributes with
293287
| None -> []
294-
| Some d -> env.processDoc d
288+
| Some d -> [d]
295289
in
296290
{docstring; exported; topLevel}
297291

@@ -402,8 +396,7 @@ and forModule env mod_desc moduleName =
402396
loc_end = env.scope.loc_end;
403397
loc_ghost = false;
404398
}
405-
~extent:t.Typedtree.mty_loc ~stamp ~modulePath:NotVisible
406-
~processDoc:env.processDoc false []
399+
~extent:t.Typedtree.mty_loc ~stamp ~modulePath:NotVisible false []
407400
in
408401
Hashtbl.add env.stamps.modules stamp declared));
409402
forModule env resultExpr.mod_desc moduleName
@@ -441,12 +434,11 @@ and forStructure ~env items =
441434
let docstring =
442435
match ProcessAttributes.findDocAttribute attributes with
443436
| None -> []
444-
| Some d -> env.processDoc d
437+
| Some d -> [d]
445438
in
446439
{docstring; exported; topLevel}
447440

448-
let forCmt ~moduleName ~uri processDoc
449-
({cmt_modname; cmt_annots} : Cmt_format.cmt_infos) =
441+
let forCmt ~moduleName ~uri ({cmt_modname; cmt_annots} : Cmt_format.cmt_infos) =
450442
match cmt_annots with
451443
| Partial_implementation parts ->
452444
let items =
@@ -474,7 +466,6 @@ let forCmt ~moduleName ~uri processDoc
474466
{
475467
scope = extent;
476468
stamps = initStamps ();
477-
processDoc;
478469
modulePath = File (uri, moduleName);
479470
}
480471
in
@@ -494,7 +485,6 @@ let forCmt ~moduleName ~uri processDoc
494485
{
495486
scope = sigItemsExtent items;
496487
stamps = initStamps ();
497-
processDoc;
498488
modulePath = File (uri, moduleName);
499489
}
500490
in
@@ -505,7 +495,6 @@ let forCmt ~moduleName ~uri processDoc
505495
{
506496
scope = itemsExtent structure.str_items;
507497
stamps = initStamps ();
508-
processDoc;
509498
modulePath = File (uri, moduleName);
510499
}
511500
in
@@ -516,7 +505,6 @@ let forCmt ~moduleName ~uri processDoc
516505
{
517506
scope = sigItemsExtent signature.sig_items;
518507
stamps = initStamps ();
519-
processDoc;
520508
modulePath = File (uri, moduleName);
521509
}
522510
in

analysis/src/ProcessExtra.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ struct
344344
loc_end = (currentScopeExtent ()).loc_end;
345345
}
346346
~modulePath:NotVisible
347-
~processDoc:(fun x -> [x])
348347
~item:val_desc.ctyp_type false val_attributes
349348
in
350349
Hashtbl.add Collector.file.stamps.values stamp declared;
@@ -372,7 +371,6 @@ struct
372371
loc_end = (currentScopeExtent ()).loc_end;
373372
}
374373
~modulePath:NotVisible ~extent:pat_loc
375-
~processDoc:(fun x -> [x])
376374
~item:pat_type false pat_attributes
377375
in
378376
Hashtbl.add Collector.file.stamps.values stamp declared;

analysis/src/Process_406.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
open SharedTypes
2-
3-
let fileForCmt ~moduleName ~uri cmt processDoc =
1+
let fileForCmt ~moduleName ~uri cmt =
42
match Shared.tryReadCmt cmt with
53
| Error e -> Error e
6-
| Ok infos -> Ok (ProcessCmt.forCmt ~moduleName ~uri processDoc infos)
4+
| Ok infos -> Ok (ProcessCmt.forCmt ~moduleName ~uri infos)
75

8-
let fullForCmt ~moduleName ~uri cmt processDoc =
6+
let fullForCmt ~moduleName ~uri cmt =
97
match Shared.tryReadCmt cmt with
108
| Error e -> Error e
119
| Ok infos ->
12-
let file = ProcessCmt.forCmt ~moduleName ~uri processDoc infos in
10+
let file = ProcessCmt.forCmt ~moduleName ~uri infos in
1311
let extra = ProcessExtra.forCmt ~file infos in
14-
Ok {file; extra}
12+
Ok {SharedTypes.file; extra}
1513

1614
module PrintType = PrintType

analysis/src/Process_406.mli

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
val fileForCmt :
2-
moduleName:string ->
3-
uri:Uri2.t ->
4-
string ->
5-
(string -> string list) ->
6-
(SharedTypes.file, string) result
2+
moduleName:string -> uri:Uri2.t -> string -> (SharedTypes.file, string) result
73

84
val fullForCmt :
9-
moduleName:string ->
10-
uri:Uri2.t ->
11-
string ->
12-
(string -> string list) ->
13-
(SharedTypes.full, string) result
5+
moduleName:string -> uri:Uri2.t -> string -> (SharedTypes.full, string) result

analysis/src/State.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
let isMl path =
2-
Filename.check_suffix path ".ml" || Filename.check_suffix path ".mli"
3-
4-
let converter src =
5-
let mlToOutput s = [s] in
6-
Infix.fold src mlToOutput (fun src ->
7-
match isMl src with true -> mlToOutput | false -> fun x -> [x])
8-
91
let newDocsForCmt ~moduleName cmtCache changed cmt src =
102
let open Infix in
113
let uri = Uri2.fromPath (src |? cmt) in
12-
match Process_406.fileForCmt ~moduleName ~uri cmt (converter src) with
4+
match Process_406.fileForCmt ~moduleName ~uri cmt with
135
| Error e ->
146
Log.log e;
157
None
@@ -51,7 +43,7 @@ let getFullFromCmt ~state ~uri =
5143
match Hashtbl.find_opt package.pathsForModule moduleName with
5244
| Some paths -> (
5345
let cmt = SharedTypes.getCmt ~interface:(Utils.endsWith path "i") paths in
54-
match Process_406.fullForCmt ~moduleName ~uri cmt (fun x -> [x]) with
46+
match Process_406.fullForCmt ~moduleName ~uri cmt with
5547
| Error e -> Error e
5648
| Ok full ->
5749
Hashtbl.replace package.interModuleDependencies moduleName

0 commit comments

Comments
 (0)