15 #include "llvm/Support/CommandLine.h"
16 #include "llvm/Support/Program.h"
23 llvm::cl::opt<JSONStreamStyle> inputStyle{
25 llvm::cl::desc(
"Input JSON stream encoding"),
27 "usual LSP protocol"),
29 "messages delimited by `// -----` lines, "
30 "with // comment support")),
34 llvm::cl::opt<bool> litTest{
37 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
38 "Intended to simplify lit tests"),
39 llvm::cl::init(
false),
41 llvm::cl::opt<Logger::Level> logLevel{
43 llvm::cl::desc(
"Verbosity of log messages written to stderr"),
47 "High level execution tracing"),
51 llvm::cl::opt<bool> prettyPrint{
53 llvm::cl::desc(
"Pretty-print JSON output"),
54 llvm::cl::init(
false),
56 llvm::cl::ParseCommandLineOptions(argc, argv,
"MLIR LSP Language Server");
68 llvm::sys::ChangeStdinToBinary();
69 JSONTransport transport(stdin, llvm::outs(), inputStyle, prettyPrint);
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
A transport class that performs the JSON-RPC communication with the LSP client.
static void setLogLevel(Level logLevel)
Set the severity level of the logger.
This class implements all of the MLIR related functionality necessary for a language server.
static void registerSupportedScheme(StringRef scheme)
Register a supported URI scheme.
@ Delimited
Messages are delimited by a '// --—' line. Comment lines start with //.
@ Standard
Encoding per the LSP specification, with mandatory Content-Length header.
llvm::LogicalResult runMlirLSPServer(MLIRServer &server, JSONTransport &transport)
Run the main loop of the LSP server using the given MLIR server and transport.
Include the generated interface declarations.
llvm::LogicalResult MlirLspServerMain(int argc, char **argv, DialectRegistry ®istry)
Implementation for tools like mlir-lsp-server.