19#ifndef LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGDOCUMENT_H_
20#define LIB_CIRCT_TOOLS_CIRCT_VERILOG_LSP_SERVER_VERILOGDOCUMENT_H_
22#include "slang/ast/Compilation.h"
23#include "slang/driver/Driver.h"
24#include "slang/text/SourceManager.h"
26#include "llvm/ADT/SmallString.h"
27#include "llvm/ADT/StringMap.h"
28#include "llvm/ADT/StringRef.h"
29#include "llvm/Support/LSP/Protocol.h"
36struct VerilogServerContext;
41 const llvm::lsp::URIForFile &
uri, llvm::StringRef contents,
42 std::vector<llvm::lsp::Diagnostic> &diagnostics);
46 const llvm::lsp::URIForFile &
getURI()
const {
return uri; }
49 return driver.sourceManager;
53 llvm::lsp::Location
getLspLocation(slang::SourceLocation loc)
const;
54 llvm::lsp::Location
getLspLocation(slang::SourceRange range)
const;
63 const llvm::lsp::Position &defPos,
64 std::vector<llvm::lsp::Location> &locations);
67 const llvm::lsp::Position &pos,
68 std::vector<llvm::lsp::Location> &references);
74 std::optional<std::pair<slang::BufferID, llvm::SmallString<128>>>
83 llvm::StringMap<std::pair<slang::BufferID, llvm::SmallString<128>>>
87 llvm::FailureOr<std::unique_ptr<slang::ast::Compilation>>
compilation;
93 std::unique_ptr<circt::lsp::VerilogIndex>
index;
100 llvm::lsp::URIForFile
uri;
std::unique_ptr< circt::lsp::VerilogIndex > index
The index of the parsed module.
slang::BufferID mainBufferId
VerilogDocument(VerilogServerContext &globalContext, const llvm::lsp::URIForFile &uri, llvm::StringRef contents, std::vector< llvm::lsp::Diagnostic > &diagnostics)
const char * getPointerFor(const llvm::lsp::Position &pos)
slang::driver::Driver driver
VerilogServerContext & globalContext
llvm::lsp::URIForFile uri
VerilogDocument(const VerilogDocument &)=delete
void getLocationsOf(const llvm::lsp::URIForFile &uri, const llvm::lsp::Position &defPos, std::vector< llvm::lsp::Location > &locations)
void computeLineOffsets(std::string_view text)
Build a vector of line start offsets (0-based).
std::optional< std::pair< slang::BufferID, llvm::SmallString< 128 > > > getOrOpenFile(llvm::StringRef filePath)
void findReferencesOf(const llvm::lsp::URIForFile &uri, const llvm::lsp::Position &pos, std::vector< llvm::lsp::Location > &references)
VerilogDocument & operator=(const VerilogDocument &)=delete
std::optional< uint32_t > lspPositionToOffset(const llvm::lsp::Position &pos)
const slang::SourceManager & getSlangSourceManager() const
llvm::StringMap< std::pair< slang::BufferID, llvm::SmallString< 128 > > > filePathMap
slang::BufferID getMainBufferID() const
const llvm::lsp::URIForFile & getURI() const
std::vector< uint32_t > lineOffsets
The precomputed line offsets for faster lookups.
llvm::FailureOr< std::unique_ptr< slang::ast::Compilation > > compilation
llvm::lsp::Location getLspLocation(slang::SourceLocation loc) const
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.