Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 5d5eafa

Browse files
committed
format
1 parent 1338bae commit 5d5eafa

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

src/References.ml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ let locForPos ~extra pos =
2828
(loc1, Typed (_, LocalReference _));
2929
(loc2, Typed (_, GlobalReference ("Js_OO", Tip "unsafe_downgrade", _)));
3030
((loc3, _) as l3);
31-
] (* For older compiler 9.0 or earlier *)
31+
]
32+
(* For older compiler 9.0 or earlier *)
3233
when loc1 = loc2 && loc2 = loc3 ->
3334
(* JSX and compiler combined: *)
3435
(* ~x becomes Js_OO.unsafe_downgrade(Props)#x *)
@@ -52,18 +53,18 @@ let definedForLoc ~file ~getModule locKind =
5253
| Constructor name -> (
5354
match Query.getConstructor file stamp name with
5455
| None -> None
55-
| Some constructor -> Some ([], `Constructor constructor) )
56+
| Some constructor -> Some ([], `Constructor constructor))
5657
| Field name -> (
5758
match Query.getField file stamp name with
5859
| None -> None
59-
| Some field -> Some ([], `Field field) )
60+
| Some field -> Some ([], `Field field))
6061
| _ -> (
6162
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);
6465
match Query.declaredForTip ~stamps:file.stamps stamp tip with
6566
| None -> None
66-
| Some declared -> Some (declared.docstring, `Declared) )
67+
| Some declared -> Some (declared.docstring, `Declared))
6768
in
6869
match locKind with
6970
| NotFound -> None
@@ -95,7 +96,7 @@ let definedForLoc ~file ~getModule locKind =
9596
None
9697
| Some res ->
9798
maybeLog "Yes!! got it";
98-
Some res ) ) ) )
99+
Some res))))
99100

100101
let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
101102
match Hashtbl.find_opt pathsForModule file.moduleName with
@@ -118,7 +119,7 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
118119
~exported:file.contents.exported declared.name.txt tip
119120
with
120121
| None -> None
121-
| Some declared -> Some (file, extra, declared) )
122+
| Some declared -> Some (file, extra, declared))
122123
else
123124
match getUri intfUri with
124125
| Error e ->
@@ -130,8 +131,8 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
130131
~exported:file.contents.exported declared.name.txt tip
131132
with
132133
| None -> None
133-
| Some declared -> Some (file, extra, declared) ) )
134-
| _ -> None )
134+
| Some declared -> Some (file, extra, declared)))
135+
| _ -> None)
135136

136137
let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
137138
match declared.item with
@@ -148,7 +149,7 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
148149
| None -> None
149150
| Some md ->
150151
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))) *)))
152153
| `Global (moduleName, path) -> (
153154
match getModule moduleName with
154155
| None -> None
@@ -165,20 +166,20 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
165166
| Some md ->
166167
Some (env.file, Some md)
167168
(* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *)
168-
) ) ) )
169+
))))
169170
| `Stamp stamp -> (
170171
match Hashtbl.find_opt file.stamps.modules stamp with
171172
| None -> None
172173
| Some md ->
173174
Some (file, Some md)
174-
(* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *) )
175+
(* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *))
175176
| `GlobalMod name -> (
176177
match getModule name with
177178
| None -> None
178179
| Some file ->
179180
(* maybeLog("Congrats, found a global mod"); *)
180-
Some (file, None) )
181-
| _ -> None )
181+
Some (file, None))
182+
| _ -> None)
182183

183184
let validateLoc (loc : Location.t) (backup : Location.t) =
184185
if loc.loc_start.pos_cnum = -1 then
@@ -203,18 +204,18 @@ let resolveModuleDefinition ~file ~getModule stamp =
203204
| None -> Utils.topLoc (Uri2.toPath file.uri)
204205
| Some declared -> validateLoc declared.name.loc declared.extentLoc
205206
in
206-
Some (file.uri, loc) )
207+
Some (file.uri, loc))
207208

208209
let definition ~file ~getModule stamp tip =
209210
match tip with
210211
| Constructor name -> (
211212
match Query.getConstructor file stamp name with
212213
| None -> None
213-
| Some constructor -> Some (file.uri, constructor.cname.loc) )
214+
| Some constructor -> Some (file.uri, constructor.cname.loc))
214215
| Field name -> (
215216
match Query.getField file stamp name with
216217
| None -> None
217-
| Some field -> Some (file.uri, field.fname.loc) )
218+
| Some field -> Some (file.uri, field.fname.loc))
218219
| Module -> resolveModuleDefinition ~file ~getModule stamp
219220
| _ -> (
220221
match Query.declaredForTip ~stamps:file.stamps stamp tip with
@@ -224,7 +225,7 @@ let definition ~file ~getModule stamp tip =
224225
let env = Query.fileEnv file in
225226
let uri = Query.getSourceUri ~env ~getModule declared.modulePath in
226227
maybeLog ("Inner uri " ^ Uri2.toString uri);
227-
Some (uri, loc) )
228+
Some (uri, loc))
228229

229230
let orLog message v =
230231
match v with
@@ -247,8 +248,8 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
247248
| None -> None
248249
| Some (file, _extra, declared) ->
249250
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)
252253
| Explanation _
253254
| Typed (_, NotFound)
254255
| LModule (NotFound | Definition (_, _))
@@ -263,16 +264,16 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
263264
|> orLog "No paths found" |?> getSrc |> orLog "No src found"
264265
with
265266
| None -> None
266-
| Some src -> Some (Uri2.fromPath src, Utils.topLoc src) )
267+
| Some src -> Some (Uri2.fromPath src, Utils.topLoc src))
267268
| LModule (LocalReference (stamp, tip))
268269
| Typed (_, LocalReference (stamp, tip)) ->
269270
maybeLog ("Local defn " ^ tipToString tip);
270271
definition ~file ~getModule stamp tip
271272
| LModule (GlobalReference (moduleName, path, tip))
272273
| Typed (_, GlobalReference (moduleName, path, tip)) -> (
273274
maybeLog
274-
( "Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
275-
^ tipToString tip );
275+
("Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
276+
^ tipToString tip);
276277
match getModule moduleName with
277278
| None -> None
278279
| Some file -> (
@@ -285,4 +286,4 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
285286
| Some stamp ->
286287
(* oooh wht do I do if the stamp is inside a pseudo-file? *)
287288
maybeLog ("Got stamp " ^ string_of_int stamp);
288-
definition ~file:env.file ~getModule stamp tip ) ) )
289+
definition ~file:env.file ~getModule stamp tip)))

0 commit comments

Comments
 (0)