Skip to content

Commit

Permalink
feat: add logging for the extension
Browse files Browse the repository at this point in the history
and for the new command
  • Loading branch information
NeoKaios committed Aug 9, 2024
1 parent 6052e56 commit 5d5dc49
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/vscode/superbol-vscode-platform/superbol_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type t =
handler: handler;
}

let extension_oc : Vscode.OutputChannel.t Lazy.t =
lazy (Vscode.Window.createOutputChannel ~name:"SuperBOL Studio Extension")

let commands = ref []

let command id handler =
Expand All @@ -35,19 +38,31 @@ let command id handler =
command

let _editor_action_findReferences =
command "superbol.editor.action.findReferences" @@ Instance
let command_name = "superbol.editor.action.findReferences" in
command command_name @@ Instance
begin fun _instance ~args ->
match args with
| [arg1; arg2] ->
let uri = Uri.parse (Ojs.string_of_js arg1) () in
let line = Ojs.get_prop_ascii arg2 "line" |> Ojs.int_of_js in
let character = Ojs.get_prop_ascii arg2 "character" |> Ojs.int_of_js in
let pos = Position.make ~line ~character in
let lazy oc = extension_oc in
let value = "Info: Performing "
^ command_name
^ " on file "
^ Ojs.string_of_js arg1
^ " at position "
^ (string_of_int line) ^ ":" ^ (string_of_int character) in
OutputChannel.appendLine oc ~value;
let _ = Commands.executeCommand
~command:"editor.action.findReferences"
~args:[Uri.t_to_js uri; Position.t_to_js pos ]
in ()
| _ -> ()
| _ ->
let lazy oc = extension_oc in
let value = "Warning: " ^ command_name ^ " requires 2 arguments" in
OutputChannel.appendLine oc ~value
end

let _restart_language_server =
Expand Down

0 comments on commit 5d5dc49

Please sign in to comment.