clang-tools 20.0.0git
Public Member Functions | List of all members
clang::clangd::remote::Marshaller Class Reference

A notable exception is URI translation. More...

#include <Marshalling.h>

Public Member Functions

 Marshaller ()=delete
 
 Marshaller (llvm::StringRef RemoteIndexRoot, llvm::StringRef LocalIndexRoot)
 
llvm::Expected< clangd::SymbolfromProtobuf (const Symbol &Message)
 
llvm::Expected< clangd::ReffromProtobuf (const Ref &Message)
 
llvm::Expected< std::pair< clangd::SymbolID, clangd::Symbol > > fromProtobuf (const Relation &Message)
 
llvm::Expected< clangd::LookupRequestfromProtobuf (const LookupRequest *Message)
 
llvm::Expected< clangd::FuzzyFindRequestfromProtobuf (const FuzzyFindRequest *Message)
 
llvm::Expected< clangd::RefsRequestfromProtobuf (const RefsRequest *Message)
 
llvm::Expected< clangd::RelationsRequestfromProtobuf (const RelationsRequest *Message)
 
LookupRequest toProtobuf (const clangd::LookupRequest &From)
 toProtobuf() functions serialize native clangd types and strip IndexRoot from the file paths specific to indexing machine.
 
FuzzyFindRequest toProtobuf (const clangd::FuzzyFindRequest &From)
 
RefsRequest toProtobuf (const clangd::RefsRequest &From)
 
RelationsRequest toProtobuf (const clangd::RelationsRequest &From)
 
llvm::Expected< SymboltoProtobuf (const clangd::Symbol &From)
 
llvm::Expected< ReftoProtobuf (const clangd::Ref &From)
 
llvm::Expected< RelationtoProtobuf (const clangd::SymbolID &Subject, const clangd::Symbol &Object)
 
llvm::Expected< std::string > relativePathToURI (llvm::StringRef RelativePath)
 Translates RelativePath into the absolute path and builds URI for the user machine.
 
llvm::Expected< std::string > uriToRelativePath (llvm::StringRef URI)
 Translates a URI from the server's backing index to a relative path suitable to send over the wire to the client.
 

Detailed Description

A notable exception is URI translation.

Because paths to files are different on indexing machine and client machine ("/remote/machine/projects/llvm-project/llvm/include/HelloWorld.h" versus "/usr/local/username/llvm-project/llvm/include/HelloWorld.h"), they need to be converted appropriately. Remote machine strips the prefix (RemoteIndexRoot) from the absolute path and passes paths relative to the project root over the wire ("include/HelloWorld.h" in this example). The indexed project root is passed to the remote server. Client receives this relative path and constructs a URI that points to the relevant file in the filesystem. The relative path is appended to LocalIndexRoot to construct the full path and build the final URI.

Definition at line 36 of file Marshalling.h.

Constructor & Destructor Documentation

◆ Marshaller() [1/2]

clang::clangd::remote::Marshaller::Marshaller ( )
delete

◆ Marshaller() [2/2]

clang::clangd::remote::Marshaller::Marshaller ( llvm::StringRef  RemoteIndexRoot,
llvm::StringRef  LocalIndexRoot 
)

Definition at line 57 of file Marshalling.cpp.

Member Function Documentation

◆ fromProtobuf() [1/7]

llvm::Expected< clangd::FuzzyFindRequest > clang::clangd::remote::Marshaller::fromProtobuf ( const FuzzyFindRequest Message)

Definition at line 89 of file Marshalling.cpp.

References clang::clangd::Type.

◆ fromProtobuf() [2/7]

llvm::Expected< clangd::LookupRequest > clang::clangd::remote::Marshaller::fromProtobuf ( const LookupRequest Message)

Definition at line 79 of file Marshalling.cpp.

References clang::clangd::LookupRequest::IDs.

◆ fromProtobuf() [3/7]

llvm::Expected< clangd::Ref > clang::clangd::remote::Marshaller::fromProtobuf ( const Ref Message)

Definition at line 183 of file Marshalling.cpp.

References clang::clangd::error(), and fromProtobuf().

◆ fromProtobuf() [4/7]

llvm::Expected< clangd::RefsRequest > clang::clangd::remote::Marshaller::fromProtobuf ( const RefsRequest Message)

◆ fromProtobuf() [5/7]

llvm::Expected< std::pair< clangd::SymbolID, clangd::Symbol > > clang::clangd::remote::Marshaller::fromProtobuf ( const Relation Message)

◆ fromProtobuf() [6/7]

llvm::Expected< clangd::RelationsRequest > clang::clangd::remote::Marshaller::fromProtobuf ( const RelationsRequest Message)

◆ fromProtobuf() [7/7]

llvm::Expected< clangd::Symbol > clang::clangd::remote::Marshaller::fromProtobuf ( const Symbol Message)

◆ relativePathToURI()

llvm::Expected< std::string > clang::clangd::remote::Marshaller::relativePathToURI ( llvm::StringRef  RelativePath)

Translates RelativePath into the absolute path and builds URI for the user machine.

This translation happens on the client side with the RelativePath received from remote index server and IndexRoot is provided by the client.

The relative path passed over the wire has unix slashes.

Definition at line 314 of file Marshalling.cpp.

References clang::clangd::URI::createFile(), and clang::clangd::error().

◆ toProtobuf() [1/7]

FuzzyFindRequest clang::clangd::remote::Marshaller::toProtobuf ( const clangd::FuzzyFindRequest From)

◆ toProtobuf() [2/7]

LookupRequest clang::clangd::remote::Marshaller::toProtobuf ( const clangd::LookupRequest From)

toProtobuf() functions serialize native clangd types and strip IndexRoot from the file paths specific to indexing machine.

fromProtobuf() functions deserialize clangd types and translate relative paths into machine-native URIs.

Definition at line 208 of file Marshalling.cpp.

References clang::clangd::LookupRequest::IDs, and clang::clangd::SymbolID::str().

Referenced by toProtobuf().

◆ toProtobuf() [3/7]

llvm::Expected< Ref > clang::clangd::remote::Marshaller::toProtobuf ( const clangd::Ref From)

◆ toProtobuf() [4/7]

RefsRequest clang::clangd::remote::Marshaller::toProtobuf ( const clangd::RefsRequest From)

◆ toProtobuf() [5/7]

RelationsRequest clang::clangd::remote::Marshaller::toProtobuf ( const clangd::RelationsRequest From)

◆ toProtobuf() [6/7]

llvm::Expected< Symbol > clang::clangd::remote::Marshaller::toProtobuf ( const clangd::Symbol From)

◆ toProtobuf() [7/7]

llvm::Expected< Relation > clang::clangd::remote::Marshaller::toProtobuf ( const clangd::SymbolID Subject,
const clangd::Symbol Object 
)

◆ uriToRelativePath()

llvm::Expected< std::string > clang::clangd::remote::Marshaller::uriToRelativePath ( llvm::StringRef  URI)

Translates a URI from the server's backing index to a relative path suitable to send over the wire to the client.

Definition at line 327 of file Marshalling.cpp.

References clang::clangd::error(), and clang::clangd::URI::parse().


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