@@ -47,54 +47,54 @@ let definedForLoc ~file ~getModule locKind =
47
47
| Constructor name -> (
48
48
match Query. getConstructor file stamp name with
49
49
| None -> None
50
- | Some constructor -> Some ([] , `Constructor constructor) )
50
+ | Some constructor -> Some ([] , `Constructor constructor))
51
51
| Field name -> (
52
52
match Query. getField file stamp name with
53
53
| None -> None
54
- | Some field -> Some ([] , `Field field) )
54
+ | Some field -> Some ([] , `Field field))
55
55
| _ -> (
56
56
maybeLog
57
- ( " Trying for declared " ^ tipToString tip ^ " " ^ string_of_int stamp
58
- ^ " in file " ^ Uri2. toString file.uri );
57
+ (" Trying for declared " ^ tipToString tip ^ " " ^ string_of_int stamp
58
+ ^ " in file " ^ Uri2. toString file.uri);
59
59
match Query. declaredForTip ~stamps: file.stamps stamp tip with
60
60
| None -> None
61
- | Some declared -> Some (declared.docstring, `Declared ) )
61
+ | Some declared -> Some (declared.docstring, `Declared ))
62
62
in
63
63
match locKind with
64
64
| NotFound -> None
65
65
| LocalReference (stamp , tip ) | Definition (stamp , tip ) ->
66
66
inner ~file stamp tip
67
67
| GlobalReference (moduleName , path , tip ) ->
68
- ( maybeLog (" Getting global " ^ moduleName);
69
- match
70
- getModule moduleName
71
- |> RResult. orError (" Cannot get module " ^ moduleName)
72
- with
73
- | Error e -> Error e
74
- | Ok file -> (
75
- let env = Query. fileEnv file in
76
- match
77
- Query. resolvePath ~env ~path ~get Module
78
- |> RResult. orError (" Cannot resolve path " ^ pathToString path)
79
- with
80
- | Error e -> Error e
81
- | Ok (env , name ) -> (
82
- match
83
- Query. exportedForTip ~env name tip
84
- |> RResult. orError
85
- (" Exported not found for tip " ^ name ^ " > " ^ tipToString tip)
86
- with
87
- | Error e -> Error e
88
- | Ok stamp -> (
89
- maybeLog (" Getting for " ^ string_of_int stamp ^ " in " ^ name);
90
- match
91
- inner ~file: env.file stamp tip
92
- |> RResult. orError " could not get defined"
93
- with
94
- | Error e -> Error e
95
- | Ok res ->
96
- maybeLog " Yes!! got it" ;
97
- Ok res ) ) ) )
68
+ (maybeLog (" Getting global " ^ moduleName);
69
+ match
70
+ getModule moduleName
71
+ |> RResult. orError (" Cannot get module " ^ moduleName)
72
+ with
73
+ | Error e -> Error e
74
+ | Ok file -> (
75
+ let env = Query. fileEnv file in
76
+ match
77
+ Query. resolvePath ~env ~path ~get Module
78
+ |> RResult. orError (" Cannot resolve path " ^ pathToString path)
79
+ with
80
+ | Error e -> Error e
81
+ | Ok (env , name ) -> (
82
+ match
83
+ Query. exportedForTip ~env name tip
84
+ |> RResult. orError
85
+ (" Exported not found for tip " ^ name ^ " > " ^ tipToString tip)
86
+ with
87
+ | Error e -> Error e
88
+ | Ok stamp -> (
89
+ maybeLog (" Getting for " ^ string_of_int stamp ^ " in " ^ name);
90
+ match
91
+ inner ~file: env.file stamp tip
92
+ |> RResult. orError " could not get defined"
93
+ with
94
+ | Error e -> Error e
95
+ | Ok res ->
96
+ maybeLog " Yes!! got it" ;
97
+ Ok res))) )
98
98
|> RResult. toOptionAndLog
99
99
100
100
let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
@@ -116,7 +116,7 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
116
116
~exported: file.contents.exported declared.name.txt tip
117
117
with
118
118
| None -> None
119
- | Some declared -> Some (file, extra, declared) )
119
+ | Some declared -> Some (file, extra, declared))
120
120
else
121
121
match getUri intfUri |> RResult. toOptionAndLog with
122
122
| None -> None
@@ -126,8 +126,8 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
126
126
~exported: file.contents.exported declared.name.txt tip
127
127
with
128
128
| None -> None
129
- | Some declared -> Some (file, extra, declared) ) )
130
- | _ -> None )
129
+ | Some declared -> Some (file, extra, declared)) )
130
+ | _ -> None )
131
131
132
132
let resolveModuleReference ~file ~getModule (declared : moduleKind declared ) =
133
133
match declared.item with
@@ -144,9 +144,7 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
144
144
| None -> None
145
145
| Some md ->
146
146
Some (env.file, Some md)
147
- (* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *)
148
- )
149
- )
147
+ (* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *) ))
150
148
| `Global (moduleName , path ) -> (
151
149
match getModule moduleName with
152
150
| None -> None
@@ -163,25 +161,20 @@ let resolveModuleReference ~file ~getModule (declared : moduleKind declared) =
163
161
| Some md ->
164
162
Some (env.file, Some md)
165
163
(* Some((env.file.uri, validateLoc(md.name.loc, md.extentLoc))) *)
166
- )
167
- )
168
- )
169
- )
164
+ ))))
170
165
| `Stamp stamp -> (
171
166
match Hashtbl. find_opt file.stamps.modules stamp with
172
167
| None -> None
173
168
| Some md ->
174
169
Some (file, Some md)
175
- (* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *)
176
- )
170
+ (* Some((file.uri, validateLoc(md.name.loc, md.extentLoc))) *) )
177
171
| `GlobalMod name -> (
178
172
match getModule name with
179
173
| None -> None
180
174
| Some file ->
181
175
(* maybeLog("Congrats, found a global mod"); *)
182
- Some (file, None )
183
- )
184
- | _ -> None )
176
+ Some (file, None ))
177
+ | _ -> None )
185
178
186
179
let validateLoc (loc : Location.t ) (backup : Location.t ) =
187
180
if loc.loc_start.pos_cnum = - 1 then
@@ -206,18 +199,18 @@ let resolveModuleDefinition ~file ~getModule stamp =
206
199
| None -> Utils. topLoc (Uri2. toPath file.uri)
207
200
| Some declared -> validateLoc declared.name.loc declared.extentLoc
208
201
in
209
- Some (file.uri, loc) )
202
+ Some (file.uri, loc))
210
203
211
204
let definition ~file ~getModule stamp tip =
212
205
match tip with
213
206
| Constructor name -> (
214
207
match Query. getConstructor file stamp name with
215
208
| None -> None
216
- | Some constructor -> Some (file.uri, constructor.cname.loc) )
209
+ | Some constructor -> Some (file.uri, constructor.cname.loc))
217
210
| Field name -> (
218
211
match Query. getField file stamp name with
219
212
| None -> None
220
- | Some field -> Some (file.uri, field.fname.loc) )
213
+ | Some field -> Some (file.uri, field.fname.loc))
221
214
| Module -> resolveModuleDefinition ~file ~get Module stamp
222
215
| _ -> (
223
216
match Query. declaredForTip ~stamps: file.stamps stamp tip with
@@ -227,7 +220,7 @@ let definition ~file ~getModule stamp tip =
227
220
let env = Query. fileEnv file in
228
221
let uri = Query. getSourceUri ~env ~get Module declared.modulePath in
229
222
maybeLog (" Inner uri " ^ Uri2. toString uri);
230
- Some (uri, loc) )
223
+ Some (uri, loc))
231
224
232
225
let orLog message v =
233
226
match v with
@@ -250,8 +243,8 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
250
243
| None -> None
251
244
| Some (file , _extra , declared ) ->
252
245
let loc = validateLoc declared.name.loc declared.extentLoc in
253
- Some (file.uri, loc) )
254
- else None )
246
+ Some (file.uri, loc))
247
+ else None )
255
248
| Explanation _
256
249
| Typed (_, NotFound )
257
250
| LModule (NotFound | Definition (_, _))
@@ -266,16 +259,16 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
266
259
|> orLog " No paths found" |?> getSrc |> orLog " No src found"
267
260
with
268
261
| None -> None
269
- | Some src -> Some (Uri2. fromPath src, Utils. topLoc src) )
262
+ | Some src -> Some (Uri2. fromPath src, Utils. topLoc src))
270
263
| LModule (LocalReference (stamp, tip))
271
264
| Typed (_ , LocalReference (stamp , tip )) ->
272
265
maybeLog (" Local defn " ^ tipToString tip);
273
266
definition ~file ~get Module stamp tip
274
267
| LModule (GlobalReference (moduleName, path, tip))
275
268
| Typed (_ , GlobalReference (moduleName , path , tip )) -> (
276
269
maybeLog
277
- ( " Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
278
- ^ tipToString tip );
270
+ (" Global defn " ^ moduleName ^ " " ^ pathToString path ^ " : "
271
+ ^ tipToString tip);
279
272
match getModule moduleName with
280
273
| None -> None
281
274
| Some file -> (
@@ -286,6 +279,6 @@ let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
286
279
match Query. exportedForTip ~env name tip with
287
280
| None -> None
288
281
| Some stamp ->
289
- (* * oooh wht do I do if the stamp is inside a pseudo-file? *)
282
+ (* oooh wht do I do if the stamp is inside a pseudo-file? *)
290
283
maybeLog (" Got stamp " ^ string_of_int stamp);
291
- definition ~file: env.file ~get Module stamp tip ) ) )
284
+ definition ~file: env.file ~get Module stamp tip)) )
0 commit comments