LLVM 22.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.
StringRef scheme () const
 Return the scheme of the uri.
 operator bool () const

Static Public Member Functions

static llvm::Expected< URIForFilefromURI (StringRef uri)
 Try to build a URIForFile from the given URI string.
static llvm::Expected< URIForFilefromFile (StringRef absoluteFilepath, StringRef scheme="file")
 Try to build a URIForFile from the given absolute file path and optional scheme.
static 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 101 of file Protocol.h.

Constructor & Destructor Documentation

◆ URIForFile()

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

References 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 114 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 227 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 220 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 122 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 238 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 236 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 117 of file Protocol.h.

Referenced by scheme(), and URIForFile().

◆ operator!=

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

Definition at line 127 of file Protocol.h.

References URIForFile().

◆ operator<

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

Definition at line 130 of file Protocol.h.

References URIForFile().

◆ operator==

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

Definition at line 124 of file Protocol.h.

References URIForFile().


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