mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Refactor how code completion results are returned to support cancellation
This refactors a bunch of code-completion methods around `performOperation` to return their results via a callback only instead of the current mixed approach of indicating failure via a return value, returning an error string as an inout parameter and success results via a callback. The new guarantee should be that the callback is always called exactly once on control flow graph. Other than a support for passing the (currently unused) cancelled state through the different instance, there should be no functionality change.
This commit is contained in:
@@ -14,13 +14,15 @@
|
||||
#define LLVM_SOURCEKIT_LIB_SWIFTLANG_SWIFTLANGSUPPORT_H
|
||||
|
||||
#include "CodeCompletion.h"
|
||||
#include "SwiftInterfaceGenContext.h"
|
||||
#include "SourceKit/Core/LangSupport.h"
|
||||
#include "SourceKit/Support/Concurrency.h"
|
||||
#include "SourceKit/Support/Statistic.h"
|
||||
#include "SourceKit/Support/ThreadSafeRefCntPtr.h"
|
||||
#include "SourceKit/Support/Tracing.h"
|
||||
#include "SwiftInterfaceGenContext.h"
|
||||
#include "swift/Basic/ThreadSafeRefCounted.h"
|
||||
#include "swift/IDE/CancellableResult.h"
|
||||
#include "swift/IDE/CompletionInstance.h"
|
||||
#include "swift/IDE/Indenting.h"
|
||||
#include "swift/IDE/Refactoring.h"
|
||||
#include "swift/Index/IndexSymbol.h"
|
||||
@@ -462,12 +464,13 @@ public:
|
||||
/// Perform a completion like operation. It initializes a \c CompilerInstance,
|
||||
/// the calls \p Callback with it. \p Callback must perform the second pass
|
||||
/// using that instance.
|
||||
bool performCompletionLikeOperation(
|
||||
void performCompletionLikeOperation(
|
||||
llvm::MemoryBuffer *UnresolvedInputFile, unsigned Offset,
|
||||
ArrayRef<const char *> Args,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
|
||||
std::string &Error,
|
||||
llvm::function_ref<void(swift::CompilerInstance &, bool)> Callback);
|
||||
llvm::function_ref<void(
|
||||
swift::ide::CancellableResult<swift::ide::CompletionInstanceResult>)>
|
||||
Callback);
|
||||
|
||||
//==========================================================================//
|
||||
// LangSupport Interface
|
||||
|
||||
Reference in New Issue
Block a user