blob: 0ee0383a4d256ab0f8a8c1a3de3985e67a6f3854 [file] [log] [blame]
Benjamin Kramerbb1cdb62017-02-07 10:28:20 +00001//===--- 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
23namespace clang {
24namespace clangd {
Benjamin Kramerbb1cdb62017-02-07 10:28:20 +000025
Ilya Biryukovafb55542017-05-16 14:40:30 +000026class ProtocolCallbacks {
27public:
28 virtual ~ProtocolCallbacks() = default;
Benjamin Kramerbb1cdb62017-02-07 10:28:20 +000029
Ilya Biryukovafb55542017-05-16 14:40:30 +000030 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 Laperle2cbf0372017-06-28 16:12:10 +000049 virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
50 JSONOutput &Out) = 0;
Benjamin Kramerbb1cdb62017-02-07 10:28:20 +000051};
52
Ilya Biryukovafb55542017-05-16 14:40:30 +000053void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
54 ProtocolCallbacks &Callbacks);
Krasimir Georgiev6d2131a2017-04-04 09:46:39 +000055
Benjamin Kramerbb1cdb62017-02-07 10:28:20 +000056} // namespace clangd
57} // namespace clang
58
59#endif