LLVM 23.0.0git
llvm::lsp::URIForFile Class Reference

URI in "file" scheme for a file. More...

#include "llvm/Support/LSP/Protocol.h"

Public Member Functions

 URIForFile ()=default
StringRef file () const
 Returns the absolute path to the file.
StringRef uri () const
 Returns the original uri of the file.
LLVM_ABI StringRef scheme () const
 Return the scheme of the uri.
 operator bool () const

Static Public Member Functions

static LLVM_ABI llvm::Expected< URIForFilefromURI (StringRef uri)
 Try to build a URIForFile from the given URI string.
static LLVM_ABI llvm::Expected< URIForFilefromFile (StringRef absoluteFilepath, StringRef scheme="file")
 Try to build a URIForFile from the given absolute file path and optional scheme.
static LLVM_ABI void registerSupportedScheme (StringRef scheme)
 Register a supported URI scheme.

Friends

bool operator== (const URIForFile &lhs, const URIForFile &rhs)
bool operator!= (const URIForFile &lhs, const URIForFile &rhs)
bool operator< (const URIForFile &lhs, const URIForFile &rhs)

Detailed Description

URI in "file" scheme for a file.

Definition at line 102 of file Protocol.h.

Constructor & Destructor Documentation

◆ URIForFile()

llvm::lsp::URIForFile::URIForFile ( )
default

References LLVM_ABI, scheme(), and uri().

Referenced by fromURI(), operator!=, operator<, and operator==.

Member Function Documentation

◆ file()

StringRef llvm::lsp::URIForFile::file ( ) const
inline

Returns the absolute path to the file.

Definition at line 115 of file Protocol.h.

◆ fromFile()

llvm::Expected< URIForFile > URIForFile::fromFile ( StringRef absoluteFilepath,
StringRef scheme = "file" )
static

Try to build a URIForFile from the given absolute file path and optional scheme.

Definition at line 223 of file Protocol.cpp.

References fromURI(), llvm::Expected< T >::takeError(), and uriFromAbsolutePath().

◆ fromURI()

llvm::Expected< URIForFile > URIForFile::fromURI ( StringRef uri)
static

Try to build a URIForFile from the given URI string.

Definition at line 216 of file Protocol.cpp.

References parseFilePathFromURI(), llvm::StringRef::str(), llvm::Expected< T >::takeError(), and URIForFile().

Referenced by fromFile(), and llvm::lsp::fromJSON().

◆ operator bool()

llvm::lsp::URIForFile::operator bool ( ) const
inlineexplicit

Definition at line 123 of file Protocol.h.

◆ registerSupportedScheme()

void URIForFile::registerSupportedScheme ( StringRef scheme)
static

Register a supported URI scheme.

The protocol supports file by default, so this is only necessary for any additional schemes that a server wants to support.

Definition at line 234 of file Protocol.cpp.

References getSupportedSchemes(), and llvm::StringSet< AllocatorTy >::insert().

◆ scheme()

StringRef URIForFile::scheme ( ) const

Return the scheme of the uri.

Definition at line 232 of file Protocol.cpp.

References llvm::StringRef::split(), and uri().

Referenced by URIForFile().

◆ uri()

StringRef llvm::lsp::URIForFile::uri ( ) const
inline

Returns the original uri of the file.

Definition at line 118 of file Protocol.h.

Referenced by scheme(), and URIForFile().

◆ operator!=

bool operator!= ( const URIForFile & lhs,
const URIForFile & rhs )
friend

Definition at line 128 of file Protocol.h.

References URIForFile().

◆ operator<

bool operator< ( const URIForFile & lhs,
const URIForFile & rhs )
friend

Definition at line 131 of file Protocol.h.

References URIForFile().

◆ operator==

bool operator== ( const URIForFile & lhs,
const URIForFile & rhs )
friend

Definition at line 125 of file Protocol.h.

References URIForFile().


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