-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow][refactor] Split lsp into parts that are are pure and the parts…
… that uses jsonrpc Summary: The goal is to make autocomplete work in try-flow. Somewhere in autocomplete and code action, we will pull in the lsp target. This is understandable, since we want to produce these lsp response objects. However, the lsp target also includes some code that does some JSON-RPC stuff, which will not work in the browser. This diff separates these two parts, so that when autocomplete and code actions pull in lsp, we only pull in these type definition and pure functions. Changelog: [internal] Reviewed By: panagosg7 Differential Revision: D55549369 fbshipit-source-id: 3839e47e95790110de158e1605a56f1e6a429c12
- Loading branch information
1 parent
9ba8a69
commit f5420c9
Showing
10 changed files
with
94 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
flow_server_files | ||
flow_server_protocol | ||
flow_server_status | ||
marshal_tools_lwt | ||
socket ; hack | ||
)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
file_content | ||
file_url | ||
hh_json | ||
jsonrpc | ||
flow_exit_status | ||
utils_core) | ||
(preprocess | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(library | ||
(name lsp_writers) | ||
(wrapped false) | ||
(libraries | ||
lsp | ||
jsonrpc) | ||
(preprocess | ||
(pps lwt_ppx ppx_deriving.show ppx_deriving.std ppx_deriving.enum ppx_deriving.eq))) | ||
|
||
(dirs | ||
(:standard __tests__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*) | ||
|
||
open Lsp | ||
open Lsp_fmt | ||
|
||
(************************************************************************) | ||
(* Wrappers for some LSP methods *) | ||
(************************************************************************) | ||
|
||
let telemetry (writer : Jsonrpc.writer) (level : MessageType.t) (message : string) : unit = | ||
print_logMessage level message |> Jsonrpc.notify writer "telemetry/event" | ||
|
||
let telemetry_error (writer : Jsonrpc.writer) = telemetry writer MessageType.ErrorMessage | ||
|
||
let telemetry_log (writer : Jsonrpc.writer) = telemetry writer MessageType.LogMessage | ||
|
||
let log (writer : Jsonrpc.writer) (level : MessageType.t) (message : string) : unit = | ||
print_logMessage level message |> Jsonrpc.notify writer "window/logMessage" | ||
|
||
let log_error (writer : Jsonrpc.writer) = log writer MessageType.ErrorMessage | ||
|
||
let log_warning (writer : Jsonrpc.writer) = log writer MessageType.WarningMessage | ||
|
||
let log_info (writer : Jsonrpc.writer) = log writer MessageType.InfoMessage | ||
|
||
let dismiss_diagnostics (writer : Jsonrpc.writer) (diagnostic_uris : UriSet.t) : UriSet.t = | ||
let dismiss_one (uri : DocumentUri.t) : unit = | ||
let message = { Lsp.PublishDiagnostics.uri; diagnostics = [] } in | ||
message |> print_diagnostics |> Jsonrpc.notify writer "textDocument/publishDiagnostics" | ||
in | ||
UriSet.iter dismiss_one diagnostic_uris; | ||
UriSet.empty | ||
|
||
let notify_connectionStatus | ||
(p : Lsp.Initialize.params) (writer : Jsonrpc.writer) (wasConnected : bool) (isConnected : bool) | ||
: bool = | ||
( if Lsp_helpers.supports_connectionStatus p && wasConnected <> isConnected then | ||
let message = { Lsp.ConnectionStatus.isConnected } in | ||
message |> print_connectionStatus |> Jsonrpc.notify writer "telemetry/connectionStatus" | ||
); | ||
isConnected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*) | ||
|
||
val telemetry : Jsonrpc.writer -> Lsp.MessageType.t -> string -> unit | ||
|
||
val telemetry_error : Jsonrpc.writer -> string -> unit | ||
|
||
val telemetry_log : Jsonrpc.writer -> string -> unit | ||
|
||
val log : Jsonrpc.writer -> Lsp.MessageType.t -> string -> unit | ||
|
||
val log_error : Jsonrpc.writer -> string -> unit | ||
|
||
val log_warning : Jsonrpc.writer -> string -> unit | ||
|
||
val log_info : Jsonrpc.writer -> string -> unit | ||
|
||
val dismiss_diagnostics : Jsonrpc.writer -> Lsp.UriSet.t -> Lsp.UriSet.t | ||
|
||
val notify_connectionStatus : Lsp.Initialize.params -> Jsonrpc.writer -> bool -> bool -> bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
(wrapped false) | ||
(libraries | ||
flow_server_protocol | ||
marshal_tools_lwt | ||
sys_utils ; hack | ||
)) |