Skip to content

Commit e283a4e

Browse files
committed
Try to output only the uri in case of references to an entire file.
1 parent e7cc545 commit e283a4e

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

analysis/.depend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ src/ProcessAttributes.cmx : src/SharedTypes.cmx src/PrepareUtils.cmx
2626
src/ProcessCmt.cmx : src/Utils.cmx src/Uri2.cmx src/SharedTypes.cmx \
2727
src/Shared.cmx src/ProcessAttributes.cmx src/Packages.cmx src/Log.cmx \
2828
src/FindFiles.cmx src/Files.cmx src/BuildSystem.cmx
29-
src/Protocol.cmx : src/vendor/Json.cmx
29+
src/Protocol.cmx : src/Uri2.cmx src/vendor/Json.cmx
3030
src/References.cmx : src/Utils.cmx src/Uri2.cmx src/SharedTypes.cmx \
3131
src/ProcessCmt.cmx src/Log.cmx src/Infix.cmx
3232
src/Shared.cmx : src/PrintType.cmx src/Log.cmx src/Files.cmx

analysis/src/Commands.ml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,16 @@ let references ~path ~line ~col =
130130
allReferences
131131
|> List.fold_left
132132
(fun acc (uri2, references) ->
133-
(references
134-
|> List.map (fun loc ->
135-
Protocol.stringifyLocation
136-
{
137-
uri = Uri2.toString uri2;
138-
range = Utils.cmtLocToRange loc;
139-
}))
140-
@ acc)
133+
if references = [] then [Protocol.stringifyFileLocation uri2]
134+
else
135+
(references
136+
|> List.map (fun loc ->
137+
Protocol.stringifyLocation
138+
{
139+
uri = Uri2.toString uri2;
140+
range = Utils.cmtLocToRange loc;
141+
}))
142+
@ acc)
141143
[]
142144
in
143145
"[\n" ^ (allLocs |> String.concat ",\n") ^ "\n]")

analysis/src/Protocol.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ let stringifyLocation h =
5656
Printf.sprintf {|{"uri": "%s", "range": %s}|} (Json.escape h.uri)
5757
(stringifyRange h.range)
5858

59+
let stringifyFileLocation uri =
60+
Printf.sprintf {|{"uri": "%s"}|} (Json.escape (Uri2.toString uri))
61+
5962
let stringifyDocumentSymbolItem i =
6063
Printf.sprintf
6164
{|{

analysis/src/References.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ let allReferencesForLocItem ~full:({file; package} as full) locItem =
475475
| None -> []
476476
| Some src ->
477477
let uri, loc = (Uri2.fromPath src, Utils.topLoc src) in
478-
[(uri, [loc])]))
478+
[(uri, [])]))
479479
| Typed (_, _, NotFound) | LModule NotFound | Constant _ -> []
480480
| TypeDefinition (_, _, stamp) -> forLocalStamp ~full stamp Type
481481
| Typed (_, _, (LocalReference (stamp, tip) | Definition (stamp, tip)))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
References tests/src/Cross.res 0:17
22
[
3-
{"uri": "References.res", "range": {"start": {"line": 0, "character": 0}, "end": {"line": 0, "character": 0}}}
3+
{"uri": "References.res"}
44
]
55

0 commit comments

Comments
 (0)