From 842a3c3948a9f241b8756acd020c899edd11e434 Mon Sep 17 00:00:00 2001 From: Marc Rasi Date: Wed, 13 Feb 2019 13:45:43 -0800 Subject: [PATCH 1/2] lsp options --- include/lldb/API/LLDB.h | 1 + include/lldb/API/SBCompletionOptions.h | 48 +++++++++++++ include/lldb/API/SBDefines.h | 2 + include/lldb/API/SBTarget.h | 2 +- include/lldb/Target/CompletionOptions.h | 25 +++++++ include/lldb/Target/Language.h | 4 +- include/lldb/Target/Target.h | 6 +- scripts/interface/SBCompletionOptions.i | 45 ++++++++++++ scripts/interface/SBTarget.i | 4 +- scripts/lldb.swig | 2 + source/API/CMakeLists.txt | 1 + source/API/SBCompletionOptions.cpp | 53 ++++++++++++++ source/API/SBTarget.cpp | 5 +- .../Language/Swift/SwiftCodeCompletion.cpp | 71 ++++++++++++++++--- .../Language/Swift/SwiftCodeCompletion.h | 3 +- .../Plugins/Language/Swift/SwiftLanguage.cpp | 5 +- source/Plugins/Language/Swift/SwiftLanguage.h | 3 +- source/Target/Language.cpp | 3 +- source/Target/Target.cpp | 6 +- 19 files changed, 265 insertions(+), 24 deletions(-) create mode 100644 include/lldb/API/SBCompletionOptions.h create mode 100644 include/lldb/Target/CompletionOptions.h create mode 100644 scripts/interface/SBCompletionOptions.i create mode 100644 source/API/SBCompletionOptions.cpp diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index 35c8e8e0e013..784571047d52 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -60,6 +60,7 @@ #include "lldb/API/SBStructuredData.h" // SWIFT_ENABLE_TENSORFLOW #include "lldb/API/SBCompletionMatch.h" +#include "lldb/API/SBCompletionOptions.h" #include "lldb/API/SBCompletionResponse.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" diff --git a/include/lldb/API/SBCompletionOptions.h b/include/lldb/API/SBCompletionOptions.h new file mode 100644 index 000000000000..f07963236bb2 --- /dev/null +++ b/include/lldb/API/SBCompletionOptions.h @@ -0,0 +1,48 @@ +//===-- SBCompletionOptions.h -----------------------------------*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBCompletionOptions_h_ +#define LLDB_SBCompletionOptions_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/Target/CompletionOptions.h" + +namespace lldb { + +class LLDB_API SBCompletionOptions { +public: + SBCompletionOptions(); + + SBCompletionOptions(const SBCompletionOptions &rhs); + + const SBCompletionOptions &operator=(const SBCompletionOptions &rhs); + + lldb::LanguageType GetLanguage() const; + void SetLanguage(lldb::LanguageType Language); + + bool GetInsertableLSPSnippets() const; + void SetInsertableLSPSnippets(bool Value); + +protected: + friend class SBTarget; + + SBCompletionOptions(const lldb_private::CompletionOptions *options); + + lldb_private::CompletionOptions *GetPointer() const; + +private: + std::unique_ptr m_opaque_ap; +}; + +} // namespace lldb + +#endif // LLDB_SBCompletionOptions_h_ diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index c42eabc3e5c0..7ef0af5cdd3c 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -42,7 +42,9 @@ class LLDB_API SBCommandPluginInterface; class LLDB_API SBCommandReturnObject; class LLDB_API SBCommunication; class LLDB_API SBCompileUnit; +// SWIFT_ENABLE_TENSORFLOW class LLDB_API SBCompletionMatch; +class LLDB_API SBCompletionOptions; class LLDB_API SBCompletionResponse; class LLDB_API SBData; class LLDB_API SBDebugger; diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 3f08acc6acb7..5d2e69b57da3 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -895,7 +895,7 @@ class LLDB_API SBTarget { // SWIFT_ENABLE_TENSORFLOW SBCompletionResponse - CompleteCode(lldb::LanguageType language, + CompleteCode(const lldb::SBCompletionOptions &options, const lldb::SBSymbolContext *symbol_context, const char *current_code); diff --git a/include/lldb/Target/CompletionOptions.h b/include/lldb/Target/CompletionOptions.h new file mode 100644 index 000000000000..51101d85150b --- /dev/null +++ b/include/lldb/Target/CompletionOptions.h @@ -0,0 +1,25 @@ +//===--- CompletionOptions.h ------------------------------------*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#ifndef CompletionOptions_h_ +#define CompletionOptions_h_ + +namespace lldb_private { + +struct CompletionOptions { + lldb::LanguageType Language; + bool InsertableLSPSnippets = false; +}; + +} // namespace lldb_private + +#endif // CompletionOptions_h_ diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index 0594b53d34c5..bfc478fab66e 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -27,6 +27,7 @@ #include "lldb/DataFormatters/StringPrinter.h" // SWIFT_ENABLE_TENSORFLOW #include "lldb/Target/CompletionResponse.h" +#include "lldb/Target/CompletionOptions.h" #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" @@ -234,7 +235,8 @@ class Language : public PluginInterface { bool throw_on, Stream &s); // SWIFT_ENABLE_TENSORFLOW - virtual CompletionResponse CompleteCode(ExecutionContextScope &exe_scope, + virtual CompletionResponse CompleteCode(const CompletionOptions &options, + ExecutionContextScope &exe_scope, const std::string &entered_code); // These are accessors for general information about the Languages lldb knows diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index d26f683a6bd7..8cf197744124 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -40,6 +40,7 @@ #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/ABI.h" // SWIFT_ENABLE_TENSORFLOW +#include "lldb/Target/CompletionOptions.h" #include "lldb/Target/CompletionResponse.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/PathMappingList.h" @@ -1220,8 +1221,9 @@ class Target : public std::enable_shared_from_this, std::string *fixed_expression = nullptr); // SWIFT_ENABLE_TENSORFLOW - CompletionResponse CompleteCode(lldb::LanguageType language, - llvm::StringRef current_code); + CompletionResponse CompleteCode( + const lldb_private::CompletionOptions &options, + llvm::StringRef current_code); // Look up a symbol by name and type in both the target's symbols and the // persistent symbols from the diff --git a/scripts/interface/SBCompletionOptions.i b/scripts/interface/SBCompletionOptions.i new file mode 100644 index 000000000000..e3402d0b7378 --- /dev/null +++ b/scripts/interface/SBCompletionOptions.i @@ -0,0 +1,45 @@ +//===-- SWIG Interface for SBCompletionOptions ------------------*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", " +Options for a completion request +") SBCompletionOptions; +class SBCompletionOptions +{ +public: + %feature("docstring", "The language used for completions.") + GetLanguage; + lldb::LanguageType GetLanguage () const; + + %feature("docstring", "Set the language used for completions.") + SetLanguage; + void SetLanguage (lldb::LanguageType Language); + + %feature("docstring", " + When this is false, the insertable text in completion matches is plain text + that can be inserted directly into the code. When this is true, the + insertable text in completion matches is a Language Server Protocol Snippet + (https://microsoft.github.io/language-server-protocol/specification#textDocument_completion), + which includes things like placeholder tabstops for function arguments. + ") GetInsertableLSPSnippets; + bool GetInsertableLSPSnippets () const; + + %feature("docstring", " + Set whether the insertable text in completion matches is a Language Server + Protocol Snippet. See the getter docstring for more information. + ") SetInsertableLSPSnippets; + void SetInsertableLSPSnippets (bool Value); +}; + +} // namespace lldb diff --git a/scripts/interface/SBTarget.i b/scripts/interface/SBTarget.i index ea4454da0e03..d12a14a65cf1 100644 --- a/scripts/interface/SBTarget.i +++ b/scripts/interface/SBTarget.i @@ -1039,14 +1039,14 @@ public: %feature("docstring", " Complete code. Parameters: - language -- the language to use + options -- the options to use symbol_context -- the context in which to do the completion current_code -- the code to complete Returns an SBCompletionResponse with completions that fit immediately after the last character of `current_code`. ") CompleteCode; lldb::SBCompletionResponse - CompleteCode (lldb::LanguageType language, + CompleteCode (const lldb::SBCompletionOptions &options, const lldb::SBSymbolContext *symbol_context, const char *current_code); diff --git a/scripts/lldb.swig b/scripts/lldb.swig index ec0c4d786c33..ea892d0e4b27 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -90,6 +90,7 @@ import six #include "lldb/API/SBCompileUnit.h" // SWIFT_ENABLE_TENSORFLOW #include "lldb/API/SBCompletionMatch.h" +#include "lldb/API/SBCompletionOptions.h" #include "lldb/API/SBCompletionResponse.h" #include "lldb/API/SBData.h" #include "lldb/API/SBDebugger.h" @@ -180,6 +181,7 @@ import six %include "./interface/SBCompileUnit.i" // SWIFT_ENABLE_TENSORFLOW %include "./interface/SBCompletionMatch.i" +%include "./interface/SBCompletionOptions.i" %include "./interface/SBCompletionResponse.i" %include "./interface/SBData.i" %include "./interface/SBDebugger.i" diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt index f9fc57623c48..9e47e44f8a5d 100644 --- a/source/API/CMakeLists.txt +++ b/source/API/CMakeLists.txt @@ -23,6 +23,7 @@ add_lldb_library(liblldb SHARED SBCommunication.cpp SBCompileUnit.cpp SBCompletionMatch.cpp + SBCompletionOptions.cpp SBCompletionResponse.cpp SBData.cpp SBDebugger.cpp diff --git a/source/API/SBCompletionOptions.cpp b/source/API/SBCompletionOptions.cpp new file mode 100644 index 000000000000..abcacfcd2eee --- /dev/null +++ b/source/API/SBCompletionOptions.cpp @@ -0,0 +1,53 @@ +//===-- SBCompletionOptions.cpp ---------------------------------*- C++ -*-===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBCompletionOptions.h" + +using namespace lldb; +using namespace lldb_private; + +SBCompletionOptions::SBCompletionOptions() + : m_opaque_ap(new lldb_private::CompletionOptions()) {} + +SBCompletionOptions::SBCompletionOptions(const SBCompletionOptions &rhs) + : m_opaque_ap(new lldb_private::CompletionOptions(*rhs.m_opaque_ap)) {} + +const SBCompletionOptions &SBCompletionOptions:: +operator=(const SBCompletionOptions &rhs) { + m_opaque_ap.reset(new lldb_private::CompletionOptions(*rhs.m_opaque_ap)); + return *this; +} + +lldb::LanguageType SBCompletionOptions::GetLanguage() const { + return m_opaque_ap->Language; +} + +void SBCompletionOptions::SetLanguage(lldb::LanguageType Language) { + m_opaque_ap->Language = Language; +} + +bool SBCompletionOptions::GetInsertableLSPSnippets() const { + return m_opaque_ap->InsertableLSPSnippets; +} + +void SBCompletionOptions::SetInsertableLSPSnippets(bool Value) { + m_opaque_ap->InsertableLSPSnippets = Value; +} + +SBCompletionOptions::SBCompletionOptions( + const lldb_private::CompletionOptions *options) + : m_opaque_ap(new lldb_private::CompletionOptions(*options)) {} + + +lldb_private::CompletionOptions *SBCompletionOptions::GetPointer() const { + return m_opaque_ap.get(); +} diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index 9369115fafd4..c16c19ce203a 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -14,6 +14,7 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBDebugger.h" // SWIFT_ENABLE_TENSORFLOW +#include "lldb/API/SBCompletionOptions.h" #include "lldb/API/SBCompletionResponse.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExpressionOptions.h" @@ -2308,10 +2309,10 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, // SWIFT_ENABLE_TENSORFLOW SBCompletionResponse -SBTarget::CompleteCode(lldb::LanguageType language, +SBTarget::CompleteCode(const lldb::SBCompletionOptions &options, const lldb::SBSymbolContext *symbol_context, const char *current_code) { - auto response = GetSP()->CompleteCode(language, current_code); + auto response = GetSP()->CompleteCode(*options.GetPointer(), current_code); return SBCompletionResponse(&response); } diff --git a/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp b/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp index ecc3a53ef4ff..ac0386023e3d 100644 --- a/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp +++ b/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp @@ -25,10 +25,33 @@ using namespace llvm; using namespace swift; using namespace ide; -static std::string toInsertableString(CodeCompletionResult *Result) { +/// Applies any escaping necessary to include `text` in an insertable string +/// result. This depends on the `options`: for example, when the insertable +/// strings are LSP Snippets, then we need to escape LSP Snippet special chars. +static std::string escapeForInsertableString( + const lldb_private::CompletionOptions &Options, StringRef Text) { + if (!Options.InsertableLSPSnippets) + return Text; + + static const char LSPSnippetMetachars[] = "\\$}"; + std::string Result; + for (unsigned i = 0; i < Text.size(); ++i) { + if (strchr(LSPSnippetMetachars, Text[i])) + Result += "\\"; + Result += Text[i]; + } + return Result; +} + +static std::string toInsertableString(const lldb_private::CompletionOptions &Options, CodeCompletionResult *Result) { using ChunkKind = CodeCompletionString::Chunk::ChunkKind; std::string Str; + llvm::raw_string_ostream Stream(Str); auto chunks = Result->getCompletionString()->getChunks(); + + // The index of the next LSP Snippet placeholder to insert. + unsigned lspSnippetPlaceholderIndex = 1; + for (unsigned i = 0; i < chunks.size(); ++i) { auto outerChunk = chunks[i]; @@ -37,8 +60,18 @@ static std::string toInsertableString(CodeCompletionResult *Result) { // should be inserted into the code buffer. if (outerChunk.is(ChunkKind::CallParameterBegin)) { ++i; + + // Keeps track of which section of the call parameter the inner loop is + // in. auto callParameterSection = ChunkKind::CallParameterBegin; + + // Keeps track of whether the call parameter has a name. bool hasParameterName = false; + + // Accumulates text that should be inserted as an LSP Snippet placeholder + // for the call parameter. + std::string PlaceholderText; + for (; i < chunks.size(); ++i) { auto innerChunk = chunks[i]; @@ -59,6 +92,17 @@ static std::string toInsertableString(CodeCompletionResult *Result) { if (callParameterSection == ChunkKind::CallParameterName) hasParameterName = true; + // These parts of the call parameter go into the LSP Snippet + // placeholder. + if (Options.InsertableLSPSnippets && ( + callParameterSection == ChunkKind::CallParameterInternalName || + (!hasParameterName && + callParameterSection == ChunkKind::CallParameterColon) || + callParameterSection == ChunkKind::CallParameterType || + callParameterSection == ChunkKind::CallParameterClosureType)) + PlaceholderText += escapeForInsertableString(Options, + innerChunk.getText()); + // Never emit these parts of the call parameter. if (callParameterSection == ChunkKind::CallParameterInternalName || callParameterSection == ChunkKind::CallParameterType || @@ -70,13 +114,21 @@ static std::string toInsertableString(CodeCompletionResult *Result) { continue; if (innerChunk.hasText() && !innerChunk.isAnnotation()) - Str += innerChunk.getText(); + Stream << escapeForInsertableString(Options, innerChunk.getText()); } + + if (Options.InsertableLSPSnippets && !PlaceholderText.empty()) { + Stream << "${" << lspSnippetPlaceholderIndex << ":" + << escapeForInsertableString(Options, PlaceholderText) + << "}"; + ++lspSnippetPlaceholderIndex; + } + continue; } if (outerChunk.hasText() && !outerChunk.isAnnotation()) - Str += outerChunk.getText(); + Stream << escapeForInsertableString(Options, outerChunk.getText()); } return Str; } @@ -144,23 +196,25 @@ static std::string toDisplayString(CodeCompletionResult *Result) { namespace lldb_private { class CodeCompletionConsumer : public SimpleCachingCodeCompletionConsumer { + const CompletionOptions &Options; CompletionResponse &Response; public: - CodeCompletionConsumer(CompletionResponse &Response) : Response(Response) {} + CodeCompletionConsumer(const CompletionOptions &Options, CompletionResponse &Response) : Options(Options), Response(Response) {} void handleResults(MutableArrayRef Results) override { CodeCompletionContext::sortCompletionResults(Results); for (auto *Result : Results) { Response.Matches.push_back( - {toDisplayString(Result), toInsertableString(Result)}); + {toDisplayString(Result), toInsertableString(Options, Result)}); } } }; /// Calculates completions at the end of `EnteredCode`. static unsigned -doCodeCompletion(SourceFile &SF, StringRef EnteredCode, +doCodeCompletion(SourceFile &SF, + StringRef EnteredCode, CodeCompletionCallbacksFactory *CompletionCallbacksFactory) { ASTContext &Ctx = SF.getASTContext(); DiagnosticTransaction DelayedDiags(Ctx.Diags); @@ -221,7 +275,8 @@ static SourceFile *GetSingleSourceFile(ModuleDecl *Module, } CompletionResponse -SwiftCompleteCode(SwiftASTContext &SwiftCtx, +SwiftCompleteCode(const CompletionOptions &Options, + SwiftASTContext &SwiftCtx, SwiftPersistentExpressionState &PersistentExpressionState, StringRef EnteredCode) { Status Error; @@ -352,7 +407,7 @@ SwiftCompleteCode(SwiftASTContext &SwiftCtx, // Set up `Response` to collect results, and set up a callback handler that // puts the results into `Response`. CompletionResponse Response; - CodeCompletionConsumer Consumer(Response); + CodeCompletionConsumer Consumer(Options, Response); CodeCompletionCache CompletionCache; CodeCompletionContext CompletionContext(CompletionCache); std::unique_ptr CompletionCallbacksFactory( diff --git a/source/Plugins/Language/Swift/SwiftCodeCompletion.h b/source/Plugins/Language/Swift/SwiftCodeCompletion.h index 023a28cf86a5..f343e472b56a 100644 --- a/source/Plugins/Language/Swift/SwiftCodeCompletion.h +++ b/source/Plugins/Language/Swift/SwiftCodeCompletion.h @@ -23,7 +23,8 @@ namespace lldb_private { CompletionResponse -SwiftCompleteCode(SwiftASTContext &SwiftCtx, +SwiftCompleteCode(const CompletionOptions &Options, + SwiftASTContext &SwiftCtx, SwiftPersistentExpressionState &PersistentExpressionState, llvm::StringRef EnteredCode); diff --git a/source/Plugins/Language/Swift/SwiftLanguage.cpp b/source/Plugins/Language/Swift/SwiftLanguage.cpp index 18989e033ac6..b7d5369f1693 100644 --- a/source/Plugins/Language/Swift/SwiftLanguage.cpp +++ b/source/Plugins/Language/Swift/SwiftLanguage.cpp @@ -1668,7 +1668,8 @@ void SwiftLanguage::GetExceptionResolverDescription(bool catch_on, } CompletionResponse -SwiftLanguage::CompleteCode(ExecutionContextScope &exe_scope, +SwiftLanguage::CompleteCode(const CompletionOptions &options, + ExecutionContextScope &exe_scope, const std::string &entered_code) { Target &target = *exe_scope.CalculateTarget(); Status error; @@ -1679,7 +1680,7 @@ SwiftLanguage::CompleteCode(ExecutionContextScope &exe_scope, auto persistent_expression_state = target.GetSwiftPersistentExpressionState(exe_scope); - return SwiftCompleteCode(*swift_ast, *persistent_expression_state, + return SwiftCompleteCode(options, *swift_ast, *persistent_expression_state, entered_code); } diff --git a/source/Plugins/Language/Swift/SwiftLanguage.h b/source/Plugins/Language/Swift/SwiftLanguage.h index ef08e947b6d9..a12c0fd6c2fc 100644 --- a/source/Plugins/Language/Swift/SwiftLanguage.h +++ b/source/Plugins/Language/Swift/SwiftLanguage.h @@ -75,7 +75,8 @@ class SwiftLanguage : public Language { Stream &s) override; // SWIFT_ENABLE_TENSORFLOW - CompletionResponse CompleteCode(ExecutionContextScope &exe_scope, + CompletionResponse CompleteCode(const CompletionOptions &options, + ExecutionContextScope &exe_scope, const std::string &entered_code); //------------------------------------------------------------------ diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp index 3cddb426e60c..12d6b4485ecf 100644 --- a/source/Target/Language.cpp +++ b/source/Target/Language.cpp @@ -446,7 +446,8 @@ void Language::GetDefaultExceptionResolverDescription(bool catch_on, catch_on ? "on" : "off", throw_on ? "on" : "off"); } -CompletionResponse Language::CompleteCode(ExecutionContextScope &exe_scope, +CompletionResponse Language::CompleteCode(const CompletionOptions &options, + ExecutionContextScope &exe_scope, const std::string &entered_code) { return CompletionResponse::error("completion unsupported for this language"); } diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp index a38303cbc66e..db812a1562bf 100644 --- a/source/Target/Target.cpp +++ b/source/Target/Target.cpp @@ -2645,12 +2645,12 @@ ExpressionResults Target::EvaluateExpression( } // SWIFT_ENABLE_TENSORFLOW -CompletionResponse Target::CompleteCode(lldb::LanguageType language, +CompletionResponse Target::CompleteCode(const CompletionOptions &options, llvm::StringRef current_code) { - auto *plugin = Language::FindPlugin(language); + auto *plugin = Language::FindPlugin(options.Language); if (!plugin) return CompletionResponse::error("language plugin not found"); - return plugin->CompleteCode(*this, current_code); + return plugin->CompleteCode(options, *this, current_code); } lldb::ExpressionVariableSP From ec6a9775bd3fdc43cfe2d3f52a646855369dff64 Mon Sep 17 00:00:00 2001 From: Marc Rasi Date: Wed, 13 Feb 2019 17:58:41 -0800 Subject: [PATCH 2/2] exclude closure parameter type from placeholder --- source/Plugins/Language/Swift/SwiftCodeCompletion.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp b/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp index ac0386023e3d..9caf82bdc384 100644 --- a/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp +++ b/source/Plugins/Language/Swift/SwiftCodeCompletion.cpp @@ -98,8 +98,7 @@ static std::string toInsertableString(const lldb_private::CompletionOptions &Opt callParameterSection == ChunkKind::CallParameterInternalName || (!hasParameterName && callParameterSection == ChunkKind::CallParameterColon) || - callParameterSection == ChunkKind::CallParameterType || - callParameterSection == ChunkKind::CallParameterClosureType)) + callParameterSection == ChunkKind::CallParameterType)) PlaceholderText += escapeForInsertableString(Options, innerChunk.getText());