@@ -28,7 +28,8 @@ let locForPos ~extra pos =
28
28
(loc1, Typed (_, LocalReference _));
29
29
(loc2, Typed (_, GlobalReference (" Js_OO" , Tip " unsafe_downgrade" , _)));
30
30
((loc3, _) as l3);
31
- ] (* For older compiler 9.0 or earlier *)
31
+ ]
32
+ (* For older compiler 9.0 or earlier *)
32
33
when loc1 = loc2 && loc2 = loc3 ->
33
34
(* JSX and compiler combined: *)
34
35
(* ~x becomes Js_OO.unsafe_downgrade(Props)#x *)
@@ -52,18 +53,18 @@ let definedForLoc ~file ~getModule locKind =
52
53
| Constructor name -> (
53
54
match Query. getConstructor file stamp name with
54
55
| None -> None
55
- | Some constructor -> Some ([] , `Constructor constructor) )
56
+ | Some constructor -> Some ([] , `Constructor constructor))
56
57
| Field name -> (
57
58
match Query. getField file stamp name with
58
59
| None -> None
59
- | Some field -> Some ([] , `Field field) )
60
+ | Some field -> Some ([] , `Field field))
60
61
| _ -> (
61
62
maybeLog
62
- ( " Trying for declared " ^ tipToString tip ^ " " ^ string_of_int stamp
63
- ^ " in file " ^ Uri2. toString file.uri );
63
+ (" Trying for declared " ^ tipToString tip ^ " " ^ string_of_int stamp
64
+ ^ " in file " ^ Uri2. toString file.uri);
64
65
match Query. declaredForTip ~stamps: file.stamps stamp tip with
65
66
| None -> None
66
- | Some declared -> Some (declared.docstring, `Declared ) )
67
+ | Some declared -> Some (declared.docstring, `Declared ))
67
68
in
68
69
match locKind with
69
70
| NotFound -> None
@@ -95,7 +96,7 @@ let definedForLoc ~file ~getModule locKind =
95
96
None
96
97
| Some res ->
97
98
maybeLog " Yes!! got it" ;
98
- Some res ) ) ) )
99
+ Some res))) )
99
100
100
101
let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
101
102
match Hashtbl. find_opt pathsForModule file.moduleName with
@@ -118,7 +119,7 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
118
119
~exported: file.contents.exported declared.name.txt tip
119
120
with
120
121
| None -> None
121
- | Some declared -> Some (file, extra, declared) )
122
+ | Some declared -> Some (file, extra, declared))
122
123
else
123
124
match getUri intfUri with
124
125
| Error e ->
@@ -130,8 +131,8 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
130
131
~exported: file.contents.exported declared.name.txt tip
131
132
with
132
133
| None -> None
133
- | Some declared -> Some (file, extra, declared) ) )
134
- | _ -> None )
134
+ | Some declared -> Some (file, extra, declared)) )
135
+ | _ -> None )
135
136
136
137
let resolveModuleReference ~file ~getModule (declared : moduleKind declared ) =
137
138
match declared.item with
@@ -148,7 +149,7 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
148
149
| None -> None
149
150
| Some md ->
150
151
Some (env.file, Some md)
151
- (* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *) ) )
152
+ (* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *) ) )
152
153
| `Global (moduleName , path ) -> (
153
154
match getModule moduleName with
154
155
| None -> None
@@ -165,20 +166,20 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
165
166
| Some md ->
166
167
Some (env.file, Some md)
167
168
(* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *)
168
- ) ) ) )
169
+ ))) )
169
170
| `Stamp stamp -> (
170
171
match Hashtbl. find_opt file.stamps.modules stamp with
171
172
| None -> None
172
173
| Some md ->
173
174
Some (file, Some md)
174
- (* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *) )
175
+ (* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *) )
175
176
| `GlobalMod name -> (
176
177
match getModule name with
177
178
| None -> None
178
179
| Some file ->
179
180
(* maybeLog("Congrats, found a global mod"); *)
180
- Some (file, None ) )
181
- | _ -> None )
181
+ Some (file, None ))
182
+ | _ -> None )
182
183
183
184
let validateLoc (loc : Location.t ) (backup : Location.t ) =
184
185
if loc.loc_start.pos_cnum = - 1 then
@@ -203,18 +204,18 @@ let resolveModuleDefinition ~file ~getModule stamp =
203
204
| None -> Utils. topLoc (Uri2. toPath file.uri)
204
205
| Some declared -> validateLoc declared.name.loc declared.extentLoc
205
206
in
206
- Some (file.uri, loc) )
207
+ Some (file.uri, loc))
207
208
208
209
let definition ~file ~getModule stamp tip =
209
210
match tip with
210
211
| Constructor name -> (
211
212
match Query. getConstructor file stamp name with
212
213
| None -> None
213
- | Some constructor -> Some (file.uri, constructor.cname.loc) )
214
+ | Some constructor -> Some (file.uri, constructor.cname.loc))
214
215
| Field name -> (
215
216
match Query. getField file stamp name with
216
217
| None -> None
217
- | Some field -> Some (file.uri, field.fname.loc) )
218
+ | Some field -> Some (file.uri, field.fname.loc))
218
219
| Module -> resolveModuleDefinition ~file ~get Module stamp
219
220
| _ -> (
220
221
match Query. declaredForTip ~stamps: file.stamps stamp tip with
@@ -224,7 +225,7 @@ let definition ~file ~getModule stamp tip =
224
225
let env = Query. fileEnv file in
225
226
let uri = Query. getSourceUri ~env ~get Module declared.modulePath in
226
227
maybeLog (" Inner uri " ^ Uri2. toString uri);
227
- Some (uri, loc) )
228
+ Some (uri, loc))
228
229
229
230
let orLog message v =
230
231
match v with
@@ -247,8 +248,8 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
247
248
| None -> None
248
249
| Some (file , _extra , declared ) ->
249
250
let loc = validateLoc declared.name.loc declared.extentLoc in
250
- Some (file.uri, loc) )
251
- else None )
251
+ Some (file.uri, loc))
252
+ else None )
252
253
| Explanation _
253
254
| Typed (_, NotFound )
254
255
| LModule (NotFound | Definition (_, _))
@@ -263,16 +264,16 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
263
264
|> orLog " No paths found" |?> getSrc |> orLog " No src found"
264
265
with
265
266
| None -> None
266
- | Some src -> Some (Uri2. fromPath src, Utils. topLoc src) )
267
+ | Some src -> Some (Uri2. fromPath src, Utils. topLoc src))
267
268
| LModule (LocalReference (stamp, tip))
268
269
| Typed (_ , LocalReference (stamp , tip )) ->
269
270
maybeLog (" Local defn " ^ tipToString tip);
270
271
definition ~file ~get Module stamp tip
271
272
| LModule (GlobalReference (moduleName, path, tip))
272
273
| Typed (_ , GlobalReference (moduleName , path , tip )) -> (
273
274
maybeLog
274
- ( " Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
275
- ^ tipToString tip );
275
+ (" Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
276
+ ^ tipToString tip);
276
277
match getModule moduleName with
277
278
| None -> None
278
279
| Some file -> (
@@ -285,4 +286,4 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
285
286
| Some stamp ->
286
287
(* oooh wht do I do if the stamp is inside a pseudo-file? *)
287
288
maybeLog (" Got stamp " ^ string_of_int stamp);
288
- definition ~file: env.file ~get Module stamp tip ) ) )
289
+ definition ~file: env.file ~get Module stamp tip)) )
0 commit comments