25 llvm::cl::opt<JSONStreamStyle> inputStyle{
27 llvm::cl::desc(
"Input JSON stream encoding"),
28 llvm::cl::values(clEnumValN(JSONStreamStyle::Standard,
"standard",
29 "usual LSP protocol"),
30 clEnumValN(JSONStreamStyle::Delimited,
"delimited",
31 "messages delimited by `// -----` lines, "
32 "with // comment support")),
33 llvm::cl::init(JSONStreamStyle::Standard),
36 llvm::cl::opt<bool> litTest{
39 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
40 "Intended to simplify lit tests"),
41 llvm::cl::init(
false),
43 llvm::cl::opt<Logger::Level> logLevel{
45 llvm::cl::desc(
"Verbosity of log messages written to stderr"),
47 clEnumValN(Logger::Level::Error,
"error",
"Error messages only"),
48 clEnumValN(Logger::Level::Info,
"info",
49 "High level execution tracing"),
50 clEnumValN(Logger::Level::Debug,
"verbose",
"Low level details")),
51 llvm::cl::init(Logger::Level::Info),
53 llvm::cl::opt<bool> prettyPrint{
55 llvm::cl::desc(
"Pretty-print JSON output"),
56 llvm::cl::init(
false),
58 llvm::cl::list<std::string> extraIncludeDirs(
59 "tablegen-extra-dir", llvm::cl::desc(
"Extra directory of include files"),
60 llvm::cl::value_desc(
"directory"), llvm::cl::Prefix);
61 llvm::cl::list<std::string> compilationDatabases(
62 "tablegen-compilation-database",
63 llvm::cl::desc(
"Compilation YAML databases containing additional "
64 "compilation information for .td files"));
66 llvm::cl::ParseCommandLineOptions(argc, argv,
"TableGen LSP Language Server");
69 inputStyle = JSONStreamStyle::Delimited;
70 logLevel = Logger::Level::Debug;
75 Logger::setLogLevel(logLevel);
78 llvm::sys::ChangeStdinToBinary();
79 JSONTransport transport(stdin, llvm::outs(), inputStyle, prettyPrint);
llvm::LogicalResult runTableGenLSPServer(TableGenServer &server, llvm::lsp::JSONTransport &transport)
Run the main loop of the LSP server using the given TableGen server and transport.