@@ -29,45 +29,48 @@ let rec relative = (ident, path) =>
29
29
| _ => None
30
30
};
31
31
32
- let findClosestMatchingOpen = (opens, path, ident, loc) => {
33
- let %opt openNeedle = relative(ident, path);
34
-
35
- let matching =
36
- Hashtbl . fold(
37
- (_, op, res) =>
38
- if (Utils . locWithinLoc(loc, op. extent)
39
- && Path . same(op. path, openNeedle)) {
40
- [ op, ... res] ;
41
- } else {
42
- res;
43
- },
44
- opens,
45
- [] ,
46
- )
47
- |> List . sort((a: SharedTypes . openTracker , b) =>
48
- b. loc. loc_start. pos_cnum - a. loc. loc_start. pos_cnum
49
- );
32
+ let findClosestMatchingOpen = (opens, path, ident, loc) =>
33
+ switch (relative(ident, path)) {
34
+ | None => None
35
+ | Some (openNeedle ) =>
36
+ let matching =
37
+ Hashtbl . fold(
38
+ (_, op, res) =>
39
+ if (Utils . locWithinLoc(loc, op. extent)
40
+ && Path . same(op. path, openNeedle)) {
41
+ [ op, ... res] ;
42
+ } else {
43
+ res;
44
+ },
45
+ opens,
46
+ [] ,
47
+ )
48
+ |> List . sort((a: SharedTypes . openTracker , b) =>
49
+ b. loc. loc_start. pos_cnum - a. loc. loc_start. pos_cnum
50
+ );
50
51
51
- switch (matching) {
52
- | [] => None
53
- | [ first , ... _ ] => Some (first)
52
+ switch (matching) {
53
+ | [] => None
54
+ | [ first , ... _ ] => Some (first)
55
+ };
54
56
};
55
- };
56
57
57
58
let getTypeAtPath = (~env, path) => {
58
59
switch (Query . fromCompilerPath(~env, path)) {
59
60
| ` GlobalMod (_ ) => ` Not_found
60
61
| ` Global (moduleName , path ) => ` Global ((moduleName, path))
61
62
| ` Not_found => ` Not_found
62
63
| ` Exported (env , name ) =>
63
- let res = {
64
- let %opt stamp = Hashtbl.find_opt(env.exported.types, name);
65
- let declaredType = Hashtbl . find_opt(env. file. stamps. types, stamp);
66
- switch (declaredType) {
67
- | Some (declaredType ) => Some (` Local (declaredType))
64
+ let res =
65
+ switch (Hashtbl . find_opt(env. exported. types, name)) {
68
66
| None => None
67
+ | Some (stamp ) =>
68
+ let declaredType = Hashtbl . find_opt(env. file. stamps. types, stamp);
69
+ switch (declaredType) {
70
+ | Some (declaredType ) => Some (` Local (declaredType))
71
+ | None => None
72
+ };
69
73
};
70
- };
71
74
res |? ` Not_found ;
72
75
| ` Stamp (stamp ) =>
73
76
let res = {
@@ -91,13 +94,16 @@ module F =
91
94
) => {
92
95
let extra = Collector . extra;
93
96
94
- let maybeAddUse = (path, ident, loc, tip) => {
95
- let %opt_consume tracker =
96
- findClosestMatchingOpen (extra .opens , path , ident , loc );
97
- let %opt_consume relpath = Query.makeRelativePath(tracker.path, path);
98
-
99
- tracker .used = [ (relpath, tip, loc), ... tracker. used] ;
100
- };
97
+ let maybeAddUse = (path, ident, loc, tip) =>
98
+ switch (findClosestMatchingOpen(extra. opens, path, ident, loc)) {
99
+ | None => ()
100
+ | Some (tracker ) =>
101
+ switch (Query . makeRelativePath(tracker. path, path)) {
102
+ | None => ()
103
+ | Some (relpath ) =>
104
+ tracker. used = [ (relpath, tip, loc), ... tracker. used]
105
+ }
106
+ };
101
107
102
108
let addLocation = (loc, ident) =>
103
109
extra. locations = [ (loc, ident), ... extra. locations] ;
0 commit comments