MLIR  19.0.0git
Functions
Protocol.cpp File Reference
#include "mlir/Tools/lsp-server-support/Protocol.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Tools/lsp-server-support/Logging.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"

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. More...
 
static std::string percentDecode (StringRef content)
 Decodes a string according to percent-encoding. More...
 
static StringSetgetSupportedSchemes ()
 Return the set containing the supported URI schemes. More...
 
static bool isStructurallyValidScheme (StringRef scheme)
 Returns true if the given scheme is structurally valid, i.e. More...
 
static llvm::Expected< std::string > uriFromAbsolutePath (StringRef absolutePath, StringRef scheme)
 
static llvm::Expected< std::string > getAbsolutePath (StringRef authority, StringRef body)
 
static llvm::Expected< std::string > parseFilePathFromURI (StringRef origUri)
 
static llvm::StringRef toTextKind (MarkupKind kind)
 

Function Documentation

◆ getAbsolutePath()

static llvm::Expected<std::string> getAbsolutePath ( StringRef  authority,
StringRef  body 
)
static

Definition at line 168 of file Protocol.cpp.

References isWindowsPath().

Referenced by parseFilePathFromURI().

◆ getSupportedSchemes()

static StringSet& getSupportedSchemes ( )
static

Return the set containing the supported URI schemes.

Definition at line 121 of file Protocol.cpp.

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

◆ isNetworkPath()

static bool isNetworkPath ( StringRef  path)
static

Definition at line 60 of file Protocol.cpp.

Referenced by uriFromAbsolutePath().

◆ isStructurallyValidScheme()

static 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 129 of file Protocol.cpp.

Referenced by parseFilePathFromURI().

◆ isWindowsPath()

static bool isWindowsPath ( StringRef  path)
static

Definition at line 56 of file Protocol.cpp.

Referenced by getAbsolutePath(), and uriFromAbsolutePath().

◆ mapOptOrNull()

template<typename T >
static bool mapOptOrNull ( const llvm::json::Value &  params,
llvm::StringLiteral  prop,
T &  out,
llvm::json::Path  path 
)
static

Definition at line 33 of file Protocol.cpp.

References mlir::lsp::fromJSON().

Referenced by mlir::lsp::fromJSON().

◆ parseFilePathFromURI()

static llvm::Expected<std::string> parseFilePathFromURI ( StringRef  origUri)
static

◆ percentDecode()

static std::string percentDecode ( StringRef  content)
static

Decodes a string according to percent-encoding.

Definition at line 102 of file Protocol.cpp.

Referenced by parseFilePathFromURI().

◆ percentEncode()

static 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 89 of file Protocol.cpp.

References shouldEscapeInURI().

Referenced by uriFromAbsolutePath().

◆ shouldEscapeInURI()

static bool shouldEscapeInURI ( unsigned char  c)
static

Definition at line 65 of file Protocol.cpp.

Referenced by percentEncode().

◆ toTextKind()

static llvm::StringRef toTextKind ( MarkupKind  kind)
static

Definition at line 564 of file Protocol.cpp.

Referenced by mlir::lsp::toJSON().

◆ uriFromAbsolutePath()

static llvm::Expected<std::string> uriFromAbsolutePath ( StringRef  absolutePath,
StringRef  scheme 
)
static

Definition at line 139 of file Protocol.cpp.

References isNetworkPath(), isWindowsPath(), and percentEncode().

Referenced by mlir::lsp::URIForFile::fromFile().