LLDB mainline
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.
void SetMaxReturnElements (size_t max_return_elements)
 Sets the maximum number of completions that should be returned.
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 ()
size_t GetCursorCharPos () const
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
size_t GetMaxReturnElements () const
bool ShouldAddCompletions () const
 Returns true if the maximum number of completions has not been reached yet, hence we should keep adding completions.
size_t GetMaxNumberOfCompletionsToAdd () const
 Returns the maximum number of completions that need to be added until reaching the maximum.
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.
size_t m_max_return_elements = std::numeric_limits<size_t>::max()
 The maximum number of completions that should be returned.
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(), CompletionRequest(), lldb_private::Args::GetArgumentCount(), GetCursorArgumentPrefix(), GetParsedLine(), m_command, m_cursor_char_position, m_cursor_index, m_parsed_line, m_raw_cursor_pos, and m_result.

Referenced by CompletionRequest().

Member Function Documentation

◆ AddCompletion()

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

◆ 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 233 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 157 of file CompletionRequest.h.

References m_cursor_char_position, m_cursor_index, and m_parsed_line.

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

◆ GetCursorArgumentPrefix()

◆ GetCursorCharPos()

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

◆ GetCursorIndex()

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

Definition at line 163 of file CompletionRequest.h.

References m_cursor_index.

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

◆ GetMaxNumberOfCompletionsToAdd()

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

Returns the maximum number of completions that need to be added until reaching the maximum.

Definition at line 175 of file CompletionRequest.h.

References m_max_return_elements, and m_result.

Referenced by ShouldAddCompletions().

◆ GetMaxReturnElements()

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

Definition at line 165 of file CompletionRequest.h.

References m_max_return_elements.

◆ GetParsedArg()

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

◆ GetParsedLine() [1/2]

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

Definition at line 141 of file CompletionRequest.h.

References m_parsed_line.

◆ GetParsedLine() [2/2]

◆ 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 125 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 135 of file CompletionRequest.h.

References m_command.

◆ SetMaxReturnElements()

void lldb_private::CompletionRequest::SetMaxReturnElements ( size_t max_return_elements)
inline

Sets the maximum number of completions that should be returned.

Definition at line 119 of file CompletionRequest.h.

References m_max_return_elements.

Referenced by lldb::SBCommandInterpreter::HandleCompletionWithDescriptions().

◆ ShiftArguments()

void lldb_private::CompletionRequest::ShiftArguments ( )
inline

◆ ShouldAddCompletions()

bool lldb_private::CompletionRequest::ShouldAddCompletions ( ) const
inline

Returns true if the maximum number of completions has not been reached yet, hence we should keep adding completions.

Definition at line 169 of file CompletionRequest.h.

References GetMaxNumberOfCompletionsToAdd().

Referenced by DiskFilesOrDirectories(), and lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks().

◆ 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 204 of file CompletionRequest.h.

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

Referenced by lldb_private::ArchSpec::AutoComplete(), lldb_private::FormattersContainer< TypeSummaryImpl >::AutoComplete(), lldb_private::OptionValueBoolean::AutoComplete(), lldb_private::OptionValueEnumeration::AutoComplete(), lldb_private::OptionValueUUID::AutoComplete(), lldb_private::Thread::AutoCompleteThreadPlans(), lldb_private::CommandCompletions::BreakpointNames(), lldb_private::CommandCompletions::Breakpoints(), CompleteEnableDisable(), lldb_private::CommandCompletions::DisassemblyFlavors(), lldb_private::CommandCompletions::FrameIndexes(), CommandObjectCommandsDelete::HandleArgumentCompletion(), CommandObjectCommandsUnalias::HandleArgumentCompletion(), CommandObjectLogList::HandleArgumentCompletion(), CommandObjectLogTimerIncrement::HandleArgumentCompletion(), CommandObjectProcessSignal::HandleArgumentCompletion(), CommandObjectProcessUnload::HandleArgumentCompletion(), CommandObjectTargetModulesSearchPathsInsert::HandleArgumentCompletion(), CommandObjectWithFrameRecognizerArg::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 247 of file CompletionRequest.h.

Referenced by CompletionRequest(), 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 255 of file CompletionRequest.h.

Referenced by AppendEmptyArgument(), CompletionRequest(), and GetCursorCharPos().

◆ 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 253 of file CompletionRequest.h.

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

◆ m_max_return_elements

size_t lldb_private::CompletionRequest::m_max_return_elements = std::numeric_limits<size_t>::max()
private

The maximum number of completions that should be returned.

Definition at line 257 of file CompletionRequest.h.

Referenced by GetMaxNumberOfCompletionsToAdd(), GetMaxReturnElements(), and SetMaxReturnElements().

◆ m_parsed_line

Args lldb_private::CompletionRequest::m_parsed_line
private

The command line parsed as arguments.

Definition at line 251 of file CompletionRequest.h.

Referenced by AppendEmptyArgument(), CompletionRequest(), GetParsedLine(), 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 249 of file CompletionRequest.h.

Referenced by CompletionRequest(), and 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 263 of file CompletionRequest.h.

Referenced by AddCompletion(), CompletionRequest(), and GetMaxNumberOfCompletionsToAdd().


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