context.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #ifndef CARBON_TOOLCHAIN_LANGUAGE_SERVER_CONTEXT_H_
  5. #define CARBON_TOOLCHAIN_LANGUAGE_SERVER_CONTEXT_H_
  6. #include <string>
  7. #include "common/map.h"
  8. #include "toolchain/diagnostics/diagnostic_consumer.h"
  9. #include "toolchain/diagnostics/diagnostic_emitter.h"
  10. namespace Carbon::LanguageServer {
  11. // Context for LSP call handling.
  12. class Context {
  13. public:
  14. // `consumer` is required.
  15. explicit Context(DiagnosticConsumer* consumer) : no_loc_emitter_(consumer) {}
  16. auto no_loc_emitter() -> NoLocDiagnosticEmitter& { return no_loc_emitter_; }
  17. auto files() -> Map<std::string, std::string>& { return files_; }
  18. private:
  19. NoLocDiagnosticEmitter no_loc_emitter_;
  20. // Content of files managed by the language client.
  21. Map<std::string, std::string> files_;
  22. };
  23. } // namespace Carbon::LanguageServer
  24. #endif // CARBON_TOOLCHAIN_LANGUAGE_SERVER_CONTEXT_H_