[Lldb-commits] [lldb] 3ce57e0 - [lldb] type language common completion
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 11 02:07:36 PDT 2020
Author: Gongyu Deng
Date: 2020-08-11T11:07:19+02:00
New Revision: 3ce57e012110519c1d3a49fc98959a64634d5d8f
URL: https://github.com/llvm/llvm-project/commit/3ce57e012110519c1d3a49fc98959a64634d5d8f
DIFF: https://github.com/llvm/llvm-project/commit/3ce57e012110519c1d3a49fc98959a64634d5d8f.diff
LOG: [lldb] type language common completion
1. Added a new common completion TypeLanguages to provide a list of supporting languages;
2. Bound the completion to eArgTypeLanguage;
3. Added a related test case.
Added:
Modified:
lldb/include/lldb/Interpreter/CommandCompletions.h
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/test/API/functionalities/completion/TestCompletion.py
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index 55ab5d8a6375..deaf39ed32a7 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -38,10 +38,11 @@ class CommandCompletions {
eBreakpointCompletion = (1u << 10),
eProcessPluginCompletion = (1u << 11),
eDisassemblyFlavorCompletion = (1u << 12),
+ eTypeLanguageCompletion = (1u << 13),
// This item serves two purposes. It is the last element in the enum, so
// you can add custom enums starting from here in your Option class. Also
// if you & in this bit the base code will not process the option.
- eCustomCompletion = (1u << 13)
+ eCustomCompletion = (1u << 14)
};
static bool InvokeCommonCompletionCallbacks(
@@ -99,6 +100,9 @@ class CommandCompletions {
static void DisassemblyFlavors(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher);
+
+ static void TypeLanguages(CommandInterpreter &interpreter,
+ CompletionRequest &request, SearchFilter *searcher);
};
} // namespace lldb_private
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 69d7f78b8c6c..795aabda787f 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -18,6 +18,7 @@
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Variable.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/StreamString.h"
@@ -60,6 +61,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
{eBreakpointCompletion, CommandCompletions::Breakpoints},
{eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
{eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors},
+ {eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
{eNoCompletion, nullptr} // This one has to be last in the list.
};
@@ -606,3 +608,13 @@ void CommandCompletions::DisassemblyFlavors(CommandInterpreter &interpreter,
request.TryCompleteCurrentArg(flavor);
}
}
+
+void CommandCompletions::TypeLanguages(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ for (int bit :
+ Language::GetLanguagesSupportingTypeSystems().bitvector.set_bits()) {
+ request.TryCompleteCurrentArg(
+ Language::GetNameForLanguageType(static_cast<lldb::LanguageType>(bit)));
+ }
+}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 946ea814bc0d..40b6749f6a56 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -1062,7 +1062,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, nullptr },
{ eArgTypeHelpText, "help-text", CommandCompletions::eNoCompletion, { nullptr, false }, "Text to be used as help for some other entity in LLDB" },
{ eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." },
- { eArgTypeLanguage, "source-language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
+ { eArgTypeLanguage, "source-language", CommandCompletions::eTypeLanguageCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
{ eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." },
{ eArgTypeFileLineColumn, "linespec", CommandCompletions::eNoCompletion, { nullptr, false }, "A source specifier in the form file:line[:column]" },
{ eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 99dcda4b4cf2..2a757638cd82 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -536,6 +536,9 @@ def test_register_read_and_write_on_x86(self):
self.complete_from_to('register write rbx ',
[])
+ def test_common_completion_type_language(self):
+ self.complete_from_to('type category -l ', ['c'])
+
def test_complete_breakpoint_with_ids(self):
"""These breakpoint subcommands should be completed with a list of breakpoint ids"""
More information about the lldb-commits
mailing list