clang-tools 24.0.0git
clang::clangd::config::Provider Class Referenceabstract

A source of configuration fragments. More...

#include <ConfigProvider.h>

Public Member Functions

virtual ~Provider ()=default
Config getConfig (const Params &, DiagnosticCallback) const
 Build a config based on this provider.

Static Public Member Functions

static std::unique_ptr< Provider > fromYAMLFile (llvm::StringRef AbsPath, llvm::StringRef Directory, const ThreadsafeFS &, bool Trusted=false)
 Reads fragments from a single YAML file with a fixed path.
static std::unique_ptr< Provider > fromAncestorRelativeYAMLFiles (llvm::StringRef RelPath, const ThreadsafeFS &, bool Trusted=false)
static std::unique_ptr< Provider > combine (std::vector< std::unique_ptr< Provider > >)
 A provider that includes fragments from all the supplied providers.
static std::vector< std::unique_ptr< Provider > > createDefaultProviders (const ThreadsafeFS &)
 Returns providers for the configuration files that clangd tools read by default: project config (ancestor .clangd files) and the user's global config file.

Static Public Attributes

static const char *const EnableConfigFlagDesc
 Help text for the –enable-config flag, shared by clangd tools that expose createDefaultProviders() on the command line.

Detailed Description

A source of configuration fragments.

Generally these providers reflect a fixed policy for obtaining config, but return different concrete configuration over time. e.g. a provider that reads config from files is responsive to file changes.

Definition at line 62 of file ConfigProvider.h.

Constructor & Destructor Documentation

◆ ~Provider()

virtual clang::clangd::config::Provider::~Provider ( )
virtualdefault

References Directory().

Member Function Documentation

◆ combine()

std::unique_ptr< Provider > clang::clangd::config::Provider::combine ( std::vector< std::unique_ptr< Provider > > Providers)
static

A provider that includes fragments from all the supplied providers.

Order is preserved; later providers take precedence over earlier ones.

Definition at line 149 of file ConfigProvider.cpp.

Referenced by clang::clangd::check(), clang::clangd::clangdMain(), and main().

◆ createDefaultProviders()

std::vector< std::unique_ptr< Provider > > clang::clangd::config::Provider::createDefaultProviders ( const ThreadsafeFS & TFS)
static

Returns providers for the configuration files that clangd tools read by default: project config (ancestor .clangd files) and the user's global config file.

Definition at line 172 of file ConfigProvider.cpp.

References clang::clangd::elog(), fromAncestorRelativeYAMLFiles(), fromYAMLFile(), and clang::clangd::vlog().

Referenced by clang::clangd::clangdMain(), and main().

◆ fromAncestorRelativeYAMLFiles()

std::unique_ptr< Provider > clang::clangd::config::Provider::fromAncestorRelativeYAMLFiles ( llvm::StringRef RelPath,
const ThreadsafeFS & FS,
bool Trusted = false )
static

Definition at line 86 of file ConfigProvider.cpp.

References clang::clangd::absoluteParent().

Referenced by createDefaultProviders().

◆ fromYAMLFile()

std::unique_ptr< Provider > clang::clangd::config::Provider::fromYAMLFile ( llvm::StringRef AbsPath,
llvm::StringRef Directory,
const ThreadsafeFS & FS,
bool Trusted = false )
static

Reads fragments from a single YAML file with a fixed path.

If non-empty, Directory will be used to resolve relative paths in the fragments.

Definition at line 58 of file ConfigProvider.cpp.

References Directory(), and clang::clangd::config::FileConfigCache::get().

Referenced by createDefaultProviders().

◆ getConfig()

Config clang::clangd::config::Provider::getConfig ( const Params & P,
DiagnosticCallback DC ) const

Build a config based on this provider.

Definition at line 196 of file ConfigProvider.cpp.

References SPAN_ATTACH.

Referenced by clang::clangd::ClangdServer::createConfiguredContextProvider().

Member Data Documentation

◆ EnableConfigFlagDesc

const char *const clang::clangd::config::Provider::EnableConfigFlagDesc
static
Initial value:
=
"Read user and project configuration from YAML files.\n"
"Project config is from a .clangd file in the project directory.\n"
"User config is from clangd/config.yaml in the following directories:\n"
"\tWindows: %USERPROFILE%\\AppData\\Local\n"
"\tMac OS: ~/Library/Preferences/\n"
"\tOthers: $XDG_CONFIG_HOME, usually ~/.config\n"
"Configuration is documented at https://clangd.llvm.org/config.html"

Help text for the –enable-config flag, shared by clangd tools that expose createDefaultProviders() on the command line.

Definition at line 99 of file ConfigProvider.h.


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