Benjamin Kramer | bb1cdb6 | 2017-02-07 10:28:20 +0000 | [diff] [blame] | 1 | //===--- ProtocolHandlers.h - LSP callbacks ---------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the actions performed when the server gets a specific |
| 11 | // request. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOLHANDLERS_H |
| 16 | #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOLHANDLERS_H |
| 17 | |
| 18 | #include "JSONRPCDispatcher.h" |
| 19 | #include "Protocol.h" |
| 20 | #include "llvm/ADT/Twine.h" |
| 21 | #include "llvm/Support/raw_ostream.h" |
| 22 | |
| 23 | namespace clang { |
| 24 | namespace clangd { |
Benjamin Kramer | bb1cdb6 | 2017-02-07 10:28:20 +0000 | [diff] [blame] | 25 | |
Ilya Biryukov | afb5554 | 2017-05-16 14:40:30 +0000 | [diff] [blame] | 26 | class ProtocolCallbacks { |
| 27 | public: |
| 28 | virtual ~ProtocolCallbacks() = default; |
Benjamin Kramer | bb1cdb6 | 2017-02-07 10:28:20 +0000 | [diff] [blame] | 29 | |
Ilya Biryukov | afb5554 | 2017-05-16 14:40:30 +0000 | [diff] [blame] | 30 | virtual void onInitialize(StringRef ID, JSONOutput &Out) = 0; |
| 31 | virtual void onShutdown(JSONOutput &Out) = 0; |
| 32 | virtual void onDocumentDidOpen(DidOpenTextDocumentParams Params, |
| 33 | JSONOutput &Out) = 0; |
| 34 | virtual void onDocumentDidChange(DidChangeTextDocumentParams Params, |
| 35 | JSONOutput &Out) = 0; |
| 36 | |
| 37 | virtual void onDocumentDidClose(DidCloseTextDocumentParams Params, |
| 38 | JSONOutput &Out) = 0; |
| 39 | virtual void onDocumentFormatting(DocumentFormattingParams Params, |
| 40 | StringRef ID, JSONOutput &Out) = 0; |
| 41 | virtual void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params, |
| 42 | StringRef ID, JSONOutput &Out) = 0; |
| 43 | virtual void onDocumentRangeFormatting(DocumentRangeFormattingParams Params, |
| 44 | StringRef ID, JSONOutput &Out) = 0; |
| 45 | virtual void onCodeAction(CodeActionParams Params, StringRef ID, |
| 46 | JSONOutput &Out) = 0; |
| 47 | virtual void onCompletion(TextDocumentPositionParams Params, StringRef ID, |
| 48 | JSONOutput &Out) = 0; |
Marc-Andre Laperle | 2cbf037 | 2017-06-28 16:12:10 +0000 | [diff] [blame] | 49 | virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, |
| 50 | JSONOutput &Out) = 0; |
Benjamin Kramer | bb1cdb6 | 2017-02-07 10:28:20 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
Ilya Biryukov | afb5554 | 2017-05-16 14:40:30 +0000 | [diff] [blame] | 53 | void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, |
| 54 | ProtocolCallbacks &Callbacks); |
Krasimir Georgiev | 6d2131a | 2017-04-04 09:46:39 +0000 | [diff] [blame] | 55 | |
Benjamin Kramer | bb1cdb6 | 2017-02-07 10:28:20 +0000 | [diff] [blame] | 56 | } // namespace clangd |
| 57 | } // namespace clang |
| 58 | |
| 59 | #endif |