CIRCT 22.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// VerilogServer.h
10//
11// This header declares VerilogServer, the top-level coordinator of the CIRCT
12// Verilog LSP server. It manages all open files and acts as the entry point for
13// language server operations such as “didOpen”, “didChange”, “didClose”,
14// “definition”, and “references”.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
19#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGSERVER_H_
20
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/LSP/Protocol.h"
23
24#include <memory>
25#include <optional>
26#include <vector>
27
28namespace mlir {
29namespace lsp {
30struct Diagnostic;
31struct Position;
32struct Location;
34class URIForFile;
35} // namespace lsp
36} // namespace mlir
37
38namespace circt {
39namespace lsp {
40struct VerilogServerOptions;
42 llvm::lsp::TextDocumentContentChangeEvent;
43using URIForFile = llvm::lsp::URIForFile;
44using Diagnostic = llvm::lsp::Diagnostic;
45
46/// This class implements all of the Verilog related functionality necessary for
47/// a language server. This class allows for keeping the Verilog specific logic
48/// separate from the logic that involves LSP server/client communication.
50public:
53
54 /// Add the document, with the provided `version`, at the given URI. Any
55 /// diagnostics emitted for this document should be added to `diagnostics`.
56 void addDocument(const URIForFile &uri, llvm::StringRef contents,
57 int64_t version, std::vector<Diagnostic> &diagnostics);
58
59 /// Update the document, with the provided `version`, at the given URI. Any
60 /// diagnostics emitted for this document should be added to `diagnostics`.
61 void updateDocument(const URIForFile &uri,
62 llvm::ArrayRef<TextDocumentContentChangeEvent> changes,
63 int64_t version, std::vector<Diagnostic> &diagnostics);
64
65 /// Remove the document with the given uri. Returns the version of the removed
66 /// document, or std::nullopt if the uri did not have a corresponding document
67 /// within the server.
68 std::optional<int64_t> removeDocument(const URIForFile &uri);
69
70 /// Return the locations of the object pointed at by the given position.
71 void getLocationsOf(const URIForFile &uri, const llvm::lsp::Position &defPos,
72 std::vector<llvm::lsp::Location> &locations);
73
74 /// Find all references of the object pointed at by the given position.
75 void findReferencesOf(const URIForFile &uri, const llvm::lsp::Position &pos,
76 std::vector<llvm::lsp::Location> &references);
77
78private:
79 struct Impl;
80 std::unique_ptr<Impl> impl;
81};
82
83} // namespace lsp
84} // namespace circt
85
86#endif
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
void getLocationsOf(const URIForFile &uri, const llvm::lsp::Position &defPos, std::vector< llvm::lsp::Location > &locations)
Return the locations of the object pointed at by the given position.
void findReferencesOf(const URIForFile &uri, const llvm::lsp::Position &pos, std::vector< llvm::lsp::Location > &references)
Find all references of the object pointed at by the given position.
llvm::lsp::TextDocumentContentChangeEvent TextDocumentContentChangeEvent
llvm::lsp::URIForFile URIForFile
llvm::lsp::Diagnostic Diagnostic
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.