CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
circt::lsp::VerilogDocument Class Reference

#include <VerilogDocument.h>

Collaboration diagram for circt::lsp::VerilogDocument:
Collaboration graph
[legend]

Public Member Functions

 VerilogDocument (VerilogServerContext &globalContext, const llvm::lsp::URIForFile &uri, llvm::StringRef contents, std::vector< llvm::lsp::Diagnostic > &diagnostics)
 
 VerilogDocument (const VerilogDocument &)=delete
 
VerilogDocumentoperator= (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

VerilogServerContextglobalContext
 
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::VerilogIndexindex
 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 
)

◆ VerilogDocument() [2/2]

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

Member Function Documentation

◆ computeLineOffsets()

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

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

Definition at line 357 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 465 of file VerilogDocument.cpp.

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

◆ 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

◆ getLspLocation() [2/2]

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

Definition at line 295 of file VerilogDocument.cpp.

References getLspLocation().

◆ getMainBufferID()

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

Definition at line 56 of file VerilogDocument.h.

References mainBufferId.

◆ getOrOpenFile()

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

◆ getPointerFor()

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

◆ getSlangSourceManager()

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

Definition at line 48 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 46 of file VerilogDocument.h.

References uri.

Referenced by circt::lsp::LSPDiagnosticClient::report().

◆ lspPositionToOffset()

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

Definition at line 370 of file VerilogDocument.cpp.

References getSlangSourceManager(), lineOffsets, and mainBufferId.

Referenced by getPointerFor().

◆ operator=()

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

Member Data Documentation

◆ compilation

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

Definition at line 87 of file VerilogDocument.h.

◆ driver

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

Definition at line 90 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 84 of file VerilogDocument.h.

Referenced by getOrOpenFile().

◆ globalContext

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

Definition at line 77 of file VerilogDocument.h.

Referenced by getOrOpenFile().

◆ index

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

The index of the parsed module.

Definition at line 93 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 96 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

Definition at line 100 of file VerilogDocument.h.

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


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