Skip to content

Commit 091f40c

Browse files
committed
Refactor: no need to pass pathsForModule.
1 parent cdca412 commit 091f40c

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

analysis/.depend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ src/Process_406.cmx : src/SharedTypes.cmx src/Shared.cmx \
3535
src/Process_406.cmi : src/Uri2.cmx src/SharedTypes.cmx
3636
src/Protocol.cmx : src/vendor/Json.cmx
3737
src/Query.cmx : src/SharedTypes.cmx src/Log.cmx src/Infix.cmx
38-
src/References.cmx : src/Utils.cmx src/Uri2.cmx src/State.cmx \
39-
src/SharedTypes.cmx src/Query.cmx src/Log.cmx src/Infix.cmx
38+
src/References.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx \
39+
src/State.cmx src/SharedTypes.cmx src/Query.cmx src/Log.cmx src/Infix.cmx
4040
src/Shared.cmx : src/PrintType.cmx src/Files.cmx
4141
src/SharedTypes.cmx : src/Utils.cmx src/Uri2.cmx src/Shared.cmx \
4242
src/Infix.cmx

analysis/src/Commands.ml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ let dumpLocations ~package ~file ~extra =
1212
match hoverText with None -> "" | Some s -> String.escaped s
1313
in
1414
let uriLocOpt =
15-
References.definitionForLoc ~pathsForModule:package.pathsForModule
16-
~file
15+
References.definitionForLoc ~package ~file
1716
~getModule:(State.fileForModule ~package)
1817
loc
1918
in
@@ -59,7 +58,6 @@ let complete ~path ~line ~col ~currentFile =
5958
print_endline result
6059

6160
let hover ~file ~line ~col ~extra ~package =
62-
let open TopTypes in
6361
let locations =
6462
extra.SharedTypes.locations
6563
|> List.filter (fun (l, _) -> not l.Location.loc_ghost)
@@ -74,7 +72,7 @@ let hover ~file ~line ~col ~extra ~package =
7472
| TypeDefinition _ | Typed _ | Constant _ | Explanation _ -> false
7573
in
7674
let uriLocOpt =
77-
References.definitionForLoc ~pathsForModule:package.pathsForModule ~file
75+
References.definitionForLoc ~package ~file
7876
~getModule:(State.fileForModule ~package)
7977
loc
8078
in
@@ -107,7 +105,6 @@ let hover ~path ~line ~col =
107105
print_endline result
108106

109107
let definition ~file ~line ~col ~extra ~package =
110-
let open TopTypes in
111108
let locations =
112109
extra.SharedTypes.locations
113110
|> List.filter (fun (l, _) -> not l.Location.loc_ghost)
@@ -123,7 +120,7 @@ let definition ~file ~line ~col ~extra ~package =
123120
| TypeDefinition _ | Typed _ | Constant _ | Explanation _ -> false
124121
in
125122
let uriLocOpt =
126-
References.definitionForLoc ~pathsForModule:package.pathsForModule ~file
123+
References.definitionForLoc ~package ~file
127124
~getModule:(State.fileForModule ~package)
128125
loc
129126
in
@@ -163,8 +160,8 @@ let references ~file ~line ~col ~extra ~package =
163160
| None -> Protocol.null
164161
| Some (_, loc) ->
165162
let allReferences =
166-
References.allReferencesForLoc ~pathsForModule:package.pathsForModule
167-
~file ~extra ~allModules:package.localModules ~getUri:State.fileForUri
163+
References.allReferencesForLoc ~package ~file ~extra
164+
~allModules:package.localModules ~getUri:State.fileForUri
168165
~getModule:(State.fileForModule ~package)
169166
~getExtra:(State.extraForModule ~package)
170167
loc

analysis/src/References.ml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ let definedForLoc ~file ~getModule locKind =
112112
maybeLog "Yes!! got it";
113113
Some res))))
114114

115-
let alternateDeclared ~file ~pathsForModule declared tip =
116-
match Hashtbl.find_opt pathsForModule file.moduleName with
115+
let alternateDeclared ~file ~package declared tip =
116+
match Hashtbl.find_opt package.TopTypes.pathsForModule file.moduleName with
117117
| None -> None
118118
| Some paths -> (
119119
maybeLog ("paths for " ^ file.moduleName);
@@ -248,7 +248,7 @@ let orLog message v =
248248
None
249249
| _ -> v
250250

251-
let definitionForLoc ~pathsForModule ~file ~getModule loc =
251+
let definitionForLoc ~package ~file ~getModule loc =
252252
match loc with
253253
| Typed (_, Definition (stamp, tip)) -> (
254254
maybeLog "Trying to find a defintion for a definition";
@@ -258,7 +258,7 @@ let definitionForLoc ~pathsForModule ~file ~getModule loc =
258258
maybeLog "Declared";
259259
if declared.exported then (
260260
maybeLog ("exported, looking for alternate " ^ file.moduleName);
261-
match alternateDeclared ~pathsForModule ~file declared tip with
261+
match alternateDeclared ~package ~file declared tip with
262262
| None -> None
263263
| Some (file, _extra, declared) ->
264264
let loc = validateLoc declared.name.loc declared.extentLoc in
@@ -274,7 +274,7 @@ let definitionForLoc ~pathsForModule ~file ~getModule loc =
274274
maybeLog ("Toplevel " ^ name);
275275
let open Infix in
276276
match
277-
Hashtbl.find_opt pathsForModule name
277+
Hashtbl.find_opt package.pathsForModule name
278278
|> orLog "No paths found" |?> getSrc |> orLog "No src found"
279279
with
280280
| None -> None
@@ -325,8 +325,8 @@ let rec pathFromVisibility visibilityPath current =
325325
let pathFromVisibility visibilityPath tipName =
326326
pathFromVisibility visibilityPath (Tip tipName)
327327

328-
let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
329-
stamp tip =
328+
let forLocalStamp ~package ~file ~extra ~allModules ~getModule ~getExtra stamp
329+
tip =
330330
let env = Query.fileEnv file in
331331
let open Infix in
332332
match
@@ -348,7 +348,7 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
348348
| Some declared ->
349349
if isVisible declared then (
350350
let alternativeReferences =
351-
match alternateDeclared ~pathsForModule ~file declared tip with
351+
match alternateDeclared ~package ~file declared tip with
352352
| None -> []
353353
| Some (file, extra, {stamp}) -> (
354354
match
@@ -406,24 +406,24 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
406406
in
407407
(file.uri, local) :: externals)
408408

409-
let allReferencesForLoc ~pathsForModule ~getUri ~file ~extra ~allModules
410-
~getModule ~getExtra loc =
409+
let allReferencesForLoc ~package ~getUri ~file ~extra ~allModules ~getModule
410+
~getExtra loc =
411411
match loc with
412412
| Explanation _
413413
| Typed (_, NotFound)
414414
| LModule NotFound
415415
| TopLevelModule _ | Constant _ ->
416416
[]
417417
| TypeDefinition (_, _, stamp) ->
418-
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
419-
stamp Type
418+
forLocalStamp ~package ~file ~extra ~allModules ~getModule ~getExtra stamp
419+
Type
420420
| Typed (_, (LocalReference (stamp, tip) | Definition (stamp, tip)))
421421
| LModule (LocalReference (stamp, tip) | Definition (stamp, tip)) ->
422422
maybeLog
423423
("Finding references for " ^ Uri2.toString file.uri ^ " and stamp "
424424
^ string_of_int stamp ^ " and tip " ^ tipToString tip);
425-
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
426-
stamp tip
425+
forLocalStamp ~package ~file ~extra ~allModules ~getModule ~getExtra stamp
426+
tip
427427
| LModule (GlobalReference (moduleName, path, tip))
428428
| Typed (_, GlobalReference (moduleName, path, tip)) -> (
429429
match getModule moduleName with
@@ -443,5 +443,5 @@ let allReferencesForLoc ~pathsForModule ~getUri ~file ~extra ~allModules
443443
("Finding references for (global) " ^ Uri2.toString env.file.uri
444444
^ " and stamp " ^ string_of_int stamp ^ " and tip "
445445
^ tipToString tip);
446-
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule
447-
~getExtra stamp tip))))
446+
forLocalStamp ~package ~file ~extra ~allModules ~getModule ~getExtra
447+
stamp tip))))

0 commit comments

Comments
 (0)