@@ -33,9 +33,16 @@ let dump files =
33
33
34
34
let completion ~path ~line ~col ~currentFile =
35
35
let uri = Uri2. fromPath path in
36
+ let pos = (line, col) in
36
37
let result =
37
38
let textOpt = Files. readFile currentFile in
38
- NewCompletions. computeCompletions ~uri ~text Opt ~pos: (line, col)
39
+ let completionItems =
40
+ match NewCompletions. getCompletable ~text Opt ~pos with
41
+ | None -> []
42
+ | Some (completable , rawOpens ) ->
43
+ NewCompletions. computeCompletions ~completable ~pos ~raw Opens ~uri
44
+ in
45
+ completionItems
39
46
|> List. map Protocol. stringifyCompletionItem
40
47
|> Protocol. array
41
48
in
@@ -143,38 +150,41 @@ let references ~path ~line ~col =
143
150
144
151
let documentSymbol ~path =
145
152
let uri = Uri2. fromPath path in
146
- match ProcessCmt. getFullFromCmt ~uri with
147
- | None -> print_endline Protocol. null
148
- | Some {file} ->
149
- let open SharedTypes in
150
- let rec getItems {topLevel} =
151
- let rec getItem = function
152
- | MValue v -> (v |> SharedTypes. variableKind, [] )
153
- | MType (t , _ ) -> (t.decl |> SharedTypes. declarationKind, [] )
154
- | Module (Structure contents ) -> (Module , getItems contents)
155
- | Module (Constraint (_ , modTypeItem )) -> getItem (Module modTypeItem)
156
- | Module (Ident _ ) -> (Module , [] )
153
+ let result =
154
+ match ProcessCmt. getFullFromCmt ~uri with
155
+ | None -> Protocol. null
156
+ | Some {file} ->
157
+ let open SharedTypes in
158
+ let rec getItems {topLevel} =
159
+ let rec getItem = function
160
+ | MValue v -> (v |> SharedTypes. variableKind, [] )
161
+ | MType (t , _ ) -> (t.decl |> SharedTypes. declarationKind, [] )
162
+ | Module (Structure contents ) -> (Module , getItems contents)
163
+ | Module (Constraint (_ , modTypeItem )) -> getItem (Module modTypeItem)
164
+ | Module (Ident _ ) -> (Module , [] )
165
+ in
166
+ let fn {name = {txt} ; extentLoc; item} =
167
+ let item, siblings = getItem item in
168
+ if extentLoc.loc_ghost then siblings
169
+ else (txt, extentLoc, item) :: siblings
170
+ in
171
+ let x = topLevel |> List. map fn |> List. concat in
172
+ x
157
173
in
158
- let fn {name = {txt} ; extentLoc; item} =
159
- let item, siblings = getItem item in
160
- if extentLoc.loc_ghost then siblings
161
- else (txt, extentLoc, item) :: siblings
174
+ let allSymbols =
175
+ getItems file.contents
176
+ |> List. map (fun (name , loc , kind ) ->
177
+ Protocol. stringifyDocumentSymbolItem
178
+ {
179
+ name;
180
+ location =
181
+ {uri = Uri2. toString uri; range = Utils. cmtLocToRange loc};
182
+ kind = SharedTypes. symbolKind kind;
183
+ })
162
184
in
163
- let x = topLevel |> List. map fn |> List. concat in
164
- x
165
- in
166
- let allSymbols =
167
- getItems file.contents
168
- |> List. map (fun (name , loc , kind ) ->
169
- Protocol. stringifyDocumentSymbolItem
170
- {
171
- name;
172
- location =
173
- {uri = Uri2. toString uri; range = Utils. cmtLocToRange loc};
174
- kind = SharedTypes. symbolKind kind;
175
- })
176
- in
177
- print_endline (" [\n " ^ (allSymbols |> String. concat " ,\n " ) ^ " \n ]" )
185
+ " [\n " ^ (allSymbols |> String. concat " ,\n " ) ^ " \n ]"
186
+ in
187
+ print_endline result
178
188
179
189
let rename ~path ~line ~col ~newName =
180
190
let uri = Uri2. fromPath path in
0 commit comments