32#include "llvm/Support/LSP/Protocol.h"
44using namespace llvm::lsp;
50 llvm::StringMap<std::unique_ptr<VerilogTextFile>>
files;
56 : impl(std::make_unique<
Impl>(options)) {}
60 const URIForFile &uri, StringRef contents, int64_t version,
61 std::vector<llvm::lsp::Diagnostic> &diagnostics) {
63 impl->files[uri.file()] = std::make_unique<VerilogTextFile>(
64 impl->context, uri, contents, version, diagnostics);
69 ArrayRef<llvm::lsp::TextDocumentContentChangeEvent> changes,
70 int64_t version, std::vector<llvm::lsp::Diagnostic> &diagnostics) {
72 auto it = impl->files.find(uri.file());
73 if (it == impl->files.end())
78 if (failed(it->second->update(uri, version, changes, diagnostics)))
79 impl->files.erase(it);
84 auto it = impl->files.find(uri.file());
85 if (it == impl->files.end())
88 int64_t version = it->second->getVersion();
89 impl->files.erase(it);
95 std::vector<llvm::lsp::Location> &locations) {
96 auto fileIt = impl->files.find(uri.file());
97 if (fileIt != impl->files.end())
98 fileIt->second->getLocationsOf(uri, defPos, locations);
103 std::vector<llvm::lsp::Location> &references) {
104 auto fileIt = impl->files.find(uri.file());
105 if (fileIt != impl->files.end())
106 fileIt->second->findReferencesOf(uri, pos, references);
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.
VerilogServer(const circt::lsp::VerilogServerOptions &options)
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.
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::URIForFile URIForFile
llvm::StringMap< std::unique_ptr< VerilogTextFile > > files
The files held by the server, mapped by their URI file name.
VerilogServerContext context
Impl(const VerilogServerOptions &options)