diff --git a/analysis/.depend b/analysis/.depend index db9ad296a..52fcc0757 100644 --- a/analysis/.depend +++ b/analysis/.depend @@ -1,8 +1,9 @@ src/BuildSystem.cmx : src/ModuleResolution.cmx src/Log.cmx src/Infix.cmx \ src/Files.cmx -src/EditorSupportCommands.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx \ - src/State.cmx src/SharedTypes.cmx src/Shared.cmx src/References.cmx \ - src/Protocol.cmx src/NewCompletions.cmx src/Hover.cmx src/Files.cmx +src/Cli.cmx : src/Commands.cmx +src/Commands.cmx : src/Utils.cmx src/Uri2.cmx src/TopTypes.cmx src/State.cmx \ + src/SharedTypes.cmx src/Shared.cmx src/References.cmx src/Protocol.cmx \ + src/NewCompletions.cmx src/Hover.cmx src/Files.cmx src/Files.cmx : src/FindFiles.cmx : src/Utils.cmx src/SharedTypes.cmx \ src/ModuleResolution.cmx src/Log.cmx src/vendor/Json.cmx src/Infix.cmx \ @@ -40,7 +41,6 @@ src/Protocol.cmx : src/vendor/Json.cmx src/Query.cmx : src/SharedTypes.cmx src/Log.cmx src/Infix.cmx src/References.cmx : src/Utils.cmx src/Uri2.cmx src/SharedTypes.cmx \ src/Query.cmx src/Log.cmx src/Infix.cmx -src/RescriptEditorSupport.cmx : src/EditorSupportCommands.cmx src/Shared.cmx : src/PrintType.cmx src/Files.cmx src/SharedTypes.cmx : src/Utils.cmx src/Uri2.cmx src/Shared.cmx \ src/Infix.cmx diff --git a/analysis/src/Cli.ml b/analysis/src/Cli.ml new file mode 100644 index 000000000..77c1907b8 --- /dev/null +++ b/analysis/src/Cli.ml @@ -0,0 +1,47 @@ +let help = + {| +**Private CLI For rescript-vscode usage only** + +Examples: + current-platform.exe dump src/MyFile.res src/MyFile2.res + current-platform.exe complete src/MyFile.res 0 4 currentContent.res + current-platform.exe hover src/MyFile.res 10 2 + current-platform.exe definition src/MyFile.res 9 3 + +Options: + dump: debugging. definition and hover for Foo.res and Foo2.res: + + current-platform.exe dump src/Foo.res src/Foo2.res + + complete: compute autocomplete for Foo.res at line 0 and column 4, + where Foo.res is being edited and the editor content is in file current.res. + + current-platform.exe complete src/Foo.res 0 4 current.res + + hover: get inferred type for Foo.res at line 10 column 2: + + current-platform.exe hover src/Foo.res 10 2 + + definition: get inferred type for Foo.res at line 10 column 2: + + current-platform.exe definition src/Foo.res 10 2|} + +let main () = + match Array.to_list Sys.argv with + | [_; "complete"; path; line; col; currentFile] -> + Commands.complete ~path ~line:(int_of_string line) ~col:(int_of_string col) + ~currentFile + | [_; "hover"; path; line; col] -> + Commands.hover ~path ~line:(int_of_string line) ~col:(int_of_string col) + | [_; "definition"; path; line; col] -> + Commands.definition ~path ~line:(int_of_string line) + ~col:(int_of_string col) + | _ :: "dump" :: files -> Commands.dump files + | [_; "test"; path] -> Commands.test ~path + | args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help + | _ -> + prerr_endline help; + exit 1 + +;; +main () diff --git a/analysis/src/EditorSupportCommands.ml b/analysis/src/Commands.ml similarity index 100% rename from analysis/src/EditorSupportCommands.ml rename to analysis/src/Commands.ml diff --git a/analysis/src/RescriptEditorSupport.ml b/analysis/src/RescriptEditorSupport.ml deleted file mode 100644 index b2975d715..000000000 --- a/analysis/src/RescriptEditorSupport.ml +++ /dev/null @@ -1,51 +0,0 @@ -let help = - {| -**Private CLI For rescript-vscode usage only** - -Examples: - rescript-editor-support.exe dump src/MyFile.res src/MyFile2.res - rescript-editor-support.exe complete src/MyFile.res 0 4 currentContent.res - rescript-editor-support.exe hover src/MyFile.res 10 2 - rescript-editor-support.exe definition src/MyFile.res 9 3 - -Options: - dump: debugging. definition and hover for Foo.res and Foo2.res: - - rescript-editor-support.exe dump src/Foo.res src/Foo2.res - - complete: compute autocomplete for Foo.res at line 0 and column 4, - where Foo.res is being edited and the editor content is in file current.res. - - rescript-editor-support.exe complete src/Foo.res 0 4 current.res - - hover: get inferred type for Foo.res at line 10 column 2: - - rescript-editor-support.exe hover src/Foo.res 10 2 - - definition: get inferred type for Foo.res at line 10 column 2: - - rescript-editor-support.exe definition src/Foo.res 10 2 -|} - -let showHelp () = prerr_endline help - -let main () = - match Array.to_list Sys.argv with - | [_; "complete"; path; line; col; currentFile] -> - EditorSupportCommands.complete ~path ~line:(int_of_string line) - ~col:(int_of_string col) ~currentFile - | [_; "hover"; path; line; col] -> - EditorSupportCommands.hover ~path ~line:(int_of_string line) - ~col:(int_of_string col) - | [_; "definition"; path; line; col] -> - EditorSupportCommands.definition ~path ~line:(int_of_string line) - ~col:(int_of_string col) - | _ :: "dump" :: files -> EditorSupportCommands.dump files - | [_; "test"; path] -> EditorSupportCommands.test ~path - | args when List.mem "-h" args || List.mem "--help" args -> showHelp () - | _ -> - showHelp (); - exit 1 - -;; -main ()