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

This class represents a text file containing one or more Verilog documents. More...

#include <VerilogTextFile.h>

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

Public Member Functions

 VerilogTextFile (VerilogServerContext &globalContext, const llvm::lsp::URIForFile &uri, llvm::StringRef fileContents, int64_t version, std::vector< llvm::lsp::Diagnostic > &diagnostics)
 Initialize a new VerilogTextFile and its VerilogDocument.
 
int64_t getVersion () const
 Return the current version of this text file.
 
llvm::LogicalResult update (const llvm::lsp::URIForFile &uri, int64_t newVersion, llvm::ArrayRef< llvm::lsp::TextDocumentContentChangeEvent > changes, std::vector< llvm::lsp::Diagnostic > &diagnostics)
 Update the file to the new version using the provided set of content changes.
 
void getLocationsOf (const llvm::lsp::URIForFile &uri, llvm::lsp::Position defPos, std::vector< llvm::lsp::Location > &locations)
 Return position of definition of an object pointed to by pos.
 
void findReferencesOf (const llvm::lsp::URIForFile &uri, llvm::lsp::Position pos, std::vector< llvm::lsp::Location > &references)
 Return all references to an object pointed to by pos.
 
std::shared_ptr< VerilogDocumentgetDocument ()
 Return document for read access.
 
void setDocument (std::shared_ptr< VerilogDocument > newDoc)
 Override document after update.
 

Private Member Functions

void initialize (const llvm::lsp::URIForFile &uri, int64_t newVersion, std::vector< llvm::lsp::Diagnostic > &diagnostics)
 Initialize the text file from the given file contents.
 
void initializeProjectDriver ()
 

Private Attributes

VerilogServerContextcontext
 
std::string contents
 The full string contents of the file.
 
std::unique_ptr< slang::driver::Driver > projectDriver
 The project-scale driver.
 
std::vector< std::string > projectIncludeDirectories
 
std::shared_mutex contentMutex
 A mutex to control updates of contents.
 
int64_t version = 0
 The version of this file.
 
std::shared_ptr< circt::lsp::VerilogDocumentdocument
 The chunks of this file.
 
std::shared_mutex docMutex
 A mutex to control updates of document; Acquire AFTER contentMutex.
 

Detailed Description

This class represents a text file containing one or more Verilog documents.

Definition at line 37 of file VerilogTextFile.h.

Constructor & Destructor Documentation

◆ VerilogTextFile()

VerilogTextFile::VerilogTextFile ( VerilogServerContext globalContext,
const llvm::lsp::URIForFile &  uri,
llvm::StringRef  fileContents,
int64_t  version,
std::vector< llvm::lsp::Diagnostic > &  diagnostics 
)

Initialize a new VerilogTextFile and its VerilogDocument.

Thread-safe; acquires contentMutex and docMutex.

Definition at line 41 of file VerilogTextFile.cpp.

References contentMutex, initialize(), initializeProjectDriver(), and version.

Member Function Documentation

◆ findReferencesOf()

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

Return all references to an object pointed to by pos.

Thread-safe; acquires docMutex.

Definition at line 153 of file VerilogTextFile.cpp.

References getDocument().

◆ getDocument()

std::shared_ptr< VerilogDocument > VerilogTextFile::getDocument ( )

Return document for read access.

Thread-safe; acquires docMutex.

Definition at line 160 of file VerilogTextFile.cpp.

References docMutex, and document.

Referenced by findReferencesOf(), and getLocationsOf().

◆ getLocationsOf()

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

Return position of definition of an object pointed to by pos.

Thread-safe; acquires docMutex.

Definition at line 146 of file VerilogTextFile.cpp.

References getDocument().

◆ getVersion()

int64_t circt::lsp::VerilogTextFile::getVersion ( ) const
inline

Return the current version of this text file.

Thread-safe.

Definition at line 48 of file VerilogTextFile.h.

References version.

◆ initialize()

void VerilogTextFile::initialize ( const llvm::lsp::URIForFile &  uri,
int64_t  newVersion,
std::vector< llvm::lsp::Diagnostic > &  diagnostics 
)
private

Initialize the text file from the given file contents.

NOT thread-safe. ONLY call with contentMutex acquired! Acquires docMutex.

Definition at line 136 of file VerilogTextFile.cpp.

References contents, context, projectDriver, projectIncludeDirectories, setDocument(), and version.

Referenced by update(), and VerilogTextFile().

◆ initializeProjectDriver()

void VerilogTextFile::initializeProjectDriver ( )
private

◆ setDocument()

void VerilogTextFile::setDocument ( std::shared_ptr< VerilogDocument newDoc)

Override document after update.

Thread-safe; acquires docMutex.

Definition at line 165 of file VerilogTextFile.cpp.

References docMutex, and document.

Referenced by initialize().

◆ update()

LogicalResult VerilogTextFile::update ( const llvm::lsp::URIForFile &  uri,
int64_t  newVersion,
llvm::ArrayRef< llvm::lsp::TextDocumentContentChangeEvent >  changes,
std::vector< llvm::lsp::Diagnostic > &  diagnostics 
)

Update the file to the new version using the provided set of content changes.

Returns failure if the update was unsuccessful. Thread-safe; acquires contentMutex and docMutex.

Definition at line 51 of file VerilogTextFile.cpp.

References contentMutex, contents, circt::lsp::Logger::error(), and initialize().

Member Data Documentation

◆ contentMutex

std::shared_mutex circt::lsp::VerilogTextFile::contentMutex
private

A mutex to control updates of contents.

Acquire BEFORE docMutex.

Definition at line 97 of file VerilogTextFile.h.

Referenced by update(), and VerilogTextFile().

◆ contents

std::string circt::lsp::VerilogTextFile::contents
private

The full string contents of the file.

Definition at line 90 of file VerilogTextFile.h.

Referenced by initialize(), and update().

◆ context

VerilogServerContext& circt::lsp::VerilogTextFile::context
private

Definition at line 87 of file VerilogTextFile.h.

Referenced by initialize(), and initializeProjectDriver().

◆ docMutex

std::shared_mutex circt::lsp::VerilogTextFile::docMutex
private

A mutex to control updates of document; Acquire AFTER contentMutex.

Definition at line 108 of file VerilogTextFile.h.

Referenced by getDocument(), and setDocument().

◆ document

std::shared_ptr<circt::lsp::VerilogDocument> circt::lsp::VerilogTextFile::document
private

The chunks of this file.

The order of these chunks is the order in which they appear in the text file.

Definition at line 104 of file VerilogTextFile.h.

Referenced by getDocument(), and setDocument().

◆ projectDriver

std::unique_ptr<slang::driver::Driver> circt::lsp::VerilogTextFile::projectDriver
private

The project-scale driver.

Definition at line 93 of file VerilogTextFile.h.

Referenced by initialize(), and initializeProjectDriver().

◆ projectIncludeDirectories

std::vector<std::string> circt::lsp::VerilogTextFile::projectIncludeDirectories
private

Definition at line 94 of file VerilogTextFile.h.

Referenced by initialize(), and initializeProjectDriver().

◆ version

int64_t circt::lsp::VerilogTextFile::version = 0
private

The version of this file.

Definition at line 100 of file VerilogTextFile.h.

Referenced by getVersion(), initialize(), and VerilogTextFile().


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