@@ -368,12 +368,8 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
368
368
with
369
369
| None -> []
370
370
| Some local -> [(file.uri, local)]))
371
- [@@ ocaml.doc
372
- " \n \
373
- \ if this file has a corresponding interface or \
374
- implementation file\n \
375
- \ also find the references in that file.\n \
376
- \ " ]
371
+ (* if this file has a corresponding interface or implementation file
372
+ also find the references in that file *)
377
373
in
378
374
match pathFromVisibility declared.modulePath declared.name.txt with
379
375
| None -> []
@@ -385,8 +381,8 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
385
381
|> List. filter (fun name -> name <> file.moduleName)
386
382
|> Utils. filterMap (fun name ->
387
383
match getModule name with
388
- | Error _ -> None
389
- | Ok file -> (
384
+ | None -> None
385
+ | Some file -> (
390
386
match getExtra name with
391
387
| Error _ -> None
392
388
| Ok extra -> (
@@ -411,3 +407,43 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
411
407
[] )
412
408
in
413
409
Some ((file.uri, local) :: externals))
410
+
411
+ let allReferencesForLoc ~pathsForModule ~getUri ~file ~extra ~allModules
412
+ ~getModule ~getExtra loc : _ option =
413
+ match loc with
414
+ | Explanation _
415
+ | Typed (_, NotFound )
416
+ | LModule NotFound
417
+ | TopLevelModule _ | Constant _ ->
418
+ None
419
+ | TypeDefinition (_ , _ , stamp ) ->
420
+ forLocalStamp ~paths ForModule ~get Uri ~file ~extra ~all Modules ~get Module
421
+ ~get Extra stamp Type
422
+ | Typed (_, (LocalReference (stamp, tip) | Definition (stamp, tip)))
423
+ | LModule (LocalReference (stamp , tip ) | Definition (stamp , tip )) ->
424
+ maybeLog
425
+ (" Finding references for " ^ Uri2. toString file.uri ^ " and stamp "
426
+ ^ string_of_int stamp ^ " and tip " ^ tipToString tip);
427
+ forLocalStamp ~paths ForModule ~get Uri ~file ~extra ~all Modules ~get Module
428
+ ~get Extra stamp tip
429
+ | LModule (GlobalReference (moduleName, path, tip))
430
+ | Typed (_ , GlobalReference (moduleName , path , tip )) -> (
431
+ match getModule moduleName with
432
+ | None -> None
433
+ | Some file -> (
434
+ let env = Query. fileEnv file in
435
+ match Query. resolvePath ~env ~path ~get Module with
436
+ | None -> None
437
+ | Some (env , name ) -> (
438
+ match Query. exportedForTip ~env name tip with
439
+ | None -> None
440
+ | Some stamp -> (
441
+ match getUri env.file.uri with
442
+ | Error _ -> None
443
+ | Ok (file , extra ) ->
444
+ maybeLog
445
+ (" Finding references for (global) " ^ Uri2. toString env.file.uri
446
+ ^ " and stamp " ^ string_of_int stamp ^ " and tip "
447
+ ^ tipToString tip);
448
+ forLocalStamp ~paths ForModule ~get Uri ~file ~extra ~all Modules
449
+ ~get Module ~get Extra stamp tip))))
0 commit comments