Skip to content

Commit 77d9780

Browse files
committed
fix: document symbol path location
Close rescript-lang#628
1 parent f7c3974 commit 77d9780

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

analysis/src/DocumentSymbol.ml

+2-9
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,9 @@ let command ~path =
137137
let result =
138138
!symbols
139139
|> List.rev_map (fun (name, loc, kind) ->
140+
let range = Utils.cmtLocToRange loc in
140141
Protocol.stringifyDocumentSymbolItem
141-
{
142-
name;
143-
location =
144-
{
145-
uri = Uri.toString (Uri.fromPath path);
146-
range = Utils.cmtLocToRange loc;
147-
};
148-
kind = kindNumber kind;
149-
})
142+
{name; range; selectionRange = range; kind = kindNumber kind})
150143
|> String.concat ",\n"
151144
in
152145
print_endline ("[\n" ^ result ^ "\n]")

analysis/src/Protocol.ml

+11-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ type completionItem = {
4242
}
4343

4444
type location = {uri: string; range: range}
45-
type documentSymbolItem = {name: string; kind: int; location: location}
45+
type documentSymbolItem = {
46+
name: string;
47+
kind: int;
48+
range: range;
49+
selectionRange: range;
50+
}
4651
type renameFile = {oldUri: string; newUri: string}
4752
type textEdit = {range: range; newText: string}
4853

@@ -103,15 +108,16 @@ let stringifyLocation (h : location) =
103108
Printf.sprintf {|{"uri": "%s", "range": %s}|} (Json.escape h.uri)
104109
(stringifyRange h.range)
105110

106-
let stringifyDocumentSymbolItem i =
111+
let stringifyDocumentSymbolItem (i : documentSymbolItem) =
112+
let range = stringifyRange i.range in
107113
Printf.sprintf
108114
{|{
109115
"name": "%s",
110116
"kind": %i,
111-
"location": %s
117+
"range": %s,
118+
"selectionRange": %s
112119
}|}
113-
(Json.escape i.name) i.kind
114-
(stringifyLocation i.location)
120+
(Json.escape i.name) i.kind range range
115121

116122
let stringifyRenameFile {oldUri; newUri} =
117123
Printf.sprintf {|{

0 commit comments

Comments
 (0)