14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/Program.h"
22 llvm::cl::opt<JSONStreamStyle> inputStyle{
24 llvm::cl::desc(
"Input JSON stream encoding"),
26 "usual LSP protocol"),
28 "messages delimited by `// -----` lines, "
29 "with // comment support")),
33 llvm::cl::opt<bool> litTest{
36 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
37 "Intended to simplify lit tests"),
38 llvm::cl::init(
false),
40 llvm::cl::opt<Logger::Level> logLevel{
42 llvm::cl::desc(
"Verbosity of log messages written to stderr"),
46 "High level execution tracing"),
50 llvm::cl::opt<bool> prettyPrint{
52 llvm::cl::desc(
"Pretty-print JSON output"),
53 llvm::cl::init(
false),
55 llvm::cl::ParseCommandLineOptions(argc, argv,
"MLIR LSP Language Server");
67 llvm::sys::ChangeStdinToBinary();
68 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.
URI in "file" scheme for a file.
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.