LLVM 22.0.0git
Protocol.cpp File Reference

Go to the source code of this file.

Functions

template<typename T>
static bool mapOptOrNull (const llvm::json::Value &Params, llvm::StringLiteral Prop, T &Out, llvm::json::Path Path)
static bool isWindowsPath (StringRef Path)
static bool isNetworkPath (StringRef Path)
static bool shouldEscapeInURI (unsigned char C)
static void percentEncode (StringRef Content, std::string &Out)
 Encodes a string according to percent-encoding.
static std::string percentDecode (StringRef Content)
 Decodes a string according to percent-encoding.
static StringSetgetSupportedSchemes ()
 Return the set containing the supported URI schemes.
static bool isStructurallyValidScheme (StringRef Scheme)
 Returns true if the given scheme is structurally valid, i.e.
static llvm::Expected< std::stringuriFromAbsolutePath (StringRef AbsolutePath, StringRef Scheme)
static llvm::Expected< std::stringgetAbsolutePath (StringRef Authority, StringRef Body)
static llvm::Expected< std::stringparseFilePathFromURI (StringRef OrigUri)
static llvm::StringRef toTextKind (MarkupKind Kind)

Function Documentation

◆ getAbsolutePath()

◆ getSupportedSchemes()

StringSet & getSupportedSchemes ( )
static

Return the set containing the supported URI schemes.

Definition at line 115 of file Protocol.cpp.

Referenced by parseFilePathFromURI(), and llvm::lsp::URIForFile::registerSupportedScheme().

◆ isNetworkPath()

bool isNetworkPath ( StringRef Path)
static

Definition at line 54 of file Protocol.cpp.

References llvm::sys::path::is_separator().

Referenced by uriFromAbsolutePath().

◆ isStructurallyValidScheme()

bool isStructurallyValidScheme ( StringRef Scheme)
static

Returns true if the given scheme is structurally valid, i.e.

it does not contain any invalid scheme characters. This does not check that the scheme is actually supported.

Definition at line 123 of file Protocol.cpp.

References llvm::all_of(), llvm::CallingConv::C, llvm::drop_begin(), llvm::StringRef::empty(), llvm::isAlnum(), and llvm::isAlpha().

Referenced by parseFilePathFromURI().

◆ isWindowsPath()

bool isWindowsPath ( StringRef Path)
static

Definition at line 50 of file Protocol.cpp.

References llvm::isAlpha().

Referenced by getAbsolutePath(), and uriFromAbsolutePath().

◆ mapOptOrNull()

template<typename T>
bool mapOptOrNull ( const llvm::json::Value & Params,
llvm::StringLiteral Prop,
T & Out,
llvm::json::Path Path )
static

◆ parseFilePathFromURI()

◆ percentDecode()

std::string percentDecode ( StringRef Content)
static

Decodes a string according to percent-encoding.

Definition at line 96 of file Protocol.cpp.

References llvm::StringRef::begin(), E(), llvm::StringRef::end(), llvm::hexFromNibbles(), I, and llvm::isHexDigit().

Referenced by parseFilePathFromURI().

◆ percentEncode()

void percentEncode ( StringRef Content,
std::string & Out )
static

Encodes a string according to percent-encoding.

  • Unreserved characters are not escaped.
  • Reserved characters always escaped with exceptions like '/'.
  • All other characters are escaped.

Definition at line 83 of file Protocol.cpp.

References llvm::CallingConv::C, llvm::hexdigit(), and shouldEscapeInURI().

Referenced by uriFromAbsolutePath().

◆ shouldEscapeInURI()

bool shouldEscapeInURI ( unsigned char C)
static

Definition at line 59 of file Protocol.cpp.

References llvm::CallingConv::C.

Referenced by percentEncode().

◆ toTextKind()

llvm::StringRef toTextKind ( MarkupKind Kind)
static

◆ uriFromAbsolutePath()