LLDB mainline
Public Member Functions | Private Attributes | List of all members
lldb_private::CompletionRequest Class Reference

"lldb/Utility/ArgCompletionRequest.h" More...

#include <CompletionRequest.h>

Public Member Functions

 CompletionRequest (llvm::StringRef command_line, unsigned raw_cursor_pos, CompletionResult &result)
 Constructs a completion request.
 
llvm::StringRef GetRawLine () const
 Returns the raw user input used to create this CompletionRequest cut off at the cursor position.
 
llvm::StringRef GetRawLineWithUnusedSuffix () const
 Returns the full raw user input used to create this CompletionRequest.
 
unsigned GetRawCursorPos () const
 
const ArgsGetParsedLine () const
 
ArgsGetParsedLine ()
 
const Args::ArgEntryGetParsedArg ()
 
void ShiftArguments ()
 Drops the first argument from the argument list.
 
void AppendEmptyArgument ()
 Adds an empty argument at the end of the argument list and moves the cursor to this new argument.
 
size_t GetCursorIndex () const
 
void AddCompletion (llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
 Adds a possible completion string.
 
template<CompletionMode M = CompletionMode::Normal>
void TryCompleteCurrentArg (llvm::StringRef completion, llvm::StringRef description="")
 Adds a possible completion string if the completion would complete the current argument.
 
void AddCompletions (const StringList &completions)
 Adds multiple possible completion strings.
 
void AddCompletions (const StringList &completions, const StringList &descriptions)
 Adds multiple possible completion strings alongside their descriptions.
 
llvm::StringRef GetCursorArgumentPrefix () const
 

Private Attributes

llvm::StringRef m_command
 The raw command line we are supposed to complete.
 
unsigned m_raw_cursor_pos
 The cursor position in m_command.
 
Args m_parsed_line
 The command line parsed as arguments.
 
size_t m_cursor_index
 The index of the argument in which the completion cursor is.
 
size_t m_cursor_char_position
 The cursor position in the argument indexed by m_cursor_index.
 
CompletionResultm_result
 The result this request is supposed to fill out.
 

Detailed Description

"lldb/Utility/ArgCompletionRequest.h"

Contains all information necessary to complete an incomplete command for the user. Will be filled with the generated completions by the different completions functions.

Definition at line 100 of file CompletionRequest.h.

Constructor & Destructor Documentation

◆ CompletionRequest()

CompletionRequest::CompletionRequest ( llvm::StringRef  command_line,
unsigned  raw_cursor_pos,
CompletionResult result 
)

Constructs a completion request.

Parameters
[in]command_lineThe command line the user has typed at this point.
[in]raw_cursor_posThe position of the cursor in the command line string. Index 0 means the cursor is at the start of the line. The completion starts from this cursor position.
[out]resultThe CompletionResult that will be filled with the results after this request has been handled.

Definition at line 14 of file CompletionRequest.cpp.

References AppendEmptyArgument(), lldb_private::Args::GetArgumentCount(), GetCursorArgumentPrefix(), GetParsedLine(), m_cursor_char_position, m_cursor_index, and m_parsed_line.

Member Function Documentation

◆ AddCompletion()

void lldb_private::CompletionRequest::AddCompletion ( llvm::StringRef  completion,
llvm::StringRef  description = "",
CompletionMode  mode = CompletionMode::Normal 
)
inline

Adds a possible completion string.

If the completion was already suggested before, it will not be added to the list of results. A copy of the suggested completion is stored, so the given string can be free'd afterwards.

Parameters
completionThe suggested completion.
descriptionAn optional description of the completion string. The description will be displayed to the user alongside the completion.
modeThe CompletionMode for this completion.

Definition at line 167 of file CompletionRequest.h.

References lldb_private::CompletionResult::AddResult(), and m_result.

Referenced by AddCompletions(), lldb_private::OptionValueEnumeration::AutoComplete(), lldb_private::FormatEntity::AutoComplete(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::AutoCompleteDiskFileOrDirectory(), lldb_private::PluginManager::AutoCompletePlatformName(), lldb_private::PluginManager::AutoCompleteProcessName(), DiskFilesOrDirectories(), lldb_private::CommandInterpreter::HandleCompletion(), lldb_private::Options::HandleOptionCompletion(), lldb_private::IOHandlerConfirm::IOHandlerComplete(), lldb_private::REPL::IOHandlerComplete(), PrivateAutoComplete(), PrivateAutoCompleteMembers(), and TryCompleteCurrentArg().

◆ AddCompletions() [1/2]

void lldb_private::CompletionRequest::AddCompletions ( const StringList completions)
inline

◆ AddCompletions() [2/2]

void lldb_private::CompletionRequest::AddCompletions ( const StringList completions,
const StringList descriptions 
)
inline

Adds multiple possible completion strings alongside their descriptions.

The number of completions and descriptions must be identical.

Parameters
completionsThe list of completions.
descriptionsThe list of descriptions.
See also
AddCompletion

Definition at line 209 of file CompletionRequest.h.

References AddCompletion(), lldb_private::StringList::GetSize(), lldb_private::StringList::GetStringAtIndex(), and lldbassert.

◆ AppendEmptyArgument()

void lldb_private::CompletionRequest::AppendEmptyArgument ( )
inline

Adds an empty argument at the end of the argument list and moves the cursor to this new argument.

Definition at line 150 of file CompletionRequest.h.

References lldb_private::Args::AppendArgument(), m_cursor_char_position, m_cursor_index, and m_parsed_line.

Referenced by CompletionRequest(), lldb_private::CommandObjectMultiword::HandleCompletion(), and lldb_private::CommandInterpreter::HandleCompletionMatches().

◆ GetCursorArgumentPrefix()

llvm::StringRef lldb_private::CompletionRequest::GetCursorArgumentPrefix ( ) const
inline

◆ GetCursorIndex()

size_t lldb_private::CompletionRequest::GetCursorIndex ( ) const
inline

Definition at line 156 of file CompletionRequest.h.

References m_cursor_index.

Referenced by CompleteEnableDisable(), GetCursorArgumentPrefix(), GetParsedArg(), lldb_private::CommandObject::HandleArgumentCompletion(), CommandObjectCommandsUnalias::HandleArgumentCompletion(), CommandObjectCommandsDelete::HandleArgumentCompletion(), CommandObjectFrameRecognizerDelete::HandleArgumentCompletion(), CommandObjectPlatformGetFile::HandleArgumentCompletion(), CommandObjectPlatformInstall::HandleArgumentCompletion(), CommandObjectProcessUnload::HandleArgumentCompletion(), CommandObjectProcessSignal::HandleArgumentCompletion(), CommandObjectRegisterWrite::HandleArgumentCompletion(), CommandObjectRegisterInfo::HandleArgumentCompletion(), CommandObjectSettingsRemove::HandleArgumentCompletion(), CommandObjectSettingsReplace::HandleArgumentCompletion(), CommandObjectSettingsInsertBefore::HandleArgumentCompletion(), CommandObjectSettingsInsertAfter::HandleArgumentCompletion(), CommandObjectSettingsAppend::HandleArgumentCompletion(), CommandObjectSettingsClear::HandleArgumentCompletion(), CommandObjectTargetModulesSearchPathsInsert::HandleArgumentCompletion(), CommandObjectTargetStopHookDelete::HandleArgumentCompletion(), CommandObjectTargetStopHookEnableDisable::HandleArgumentCompletion(), CommandObjectThreadStepWithTypeAndScope::HandleArgumentCompletion(), CommandObjectThreadSelect::HandleArgumentCompletion(), CommandObjectThreadPlanDiscard::HandleArgumentCompletion(), CommandObjectTypeFormatterDelete::HandleArgumentCompletion(), lldb_private::CommandObject::HandleCompletion(), lldb_private::CommandObjectMultiword::HandleCompletion(), lldb_private::CommandObjectHelp::HandleCompletion(), lldb_private::CommandInterpreter::HandleCompletionMatches(), lldb_private::Options::HandleOptionCompletion(), lldb_private::REPL::IOHandlerComplete(), and lldb_private::Editline::TabCommand().

◆ GetParsedArg()

const Args::ArgEntry & lldb_private::CompletionRequest::GetParsedArg ( )
inline

◆ GetParsedLine() [1/2]

Args & lldb_private::CompletionRequest::GetParsedLine ( )
inline

Definition at line 136 of file CompletionRequest.h.

References m_parsed_line.

◆ GetParsedLine() [2/2]

const Args & lldb_private::CompletionRequest::GetParsedLine ( ) const
inline

◆ GetRawCursorPos()

unsigned lldb_private::CompletionRequest::GetRawCursorPos ( ) const
inline

◆ GetRawLine()

llvm::StringRef lldb_private::CompletionRequest::GetRawLine ( ) const
inline

Returns the raw user input used to create this CompletionRequest cut off at the cursor position.

The cursor will be at the end of the raw line.

Definition at line 120 of file CompletionRequest.h.

References GetRawCursorPos(), and m_command.

Referenced by lldb_private::REPL::IOHandlerComplete().

◆ GetRawLineWithUnusedSuffix()

llvm::StringRef lldb_private::CompletionRequest::GetRawLineWithUnusedSuffix ( ) const
inline

Returns the full raw user input used to create this CompletionRequest.

This string is not cut off at the cursor position and will include characters behind the cursor position.

You should most likely not use this function unless the characters behind the cursor position influence the completion.

Definition at line 130 of file CompletionRequest.h.

References m_command.

◆ ShiftArguments()

void lldb_private::CompletionRequest::ShiftArguments ( )
inline

◆ TryCompleteCurrentArg()

template<CompletionMode M = CompletionMode::Normal>
void lldb_private::CompletionRequest::TryCompleteCurrentArg ( llvm::StringRef  completion,
llvm::StringRef  description = "" 
)
inline

Adds a possible completion string if the completion would complete the current argument.

Parameters
completionThe suggested completion.
descriptionAn optional description of the completion string. The description will be displayed to the user alongside the completion.

Definition at line 180 of file CompletionRequest.h.

References AddCompletion(), GetCursorArgumentPrefix(), and lldb_private::RewriteLine.

Referenced by lldb_private::OptionValueBoolean::AutoComplete(), lldb_private::OptionValueEnumeration::AutoComplete(), lldb_private::OptionValueUUID::AutoComplete(), lldb_private::FormattersContainer< ValueType >::AutoComplete(), lldb_private::ArchSpec::AutoComplete(), lldb_private::Thread::AutoCompleteThreadPlans(), lldb_private::CommandCompletions::BreakpointNames(), lldb_private::CommandCompletions::Breakpoints(), CompleteEnableDisable(), lldb_private::CommandCompletions::DisassemblyFlavors(), lldb_private::CommandCompletions::FrameIndexes(), CommandObjectCommandsUnalias::HandleArgumentCompletion(), CommandObjectCommandsDelete::HandleArgumentCompletion(), CommandObjectFrameRecognizerDelete::HandleArgumentCompletion(), CommandObjectLogList::HandleArgumentCompletion(), CommandObjectLogTimerIncrement::HandleArgumentCompletion(), CommandObjectProcessUnload::HandleArgumentCompletion(), CommandObjectProcessSignal::HandleArgumentCompletion(), CommandObjectTargetModulesSearchPathsInsert::HandleArgumentCompletion(), CommandObjectBreakpointRead::CommandOptions::HandleOptionArgumentCompletion(), lldb_private::Options::HandleOptionArgumentCompletion(), lldb_private::CommandCompletions::ModuleUUIDs(), lldb_private::CommandCompletions::ProcessIDs(), lldb_private::CommandCompletions::ProcessNames(), lldb_private::CommandCompletions::Registers(), lldb_private::CommandCompletions::SettingsNames(), lldb_private::CommandCompletions::StopHookIDs(), lldb_private::CommandCompletions::ThreadIDs(), lldb_private::CommandCompletions::ThreadIndexes(), lldb_private::CommandCompletions::TypeCategoryNames(), lldb_private::CommandCompletions::TypeLanguages(), and lldb_private::CommandCompletions::WatchPointIDs().

Member Data Documentation

◆ m_command

llvm::StringRef lldb_private::CompletionRequest::m_command
private

The raw command line we are supposed to complete.

Definition at line 223 of file CompletionRequest.h.

Referenced by GetRawLine(), and GetRawLineWithUnusedSuffix().

◆ m_cursor_char_position

size_t lldb_private::CompletionRequest::m_cursor_char_position
private

The cursor position in the argument indexed by m_cursor_index.

Definition at line 231 of file CompletionRequest.h.

Referenced by AppendEmptyArgument(), and CompletionRequest().

◆ m_cursor_index

size_t lldb_private::CompletionRequest::m_cursor_index
private

The index of the argument in which the completion cursor is.

Definition at line 229 of file CompletionRequest.h.

Referenced by AppendEmptyArgument(), CompletionRequest(), GetCursorIndex(), and ShiftArguments().

◆ m_parsed_line

Args lldb_private::CompletionRequest::m_parsed_line
private

The command line parsed as arguments.

Definition at line 227 of file CompletionRequest.h.

Referenced by AppendEmptyArgument(), CompletionRequest(), GetParsedLine(), and ShiftArguments().

◆ m_raw_cursor_pos

unsigned lldb_private::CompletionRequest::m_raw_cursor_pos
private

The cursor position in m_command.

Definition at line 225 of file CompletionRequest.h.

Referenced by GetRawCursorPos().

◆ m_result

CompletionResult& lldb_private::CompletionRequest::m_result
private

The result this request is supposed to fill out.

We keep this object private to ensure that no backend can in any way depend on already calculated completions (which would make debugging and testing them much more complicated).

Definition at line 237 of file CompletionRequest.h.

Referenced by AddCompletion().


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