clang-tools 22.0.0git
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< clangd::ContainedRefsResultfromProtobuf (const ContainedRef &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::ContainedRefsRequestfromProtobuf (const ContainedRefsRequest *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)
ContainedRefsRequest toProtobuf (const clangd::ContainedRefsRequest &From)
RelationsRequest toProtobuf (const clangd::RelationsRequest &From)
llvm::Expected< SymboltoProtobuf (const clangd::Symbol &From)
llvm::Expected< ReftoProtobuf (const clangd::Ref &From)
llvm::Expected< ContainedRef > toProtobuf (const clangd::ContainedRefsResult &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/9]

◆ fromProtobuf() [2/9]

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

◆ fromProtobuf() [3/9]

◆ fromProtobuf() [4/9]

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() [5/9]

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

◆ fromProtobuf() [6/9]

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

◆ fromProtobuf() [7/9]

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

◆ fromProtobuf() [8/9]

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

◆ fromProtobuf() [9/9]

◆ 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 374 of file Marshalling.cpp.

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

◆ toProtobuf() [1/9]

◆ toProtobuf() [2/9]

llvm::Expected< ContainedRef > clang::clangd::remote::Marshaller::toProtobuf ( const clangd::ContainedRefsResult & From)

◆ toProtobuf() [3/9]

◆ toProtobuf() [4/9]

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 246 of file Marshalling.cpp.

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

Referenced by toProtobuf(), toProtobuf(), toProtobuf(), and toProtobuf().

◆ toProtobuf() [5/9]

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

◆ toProtobuf() [6/9]

◆ toProtobuf() [7/9]

◆ toProtobuf() [8/9]

◆ toProtobuf() [9/9]

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 387 of file Marshalling.cpp.

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


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