[libc++][NFC] Add missing includes in tzdb.cpp
[llvm-project.git] / mlir / lib / Tools / mlir-pdll-lsp-server / PDLLServer.h
blob134431fa63bf87e9f667337f562197cd1125fe80
1 //===- PDLLServer.h - PDL General Language Server ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_
10 #define LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_
12 #include "mlir/Support/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 #include <memory>
15 #include <optional>
16 #include <string>
17 #include <vector>
19 namespace mlir {
20 namespace lsp {
21 struct Diagnostic;
22 class CompilationDatabase;
23 struct PDLLViewOutputResult;
24 enum class PDLLViewOutputKind;
25 struct CompletionList;
26 struct DocumentLink;
27 struct DocumentSymbol;
28 struct Hover;
29 struct InlayHint;
30 struct Location;
31 struct Position;
32 struct Range;
33 struct SignatureHelp;
34 struct TextDocumentContentChangeEvent;
35 class URIForFile;
37 /// This class implements all of the PDLL related functionality necessary for a
38 /// language server. This class allows for keeping the PDLL specific logic
39 /// separate from the logic that involves LSP server/client communication.
40 class PDLLServer {
41 public:
42 struct Options {
43 Options(const std::vector<std::string> &compilationDatabases,
44 const std::vector<std::string> &extraDirs)
45 : compilationDatabases(compilationDatabases), extraDirs(extraDirs) {}
47 /// The filenames for databases containing compilation commands for PDLL
48 /// files passed to the server.
49 const std::vector<std::string> &compilationDatabases;
51 /// Additional list of include directories to search.
52 const std::vector<std::string> &extraDirs;
55 PDLLServer(const Options &options);
56 ~PDLLServer();
58 /// Add the document, with the provided `version`, at the given URI. Any
59 /// diagnostics emitted for this document should be added to `diagnostics`.
60 void addDocument(const URIForFile &uri, StringRef contents, int64_t version,
61 std::vector<Diagnostic> &diagnostics);
63 /// Update the document, with the provided `version`, at the given URI. Any
64 /// diagnostics emitted for this document should be added to `diagnostics`.
65 void updateDocument(const URIForFile &uri,
66 ArrayRef<TextDocumentContentChangeEvent> changes,
67 int64_t version, std::vector<Diagnostic> &diagnostics);
69 /// Remove the document with the given uri. Returns the version of the removed
70 /// document, or std::nullopt if the uri did not have a corresponding document
71 /// within the server.
72 std::optional<int64_t> removeDocument(const URIForFile &uri);
74 /// Return the locations of the object pointed at by the given position.
75 void getLocationsOf(const URIForFile &uri, const Position &defPos,
76 std::vector<Location> &locations);
78 /// Find all references of the object pointed at by the given position.
79 void findReferencesOf(const URIForFile &uri, const Position &pos,
80 std::vector<Location> &references);
82 /// Return the document links referenced by the given file.
83 void getDocumentLinks(const URIForFile &uri,
84 std::vector<DocumentLink> &documentLinks);
86 /// Find a hover description for the given hover position, or std::nullopt if
87 /// one couldn't be found.
88 std::optional<Hover> findHover(const URIForFile &uri,
89 const Position &hoverPos);
91 /// Find all of the document symbols within the given file.
92 void findDocumentSymbols(const URIForFile &uri,
93 std::vector<DocumentSymbol> &symbols);
95 /// Get the code completion list for the position within the given file.
96 CompletionList getCodeCompletion(const URIForFile &uri,
97 const Position &completePos);
99 /// Get the signature help for the position within the given file.
100 SignatureHelp getSignatureHelp(const URIForFile &uri,
101 const Position &helpPos);
103 /// Get the inlay hints for the range within the given file.
104 void getInlayHints(const URIForFile &uri, const Range &range,
105 std::vector<InlayHint> &inlayHints);
107 /// Get the output of the given PDLL file, or std::nullopt if there is no
108 /// valid output.
109 std::optional<PDLLViewOutputResult>
110 getPDLLViewOutput(const URIForFile &uri, PDLLViewOutputKind kind);
112 private:
113 struct Impl;
114 std::unique_ptr<Impl> impl;
117 } // namespace lsp
118 } // namespace mlir
120 #endif // LIB_MLIR_TOOLS_MLIRPDLLSPSERVER_SERVER_H_