Skip to content

Commit 1dffd99

Browse files
committed
rename
1 parent 3fb0ee0 commit 1dffd99

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

analysis/src/Cmt.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
open SharedTypes
22

3-
let fromUri ~uri =
3+
let fullFromUri ~uri =
44
let path = Uri2.toPath uri in
55
match Packages.getPackage ~uri with
66
| None -> None
@@ -16,16 +16,16 @@ let fromUri ~uri =
1616
prerr_endline ("can't find module " ^ moduleName);
1717
None)
1818

19-
let fromModule ~package modname =
20-
if Hashtbl.mem package.pathsForModule modname then
21-
let paths = Hashtbl.find package.pathsForModule modname in
19+
let fullFromModule ~package ~moduleName =
20+
if Hashtbl.mem package.pathsForModule moduleName then
21+
let paths = Hashtbl.find package.pathsForModule moduleName in
2222
let uri = getUri paths in
23-
fromUri ~uri
23+
fullFromUri ~uri
2424
else None
2525

26-
let fromPath ~path =
26+
let fullFromPath ~path =
2727
let uri = Uri2.fromPath path in
28-
fromUri ~uri
28+
fullFromUri ~uri
2929

3030
let resolveModuleFromCompilerPath ~env ~package path =
3131
match ProcessCmt.fromCompilerPath ~env path with

analysis/src/Commands.ml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ let getCompletions ~debug ~path ~pos ~currentFile ~forHover =
1313
Printf.printf "Completable: %s\n"
1414
(SharedTypes.Completable.toString completable);
1515
(* Only perform expensive ast operations if there are completables *)
16-
match Cmt.fromPath ~path with
16+
match Cmt.fullFromPath ~path with
1717
| None -> []
18-
| Some full ->
19-
let env = SharedTypes.QueryEnv.fromFile full.file in
20-
let package = full.package in
18+
| Some {file; package} ->
19+
let env = SharedTypes.QueryEnv.fromFile file in
2120
completable
2221
|> CompletionBackEnd.processCompletable ~debug ~package ~pos ~scope ~env
2322
~forHover))
@@ -31,9 +30,9 @@ let completion ~debug ~path ~pos ~currentFile =
3130

3231
let hover ~path ~line ~col ~currentFile ~debug =
3332
let result =
34-
match Cmt.fromPath ~path with
33+
match Cmt.fullFromPath ~path with
3534
| None -> Protocol.null
36-
| Some ({file} as full) -> (
35+
| Some full -> (
3736
match References.getLocItem ~full ~line ~col with
3837
| None -> (
3938
if debug then
@@ -62,7 +61,7 @@ let hover ~path ~line ~col ~currentFile ~debug =
6261
match uriLocOpt with
6362
| None -> false
6463
| Some (_, loc) ->
65-
let isInterface = file.uri |> Uri2.isInterface in
64+
let isInterface = full.file.uri |> Uri2.isInterface in
6665
let posIsZero {Lexing.pos_lnum; pos_bol; pos_cnum} =
6766
(not isInterface) && pos_lnum = 1 && pos_cnum - pos_bol = 0
6867
in
@@ -84,16 +83,16 @@ let codeAction ~path ~line ~col ~currentFile =
8483

8584
let definition ~path ~line ~col =
8685
let locationOpt =
87-
match Cmt.fromPath ~path with
86+
match Cmt.fullFromPath ~path with
8887
| None -> None
89-
| Some ({file} as full) -> (
88+
| Some full -> (
9089
match References.getLocItem ~full ~line ~col with
9190
| None -> None
9291
| Some locItem -> (
9392
match References.definitionForLocItem ~full locItem with
9493
| None -> None
9594
| Some (uri, loc) ->
96-
let isInterface = file.uri |> Uri2.isInterface in
95+
let isInterface = full.file.uri |> Uri2.isInterface in
9796
let posIsZero {Lexing.pos_lnum; pos_bol; pos_cnum} =
9897
(* range is zero *)
9998
pos_lnum = 1 && pos_cnum - pos_bol = 0
@@ -122,7 +121,7 @@ let definition ~path ~line ~col =
122121

123122
let typeDefinition ~path ~line ~col =
124123
let maybeLocation =
125-
match Cmt.fromPath ~path with
124+
match Cmt.fullFromPath ~path with
126125
| None -> None
127126
| Some full -> (
128127
match References.getLocItem ~full ~line ~col with
@@ -142,7 +141,7 @@ let typeDefinition ~path ~line ~col =
142141

143142
let references ~path ~line ~col =
144143
let allLocs =
145-
match Cmt.fromPath ~path with
144+
match Cmt.fullFromPath ~path with
146145
| None -> []
147146
| Some full -> (
148147
match References.getLocItem ~full ~line ~col with
@@ -168,7 +167,7 @@ let references ~path ~line ~col =
168167

169168
let rename ~path ~line ~col ~newName =
170169
let result =
171-
match Cmt.fromPath ~path with
170+
match Cmt.fullFromPath ~path with
172171
| None -> Protocol.null
173172
| Some full -> (
174173
match References.getLocItem ~full ~line ~col with

analysis/src/References.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ let alternateDeclared ~(file : File.t) ~package (declared : _ Declared.t) tip =
199199
maybeLog
200200
("alternateDeclared for " ^ file.moduleName ^ " has both resi and res");
201201
let alternateUri = if Uri2.isInterface file.uri then res else resi in
202-
match Cmt.fromUri ~uri:(Uri2.fromPath alternateUri) with
202+
match Cmt.fullFromUri ~uri:(Uri2.fromPath alternateUri) with
203203
| None -> None
204204
| Some {file; extra} -> (
205205
match
@@ -473,11 +473,11 @@ let forLocalStamp ~full:{file; extra; package} stamp (tip : Tip.t) =
473473
let externals =
474474
package.projectFiles |> FileSet.elements
475475
|> List.filter (fun name -> name <> file.moduleName)
476-
|> List.map (fun name ->
477-
match ProcessCmt.fileForModule ~package name with
476+
|> List.map (fun moduleName ->
477+
match ProcessCmt.fileForModule ~package moduleName with
478478
| None -> []
479479
| Some file -> (
480-
match Cmt.fromModule ~package name with
480+
match Cmt.fullFromModule ~package ~moduleName with
481481
| None -> []
482482
| Some {extra} -> (
483483
match
@@ -514,7 +514,7 @@ let allReferencesForLocItem ~full:({file; package} as full) locItem =
514514
|> Utils.filterMap (fun name ->
515515
match ProcessCmt.fileForModule ~package name with
516516
| None -> None
517-
| Some file -> Cmt.fromUri ~uri:file.uri)
517+
| Some file -> Cmt.fullFromUri ~uri:file.uri)
518518
|> List.map (fun full ->
519519
match Hashtbl.find_opt full.extra.fileReferences moduleName with
520520
| None -> []
@@ -555,7 +555,7 @@ let allReferencesForLocItem ~full:({file; package} as full) locItem =
555555
match exportedForTip ~env name tip with
556556
| None -> []
557557
| Some stamp -> (
558-
match Cmt.fromUri ~uri:env.file.uri with
558+
match Cmt.fullFromUri ~uri:env.file.uri with
559559
| None -> []
560560
| Some full ->
561561
maybeLog

analysis/src/Xform.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ let parse ~filename =
298298
(structure, printExpr, printStructureItem)
299299

300300
let extractCodeActions ~path ~pos ~currentFile =
301-
let fullOpt = Cmt.fromPath ~path in
302-
match fullOpt with
301+
match Cmt.fullFromPath ~path with
303302
| Some full when Filename.check_suffix currentFile ".res" ->
304303
let structure, printExpr, printStructureItem =
305304
parse ~filename:currentFile

0 commit comments

Comments
 (0)