language_server_subcommand.cpp 873 B

12345678910111213141516171819202122232425262728
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/driver/language_server_subcommand.h"
  5. #include "toolchain/language_server/language_server.h"
  6. namespace Carbon {
  7. constexpr CommandLine::CommandInfo LanguageServerSubcommand::Info = {
  8. .name = "language-server",
  9. .help = R"""(
  10. Runs the language server.
  11. )""",
  12. };
  13. auto LanguageServerSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
  14. // TODO: Consider a way to override stdin, but it's a `FILE*` so less
  15. // convenient to work with.
  16. auto err = LanguageServer::Run(stdin, driver_env.output_stream);
  17. if (!err.ok()) {
  18. driver_env.error_stream << "error: " << err.error() << "\n";
  19. }
  20. return {.success = err.ok()};
  21. }
  22. } // namespace Carbon