@@ -368,12 +368,8 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
368368 with
369369 | None -> []
370370 | 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 *)
377373 in
378374 match pathFromVisibility declared.modulePath declared.name.txt with
379375 | None -> []
@@ -385,8 +381,8 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
385381 |> List. filter (fun name -> name <> file.moduleName)
386382 |> Utils. filterMap (fun name ->
387383 match getModule name with
388- | Error _ -> None
389- | Ok file -> (
384+ | None -> None
385+ | Some file -> (
390386 match getExtra name with
391387 | Error _ -> None
392388 | Ok extra -> (
@@ -411,3 +407,43 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
411407 [] )
412408 in
413409 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