12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/Support/LSP/Logging.h"
14 #include "llvm/Support/LSP/Transport.h"
15 #include "llvm/Support/Program.h"
20 using llvm::lsp::JSONStreamStyle;
21 using llvm::lsp::JSONTransport;
22 using llvm::lsp::Logger;
26 llvm::cl::opt<JSONStreamStyle> inputStyle{
28 llvm::cl::desc(
"Input JSON stream encoding"),
29 llvm::cl::values(clEnumValN(JSONStreamStyle::Standard,
"standard",
30 "usual LSP protocol"),
31 clEnumValN(JSONStreamStyle::Delimited,
"delimited",
32 "messages delimited by `// -----` lines, "
33 "with // comment support")),
34 llvm::cl::init(JSONStreamStyle::Standard),
37 llvm::cl::opt<bool> litTest{
40 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
41 "Intended to simplify lit tests"),
42 llvm::cl::init(
false),
44 llvm::cl::opt<Logger::Level> logLevel{
46 llvm::cl::desc(
"Verbosity of log messages written to stderr"),
49 clEnumValN(Logger::Level::Info,
"info",
50 "High level execution tracing"),
51 clEnumValN(Logger::Level::Debug,
"verbose",
"Low level details")),
52 llvm::cl::init(Logger::Level::Info),
54 llvm::cl::opt<bool> prettyPrint{
56 llvm::cl::desc(
"Pretty-print JSON output"),
57 llvm::cl::init(
false),
59 llvm::cl::ParseCommandLineOptions(argc, argv,
"MLIR LSP Language Server");
62 inputStyle = JSONStreamStyle::Delimited;
63 logLevel = Logger::Level::Debug;
68 Logger::setLogLevel(logLevel);
71 llvm::sys::ChangeStdinToBinary();
72 JSONTransport transport(stdin, llvm::outs(), inputStyle, prettyPrint);
75 URIForFile::registerSupportedScheme(
"mlir.bytecode-mlir");
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
This class implements all of the MLIR related functionality necessary for a language server.
llvm::LogicalResult runMlirLSPServer(MLIRServer &server, llvm::lsp::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.