CIRCT 24.0.0git
Loading...
Searching...
No Matches
circt::lsp::VerilogDocument Class Reference

#include <VerilogDocument.h>

Collaboration diagram for circt::lsp::VerilogDocument:

Public Member Functions

 VerilogDocument (VerilogServerContext &globalContext, const llvm::lsp::URIForFile &uri, llvm::StringRef contents, std::vector< llvm::lsp::Diagnostic > &diagnostics, const slang::driver::Driver *projectDriver=nullptr, const std::vector< std::string > &projectIncludeDirectories={})
 VerilogDocument (const VerilogDocument &)=delete
VerilogDocument & operator= (const VerilogDocument &)=delete
const llvm::lsp::URIForFile & getURI () const
const slang::SourceManager & getSlangSourceManager () const
llvm::lsp::Location getLspLocation (slang::SourceLocation loc) const
llvm::lsp::Location getLspLocation (slang::SourceRange range) const
slang::BufferID getMainBufferID () const
void getLocationsOf (const llvm::lsp::URIForFile &uri, const llvm::lsp::Position &defPos, std::vector< llvm::lsp::Location > &locations)
void findReferencesOf (const llvm::lsp::URIForFile &uri, const llvm::lsp::Position &pos, std::vector< llvm::lsp::Location > &references)
std::optional< uint32_t > lspPositionToOffset (const llvm::lsp::Position &pos)
const char * getPointerFor (const llvm::lsp::Position &pos)

Private Member Functions

std::optional< std::pair< slang::BufferID, llvm::SmallString< 128 > > > getOrOpenFile (llvm::StringRef filePath)
void computeLineOffsets (std::string_view text)
 Build a vector of line start offsets (0-based).

Private Attributes

VerilogServerContext & globalContext
slang::BufferID mainBufferId
llvm::StringMap< std::pair< slang::BufferID, llvm::SmallString< 128 > > > filePathMap
llvm::FailureOr< std::unique_ptr< slang::ast::Compilation > > compilation
slang::driver::Driver driver
std::unique_ptr< circt::lsp::VerilogIndex > index
 The index of the parsed module.
std::vector< uint32_t > lineOffsets
 The precomputed line offsets for faster lookups.
llvm::lsp::URIForFile uri

Detailed Description

Definition at line 38 of file VerilogDocument.h.

Constructor & Destructor Documentation

◆ VerilogDocument() [1/2]

circt::lsp::VerilogDocument::VerilogDocument ( VerilogServerContext & globalContext,
const llvm::lsp::URIForFile & uri,
llvm::StringRef contents,
std::vector< llvm::lsp::Diagnostic > & diagnostics,
const slang::driver::Driver * projectDriver = nullptr,
const std::vector< std::string > & projectIncludeDirectories = {} )

References globalContext, and uri.

Referenced by operator=(), and VerilogDocument().

◆ VerilogDocument() [2/2]

circt::lsp::VerilogDocument::VerilogDocument ( const VerilogDocument & )
delete

References VerilogDocument().

Member Function Documentation

◆ computeLineOffsets()

void VerilogDocument::computeLineOffsets ( std::string_view text)
private

Build a vector of line start offsets (0-based).

Definition at line 296 of file VerilogDocument.cpp.

References lineOffsets.

◆ findReferencesOf()

void VerilogDocument::findReferencesOf ( const llvm::lsp::URIForFile & uri,
const llvm::lsp::Position & pos,
std::vector< llvm::lsp::Location > & references )

Definition at line 404 of file VerilogDocument.cpp.

References getLspLocation(), getPointerFor(), index, and uri.

◆ getLocationsOf()

void VerilogDocument::getLocationsOf ( const llvm::lsp::URIForFile & uri,
const llvm::lsp::Position & defPos,
std::vector< llvm::lsp::Location > & locations )

◆ getLspLocation() [1/2]

llvm::lsp::Location VerilogDocument::getLspLocation ( slang::SourceLocation loc) const

Definition at line 201 of file VerilogDocument.cpp.

References getSlangSourceManager(), mainBufferId, and uri.

Referenced by findReferencesOf(), getLocationsOf(), and getLspLocation().

◆ getLspLocation() [2/2]

llvm::lsp::Location VerilogDocument::getLspLocation ( slang::SourceRange range) const

Definition at line 234 of file VerilogDocument.cpp.

References getLspLocation().

◆ getMainBufferID()

slang::BufferID circt::lsp::VerilogDocument::getMainBufferID ( ) const
inline

Definition at line 58 of file VerilogDocument.h.

References mainBufferId.

◆ getOrOpenFile()

std::optional< std::pair< slang::BufferID, llvm::SmallString< 128 > > > VerilogDocument::getOrOpenFile ( llvm::StringRef filePath)
private

Definition at line 247 of file VerilogDocument.cpp.

References driver, filePathMap, and globalContext.

Referenced by getLocationsOf().

◆ getPointerFor()

const char * VerilogDocument::getPointerFor ( const llvm::lsp::Position & pos)

◆ getSlangSourceManager()

const slang::SourceManager & circt::lsp::VerilogDocument::getSlangSourceManager ( ) const
inline

Definition at line 50 of file VerilogDocument.h.

References driver.

Referenced by getLspLocation(), getPointerFor(), and lspPositionToOffset().

◆ getURI()

const llvm::lsp::URIForFile & circt::lsp::VerilogDocument::getURI ( ) const
inline

Definition at line 48 of file VerilogDocument.h.

References uri.

◆ lspPositionToOffset()

std::optional< uint32_t > VerilogDocument::lspPositionToOffset ( const llvm::lsp::Position & pos)

Definition at line 309 of file VerilogDocument.cpp.

References getSlangSourceManager(), lineOffsets, and mainBufferId.

Referenced by getPointerFor().

◆ operator=()

VerilogDocument & circt::lsp::VerilogDocument::operator= ( const VerilogDocument & )
delete

References VerilogDocument().

Member Data Documentation

◆ compilation

llvm::FailureOr<std::unique_ptr<slang::ast::Compilation> > circt::lsp::VerilogDocument::compilation
private

Definition at line 89 of file VerilogDocument.h.

◆ driver

slang::driver::Driver circt::lsp::VerilogDocument::driver
private

Definition at line 92 of file VerilogDocument.h.

Referenced by getOrOpenFile(), and getSlangSourceManager().

◆ filePathMap

llvm::StringMap<std::pair<slang::BufferID, llvm::SmallString<128> > > circt::lsp::VerilogDocument::filePathMap
private

Definition at line 86 of file VerilogDocument.h.

Referenced by getOrOpenFile().

◆ globalContext

VerilogServerContext& circt::lsp::VerilogDocument::globalContext
private

Definition at line 79 of file VerilogDocument.h.

Referenced by getOrOpenFile(), and VerilogDocument().

◆ index

std::unique_ptr<circt::lsp::VerilogIndex> circt::lsp::VerilogDocument::index
private

The index of the parsed module.

Definition at line 95 of file VerilogDocument.h.

Referenced by findReferencesOf(), and getLocationsOf().

◆ lineOffsets

std::vector<uint32_t> circt::lsp::VerilogDocument::lineOffsets
private

The precomputed line offsets for faster lookups.

Definition at line 98 of file VerilogDocument.h.

Referenced by computeLineOffsets(), and lspPositionToOffset().

◆ mainBufferId

slang::BufferID circt::lsp::VerilogDocument::mainBufferId
private

◆ uri

llvm::lsp::URIForFile circt::lsp::VerilogDocument::uri
private

The documentation for this class was generated from the following files: