Skip to content

Commit cdca412

Browse files
committed
Refactor: no need for getUri.
1 parent 2d6e99e commit cdca412

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
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/SharedTypes.cmx \
39-
src/Query.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
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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let dumpLocations ~package ~file ~extra =
1313
in
1414
let uriLocOpt =
1515
References.definitionForLoc ~pathsForModule:package.pathsForModule
16-
~file ~getUri:State.fileForUri
16+
~file
1717
~getModule:(State.fileForModule ~package)
1818
loc
1919
in
@@ -75,7 +75,6 @@ let hover ~file ~line ~col ~extra ~package =
7575
in
7676
let uriLocOpt =
7777
References.definitionForLoc ~pathsForModule:package.pathsForModule ~file
78-
~getUri:State.fileForUri
7978
~getModule:(State.fileForModule ~package)
8079
loc
8180
in
@@ -125,7 +124,6 @@ let definition ~file ~line ~col ~extra ~package =
125124
in
126125
let uriLocOpt =
127126
References.definitionForLoc ~pathsForModule:package.pathsForModule ~file
128-
~getUri:State.fileForUri
129127
~getModule:(State.fileForModule ~package)
130128
loc
131129
in

analysis/src/References.ml

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

115-
let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
115+
let alternateDeclared ~file ~pathsForModule declared tip =
116116
match Hashtbl.find_opt pathsForModule file.moduleName with
117117
| None -> None
118118
| Some paths -> (
@@ -123,7 +123,7 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
123123
let intfUri = Uri2.fromPath intf in
124124
let implUri = Uri2.fromPath impl in
125125
if intfUri = file.uri then
126-
match getUri implUri with
126+
match State.fileForUri implUri with
127127
| Error e ->
128128
Log.log e;
129129
None
@@ -135,7 +135,7 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
135135
| None -> None
136136
| Some declared -> Some (file, extra, declared))
137137
else
138-
match getUri intfUri with
138+
match State.fileForUri intfUri with
139139
| Error e ->
140140
Log.log e;
141141
None
@@ -248,7 +248,7 @@ let orLog message v =
248248
None
249249
| _ -> v
250250

251-
let definitionForLoc ~pathsForModule ~file ~getUri ~getModule loc =
251+
let definitionForLoc ~pathsForModule ~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 ~getUri ~getModule loc =
258258
maybeLog "Declared";
259259
if declared.exported then (
260260
maybeLog ("exported, looking for alternate " ^ file.moduleName);
261-
match alternateDeclared ~pathsForModule ~file ~getUri declared tip with
261+
match alternateDeclared ~pathsForModule ~file declared tip with
262262
| None -> None
263263
| Some (file, _extra, declared) ->
264264
let loc = validateLoc declared.name.loc declared.extentLoc in
@@ -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 ~getUri
329-
~getExtra stamp tip =
328+
let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
329+
stamp tip =
330330
let env = Query.fileEnv file in
331331
let open Infix in
332332
match
@@ -348,9 +348,7 @@ let forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getUri
348348
| Some declared ->
349349
if isVisible declared then (
350350
let alternativeReferences =
351-
match
352-
alternateDeclared ~pathsForModule ~file ~getUri declared tip
353-
with
351+
match alternateDeclared ~pathsForModule ~file declared tip with
354352
| None -> []
355353
| Some (file, extra, {stamp}) -> (
356354
match
@@ -417,15 +415,15 @@ let allReferencesForLoc ~pathsForModule ~getUri ~file ~extra ~allModules
417415
| TopLevelModule _ | Constant _ ->
418416
[]
419417
| TypeDefinition (_, _, stamp) ->
420-
forLocalStamp ~pathsForModule ~getUri ~file ~extra ~allModules ~getModule
421-
~getExtra stamp Type
418+
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
419+
stamp Type
422420
| Typed (_, (LocalReference (stamp, tip) | Definition (stamp, tip)))
423421
| LModule (LocalReference (stamp, tip) | Definition (stamp, tip)) ->
424422
maybeLog
425423
("Finding references for " ^ Uri2.toString file.uri ^ " and stamp "
426424
^ string_of_int stamp ^ " and tip " ^ tipToString tip);
427-
forLocalStamp ~pathsForModule ~getUri ~file ~extra ~allModules ~getModule
428-
~getExtra stamp tip
425+
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule ~getExtra
426+
stamp tip
429427
| LModule (GlobalReference (moduleName, path, tip))
430428
| Typed (_, GlobalReference (moduleName, path, tip)) -> (
431429
match getModule moduleName with
@@ -445,5 +443,5 @@ let allReferencesForLoc ~pathsForModule ~getUri ~file ~extra ~allModules
445443
("Finding references for (global) " ^ Uri2.toString env.file.uri
446444
^ " and stamp " ^ string_of_int stamp ^ " and tip "
447445
^ tipToString tip);
448-
forLocalStamp ~pathsForModule ~getUri ~file ~extra ~allModules
449-
~getModule ~getExtra stamp tip))))
446+
forLocalStamp ~pathsForModule ~file ~extra ~allModules ~getModule
447+
~getExtra stamp tip))))

0 commit comments

Comments
 (0)