CommandCompletions.h [plain text]
#ifndef lldb_CommandCompletions_h_
#define lldb_CommandCompletions_h_
#include "lldb/lldb-private.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/RegularExpression.h"
namespace lldb_private
{
class CommandCompletions
{
public:
typedef int (*CompletionCallback) (CommandInterpreter &interpreter,
const char *completion_str, int match_start_point, int max_return_elements, lldb_private::SearchFilter *searcher, bool &word_complete,
lldb_private::StringList &matches); typedef enum
{
eNoCompletion = 0u,
eSourceFileCompletion = (1u << 0),
eDiskFileCompletion = (1u << 1),
eDiskDirectoryCompletion = (1u << 2),
eSymbolCompletion = (1u << 3),
eModuleCompletion = (1u << 4),
eSettingsNameCompletion = (1u << 5),
ePlatformPluginCompletion = (1u << 6),
eArchitectureCompletion = (1u << 7),
eCustomCompletion = (1u << 8)
} CommonCompletionTypes;
struct CommonCompletionElement
{
uint32_t type;
CompletionCallback callback;
};
static bool InvokeCommonCompletionCallbacks (CommandInterpreter &interpreter,
uint32_t completion_mask,
const char *completion_str,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
StringList &matches);
static int
DiskFiles (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
StringList &matches);
static int
DiskDirectories (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
StringList &matches);
static int
SourceFiles (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
StringList &matches);
static int
Modules (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
lldb_private::StringList &matches);
static int
Symbols (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
lldb_private::StringList &matches);
static int
SettingsNames (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
lldb_private::StringList &matches);
static int
PlatformPluginNames (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
lldb_private::StringList &matches);
static int
ArchitectureNames (CommandInterpreter &interpreter,
const char *partial_file_name,
int match_start_point,
int max_return_elements,
SearchFilter *searcher,
bool &word_complete,
lldb_private::StringList &matches);
class Completer : public Searcher
{
public:
Completer (CommandInterpreter &interpreter,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
virtual ~Completer ();
virtual CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete) = 0;
virtual Depth
GetDepth () = 0;
virtual size_t
DoCompletion (SearchFilter *filter) = 0;
protected:
CommandInterpreter &m_interpreter;
std::string m_completion_str;
int m_match_start_point;
int m_max_return_elements;
StringList &m_matches;
private:
DISALLOW_COPY_AND_ASSIGN (Completer);
};
class SourceFileCompleter : public Completer
{
public:
SourceFileCompleter (CommandInterpreter &interpreter,
bool include_support_files,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
virtual Searcher::Depth GetDepth ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete);
size_t
DoCompletion (SearchFilter *filter);
private:
bool m_include_support_files;
FileSpecList m_matching_files;
const char *m_file_name;
const char *m_dir_name;
DISALLOW_COPY_AND_ASSIGN (SourceFileCompleter);
};
class ModuleCompleter : public Completer
{
public:
ModuleCompleter (CommandInterpreter &interpreter,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
virtual Searcher::Depth GetDepth ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete);
size_t
DoCompletion (SearchFilter *filter);
private:
const char *m_file_name;
const char *m_dir_name;
DISALLOW_COPY_AND_ASSIGN (ModuleCompleter);
};
class SymbolCompleter : public Completer
{
public:
SymbolCompleter (CommandInterpreter &interpreter,
const char *completion_str,
int match_start_point,
int max_return_elements,
StringList &matches);
virtual Searcher::Depth GetDepth ();
virtual Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete);
size_t
DoCompletion (SearchFilter *filter);
private:
RegularExpression m_regex;
typedef std::set<ConstString> collection;
collection m_match_set;
DISALLOW_COPY_AND_ASSIGN (SymbolCompleter);
};
private:
static CommonCompletionElement g_common_completions[];
};
} #endif // lldb_CommandCompletions_h_