Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion analysis/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ let main () =
(match allowForConstructorPayloads with
| "true" -> true
| _ -> false)
| [_; "inlayHint"; path; line_start; line_end; maxLength; currentFile] ->
Commands.inlayhint ~path
~pos:(int_of_string line_start, int_of_string line_end)
~maxLength ~currentFile:(Some currentFile) ~debug
| [_; "inlayHint"; path; line_start; line_end; maxLength] ->
Commands.inlayhint ~path
~pos:(int_of_string line_start, int_of_string line_end)
~maxLength ~debug
~maxLength ~currentFile:None ~debug
| [_; "codeLens"; path] -> Commands.codeLens ~path ~debug
| [_; "codeAction"; path; startLine; startCol; endLine; endCol; currentFile]
->
Expand Down
6 changes: 3 additions & 3 deletions analysis/src/Commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ let completionResolve ~path ~modulePath =
in
print_endline docstring

let inlayhint ~path ~pos ~maxLength ~debug =
let inlayhint ~path ~pos ~maxLength ~currentFile ~debug =
let result =
match Hint.inlay ~path ~pos ~maxLength ~debug with
match Hint.inlay ~path ~pos ~maxLength ~currentFile ~debug with
| Some hints -> hints |> Protocol.array
| None -> Protocol.null
in
Expand Down Expand Up @@ -516,7 +516,7 @@ let test ~path =
("Inlay Hint " ^ path ^ " " ^ string_of_int line_start ^ ":"
^ string_of_int line_end);
inlayhint ~path ~pos:(line_start, line_end) ~maxLength:"25"
~debug:false
~currentFile:None ~debug:false
| "cle" ->
print_endline ("Code Lens " ^ path);
codeLens ~path ~debug:false
Expand Down
9 changes: 7 additions & 2 deletions analysis/src/Hint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let locItemToTypeHint ~full:{file; package} locItem =
| `Field -> fromType t))
| _ -> None

let inlay ~path ~pos ~maxLength ~debug =
let inlay ~path ~pos ~maxLength ~currentFile ~debug =
Comment thread
shulhi marked this conversation as resolved.
let maxlen = try Some (int_of_string maxLength) with Failure _ -> None in
let hints = ref [] in
let start_line, end_line = pos in
Expand Down Expand Up @@ -71,11 +71,16 @@ let inlay ~path ~pos ~maxLength ~debug =
Ast_iterator.default_iterator.value_binding iterator vb
in
let iterator = {Ast_iterator.default_iterator with value_binding} in
let sourceFile =
match currentFile with
| Some f -> f
| None -> path
in
(if Files.classifySourceFile path = Res then
let parser =
Res_driver.parsing_engine.parse_implementation ~for_printer:false
in
let {Res_driver.parsetree = structure} = parser ~filename:path in
let {Res_driver.parsetree = structure} = parser ~filename:sourceFile in
iterator.structure iterator structure |> ignore);
match Cmt.loadFullCmtFromPath ~path with
| None -> None
Expand Down
Loading