clang-tools  7.0.0
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
clang::clangd Namespace Reference

Namespaces

 detail
 
 dex
 
 trace
 

Classes

struct  ApplyWorkspaceEditParams
 
struct  ASTRetentionPolicy
 Configuration of the AST retention policy. More...
 
class  AsyncTaskRunner
 Runs tasks on separate (detached) threads and wait for all tasks to finish. More...
 
class  CachingCompilationDb
 A wrapper around GlobalCompilationDatabase that caches the compile commands. More...
 
class  CanonicalIncludes
 Maps a definition location onto an #include file, based on a set of filename rules. More...
 
struct  ClangdConfigurationParamsChange
 Clangd extension to set clangd-specific "initializationOptions" in the "initialize" request and for the "workspace/didChangeConfiguration" notification since the data received is described as 'any' type in LSP. More...
 
struct  ClangdInitializationOptions
 
class  ClangdLSPServer
 This class provides implementation of an LSP server, glueing the JSON dispatch and ClangdServer together. More...
 
class  ClangdServer
 Provides API to manage ASTs for a collection of C++ files and request various language features. More...
 
struct  ClientCapabilities
 
struct  CodeActionContext
 
struct  CodeActionParams
 
class  CodeCompleteFlow
 
struct  CodeCompleteOptions
 
struct  CodeCompleteResult
 
struct  CodeCompletion
 
struct  Command
 
struct  CompletionClientCapabilities
 
struct  CompletionItem
 
struct  CompletionItemClientCapabilities
 
struct  CompletionList
 Represents a collection of completion items to be presented in the editor. More...
 
class  Context
 A context is an immutable container for per-request data that must be propagated through layers that don't care about it. More...
 
class  Deadline
 A point in time we can wait for. More...
 
struct  Diag
 A top-level diagnostic that may have Notes and Fixes. More...
 
struct  DiagBase
 Contains basic information about a diagnostic. More...
 
struct  Diagnostic
 
class  DiagnosticsConsumer
 
struct  DidChangeConfigurationParams
 
struct  DidChangeTextDocumentParams
 
struct  DidChangeWatchedFilesParams
 
struct  DidCloseTextDocumentParams
 
struct  DidOpenTextDocumentParams
 
class  DirectoryBasedGlobalCompilationDatabase
 Gets compile args from tooling::CompilationDatabases built for parent directories. More...
 
struct  DocumentFormattingParams
 
struct  DocumentHighlight
 A document highlight is a range inside a text document which deserves special attention. More...
 
struct  DocumentOnTypeFormattingParams
 
struct  DocumentRangeFormattingParams
 
struct  DocumentSymbolParams
 
class  DraftStore
 A thread-safe container for files opened in a workspace, addressed by filenames. More...
 
struct  ExecuteCommandParams
 Exact commands are not specified in the protocol so we define the ones supported by Clangd here. More...
 
class  FileDistance
 
struct  FileDistanceOptions
 
struct  FileEvent
 
class  FileIndex
 This manages symbls from files and an in-memory index on all symbols. More...
 
class  FileSymbols
 A container of Symbols from several source files. More...
 
class  FileSystemProvider
 
struct  Fix
 Represents a single fix-it that editor can apply to fix the error. More...
 
struct  FormattingOptions
 
struct  ForwardBinder
 Stores a callable object (Func) and arguments (Args) and allows to call the callable with provided arguments later using operator (). More...
 
struct  FuzzyFindRequest
 
class  FuzzyMatcher
 
class  GlobalCompilationDatabase
 Provides compilation arguments used for parsing C and C++ files. More...
 
struct  HeaderFile
 Represents a header file to be #include'd. More...
 
struct  Hover
 
class  IgnoreDiagnostics
 
class  IncludeInserter
 
class  IncludeStructure
 
struct  Inclusion
 
struct  InitializeParams
 
struct  InputsAndAST
 
struct  InputsAndPreamble
 
class  JSONOutput
 Encapsulates output and logs streams and provides thread-safe access to them. More...
 
class  JSONRPCDispatcher
 Main JSONRPC entry point. More...
 
class  Key
 Values in a Context are indexed by typed keys. More...
 
struct  Location
 
class  Logger
 Interface to allow custom logging in clangd. More...
 
class  LoggingSession
 Only one LoggingSession can be active at a time. More...
 
struct  LookupRequest
 
struct  LSPDiagnosticCompare
 A LSP-specific comparator used to find diagnostic in a container like std:map. More...
 
struct  MarkupContent
 
class  MemIndex
 This implements an index for a (relatively small) set of symbols that can be easily managed in memory. More...
 
struct  Metadata
 
struct  NoParams
 
struct  Note
 Represents a note for the diagnostic. More...
 
class  Notification
 A threadsafe flag that is initially clear. More...
 
struct  ParameterInformation
 A single parameter of a particular signature. More...
 
class  ParsedAST
 Stores and provides access to parsed AST. More...
 
struct  ParseInputs
 Information required to run clang, e.g. to parse AST or do code completion. More...
 
struct  Position
 
struct  PreambleData
 
class  ProtocolCallbacks
 
struct  Range
 
class  RealFileSystemProvider
 
struct  RenameParams
 
class  Semaphore
 Limits the number of threads that can acquire the lock at the same time. More...
 
struct  SignatureHelp
 Represents the signature of a callable. More...
 
struct  SignatureInformation
 Represents the signature of something callable. More...
 
struct  SourceParams
 
class  StoreDiags
 StoreDiags collects the diagnostics that can later be reported by clangd. More...
 
struct  Symbol
 
class  SymbolCollector
 Collect declarations (symbols) from an AST. More...
 
class  SymbolID
 
class  SymbolIndex
 Interface for symbol indexes that can be used for searching or matching symbols among a set of symbols based on names or unique IDs. More...
 
struct  SymbolInformation
 Represents information about programming constructs like variables, classes, interfaces etc. More...
 
struct  SymbolKindCapabilities
 
struct  SymbolLocation
 
struct  SymbolQualitySignals
 Attributes of a symbol that affect how much we like it. More...
 
struct  SymbolRelevanceSignals
 Attributes of a symbol-query pair that affect how much we like it. More...
 
class  SymbolSlab
 
struct  TextDocumentClientCapabilities
 
struct  TextDocumentContentChangeEvent
 
struct  TextDocumentIdentifier
 
struct  TextDocumentItem
 
struct  TextDocumentPositionParams
 
struct  TextEdit
 
class  TopN
 TopN<T> is a lossy container that preserves only the "best" N elements. More...
 
class  TUScheduler
 Handles running tasks for ClangdServer and managing the resources (e.g., preambles and ASTs) for opened files. More...
 
class  URI
 A URI describes the location of a source file. More...
 
class  URIDistance
 
struct  URIForFile
 
class  URIScheme
 URIScheme is an extension point for teaching clangd to recognize a custom URI scheme. More...
 
class  WithContext
 WithContext replaces Context::current() with a provided scope. More...
 
class  WithContextValue
 WithContextValue extends Context::current() with a single value. More...
 
struct  WorkspaceClientCapabilities
 
struct  WorkspaceEdit
 
struct  WorkspaceSymbolCapabilities
 
struct  WorkspaceSymbolParams
 The parameters of a Workspace Symbol Request. More...
 

Typedefs

using PreambleParsedCallback = std::function< void(PathRef Path, ASTContext &, std::shared_ptr< clang::Preprocessor >)>
 
template<typename T >
using Callback = llvm::unique_function< void(llvm::Expected< T >)>
 A Callback<T> is a void function that accepts Expected<T>. More...
 
using CharTypeSet = unsigned char
 
using Path = std::string
 A typedef to represent a file path. More...
 
using PathRef = llvm::StringRef
 A typedef to represent a ref to file path. More...
 
using ShutdownParams = NoParams
 
using ExitParams = NoParams
 
using SymbolKindBitset = std::bitset< SymbolKindMax+1 >
 
typedef llvm::Registry< URISchemeURISchemeRegistry
 By default, a "file" scheme is supported where URI paths are always absolute in the file system. More...
 

Enumerations

enum  CharType : unsigned char { Empty = 0, Lower = 1, Upper = 2, Punctuation = 3 }
 
enum  CharRole : unsigned char { Unknown = 0, Tail = 1, Head = 2, Separator = 3 }
 
enum  SymbolOrigin : uint8_t {
  SymbolOrigin::Unknown = 0, SymbolOrigin::AST = 1 << 0, SymbolOrigin::Dynamic = 1 << 1, SymbolOrigin::Static = 1 << 2,
  SymbolOrigin::Merge = 1 << 3
}
 
enum  JSONStreamStyle { Standard, Delimited }
 Controls the way JSON-RPC messages are encoded (both input and output). More...
 
enum  ErrorCode {
  ErrorCode::ParseError = -32700, ErrorCode::InvalidRequest = -32600, ErrorCode::MethodNotFound = -32601, ErrorCode::InvalidParams = -32602,
  ErrorCode::InternalError = -32603, ErrorCode::ServerNotInitialized = -32002, ErrorCode::UnknownErrorCode = -32001, ErrorCode::RequestCancelled = -32800
}
 
enum  TraceLevel { TraceLevel::Off = 0, TraceLevel::Messages = 1, TraceLevel::Verbose = 2 }
 
enum  TextDocumentSyncKind { TextDocumentSyncKind::None = 0, TextDocumentSyncKind::Full = 1, TextDocumentSyncKind::Incremental = 2 }
 Defines how the host (editor) should sync document changes to the language server. More...
 
enum  SymbolKind {
  SymbolKind::File = 1, SymbolKind::Module = 2, SymbolKind::Namespace = 3, SymbolKind::Package = 4,
  SymbolKind::Class = 5, SymbolKind::Method = 6, SymbolKind::Property = 7, SymbolKind::Field = 8,
  SymbolKind::Constructor = 9, SymbolKind::Enum = 10, SymbolKind::Interface = 11, SymbolKind::Function = 12,
  SymbolKind::Variable = 13, SymbolKind::Constant = 14, SymbolKind::String = 15, SymbolKind::Number = 16,
  SymbolKind::Boolean = 17, SymbolKind::Array = 18, SymbolKind::Object = 19, SymbolKind::Key = 20,
  SymbolKind::Null = 21, SymbolKind::EnumMember = 22, SymbolKind::Struct = 23, SymbolKind::Event = 24,
  SymbolKind::Operator = 25, SymbolKind::TypeParameter = 26
}
 A symbol kind. More...
 
enum  FileChangeType { FileChangeType::Created = 1, FileChangeType::Changed = 2, FileChangeType::Deleted = 3 }
 
enum  MarkupKind { MarkupKind::PlainText, MarkupKind::Markdown }
 
enum  CompletionItemKind {
  CompletionItemKind::Missing = 0, CompletionItemKind::Text = 1, CompletionItemKind::Method = 2, CompletionItemKind::Function = 3,
  CompletionItemKind::Constructor = 4, CompletionItemKind::Field = 5, CompletionItemKind::Variable = 6, CompletionItemKind::Class = 7,
  CompletionItemKind::Interface = 8, CompletionItemKind::Module = 9, CompletionItemKind::Property = 10, CompletionItemKind::Unit = 11,
  CompletionItemKind::Value = 12, CompletionItemKind::Enum = 13, CompletionItemKind::Keyword = 14, CompletionItemKind::Snippet = 15,
  CompletionItemKind::Color = 16, CompletionItemKind::File = 17, CompletionItemKind::Reference = 18
}
 The kind of a completion entry. More...
 
enum  InsertTextFormat { InsertTextFormat::Missing = 0, InsertTextFormat::PlainText = 1, InsertTextFormat::Snippet = 2 }
 Defines whether the insert text in a completion item should be interpreted as plain text or a snippet. More...
 
enum  DocumentHighlightKind { DocumentHighlightKind::Text = 1, DocumentHighlightKind::Read = 2, DocumentHighlightKind::Write = 3 }
 
enum  WantDiagnostics { WantDiagnostics::Yes, WantDiagnostics::No, WantDiagnostics::Auto }
 Determines whether diagnostics should be generated for a file snapshot. More...
 

Functions

SourceLocation findNameLoc (const clang::Decl *D)
 Find the identifier source location of the given D. More...
 
std::string printQualifiedName (const NamedDecl &ND)
 Returns the qualified name of ND. More...
 
std::unique_ptr< CompilerInvocation > buildCompilerInvocation (const ParseInputs &Inputs)
 Builds compiler invocation that could be used to build AST or preamble. More...
 
std::shared_ptr< const PreambleDatabuildPreamble (PathRef FileName, CompilerInvocation &CI, std::shared_ptr< const PreambleData > OldPreamble, const tooling::CompileCommand &OldCompileCommand, const ParseInputs &Inputs, std::shared_ptr< PCHContainerOperations > PCHs, bool StoreInMemory, PreambleParsedCallback PreambleCallback)
 Rebuild the preamble for the new inputs unless the old one can be reused. More...
 
llvm::Optional< ParsedASTbuildAST (PathRef FileName, std::unique_ptr< CompilerInvocation > Invocation, const ParseInputs &Inputs, std::shared_ptr< const PreambleData > Preamble, std::shared_ptr< PCHContainerOperations > PCHs)
 Build an AST from provided user inputs. More...
 
SourceLocation getBeginningOfIdentifier (ParsedAST &Unit, const Position &Pos, const FileID FID)
 Get the beginning SourceLocation at a specified Pos. More...
 
void dumpAST (ParsedAST &AST, llvm::raw_ostream &OS)
 For testing/debugging purposes. More...
 
CodeCompleteResult codeComplete (PathRef FileName, const tooling::CompileCommand &Command, PrecompiledPreamble const *Preamble, const IncludeStructure &PreambleInclusions, StringRef Contents, Position Pos, IntrusiveRefCntPtr< vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs, CodeCompleteOptions Opts)
 Get code completions at a specified Pos in FileName. More...
 
SignatureHelp signatureHelp (PathRef FileName, const tooling::CompileCommand &Command, PrecompiledPreamble const *Preamble, StringRef Contents, Position Pos, IntrusiveRefCntPtr< vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs)
 Get signature help at a specified Pos in FileName. More...
 
bool isIndexedForCodeCompletion (const NamedDecl &ND, ASTContext &ASTCtx)
 
raw_ostream & operator<< (raw_ostream &OS, const CodeCompletion &C)
 
raw_ostream & operator<< (raw_ostream &OS, const CodeCompleteResult &R)
 
std::string getDocComment (const ASTContext &Ctx, const CodeCompletionResult &Result, bool CommentsFromHeaders)
 Gets a minimally formatted documentation comment of Result, with comment markers stripped. More...
 
std::string getParameterDocComment (const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex, bool CommentsFromHeaders)
 Gets a minimally formatted documentation for parameter of Result, corresponding to argument number ArgIndex. More...
 
void getSignature (const CodeCompletionString &CCS, std::string *Signature, std::string *Snippet, std::string *RequiredQualifiers=nullptr)
 Formats the signature for an item, as a display string and snippet. More...
 
std::string formatDocumentation (const CodeCompletionString &CCS, llvm::StringRef DocComment)
 Assembles formatted documentation for a completion result. More...
 
std::string getReturnType (const CodeCompletionString &CCS)
 Gets detail to be used as the detail field in an LSP completion item. More...
 
std::unique_ptr< CompilerInstance > prepareCompilerInstance (std::unique_ptr< clang::CompilerInvocation >, const PrecompiledPreamble *, std::unique_ptr< llvm::MemoryBuffer > MainFile, std::shared_ptr< PCHContainerOperations >, IntrusiveRefCntPtr< vfs::FileSystem >, DiagnosticConsumer &)
 Creates a compiler instance, configured so that: More...
 
static ContextcurrentContext ()
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const DiagBase &D)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Fix &F)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Diag &D)
 
void toLSPDiags (const Diag &D, llvm::function_ref< void(clangd::Diagnostic, llvm::ArrayRef< Fix >)> OutFn)
 Conversion to LSP diagnostics. More...
 
int getSeverity (DiagnosticsEngine::Level L)
 Convert from clang diagnostic level to LSP severity. More...
 
static SmallString< 128 > canonicalize (StringRef Path)
 
llvm::Expected< std::vector< SymbolInformation > > getWorkspaceSymbols (StringRef Query, int Limit, const SymbolIndex *const Index, StringRef HintPath)
 
llvm::Expected< std::vector< SymbolInformation > > getDocumentSymbols (ParsedAST &AST)
 Retrieves the symbols contained in the "main file" section of an AST in the same order that they appear. More...
 
llvm::Expected< std::vector< SymbolInformation > > getWorkspaceSymbols (llvm::StringRef Query, int Limit, const SymbolIndex *const Index, llvm::StringRef HintPath)
 Searches for the symbols matching Query. More...
 
template<class Func , class... Args>
ForwardBinder< Func, Args... > Bind (Func F, Args &&... As)
 Creates an object that stores a callable (F) and first arguments to the callable (As) and allows to call F with at a later point. More...
 
static char lower (char C)
 
static bool isAwful (int S)
 
template<typename T >
static T packedLookup (const uint8_t *Data, int I)
 
CharTypeSet calculateRoles (StringRef Text, MutableArrayRef< CharRole > Roles)
 
CharTypeSet calculateRoles (llvm::StringRef Text, llvm::MutableArrayRef< CharRole > Roles)
 
bool isLiteralInclude (llvm::StringRef Include)
 Returns true if Include is literal include like "path" or <path>. More...
 
std::unique_ptr< PPCallbackscollectIncludeStructureCallback (const SourceManager &SM, IncludeStructure *Out)
 Returns a PPCallback that visits all inclusions in the main file. More...
 
std::unique_ptr< CommentHandler > collectIWYUHeaderMaps (CanonicalIncludes *Includes)
 Returns a CommentHandler that parses pragma comment on include files to determine when we should include a different header from the header that directly defines a symbol. More...
 
void addSystemHeadersMapping (CanonicalIncludes *Includes)
 Adds mapping for system headers and some special symbols (e.g. More...
 
SymbolSlab indexAST (ASTContext &AST, std::shared_ptr< Preprocessor > PP, llvm::ArrayRef< std::string > URISchemes={})
 Retrieves namespace and class level symbols in AST. More...
 
raw_ostream & operator<< (raw_ostream &OS, const SymbolLocation &L)
 
raw_ostream & operator<< (raw_ostream &OS, const SymbolID &ID)
 
void operator>> (StringRef Str, SymbolID &ID)
 
raw_ostream & operator<< (raw_ostream &OS, SymbolOrigin O)
 
raw_ostream & operator<< (raw_ostream &OS, const Symbol &S)
 
double quality (const Symbol &S)
 
static void own (Symbol &S, DenseSet< StringRef > &Strings, BumpPtrAllocator &Arena)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const SymbolLocation &)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const SymbolID &ID)
 
void operator>> (llvm::StringRef HexStr, SymbolID &ID)
 
SymbolOrigin operator| (SymbolOrigin A, SymbolOrigin B)
 
SymbolOriginoperator|= (SymbolOrigin &A, SymbolOrigin B)
 
SymbolOrigin operator & (SymbolOrigin A, SymbolOrigin B)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Symbol &S)
 
Symbol mergeSymbol (const Symbol &L, const Symbol &R, Symbol::Details *Scratch)
 
std::unique_ptr< SymbolIndexmergeIndex (const SymbolIndex *Dynamic, const SymbolIndex *Static)
 
SymbolSlab symbolsFromYAML (llvm::StringRef YAMLContent)
 
Symbol SymbolFromYAML (llvm::yaml::Input &Input, llvm::BumpPtrAllocator &Arena)
 
void SymbolsToYAML (const SymbolSlab &Symbols, llvm::raw_ostream &OS)
 
std::string SymbolToYAML (Symbol Sym)
 
void reply (llvm::json::Value &&Result)
 Sends a successful reply. More...
 
void replyError (ErrorCode Code, const llvm::StringRef &Message)
 Sends an error response to the client, and logs it. More...
 
void call (llvm::StringRef Method, llvm::json::Value &&Params)
 Sends a request to the client. More...
 
void runLanguageServerLoop (std::FILE *In, JSONOutput &Out, JSONStreamStyle InputStyle, JSONRPCDispatcher &Dispatcher, bool &IsDone)
 Parses input queries from LSP client (coming from In) and runs call method of Dispatcher for each query. More...
 
template<typename... Ts>
void elog (const char *Fmt, Ts &&... Vals)
 
template<typename... Ts>
void log (const char *Fmt, Ts &&... Vals)
 
template<typename... Ts>
void vlog (const char *Fmt, Ts &&... Vals)
 
bool fromJSON (const json::Value &E, URIForFile &R)
 
json::Value toJSON (const URIForFile &U)
 Serialize/deserialize URIForFile to/from a string URI. More...
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const URIForFile &U)
 
json::Value toJSON (const TextDocumentIdentifier &R)
 
bool fromJSON (const json::Value &Params, TextDocumentIdentifier &R)
 
bool fromJSON (const json::Value &Params, Position &R)
 
json::Value toJSON (const Position &P)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Position &P)
 
bool fromJSON (const json::Value &Params, Range &R)
 
json::Value toJSON (const Range &P)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Range &R)
 
json::Value toJSON (const Location &P)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Location &L)
 
bool fromJSON (const json::Value &Params, TextDocumentItem &R)
 
bool fromJSON (const json::Value &Params, Metadata &R)
 
bool fromJSON (const json::Value &Params, TextEdit &R)
 
json::Value toJSON (const TextEdit &P)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const TextEdit &TE)
 
bool fromJSON (const json::Value &E, TraceLevel &Out)
 
bool fromJSON (const json::Value &Params, CompletionItemClientCapabilities &R)
 
bool fromJSON (const json::Value &Params, CompletionClientCapabilities &R)
 
bool fromJSON (const json::Value &E, SymbolKind &Out)
 
bool fromJSON (const json::Value &E, std::vector< SymbolKind > &Out)
 
bool fromJSON (const json::Value &Params, SymbolKindCapabilities &R)
 
SymbolKind adjustKindToCapability (SymbolKind Kind, SymbolKindBitset &SupportedSymbolKinds)
 
bool fromJSON (const json::Value &Params, WorkspaceSymbolCapabilities &R)
 
bool fromJSON (const json::Value &Params, WorkspaceClientCapabilities &R)
 
bool fromJSON (const json::Value &Params, TextDocumentClientCapabilities &R)
 
bool fromJSON (const json::Value &Params, ClientCapabilities &R)
 
bool fromJSON (const json::Value &Params, InitializeParams &R)
 
bool fromJSON (const json::Value &Params, DidOpenTextDocumentParams &R)
 
bool fromJSON (const json::Value &Params, DidCloseTextDocumentParams &R)
 
bool fromJSON (const json::Value &Params, DidChangeTextDocumentParams &R)
 
bool fromJSON (const json::Value &E, FileChangeType &Out)
 
bool fromJSON (const json::Value &Params, FileEvent &R)
 
bool fromJSON (const json::Value &Params, DidChangeWatchedFilesParams &R)
 
bool fromJSON (const json::Value &Params, TextDocumentContentChangeEvent &R)
 
bool fromJSON (const json::Value &Params, FormattingOptions &R)
 
json::Value toJSON (const FormattingOptions &P)
 
bool fromJSON (const json::Value &Params, DocumentRangeFormattingParams &R)
 
bool fromJSON (const json::Value &Params, DocumentOnTypeFormattingParams &R)
 
bool fromJSON (const json::Value &Params, DocumentFormattingParams &R)
 
bool fromJSON (const json::Value &Params, DocumentSymbolParams &R)
 
bool fromJSON (const json::Value &Params, Diagnostic &R)
 
bool fromJSON (const json::Value &Params, CodeActionContext &R)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Diagnostic &D)
 
bool fromJSON (const json::Value &Params, CodeActionParams &R)
 
bool fromJSON (const json::Value &Params, WorkspaceEdit &R)
 
bool fromJSON (const json::Value &Params, ExecuteCommandParams &R)
 
json::Value toJSON (const SymbolInformation &P)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &O, const SymbolInformation &SI)
 
bool fromJSON (const json::Value &Params, WorkspaceSymbolParams &R)
 
json::Value toJSON (const Command &C)
 
json::Value toJSON (const WorkspaceEdit &WE)
 
json::Value toJSON (const ApplyWorkspaceEditParams &Params)
 
bool fromJSON (const json::Value &Params, TextDocumentPositionParams &R)
 
static StringRef toTextKind (MarkupKind Kind)
 
json::Value toJSON (const MarkupContent &MC)
 
json::Value toJSON (const Hover &H)
 
json::Value toJSON (const CompletionItem &CI)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &O, const CompletionItem &I)
 
bool operator< (const CompletionItem &L, const CompletionItem &R)
 
json::Value toJSON (const CompletionList &L)
 
json::Value toJSON (const ParameterInformation &PI)
 
json::Value toJSON (const SignatureInformation &SI)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &O, const SignatureInformation &I)
 
json::Value toJSON (const SignatureHelp &SH)
 
bool fromJSON (const json::Value &Params, RenameParams &R)
 
json::Value toJSON (const DocumentHighlight &DH)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &O, const DocumentHighlight &V)
 
bool fromJSON (const json::Value &Params, DidChangeConfigurationParams &CCP)
 
bool fromJSON (const json::Value &Params, ClangdConfigurationParamsChange &CCPC)
 
bool fromJSON (const llvm::json::Value &, URIForFile &)
 
bool fromJSON (const llvm::json::Value &, TextDocumentIdentifier &)
 
bool fromJSON (const llvm::json::Value &, Position &)
 
bool fromJSON (const llvm::json::Value &, Range &)
 
bool fromJSON (const llvm::json::Value &, Metadata &)
 
bool fromJSON (const llvm::json::Value &, TextEdit &)
 
bool fromJSON (const llvm::json::Value &, TextDocumentItem &)
 
bool fromJSON (const llvm::json::Value &E, TraceLevel &Out)
 
bool fromJSON (const llvm::json::Value &, NoParams &)
 
bool fromJSON (const llvm::json::Value &, CompletionItemClientCapabilities &)
 
bool fromJSON (const llvm::json::Value &, CompletionClientCapabilities &)
 
bool fromJSON (const llvm::json::Value &, SymbolKind &)
 
bool fromJSON (const llvm::json::Value &, std::vector< SymbolKind > &)
 
bool fromJSON (const llvm::json::Value &, SymbolKindCapabilities &)
 
bool fromJSON (const llvm::json::Value &, WorkspaceSymbolCapabilities &)
 
bool fromJSON (const llvm::json::Value &, WorkspaceClientCapabilities &)
 
bool fromJSON (const llvm::json::Value &, TextDocumentClientCapabilities &)
 
bool fromJSON (const llvm::json::Value &, ClientCapabilities &)
 
bool fromJSON (const llvm::json::Value &, ClangdConfigurationParamsChange &)
 
bool fromJSON (const llvm::json::Value &, InitializeParams &)
 
bool fromJSON (const llvm::json::Value &, DidOpenTextDocumentParams &)
 
bool fromJSON (const llvm::json::Value &, DidCloseTextDocumentParams &)
 
bool fromJSON (const llvm::json::Value &, TextDocumentContentChangeEvent &)
 
bool fromJSON (const llvm::json::Value &, DidChangeTextDocumentParams &)
 
bool fromJSON (const llvm::json::Value &E, FileChangeType &Out)
 
bool fromJSON (const llvm::json::Value &, FileEvent &)
 
bool fromJSON (const llvm::json::Value &, DidChangeWatchedFilesParams &)
 
bool fromJSON (const llvm::json::Value &, DidChangeConfigurationParams &)
 
bool fromJSON (const llvm::json::Value &, FormattingOptions &)
 
bool fromJSON (const llvm::json::Value &, DocumentRangeFormattingParams &)
 
bool fromJSON (const llvm::json::Value &, DocumentOnTypeFormattingParams &)
 
bool fromJSON (const llvm::json::Value &, DocumentFormattingParams &)
 
bool fromJSON (const llvm::json::Value &, DocumentSymbolParams &)
 
bool fromJSON (const llvm::json::Value &, Diagnostic &)
 
bool fromJSON (const llvm::json::Value &, CodeActionContext &)
 
bool fromJSON (const llvm::json::Value &, CodeActionParams &)
 
bool fromJSON (const llvm::json::Value &, WorkspaceEdit &)
 
bool fromJSON (const llvm::json::Value &, ExecuteCommandParams &)
 
bool fromJSON (const llvm::json::Value &, WorkspaceSymbolParams &)
 
bool fromJSON (const llvm::json::Value &, TextDocumentPositionParams &)
 
bool fromJSON (const llvm::json::Value &, RenameParams &)
 
void registerCallbackHandlers (JSONRPCDispatcher &Dispatcher, ProtocolCallbacks &Callbacks)
 
static bool isReserved (StringRef Name)
 
static bool hasDeclInMainFile (const Decl &D)
 
static bool hasUsingDeclInMainFile (const CodeCompletionResult &R)
 
static SymbolQualitySignals::SymbolCategory categorize (const NamedDecl &ND)
 
static SymbolQualitySignals::SymbolCategory categorize (const CodeCompletionResult &R)
 
static SymbolQualitySignals::SymbolCategory categorize (const index::SymbolInfo &D)
 
static bool isInstanceMember (const NamedDecl *ND)
 
static bool isInstanceMember (const index::SymbolInfo &D)
 
raw_ostream & operator<< (raw_ostream &OS, const SymbolQualitySignals &S)
 
static SymbolRelevanceSignals::AccessibleScope computeScope (const NamedDecl *D)
 
static std::pair< float, unsigned > proximityScore (llvm::StringRef SymbolURI, URIDistance *D)
 
raw_ostream & operator<< (raw_ostream &OS, const SymbolRelevanceSignals &S)
 
float evaluateSymbolAndRelevance (float SymbolQuality, float SymbolRelevance)
 Combine symbol quality and relevance into a single score. More...
 
static uint32_t encodeFloat (float F)
 
std::string sortText (float Score, llvm::StringRef Tiebreak="")
 Returns a string that sorts in the same order as (-Score, Tiebreak), for LSP. More...
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const SymbolQualitySignals &)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const SymbolRelevanceSignals &)
 
template<typename Callback >
static bool iterateCodepoints (StringRef U8, const Callback &CB)
 
static size_t measureUTF16 (StringRef U8, int U16Units, bool &Valid)
 
static size_t utf16Len (StringRef U8)
 
llvm::Expected< size_t > positionToOffset (StringRef Code, Position P, bool AllowColumnsBeyondLineLength)
 
Position offsetToPosition (StringRef Code, size_t Offset)
 
Position sourceLocToPosition (const SourceManager &SM, SourceLocation Loc)
 Turn a SourceLocation into a [line, column] pair. More...
 
Range halfOpenToRange (const SourceManager &SM, CharSourceRange R)
 
std::pair< size_t, size_t > offsetToClangLineColumn (StringRef Code, size_t Offset)
 
std::pair< llvm::StringRef, llvm::StringRef > splitQualifiedName (llvm::StringRef QName)
 From "a::b::c", return {"a::b::", "c"}. More...
 
TextEdit replacementToEdit (StringRef Code, const tooling::Replacement &R)
 
std::vector< TextEditreplacementsToEdits (StringRef Code, const tooling::Replacements &Repls)
 
llvm::Optional< std::string > getAbsoluteFilePath (const FileEntry *F, const SourceManager &SourceMgr)
 Get the absolute file path of a given file entry. More...
 
llvm::Expected< size_t > positionToOffset (llvm::StringRef Code, Position P, bool AllowColumnsBeyondLineLength=true)
 Turn a [line, column] pair into an offset in Code. More...
 
Position offsetToPosition (llvm::StringRef Code, size_t Offset)
 Turn an offset in Code into a [line, column] pair. More...
 
std::pair< size_t, size_t > offsetToClangLineColumn (llvm::StringRef Code, size_t Offset)
 
Deadline timeoutSeconds (llvm::Optional< double > Seconds)
 Makes a deadline from a timeout in seconds. None means wait forever. More...
 
void wait (std::unique_lock< std::mutex > &Lock, std::condition_variable &CV, Deadline D)
 Wait once on CV for the specified duration. More...
 
template<typename Func >
LLVM_NODISCARD bool wait (std::unique_lock< std::mutex > &Lock, std::condition_variable &CV, Deadline D, Func F)
 Waits on a condition variable until F() is true or D expires. More...
 
unsigned getDefaultAsyncThreadsCount ()
 Returns a number of a default async threads to use for TUScheduler. More...
 
std::vector< LocationfindDefinitions (ParsedAST &AST, Position Pos, const SymbolIndex *Index=nullptr)
 Get definition of symbol at a specified Pos. More...
 
std::vector< DocumentHighlightfindDocumentHighlights (ParsedAST &AST, Position Pos)
 Returns highlights for all usages of a symbol at Pos. More...
 
static PrintingPolicy printingPolicyForDecls (PrintingPolicy Base)
 
static std::string typeDeclToString (const TypeDecl *TD)
 Return a string representation (e.g. More...
 
static std::string namedDeclQualifiedName (const NamedDecl *ND, StringRef Prefix)
 Return a string representation (e.g. More...
 
static llvm::Optional< std::string > getScopeName (const Decl *D)
 Given a declaration D, return a human-readable string representing the scope in which it is declared. More...
 
static Hover getHoverContents (const Decl *D)
 Generate a Hover object given the declaration D. More...
 
static Hover getHoverContents (QualType T, ASTContext &ASTCtx)
 Generate a Hover object given the type T. More...
 
static Hover getHoverContents (StringRef MacroName)
 Generate a Hover object given the macro MacroInf. More...
 
llvm::Optional< QualType > getDeducedType (ParsedAST &AST, SourceLocation SourceLocationBeg)
 Retrieves the deduced type at a given location (auto, decltype). More...
 
Optional< HovergetHover (ParsedAST &AST, Position Pos)
 Get the hover information when hovering at Pos. More...
 

Variables

static constexpr int AwfulScore = -(1 << 13)
 
static constexpr int PerfectBonus = 3
 
static constexpr uint8_t CharTypes []
 
static constexpr uint8_t CharRoles []
 
constexpr auto SymbolKindMin = static_cast<size_t>(SymbolKind::File)
 
constexpr auto SymbolKindMax = static_cast<size_t>(SymbolKind::TypeParameter)
 

Typedef Documentation

◆ Callback

template<typename T >
using clang::clangd::Callback = typedef llvm::unique_function<void(llvm::Expected<T>)>

A Callback<T> is a void function that accepts Expected<T>.

This is accepted by ClangdServer functions that logically return T.

Definition at line 28 of file Function.h.

◆ CharTypeSet

using clang::clangd::CharTypeSet = typedef unsigned char

Definition at line 50 of file FuzzyMatch.h.

◆ ExitParams

Definition at line 204 of file Protocol.h.

◆ Path

using clang::clangd::Path = typedef std::string

A typedef to represent a file path.

Used solely for more descriptive signatures.

Definition at line 21 of file Path.h.

◆ PathRef

using clang::clangd::PathRef = typedef llvm::StringRef

A typedef to represent a ref to file path.

Used solely for more descriptive signatures.

Definition at line 24 of file Path.h.

◆ PreambleParsedCallback

using clang::clangd::PreambleParsedCallback = typedef std::function<void( PathRef Path, ASTContext &, std::shared_ptr<clang::Preprocessor>)>

Definition at line 131 of file ClangdUnit.h.

◆ ShutdownParams

Definition at line 203 of file Protocol.h.

◆ SymbolKindBitset

using clang::clangd::SymbolKindBitset = typedef std::bitset<SymbolKindMax + 1>

Definition at line 278 of file Protocol.h.

◆ URISchemeRegistry

By default, a "file" scheme is supported where URI paths are always absolute in the file system.

Definition at line 117 of file URI.h.

Enumeration Type Documentation

◆ CharRole

enum clang::clangd::CharRole : unsigned char
Enumerator
Unknown 
Tail 
Head 
Separator 

Definition at line 56 of file FuzzyMatch.h.

◆ CharType

enum clang::clangd::CharType : unsigned char
Enumerator
Empty 
Lower 
Upper 
Punctuation 

Definition at line 42 of file FuzzyMatch.h.

◆ CompletionItemKind

The kind of a completion entry.

Enumerator
Missing 
Text 
Method 
Function 
Constructor 
Field 
Variable 
Class 
Interface 
Module 
Property 
Unit 
Value 
Enum 
Keyword 
Snippet 
Color 
File 
Reference 

Definition at line 644 of file Protocol.h.

◆ DocumentHighlightKind

Enumerator
Text 
Read 
Write 

Definition at line 803 of file Protocol.h.

◆ ErrorCode

Enumerator
ParseError 
InvalidRequest 
MethodNotFound 
InvalidParams 
InternalError 
ServerNotInitialized 
UnknownErrorCode 
RequestCancelled 

Definition at line 37 of file Protocol.h.

◆ FileChangeType

Enumerator
Created 

The file got created.

Changed 

The file got changed.

Deleted 

The file got deleted.

Definition at line 412 of file Protocol.h.

◆ InsertTextFormat

Defines whether the insert text in a completion item should be interpreted as plain text or a snippet.

Enumerator
Missing 
PlainText 

The primary text to be inserted is treated as a plain string.

Snippet 

The primary text to be inserted is treated as a snippet.

A snippet can define tab stops and placeholders with $1, $2 and ${3:foo}. $0 defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too.

See also: https//github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md

Definition at line 668 of file Protocol.h.

◆ JSONStreamStyle

Controls the way JSON-RPC messages are encoded (both input and output).

Enumerator
Standard 

Encoding per the LSP specification, with mandatory Content-Length header.

Delimited 

Messages are delimited by a '—' line. Comment lines start with #.

Definition at line 95 of file JSONRPCDispatcher.h.

◆ MarkupKind

Enumerator
PlainText 
Markdown 

Definition at line 622 of file Protocol.h.

◆ SymbolKind

A symbol kind.

Enumerator
File 
Module 
Namespace 
Package 
Class 
Method 
Property 
Field 
Constructor 
Enum 
Interface 
Function 
Variable 
Constant 
String 
Number 
Boolean 
Array 
Object 
Key 
Null 
EnumMember 
Struct 
Event 
Operator 
TypeParameter 

Definition at line 247 of file Protocol.h.

◆ SymbolOrigin

enum clang::clangd::SymbolOrigin : uint8_t
strong
Enumerator
Unknown 
AST 
Dynamic 
Static 
Merge 

Definition at line 130 of file Index.h.

◆ TextDocumentSyncKind

Defines how the host (editor) should sync document changes to the language server.

Enumerator
None 

Documents should not be synced at all.

Full 

Documents are synced by always sending the full content of the document.

Incremental 

Documents are synced by sending the full content on open.

After that only incremental updates to the document are send.

Definition at line 208 of file Protocol.h.

◆ TraceLevel

Enumerator
Off 
Messages 
Verbose 

Definition at line 194 of file Protocol.h.

◆ WantDiagnostics

Determines whether diagnostics should be generated for a file snapshot.

Enumerator
Yes 
No 

Diagnostics must be generated for this snapshot.

Auto 

Diagnostics must not be generated for this snapshot.

Definition at line 38 of file TUScheduler.h.

Function Documentation

◆ addSystemHeadersMapping()

void clang::clangd::addSystemHeadersMapping ( CanonicalIncludes Includes)

Adds mapping for system headers and some special symbols (e.g.

STL symbols in <iosfwd> need to be mapped individually). Approximately, the following system headers are handled:

  • C++ standard library e.g. bits/basic_string.h$ -> <string>
  • Posix library e.g. bits/pthreadtypes.h$ -> <pthread.h>
  • Compiler extensions, e.g. include/avx512bwintrin.h$ -> <immintrin.h> The mapping is hardcoded and hand-maintained, so it might not cover all headers.

Definition at line 102 of file CanonicalIncludes.cpp.

References clang::clangd::CanonicalIncludes::addRegexMapping(), and clang::clangd::CanonicalIncludes::addSymbolMapping().

◆ adjustKindToCapability()

SymbolKind clang::clangd::adjustKindToCapability ( SymbolKind  Kind,
SymbolKindBitset SupportedSymbolKinds 
)

Definition at line 210 of file Protocol.cpp.

References Class, Enum, EnumMember, Kind, String, Struct, and SymbolKindMin.

◆ Bind()

template<class Func , class... Args>
ForwardBinder<Func, Args...> clang::clangd::Bind ( Func  F,
Args &&...  As 
)

Creates an object that stores a callable (F) and first arguments to the callable (As) and allows to call F with at a later point.

Similar to std::bind, but also works with move-only F and As.

The returned object must be called no more than once, as As are std::forwarded'ed (therefore can be moved) into F during the call.

Definition at line 81 of file Function.h.

Referenced by clang::clangd::ClangdServer::documentSymbols(), clang::clangd::ClangdServer::dumpAST(), clang::clangd::ClangdServer::findDefinitions(), clang::clangd::ClangdServer::findDocumentHighlights(), clang::clangd::ClangdServer::findHover(), and clang::clangd::ClangdServer::signatureHelp().

◆ buildAST()

llvm::Optional< ParsedAST > clang::clangd::buildAST ( PathRef  FileName,
std::unique_ptr< CompilerInvocation >  Invocation,
const ParseInputs Inputs,
std::shared_ptr< const PreambleData Preamble,
std::shared_ptr< PCHContainerOperations >  PCHs 
)

Build an AST from provided user inputs.

This function does not check if preamble can be reused, as this function expects that Preamble is the result of calling buildPreamble.

Definition at line 357 of file ClangdUnit.cpp.

◆ buildCompilerInvocation()

std::unique_ptr< CompilerInvocation > clang::clangd::buildCompilerInvocation ( const ParseInputs Inputs)

Builds compiler invocation that could be used to build AST or preamble.

Definition at line 267 of file ClangdUnit.cpp.

References clang::clangd::ParseInputs::CompileCommand, clang::clangd::ParseInputs::FS, and log().

◆ buildPreamble()

std::shared_ptr< const PreambleData > clang::clangd::buildPreamble ( PathRef  FileName,
CompilerInvocation &  CI,
std::shared_ptr< const PreambleData OldPreamble,
const tooling::CompileCommand &  OldCompileCommand,
const ParseInputs Inputs,
std::shared_ptr< PCHContainerOperations >  PCHs,
bool  StoreInMemory,
PreambleParsedCallback  PreambleCallback 
)

Rebuild the preamble for the new inputs unless the old one can be reused.

If OldPreamble can be reused, it is returned unchanged. If OldPreamble is null, always builds the preamble. If PreambleCallback is set, it will be run on top of the AST while building the preamble. Note that if the old preamble was reused, no AST is built and, therefore, the callback will not be executed.

Definition at line 294 of file ClangdUnit.cpp.

◆ calculateRoles() [1/2]

CharTypeSet clang::clangd::calculateRoles ( llvm::StringRef  Text,
llvm::MutableArrayRef< CharRole Roles 
)

◆ calculateRoles() [2/2]

CharTypeSet clang::clangd::calculateRoles ( StringRef  Text,
MutableArrayRef< CharRole Roles 
)

◆ call()

void clang::clangd::call ( llvm::StringRef  Method,
llvm::json::Value &&  Params 
)

Sends a request to the client.

Current context must derive from JSONRPCDispatcher::Handler.

Referenced by clang::clangd::JSONRPCDispatcher::JSONRPCDispatcher(), and replyError().

◆ canonicalize()

static SmallString<128> clang::clangd::canonicalize ( StringRef  Path)
static

◆ categorize() [1/3]

static SymbolQualitySignals::SymbolCategory clang::clangd::categorize ( const NamedDecl &  ND)
static

Definition at line 57 of file Quality.cpp.

References Constructor, Function, MAP, Namespace, Unknown, and Variable.

Referenced by categorize(), and clang::clangd::SymbolQualitySignals::merge().

◆ categorize() [2/3]

static SymbolQualitySignals::SymbolCategory clang::clangd::categorize ( const CodeCompletionResult &  R)
static

◆ categorize() [3/3]

static SymbolQualitySignals::SymbolCategory clang::clangd::categorize ( const index::SymbolInfo D)
static

◆ codeComplete()

CodeCompleteResult clang::clangd::codeComplete ( PathRef  FileName,
const tooling::CompileCommand &  Command,
PrecompiledPreamble const *  Preamble,
const IncludeStructure PreambleInclusions,
StringRef  Contents,
Position  Pos,
IntrusiveRefCntPtr< vfs::FileSystem >  VFS,
std::shared_ptr< PCHContainerOperations >  PCHs,
CodeCompleteOptions  Opts 
)

Get code completions at a specified Pos in FileName.

Definition at line 1220 of file CodeComplete.cpp.

◆ collectIncludeStructureCallback()

std::unique_ptr< PPCallbacks > clang::clangd::collectIncludeStructureCallback ( const SourceManager &  SM,
IncludeStructure Out 
)

Returns a PPCallback that visits all inclusions in the main file.

Definition at line 74 of file Headers.cpp.

Referenced by clang::clangd::ParsedAST::build().

◆ collectIWYUHeaderMaps()

std::unique_ptr< CommentHandler > clang::clangd::collectIWYUHeaderMaps ( CanonicalIncludes Includes)

Returns a CommentHandler that parses pragma comment on include files to determine when we should include a different header from the header that directly defines a symbol.

Mappinps are registered with Includes.

Currently it only supports IWYU private pragma: https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private

Definition at line 77 of file CanonicalIncludes.cpp.

◆ computeScope()

static SymbolRelevanceSignals::AccessibleScope clang::clangd::computeScope ( const NamedDecl *  D)
static

◆ currentContext()

static Context& clang::clangd::currentContext ( )
static

◆ dumpAST()

void clang::clangd::dumpAST ( ParsedAST AST,
llvm::raw_ostream &  OS 
)

For testing/debugging purposes.

Note that this method deserializes all unserialized Decls, so use with care.

Definition at line 119 of file ClangdUnit.cpp.

References clang::clangd::ParsedAST::getASTContext().

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

◆ elog()

template<typename... Ts>
void clang::clangd::elog ( const char *  Fmt,
Ts &&...  Vals 
)

◆ encodeFloat()

static uint32_t clang::clangd::encodeFloat ( float  F)
static

Definition at line 373 of file Quality.cpp.

Referenced by sortText().

◆ evaluateSymbolAndRelevance()

float clang::clangd::evaluateSymbolAndRelevance ( float  SymbolQuality,
float  SymbolRelevance 
)

Combine symbol quality and relevance into a single score.

Definition at line 367 of file Quality.cpp.

◆ findDefinitions()

std::vector< Location > clang::clangd::findDefinitions ( ParsedAST AST,
Position  Pos,
const SymbolIndex Index 
)

Get definition of symbol at a specified Pos.

Definition at line 216 of file XRefs.cpp.

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

◆ findDocumentHighlights()

std::vector< DocumentHighlight > clang::clangd::findDocumentHighlights ( ParsedAST AST,
Position  Pos 
)

Returns highlights for all usages of a symbol at Pos.

Definition at line 391 of file XRefs.cpp.

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

◆ findNameLoc()

SourceLocation clang::clangd::findNameLoc ( const clang::Decl *  D)

Find the identifier source location of the given D.

The returned location is usually the spelling location where the name of the decl occurs in the code.

Definition at line 20 of file AST.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ formatDocumentation()

std::string clang::clangd::formatDocumentation ( const CodeCompletionString &  CCS,
llvm::StringRef  DocComment 
)

Assembles formatted documentation for a completion result.

This includes documentation comments and other relevant information like annotations.

Parameters
DocCommentis a documentation comment for the original declaration, it should be obtained via getDocComment or getParameterDocComment.

Definition at line 166 of file CodeCompletionStrings.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ fromJSON() [1/81]

bool clang::clangd::fromJSON ( const json::Value E,
URIForFile R 
)

◆ fromJSON() [2/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextDocumentIdentifier R 
)

Definition at line 66 of file Protocol.cpp.

References clang::clangd::TextDocumentIdentifier::uri.

◆ fromJSON() [3/81]

bool clang::clangd::fromJSON ( const json::Value Params,
Position R 
)

◆ fromJSON() [4/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
URIForFile  
)

◆ fromJSON() [5/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextDocumentIdentifier  
)

◆ fromJSON() [6/81]

bool clang::clangd::fromJSON ( const json::Value Params,
Range R 
)

Definition at line 87 of file Protocol.cpp.

References clang::clangd::Range::end, and clang::clangd::Range::start.

◆ fromJSON() [7/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
Position  
)

◆ fromJSON() [8/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextDocumentItem R 
)

◆ fromJSON() [9/81]

bool clang::clangd::fromJSON ( const json::Value Params,
Metadata R 
)

Definition at line 120 of file Protocol.cpp.

References clang::clangd::Metadata::extraFlags.

◆ fromJSON() [10/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextEdit R 
)

◆ fromJSON() [11/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
Range  
)

◆ fromJSON() [12/81]

bool clang::clangd::fromJSON ( const json::Value E,
TraceLevel Out 
)

Definition at line 146 of file Protocol.cpp.

◆ fromJSON() [13/81]

bool clang::clangd::fromJSON ( const json::Value Params,
CompletionItemClientCapabilities R 
)

◆ fromJSON() [14/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
Metadata  
)

◆ fromJSON() [15/81]

bool clang::clangd::fromJSON ( const json::Value Params,
CompletionClientCapabilities R 
)

◆ fromJSON() [16/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextEdit  
)

◆ fromJSON() [17/81]

bool clang::clangd::fromJSON ( const json::Value E,
SymbolKind Out 
)

Definition at line 181 of file Protocol.cpp.

◆ fromJSON() [18/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextDocumentItem  
)

◆ fromJSON() [19/81]

bool clang::clangd::fromJSON ( const json::Value E,
std::vector< SymbolKind > &  Out 
)

Definition at line 192 of file Protocol.cpp.

◆ fromJSON() [20/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  E,
TraceLevel Out 
)

◆ fromJSON() [21/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
NoParams  
)
inline

Definition at line 202 of file Protocol.h.

◆ fromJSON() [22/81]

bool clang::clangd::fromJSON ( const json::Value Params,
SymbolKindCapabilities R 
)

Definition at line 205 of file Protocol.cpp.

References clang::clangd::SymbolKindCapabilities::valueSet.

◆ fromJSON() [23/81]

bool clang::clangd::fromJSON ( const json::Value Params,
WorkspaceSymbolCapabilities R 
)

◆ fromJSON() [24/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
CompletionItemClientCapabilities  
)

◆ fromJSON() [25/81]

bool clang::clangd::fromJSON ( const json::Value Params,
WorkspaceClientCapabilities R 
)

Definition at line 233 of file Protocol.cpp.

References clang::clangd::WorkspaceClientCapabilities::symbol.

◆ fromJSON() [26/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextDocumentClientCapabilities R 
)

◆ fromJSON() [27/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
CompletionClientCapabilities  
)

◆ fromJSON() [28/81]

bool clang::clangd::fromJSON ( const json::Value Params,
ClientCapabilities R 
)

◆ fromJSON() [29/81]

bool clang::clangd::fromJSON ( const json::Value Params,
InitializeParams R 
)

◆ fromJSON() [30/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DidOpenTextDocumentParams R 
)

◆ fromJSON() [31/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DidCloseTextDocumentParams R 
)

◆ fromJSON() [32/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
SymbolKind  
)

◆ fromJSON() [33/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DidChangeTextDocumentParams R 
)

◆ fromJSON() [34/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
std::vector< SymbolKind > &   
)

◆ fromJSON() [35/81]

bool clang::clangd::fromJSON ( const json::Value E,
FileChangeType Out 
)

Definition at line 288 of file Protocol.cpp.

◆ fromJSON() [36/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
SymbolKindCapabilities  
)

◆ fromJSON() [37/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
WorkspaceSymbolCapabilities  
)

◆ fromJSON() [38/81]

bool clang::clangd::fromJSON ( const json::Value Params,
FileEvent R 
)

Definition at line 299 of file Protocol.cpp.

References clang::clangd::FileEvent::type, and clang::clangd::FileEvent::uri.

◆ fromJSON() [39/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DidChangeWatchedFilesParams R 
)

Definition at line 304 of file Protocol.cpp.

References clang::clangd::DidChangeWatchedFilesParams::changes.

◆ fromJSON() [40/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
WorkspaceClientCapabilities  
)

◆ fromJSON() [41/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextDocumentContentChangeEvent R 
)

◆ fromJSON() [42/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextDocumentClientCapabilities  
)

◆ fromJSON() [43/81]

bool clang::clangd::fromJSON ( const json::Value Params,
FormattingOptions R 
)

◆ fromJSON() [44/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
ClientCapabilities  
)

◆ fromJSON() [45/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DocumentRangeFormattingParams R 
)

◆ fromJSON() [46/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
ClangdConfigurationParamsChange  
)

◆ fromJSON() [47/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DocumentOnTypeFormattingParams R 
)

◆ fromJSON() [48/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DocumentFormattingParams R 
)

◆ fromJSON() [49/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DocumentSymbolParams R 
)

Definition at line 347 of file Protocol.cpp.

References clang::clangd::DocumentSymbolParams::textDocument.

◆ fromJSON() [50/81]

bool clang::clangd::fromJSON ( const json::Value Params,
Diagnostic R 
)

◆ fromJSON() [51/81]

bool clang::clangd::fromJSON ( const json::Value Params,
CodeActionContext R 
)

Definition at line 360 of file Protocol.cpp.

References clang::clangd::CodeActionContext::diagnostics.

◆ fromJSON() [52/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
InitializeParams  
)

◆ fromJSON() [53/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DidOpenTextDocumentParams  
)

◆ fromJSON() [54/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DidCloseTextDocumentParams  
)

◆ fromJSON() [55/81]

bool clang::clangd::fromJSON ( const json::Value Params,
CodeActionParams R 
)

◆ fromJSON() [56/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextDocumentContentChangeEvent  
)

◆ fromJSON() [57/81]

bool clang::clangd::fromJSON ( const json::Value Params,
WorkspaceEdit R 
)

◆ fromJSON() [58/81]

bool clang::clangd::fromJSON ( const json::Value Params,
ExecuteCommandParams R 
)

Definition at line 400 of file Protocol.cpp.

References clang::clangd::ExecuteCommandParams::command.

◆ fromJSON() [59/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DidChangeTextDocumentParams  
)

◆ fromJSON() [60/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  E,
FileChangeType Out 
)

◆ fromJSON() [61/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
FileEvent  
)

◆ fromJSON() [62/81]

bool clang::clangd::fromJSON ( const json::Value Params,
WorkspaceSymbolParams R 
)

Definition at line 428 of file Protocol.cpp.

References clang::clangd::WorkspaceSymbolParams::query.

◆ fromJSON() [63/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DidChangeWatchedFilesParams  
)

◆ fromJSON() [64/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DidChangeConfigurationParams  
)

◆ fromJSON() [65/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
FormattingOptions  
)

◆ fromJSON() [66/81]

bool clang::clangd::fromJSON ( const json::Value Params,
TextDocumentPositionParams R 
)

◆ fromJSON() [67/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DocumentRangeFormattingParams  
)

◆ fromJSON() [68/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DocumentOnTypeFormattingParams  
)

◆ fromJSON() [69/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DocumentFormattingParams  
)

◆ fromJSON() [70/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
DocumentSymbolParams  
)

◆ fromJSON() [71/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
Diagnostic  
)

◆ fromJSON() [72/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
CodeActionContext  
)

◆ fromJSON() [73/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
CodeActionParams  
)

◆ fromJSON() [74/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
WorkspaceEdit  
)

◆ fromJSON() [75/81]

bool clang::clangd::fromJSON ( const json::Value Params,
RenameParams R 
)

◆ fromJSON() [76/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
ExecuteCommandParams  
)

◆ fromJSON() [77/81]

bool clang::clangd::fromJSON ( const json::Value Params,
DidChangeConfigurationParams CCP 
)

◆ fromJSON() [78/81]

bool clang::clangd::fromJSON ( const json::Value Params,
ClangdConfigurationParamsChange CCPC 
)

◆ fromJSON() [79/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
WorkspaceSymbolParams  
)

◆ fromJSON() [80/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
TextDocumentPositionParams  
)

◆ fromJSON() [81/81]

bool clang::clangd::fromJSON ( const llvm::json::Value &  ,
RenameParams  
)

◆ getAbsoluteFilePath()

llvm::Optional< std::string > clang::clangd::getAbsoluteFilePath ( const FileEntry *  F,
const SourceManager &  SourceMgr 
)

Get the absolute file path of a given file entry.

Definition at line 189 of file SourceCode.cpp.

◆ getBeginningOfIdentifier()

SourceLocation clang::clangd::getBeginningOfIdentifier ( ParsedAST Unit,
const Position Pos,
const FileID  FID 
)

Get the beginning SourceLocation at a specified Pos.

May be invalid if Pos is, or if there's no identifier.

Definition at line 375 of file ClangdUnit.cpp.

References AST, and clang::clangd::ParsedAST::getASTContext().

◆ getDeducedType()

llvm::Optional<QualType> clang::clangd::getDeducedType ( ParsedAST AST,
SourceLocation  SourceLocationBeg 
)

Retrieves the deduced type at a given location (auto, decltype).

Definition at line 631 of file XRefs.cpp.

◆ getDefaultAsyncThreadsCount()

unsigned clang::clangd::getDefaultAsyncThreadsCount ( )

Returns a number of a default async threads to use for TUScheduler.

Returned value is always >= 1 (i.e. will not cause requests to be processed synchronously).

Definition at line 603 of file TUScheduler.cpp.

◆ getDocComment()

std::string clang::clangd::getDocComment ( const ASTContext &  Ctx,
const CodeCompletionResult &  Result,
bool  CommentsFromHeaders 
)

Gets a minimally formatted documentation comment of Result, with comment markers stripped.

See clang::RawComment::getFormattedText() for the detailed explanation of how the comment text is transformed. Returns empty string when no comment is available. If CommentsFromHeaders parameter is set, only comments from the main file will be returned. It is used to workaround crashes when parsing comments in the stale headers, coming from completion preamble.

Definition at line 46 of file CodeCompletionStrings.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ getDocumentSymbols()

llvm::Expected< std::vector< SymbolInformation > > clang::clangd::getDocumentSymbols ( ParsedAST AST)

Retrieves the symbols contained in the "main file" section of an AST in the same order that they appear.

Definition at line 265 of file FindSymbols.cpp.

References clang::clangd::ParsedAST::getASTContext(), and clang::clangd::ParsedAST::getLocalTopLevelDecls().

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

◆ getHover()

llvm::Optional< Hover > clang::clangd::getHover ( ParsedAST AST,
Position  Pos 
)

Get the hover information when hovering at Pos.

Definition at line 652 of file XRefs.cpp.

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

◆ getHoverContents() [1/3]

static Hover clang::clangd::getHoverContents ( const Decl *  D)
static

Generate a Hover object given the declaration D.

Definition at line 474 of file XRefs.cpp.

References clang::clangd::Hover::contents, getScopeName(), printingPolicyForDecls(), and clang::clangd::MarkupContent::value.

◆ getHoverContents() [2/3]

static Hover clang::clangd::getHoverContents ( QualType  T,
ASTContext &  ASTCtx 
)
static

Generate a Hover object given the type T.

Definition at line 506 of file XRefs.cpp.

◆ getHoverContents() [3/3]

static Hover clang::clangd::getHoverContents ( StringRef  MacroName)
static

Generate a Hover object given the macro MacroInf.

Definition at line 518 of file XRefs.cpp.

References clang::clangd::Hover::contents, and clang::clangd::MarkupContent::value.

◆ getParameterDocComment()

std::string clang::clangd::getParameterDocComment ( const ASTContext &  Ctx,
const CodeCompleteConsumer::OverloadCandidate &  Result,
unsigned  ArgIndex,
bool  CommentsFromHeaders 
)

Gets a minimally formatted documentation for parameter of Result, corresponding to argument number ArgIndex.

This currently looks for comments attached to the parameter itself, and doesn't extract them from function documentation. Returns empty string when no comment is available. If CommentsFromHeaders parameter is set, only comments from the main file will be returned. It is used to workaround crashes when parsing comments in the stale headers, coming from completion preamble.

Definition at line 76 of file CodeCompletionStrings.cpp.

◆ getReturnType()

std::string clang::clangd::getReturnType ( const CodeCompletionString &  CCS)

Gets detail to be used as the detail field in an LSP completion item.

This is usually the return type of a function.

Definition at line 196 of file CodeCompletionStrings.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ getScopeName()

static llvm::Optional<std::string> clang::clangd::getScopeName ( const Decl *  D)
static

Given a declaration D, return a human-readable string representing the scope in which it is declared.

If the declaration is in the global scope, return the string "global namespace".

Definition at line 458 of file XRefs.cpp.

References namedDeclQualifiedName(), None, and typeDeclToString().

Referenced by getHoverContents().

◆ getSeverity()

int clang::clangd::getSeverity ( DiagnosticsEngine::Level  L)

Convert from clang diagnostic level to LSP severity.

Definition at line 249 of file Diagnostics.cpp.

Referenced by toLSPDiags().

◆ getSignature()

void clang::clangd::getSignature ( const CodeCompletionString &  CCS,
std::string *  Signature,
std::string *  Snippet,
std::string *  RequiredQualifiers = nullptr 
)

Formats the signature for an item, as a display string and snippet.

e.g. for const_reference std::vector<T>::at(size_type) const, this returns: *Signature = "(size_type) const" *Snippet = "(${0:size_type})" If set, RequiredQualifiers is the text that must be typed before the name. e.g "Base::" when calling a base class member function that's hidden.

Definition at line 94 of file CodeCompletionStrings.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ getWorkspaceSymbols() [1/2]

llvm::Expected<std::vector<SymbolInformation> > clang::clangd::getWorkspaceSymbols ( llvm::StringRef  Query,
int  Limit,
const SymbolIndex *const  Index,
llvm::StringRef  HintPath 
)

Searches for the symbols matching Query.

The syntax of Query can be the non-qualified name or fully qualified of a symbol. For example, "vector" will match the symbol std::vector and "std::vector" would also match it. Direct children of scopes (namepaces, etc) can be listed with a trailing "::". For example, "std::" will list all children of the std namespace and "::" alone will list all children of the global namespace. Limit limits the number of results returned (0 means no limit). HintPath This is used when resolving URIs. If empty, URI resolution can fail if a hint path is required for the scheme of a specific URI.

◆ getWorkspaceSymbols() [2/2]

llvm::Expected<std::vector<SymbolInformation> > clang::clangd::getWorkspaceSymbols ( StringRef  Query,
int  Limit,
const SymbolIndex *const  Index,
StringRef  HintPath 
)

Definition at line 102 of file FindSymbols.cpp.

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

◆ halfOpenToRange()

Range clang::clangd::halfOpenToRange ( const SourceManager &  SM,
CharSourceRange  R 
)

Definition at line 147 of file SourceCode.cpp.

◆ hasDeclInMainFile()

static bool clang::clangd::hasDeclInMainFile ( const Decl &  D)
static

Definition at line 36 of file Quality.cpp.

Referenced by clang::clangd::SymbolRelevanceSignals::merge().

◆ hasUsingDeclInMainFile()

static bool clang::clangd::hasUsingDeclInMainFile ( const CodeCompletionResult &  R)
static

Definition at line 46 of file Quality.cpp.

Referenced by clang::clangd::SymbolRelevanceSignals::merge().

◆ indexAST()

SymbolSlab clang::clangd::indexAST ( ASTContext &  AST,
std::shared_ptr< Preprocessor >  PP,
llvm::ArrayRef< std::string >  URISchemes = {} 
)

Retrieves namespace and class level symbols in AST.

Exposed to assist in unit tests. If URISchemes is empty, the default schemes in SymbolCollector will be used.

Definition at line 18 of file FileIndex.cpp.

◆ isAwful()

static bool clang::clangd::isAwful ( int  S)
static

◆ isIndexedForCodeCompletion()

bool clang::clangd::isIndexedForCodeCompletion ( const NamedDecl &  ND,
ASTContext &  ASTCtx 
)

Definition at line 1252 of file CodeComplete.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ isInstanceMember() [1/2]

static bool clang::clangd::isInstanceMember ( const NamedDecl *  ND)
static

Definition at line 148 of file Quality.cpp.

Referenced by clang::clangd::SymbolRelevanceSignals::merge().

◆ isInstanceMember() [2/2]

static bool clang::clangd::isInstanceMember ( const index::SymbolInfo D)
static

Definition at line 158 of file Quality.cpp.

◆ isLiteralInclude()

bool clang::clangd::isLiteralInclude ( llvm::StringRef  Include)

Returns true if Include is literal include like "path" or <path>.

Definition at line 64 of file Headers.cpp.

Referenced by clang::clangd::HeaderFile::valid().

◆ isReserved()

static bool clang::clangd::isReserved ( StringRef  Name)
static

Definition at line 30 of file Quality.cpp.

Referenced by clang::clangd::SymbolQualitySignals::merge().

◆ iterateCodepoints()

template<typename Callback >
static bool clang::clangd::iterateCodepoints ( StringRef  U8,
const Callback CB 
)
static

Definition at line 30 of file SourceCode.cpp.

Referenced by measureUTF16(), and utf16Len().

◆ log()

template<typename... Ts>
void clang::clangd::log ( const char *  Fmt,
Ts &&...  Vals 
)

◆ lower()

static char clang::clangd::lower ( char  C)
static

◆ measureUTF16()

static size_t clang::clangd::measureUTF16 ( StringRef  U8,
int  U16Units,
bool &  Valid 
)
static

Definition at line 57 of file SourceCode.cpp.

References iterateCodepoints().

Referenced by positionToOffset().

◆ mergeIndex()

std::unique_ptr< SymbolIndex > clang::clangd::mergeIndex ( const SymbolIndex Dynamic,
const SymbolIndex Static 
)

Definition at line 123 of file Merge.cpp.

References Dynamic, and Static.

◆ mergeSymbol()

Symbol clang::clangd::mergeSymbol ( const Symbol L,
const Symbol R,
Symbol::Details Scratch 
)

◆ namedDeclQualifiedName()

static std::string clang::clangd::namedDeclQualifiedName ( const NamedDecl *  ND,
StringRef  Prefix 
)
static

Return a string representation (e.g.

"namespace ns1::ns2") of the named declaration ND.

Definition at line 442 of file XRefs.cpp.

References Name, and printingPolicyForDecls().

Referenced by getScopeName().

◆ offsetToClangLineColumn() [1/2]

std::pair<size_t, size_t> clang::clangd::offsetToClangLineColumn ( llvm::StringRef  Code,
size_t  Offset 
)

◆ offsetToClangLineColumn() [2/2]

std::pair<size_t, size_t> clang::clangd::offsetToClangLineColumn ( StringRef  Code,
size_t  Offset 
)

Definition at line 155 of file SourceCode.cpp.

References Lines.

◆ offsetToPosition() [1/2]

Position clang::clangd::offsetToPosition ( llvm::StringRef  Code,
size_t  Offset 
)

Turn an offset in Code into a [line, column] pair.

The offset must be in range [0, Code.size()].

◆ offsetToPosition() [2/2]

Position clang::clangd::offsetToPosition ( StringRef  Code,
size_t  Offset 
)

◆ operator &()

SymbolOrigin clang::clangd::operator& ( SymbolOrigin  A,
SymbolOrigin  B 
)
inline

Definition at line 145 of file Index.h.

References operator<<().

◆ operator<()

bool clang::clangd::operator< ( const CompletionItem L,
const CompletionItem R 
)

◆ operator<<() [1/26]

raw_ostream& clang::clangd::operator<< ( raw_ostream &  OS,
const SymbolLocation L 
)

◆ operator<<() [2/26]

raw_ostream& clang::clangd::operator<< ( raw_ostream &  OS,
const SymbolID ID 
)

Definition at line 29 of file Index.cpp.

◆ operator<<() [3/26]

raw_ostream & clang::clangd::operator<< ( raw_ostream &  OS,
SymbolOrigin  O 
)

Definition at line 47 of file Index.cpp.

References Unknown.

◆ operator<<() [4/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  ,
const SymbolLocation  
)

◆ operator<<() [5/26]

raw_ostream& clang::clangd::operator<< ( raw_ostream &  OS,
const Symbol S 
)

Definition at line 57 of file Index.cpp.

References clang::clangd::Symbol::Name, and clang::clangd::Symbol::Scope.

◆ operator<<() [6/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const URIForFile U 
)

Definition at line 58 of file Protocol.cpp.

References clang::clangd::URIForFile::uri().

◆ operator<<() [7/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  ,
const SymbolQualitySignals  
)

◆ operator<<() [8/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Position P 
)

◆ operator<<() [9/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const SymbolID ID 
)

◆ operator<<() [10/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Range R 
)

Definition at line 99 of file Protocol.cpp.

References clang::clangd::Range::end, and clang::clangd::Range::start.

◆ operator<<() [11/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Location L 
)

Definition at line 110 of file Protocol.cpp.

References clang::clangd::Location::range, and clang::clangd::Location::uri.

◆ operator<<() [12/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  ,
const SymbolRelevanceSignals  
)

◆ operator<<() [13/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const TextEdit TE 
)

◆ operator<<() [14/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const DiagBase D 
)

◆ operator<<() [15/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Fix F 
)

Definition at line 192 of file Diagnostics.cpp.

References clang::clangd::Fix::Message.

◆ operator<<() [16/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Diag D 
)

Definition at line 202 of file Diagnostics.cpp.

References clang::clangd::Diag::Notes.

◆ operator<<() [17/26]

llvm::raw_ostream& clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Symbol S 
)

◆ operator<<() [18/26]

raw_ostream& clang::clangd::operator<< ( raw_ostream &  OS,
const SymbolQualitySignals S 
)

◆ operator<<() [19/26]

raw_ostream& clang::clangd::operator<< ( raw_ostream &  OS,
const SymbolRelevanceSignals S 
)

◆ operator<<() [20/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  OS,
const Diagnostic D 
)

◆ operator<<() [21/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  O,
const SymbolInformation SI 
)

◆ operator<<() [22/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  O,
const CompletionItem I 
)

Definition at line 512 of file Protocol.cpp.

References clang::clangd::CompletionItem::label, and toJSON().

◆ operator<<() [23/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  O,
const SignatureInformation I 
)

Definition at line 548 of file Protocol.cpp.

References clang::clangd::SignatureInformation::label, and toJSON().

◆ operator<<() [24/26]

llvm::raw_ostream & clang::clangd::operator<< ( llvm::raw_ostream &  O,
const DocumentHighlight V 
)

◆ operator<<() [25/26]

raw_ostream & clang::clangd::operator<< ( raw_ostream &  OS,
const CodeCompletion C 
)

◆ operator<<() [26/26]

raw_ostream & clang::clangd::operator<< ( raw_ostream &  OS,
const CodeCompleteResult R 
)

◆ operator>>() [1/2]

void clang::clangd::operator>> ( StringRef  Str,
SymbolID ID 
)

Definition at line 41 of file Index.cpp.

◆ operator>>() [2/2]

void clang::clangd::operator>> ( llvm::StringRef  HexStr,
SymbolID ID 
)

◆ operator|()

SymbolOrigin clang::clangd::operator| ( SymbolOrigin  A,
SymbolOrigin  B 
)
inline

Definition at line 138 of file Index.h.

◆ operator|=()

SymbolOrigin& clang::clangd::operator|= ( SymbolOrigin A,
SymbolOrigin  B 
)
inline

Definition at line 142 of file Index.h.

◆ own()

static void clang::clangd::own ( Symbol S,
DenseSet< StringRef > &  Strings,
BumpPtrAllocator &  Arena 
)
static

Definition at line 80 of file Index.cpp.

◆ packedLookup()

template<typename T >
static T clang::clangd::packedLookup ( const uint8_t *  Data,
int  I 
)
static

Definition at line 153 of file FuzzyMatch.cpp.

◆ positionToOffset() [1/2]

llvm::Expected<size_t> clang::clangd::positionToOffset ( llvm::StringRef  Code,
Position  P,
bool  AllowColumnsBeyondLineLength = true 
)

Turn a [line, column] pair into an offset in Code.

If P.character exceeds the line length, returns the offset at end-of-line. (If !AllowColumnsBeyondLineLength, then returns an error instead). If the line number is out of range, returns an error.

The returned value is in the range [0, Code.size()].

◆ positionToOffset() [2/2]

llvm::Expected<size_t> clang::clangd::positionToOffset ( StringRef  Code,
Position  P,
bool  AllowColumnsBeyondLineLength 
)

◆ prepareCompilerInstance()

std::unique_ptr< CompilerInstance > clang::clangd::prepareCompilerInstance ( std::unique_ptr< clang::CompilerInvocation >  ,
const PrecompiledPreamble *  ,
std::unique_ptr< llvm::MemoryBuffer >  MainFile,
std::shared_ptr< PCHContainerOperations >  ,
IntrusiveRefCntPtr< vfs::FileSystem >  ,
DiagnosticConsumer  
)

Creates a compiler instance, configured so that:

  • Contents of the parsed file are remapped to MainFile.
  • Preamble is overriden to use PCH passed to this function. It means the changes to the preamble headers or files included in the preamble are not visible to this compiler instance.
  • vfs::FileSystem is used for all underlying file accesses. The actual vfs used by the compiler may be an overlay over the passed vfs. Returns null on errors. When non-null value is returned, it is expected to be consumed by FrontendAction::BeginSourceFile to properly destroy MainFile.

Definition at line 43 of file Compiler.cpp.

References PCHs, and VFS.

Referenced by clang::clangd::ParsedAST::build().

◆ printingPolicyForDecls()

static PrintingPolicy clang::clangd::printingPolicyForDecls ( PrintingPolicy  Base)
static

Definition at line 413 of file XRefs.cpp.

Referenced by getHoverContents(), namedDeclQualifiedName(), and typeDeclToString().

◆ printQualifiedName()

std::string clang::clangd::printQualifiedName ( const NamedDecl &  ND)

Returns the qualified name of ND.

The scope doesn't contain unwritten scopes like inline namespaces.

Definition at line 41 of file AST.cpp.

Referenced by clang::clangd::SymbolCollector::finish().

◆ proximityScore()

static std::pair<float, unsigned> clang::clangd::proximityScore ( llvm::StringRef  SymbolURI,
URIDistance D 
)
static

◆ quality()

double clang::clangd::quality ( const Symbol S)

◆ registerCallbackHandlers()

void clang::clangd::registerCallbackHandlers ( JSONRPCDispatcher Dispatcher,
ProtocolCallbacks Callbacks 
)

◆ replacementsToEdits()

std::vector< TextEdit > clang::clangd::replacementsToEdits ( StringRef  Code,
const tooling::Replacements &  Repls 
)

Definition at line 180 of file SourceCode.cpp.

◆ replacementToEdit()

TextEdit clang::clangd::replacementToEdit ( StringRef  Code,
const tooling::Replacement &  R 
)

Definition at line 173 of file SourceCode.cpp.

References offsetToPosition().

Referenced by clang::clangd::IncludeInserter::insert().

◆ reply()

void clang::clangd::reply ( llvm::json::Value &&  Result)

Sends a successful reply.

Current context must derive from JSONRPCDispatcher::Handler.

Referenced by clang::clangd::JSONOutput::mirrorInput().

◆ replyError()

void clang::clangd::replyError ( ErrorCode  Code,
const llvm::StringRef &  Message 
)

Sends an error response to the client, and logs it.

Current context must derive from JSONRPCDispatcher::Handler.

Definition at line 112 of file JSONRPCDispatcher.cpp.

References call(), elog(), clang::clangd::detail::log(), and Method.

Referenced by clang::clangd::ClangdLSPServer::run().

◆ runLanguageServerLoop()

void clang::clangd::runLanguageServerLoop ( std::FILE *  In,
JSONOutput Out,
JSONStreamStyle  InputStyle,
JSONRPCDispatcher Dispatcher,
bool &  IsDone 
)

Parses input queries from LSP client (coming from In) and runs call method of Dispatcher for each query.

After handling each query checks if IsDone is set true and exits the loop if it is. Input stream(In) must be opened in binary mode to avoid preliminary replacements of
with
. We use C-style FILE* for reading as std::istream has unclear interaction with signals, which are sent by debuggers on some OSs.

Definition at line 343 of file JSONRPCDispatcher.cpp.

Referenced by clang::clangd::ClangdLSPServer::run().

◆ signatureHelp()

SignatureHelp clang::clangd::signatureHelp ( PathRef  FileName,
const tooling::CompileCommand &  Command,
PrecompiledPreamble const *  Preamble,
StringRef  Contents,
Position  Pos,
IntrusiveRefCntPtr< vfs::FileSystem >  VFS,
std::shared_ptr< PCHContainerOperations >  PCHs 
)

Get signature help at a specified Pos in FileName.

Definition at line 1232 of file CodeComplete.cpp.

References Command, Contents, FileName, Pos, and Preamble.

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

◆ sortText()

std::string clang::clangd::sortText ( float  Score,
llvm::StringRef  Tiebreak = "" 
)

Returns a string that sorts in the same order as (-Score, Tiebreak), for LSP.

(The highest score compares smallest so it sorts at the top).

Definition at line 385 of file Quality.cpp.

References encodeFloat(), Lower, and Name.

Referenced by clang::clangd::TopN< T, Compare >::items().

◆ sourceLocToPosition()

Position clang::clangd::sourceLocToPosition ( const SourceManager &  SM,
SourceLocation  Loc 
)

Turn a SourceLocation into a [line, column] pair.

FIXME: This should return an error if the location is invalid.

Definition at line 130 of file SourceCode.cpp.

◆ splitQualifiedName()

std::pair< llvm::StringRef, llvm::StringRef > clang::clangd::splitQualifiedName ( llvm::StringRef  QName)

From "a::b::c", return {"a::b::", "c"}.

Scope is empty if there's no qualifier.

Definition at line 166 of file SourceCode.cpp.

References Pos.

Referenced by clang::clangd::SymbolCollector::finish().

◆ SymbolFromYAML()

Symbol clang::clangd::SymbolFromYAML ( llvm::yaml::Input &  Input,
llvm::BumpPtrAllocator &  Arena 
)

Definition at line 184 of file SymbolYAML.cpp.

◆ symbolsFromYAML()

SymbolSlab clang::clangd::symbolsFromYAML ( llvm::StringRef  YAMLContent)

Definition at line 171 of file SymbolYAML.cpp.

References clang::clangd::SymbolSlab::Builder::insert().

◆ SymbolsToYAML()

void clang::clangd::SymbolsToYAML ( const SymbolSlab Symbols,
llvm::raw_ostream &  OS 
)

Definition at line 192 of file SymbolYAML.cpp.

Referenced by main().

◆ SymbolToYAML()

std::string clang::clangd::SymbolToYAML ( Symbol  Sym)

Definition at line 198 of file SymbolYAML.cpp.

◆ timeoutSeconds()

Deadline clang::clangd::timeoutSeconds ( llvm::Optional< double >  Seconds)

Makes a deadline from a timeout in seconds. None means wait forever.

Definition at line 82 of file Threading.cpp.

References clang::clangd::Deadline::infinity().

Referenced by clang::clangd::ClangdServer::blockUntilIdleForTest(), and clang::clangd::Deadline::operator==().

◆ toJSON() [1/19]

llvm::json::Value clang::clangd::toJSON ( const URIForFile U)

Serialize/deserialize URIForFile to/from a string URI.

Definition at line 56 of file Protocol.cpp.

References clang::clangd::URIForFile::uri().

Referenced by clang::clangd::Range::contains(), operator<<(), and toJSON().

◆ toJSON() [2/19]

llvm::json::Value clang::clangd::toJSON ( const TextDocumentIdentifier R)

Definition at line 62 of file Protocol.cpp.

References Object, and clang::clangd::TextDocumentIdentifier::uri.

◆ toJSON() [3/19]

llvm::json::Value clang::clangd::toJSON ( const Position P)

◆ toJSON() [4/19]

llvm::json::Value clang::clangd::toJSON ( const Range P)

Definition at line 92 of file Protocol.cpp.

References clang::clangd::Range::end, Object, and clang::clangd::Range::start.

◆ toJSON() [5/19]

llvm::json::Value clang::clangd::toJSON ( const Location P)

◆ toJSON() [6/19]

llvm::json::Value clang::clangd::toJSON ( const TextEdit P)

◆ toJSON() [7/19]

llvm::json::Value clang::clangd::toJSON ( const FormattingOptions P)

◆ toJSON() [8/19]

llvm::json::Value clang::clangd::toJSON ( const SymbolInformation P)

◆ toJSON() [9/19]

llvm::json::Value clang::clangd::toJSON ( const Command C)

◆ toJSON() [10/19]

llvm::json::Value clang::clangd::toJSON ( const WorkspaceEdit WE)

Definition at line 440 of file Protocol.cpp.

References Array, clang::clangd::WorkspaceEdit::changes, and Object.

◆ toJSON() [11/19]

llvm::json::Value clang::clangd::toJSON ( const ApplyWorkspaceEditParams Params)

Definition at line 449 of file Protocol.cpp.

References clang::clangd::ApplyWorkspaceEditParams::edit, and Object.

◆ toJSON() [12/19]

llvm::json::Value clang::clangd::toJSON ( const MarkupContent MC)

◆ toJSON() [13/19]

llvm::json::Value clang::clangd::toJSON ( const Hover H)

◆ toJSON() [14/19]

llvm::json::Value clang::clangd::toJSON ( const CompletionItem CI)

◆ toJSON() [15/19]

llvm::json::Value clang::clangd::toJSON ( const CompletionList L)

◆ toJSON() [16/19]

llvm::json::Value clang::clangd::toJSON ( const ParameterInformation PI)

◆ toJSON() [17/19]

llvm::json::Value clang::clangd::toJSON ( const SignatureInformation SI)

◆ toJSON() [18/19]

llvm::json::Value clang::clangd::toJSON ( const SignatureHelp SH)

◆ toJSON() [19/19]

llvm::json::Value clang::clangd::toJSON ( const DocumentHighlight DH)

◆ toLSPDiags()

void clang::clangd::toLSPDiags ( const Diag D,
llvm::function_ref< void(clangd::Diagnostic, llvm::ArrayRef< Fix >)>  OutFn 
)

Conversion to LSP diagnostics.

Formats the error message of each diagnostic to include all its notes. Notes inside main file are also provided as separate diagnostics with their corresponding fixits. Notes outside main file do not have a corresponding LSP diagnostic, but can still be included as part of their main diagnostic's message.

Definition at line 224 of file Diagnostics.cpp.

References clang::clangd::Diag::Fixes, getSeverity(), clang::clangd::DiagBase::InsideMainFile, clang::clangd::Diagnostic::message, clang::clangd::Diag::Notes, clang::clangd::DiagBase::Range, clang::clangd::Diagnostic::range, clang::clangd::DiagBase::Severity, and clang::clangd::Diagnostic::severity.

Referenced by clang::clangd::ClangdLSPServer::run().

◆ toTextKind()

static StringRef clang::clangd::toTextKind ( MarkupKind  Kind)
static

Definition at line 459 of file Protocol.cpp.

References Markdown, and PlainText.

Referenced by toJSON().

◆ typeDeclToString()

static std::string clang::clangd::typeDeclToString ( const TypeDecl *  TD)
static

Return a string representation (e.g.

"class MyNamespace::MyClass") of the type declaration TD.

Definition at line 427 of file XRefs.cpp.

References Name, and printingPolicyForDecls().

Referenced by getScopeName().

◆ utf16Len()

static size_t clang::clangd::utf16Len ( StringRef  U8)
static

Definition at line 72 of file SourceCode.cpp.

References iterateCodepoints().

Referenced by offsetToPosition().

◆ vlog()

template<typename... Ts>
void clang::clangd::vlog ( const char *  Fmt,
Ts &&...  Vals 
)

◆ wait() [1/2]

template<typename Func >
LLVM_NODISCARD bool clang::clangd::wait ( std::unique_lock< std::mutex > &  Lock,
std::condition_variable &  CV,
Deadline  D,
Func  F 
)

Waits on a condition variable until F() is true or D expires.

Definition at line 90 of file Threading.h.

References clang::clangd::Deadline::expired(), and clang::clangd::Notification::wait().

◆ wait() [2/2]

void clang::clangd::wait ( std::unique_lock< std::mutex > &  Lock,
std::condition_variable &  CV,
Deadline  D 
)

Variable Documentation

◆ AwfulScore

constexpr int clang::clangd::AwfulScore = -(1 << 13)
static

Definition at line 74 of file FuzzyMatch.cpp.

Referenced by calculateRoles(), and clang::clangd::FuzzyMatcher::FuzzyMatcher().

◆ CharRoles

constexpr uint8_t clang::clangd::CharRoles[]
static
Initial value:
= {
0x00, 0xaa, 0xaa, 0xff,
0x00, 0x55, 0xaa, 0xff,
0x00, 0x55, 0x59, 0xff,
0x00, 0xaa, 0xaa, 0xff,
}

Definition at line 143 of file FuzzyMatch.cpp.

Referenced by calculateRoles().

◆ CharTypes

constexpr uint8_t clang::clangd::CharTypes[]
static
Initial value:
= {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff,
0x55, 0x55, 0xf5, 0xff,
0xab, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xea, 0xff,
0x57, 0x55, 0x55, 0x55,
0x55, 0x55, 0xd5, 0x3f,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
}

Definition at line 116 of file FuzzyMatch.cpp.

Referenced by calculateRoles().

◆ PerfectBonus

constexpr int clang::clangd::PerfectBonus = 3
static

Definition at line 76 of file FuzzyMatch.cpp.

◆ SymbolKindMax

constexpr auto clang::clangd::SymbolKindMax = static_cast<size_t>(SymbolKind::TypeParameter)

Definition at line 277 of file Protocol.h.

◆ SymbolKindMin

constexpr auto clang::clangd::SymbolKindMin = static_cast<size_t>(SymbolKind::File)

Definition at line 276 of file Protocol.h.

Referenced by adjustKindToCapability().