clang-tools 20.0.0git
Public Member Functions | Public Attributes | Protected Attributes | List of all members
clang::clangd::MockCompilationDatabase Class Reference

#include <TestFS.h>

Inheritance diagram for clang::clangd::MockCompilationDatabase:
Inheritance graph
[legend]

Public Member Functions

 MockCompilationDatabase (StringRef Directory=StringRef(), StringRef RelPathPrefix=StringRef())
 If Directory is not empty, use that as the Directory field of the CompileCommand, and as project SourceRoot.
 
std::optional< tooling::CompileCommand > getCompileCommand (PathRef File) const override
 If there are any known-good commands for building this file, returns one.
 
std::optional< ProjectInfogetProjectInfo (PathRef File) const override
 Finds the closest project to File.
 
- Public Member Functions inherited from clang::clangd::GlobalCompilationDatabase
virtual ~GlobalCompilationDatabase ()=default
 
virtual std::optional< tooling::CompileCommand > getCompileCommand (PathRef File) const =0
 If there are any known-good commands for building this file, returns one.
 
virtual std::optional< ProjectInfogetProjectInfo (PathRef File) const
 Finds the closest project to File.
 
virtual std::unique_ptr< ProjectModulesgetProjectModules (PathRef File) const
 Get the modules in the closest project to File.
 
virtual tooling::CompileCommand getFallbackCommand (PathRef File) const
 Makes a guess at how to build a file.
 
virtual bool blockUntilIdle (Deadline D) const
 If the CDB does any asynchronous work, wait for it to complete.
 
CommandChanged::Subscription watch (CommandChanged::Listener L) const
 The callback is notified when files may have new compile commands.
 

Public Attributes

std::vector< std::string > ExtraClangFlags
 

Protected Attributes

StringRef Directory
 
StringRef RelPathPrefix
 
- Protected Attributes inherited from clang::clangd::GlobalCompilationDatabase
CommandChanged OnCommandChanged
 

Additional Inherited Members

- Public Types inherited from clang::clangd::GlobalCompilationDatabase
using CommandChanged = Event< std::vector< std::string > >
 

Detailed Description

Definition at line 53 of file TestFS.h.

Constructor & Destructor Documentation

◆ MockCompilationDatabase()

clang::clangd::MockCompilationDatabase::MockCompilationDatabase ( StringRef  Directory = StringRef(),
StringRef  RelPathPrefix = StringRef() 
)

If Directory is not empty, use that as the Directory field of the CompileCommand, and as project SourceRoot.

If RelPathPrefix is not empty, use that as a prefix in front of the source file name, instead of using an absolute path.

Definition at line 47 of file TestFS.cpp.

Member Function Documentation

◆ getCompileCommand()

std::optional< tooling::CompileCommand > clang::clangd::MockCompilationDatabase::getCompileCommand ( PathRef  File) const
overridevirtual

If there are any known-good commands for building this file, returns one.

Implements clang::clangd::GlobalCompilationDatabase.

Definition at line 60 of file TestFS.cpp.

References CommandLine, Directory, ExtraClangFlags, clang::clangd::File, FileName, and RelPathPrefix.

◆ getProjectInfo()

std::optional< ProjectInfo > clang::clangd::MockCompilationDatabase::getProjectInfo ( PathRef  File) const
overridevirtual

Finds the closest project to File.

Reimplemented from clang::clangd::GlobalCompilationDatabase.

Definition at line 55 of file TestFS.cpp.

References Directory.

Member Data Documentation

◆ Directory

StringRef clang::clangd::MockCompilationDatabase::Directory
protected

Definition at line 71 of file TestFS.h.

Referenced by getCompileCommand(), and getProjectInfo().

◆ ExtraClangFlags

std::vector<std::string> clang::clangd::MockCompilationDatabase::ExtraClangFlags

Definition at line 68 of file TestFS.h.

Referenced by getCompileCommand().

◆ RelPathPrefix

StringRef clang::clangd::MockCompilationDatabase::RelPathPrefix
protected

Definition at line 72 of file TestFS.h.

Referenced by getCompileCommand().


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