Soilihi BEN SOILIHI BOINA pushed to branch soilih at Stefan / Typer
Commits: cc0bd4d8 by Soilih BEN SOILIH at 2021-03-30T20:58:46-06:00 diagnostics
- - - - - 1b7204e3 by Soilih BEN SOILIH at 2021-03-31T10:23:12-06:00 Errors handling
- - - - -
5 changed files:
- + .vscode/launch.json - emacs/typer-mode.el - src/REPL.ml - src/dune - src/typer_lsp_server.ml
Changes:
===================================== .vscode/launch.json ===================================== @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file
===================================== emacs/typer-mode.el ===================================== @@ -279,5 +279,18 @@ (easy-menu-add typer-mode-menu) )
+ +(defvar typer-lsp-server-command '("typer-lsp-server")) + + (with-eval-after-load 'lsp-mode + (lsp-register-client + (make-lsp-client :new-connection + (lsp-stdio-connection + (lambda () typer-lsp-server-command)) + :major-modes '(typer-mode) + :priority -1 + :server-id 'typer-ls))) + + (provide 'typer-mode) ;;; typer-mode.el ends here
===================================== src/REPL.ml ===================================== @@ -54,7 +54,7 @@ module OL = Opslexp module EL = Elexp
let arg_batch = ref false -let lsp_server = ref false +let lsp_server = ref true
let print_input_line i = print_string " In["; @@ -207,8 +207,9 @@ let help_msg = let readstring (str:string) = let ectx = Elab.default_ectx in (*let rctx = Elab.default_rctx in*) - let (list, _) = Elab.lexp_decl_str str ectx in - list + Elab.lexp_decl_str str ectx ; + let ret = Log.typer_log in + ret
let readfiles files (i, lctx, rctx) prt =
===================================== src/dune ===================================== @@ -1,9 +1,9 @@ ;; -*- lisp-data -*- (executable - (name REPL) + (name REPL ) ;; (public_name typer) (libraries "zarith" "str" "linol" "linol-lwt" "lsp" "jsonrpc" ) -) \ No newline at end of file +)
===================================== src/typer_lsp_server.ml ===================================== @@ -36,15 +36,45 @@ Diagnostics includes all the warnings, errors and messages that the processing of a document are expected to be able to return. *) +open Log +open Util
+type state_after_processing = log_entry list
-type state_after_processing = unit +let log_entry_to_list (tab:log_entry list) : ((string * int * int * string) * log_level * string) list = + List.map (fun x -> let location = Option.get x.loc in + ((location.file,location.line,location.column,location.docstr) + ,x.level,x.msg) + ) tab
-let process_some_input_file (_file_contents : string) : state_after_processing = - () +let log_level_to_severity (level:log_level) : Lsp.Types.DiagnosticSeverity.t = + match level with + | Error -> Lsp.Types.DiagnosticSeverity.Error + | Warning -> Lsp.Types.DiagnosticSeverity.Warning + | Info -> Lsp.Types.DiagnosticSeverity.Information + | _ -> Lsp.Types.DiagnosticSeverity.Hint
-let diagnostics (_state : state_after_processing ) : Lsp.Types.Diagnostic.t list = - [] + +let process_some_input_file (_file_contents : string) : state_after_processing = + REPL.readstring _file_contents +let diagnostics (_state : state_after_processing) : Lsp.Types.Diagnostic.t list = +let log_tab = log_entry_to_list _state in +List.map (fun x -> + let (loc, lev, msg) = x in + let (_ (* file *), line, column, _ (* docstr *) ) = loc in + let severity = log_level_to_severity lev in + let message = msg in + let start_pos = Lsp.Types.Position.create ~line:line ~character:column in + let end_pos = Lsp.Types.Position.create ~line:line ~character:(column + 1) in + let range = Lsp.Types.Range.create ~start:start_pos ~end_:end_pos in + let diagnostic = Lsp.Types.Diagnostic.create () + ~range:range + ~severity:severity + ~source:"typerlsp" + ~message:message + in + diagnostic +) log_tab
(* Lsp server class This is the main point of interaction beetween the code checking documents
View it on GitLab: https://gitlab.com/monnier/typer/-/compare/a4a9cf9e4aea9600b10c2c96551d7130b...
Afficher les réponses par date