CIRCT 21.0.0git
Loading...
Searching...
No Matches
VerilogServer.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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//===----------------------------------------------------------------------===//
8//
9// Main entry function for circt-verilog-lsp-server for when built as standalone
10// binary.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
15#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
16
17#include "mlir/Support/LLVM.h"
18#include "llvm/ADT/StringRef.h"
19#include <memory>
20#include <optional>
21#include <vector>
22
23namespace mlir {
24namespace lsp {
25struct Diagnostic;
27class URIForFile;
28} // namespace lsp
29} // namespace mlir
30
31namespace circt {
32namespace lsp {
33struct VerilogServerOptions;
35 mlir::lsp::TextDocumentContentChangeEvent;
36using URIForFile = mlir::lsp::URIForFile;
37using Diagnostic = mlir::lsp::Diagnostic;
38
39/// This class implements all of the Verilog related functionality necessary for
40/// a language server. This class allows for keeping the Verilog specific logic
41/// separate from the logic that involves LSP server/client communication.
43public:
46
47 /// Add the document, with the provided `version`, at the given URI. Any
48 /// diagnostics emitted for this document should be added to `diagnostics`.
49 void addDocument(const URIForFile &uri, llvm::StringRef contents,
50 int64_t version, std::vector<Diagnostic> &diagnostics);
51
52 /// Update the document, with the provided `version`, at the given URI. Any
53 /// diagnostics emitted for this document should be added to `diagnostics`.
54 void updateDocument(const URIForFile &uri,
55 llvm::ArrayRef<TextDocumentContentChangeEvent> changes,
56 int64_t version, std::vector<Diagnostic> &diagnostics);
57
58 /// Remove the document with the given uri. Returns the version of the removed
59 /// document, or std::nullopt if the uri did not have a corresponding document
60 /// within the server.
61 std::optional<int64_t> removeDocument(const URIForFile &uri);
62
63private:
64 struct Impl;
65 std::unique_ptr<Impl> impl;
66};
67
68} // namespace lsp
69} // namespace circt
70
71#endif // LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
This class implements all of the Verilog related functionality necessary for a language server.
std::optional< int64_t > removeDocument(const URIForFile &uri)
Remove the document with the given uri.
void updateDocument(const URIForFile &uri, llvm::ArrayRef< TextDocumentContentChangeEvent > changes, int64_t version, std::vector< Diagnostic > &diagnostics)
Update the document, with the provided version, at the given URI.
void addDocument(const URIForFile &uri, llvm::StringRef contents, int64_t version, std::vector< Diagnostic > &diagnostics)
Add the document, with the provided version, at the given URI.
std::unique_ptr< Impl > impl
mlir::lsp::URIForFile URIForFile
mlir::lsp::TextDocumentContentChangeEvent TextDocumentContentChangeEvent
mlir::lsp::Diagnostic Diagnostic
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.