[SourceKit] Fail requests when an error occurs

Previously, requests would fail silently by returning an empty struct
in the response.

With this change, responses will properly report fail with the internal
error.
This commit is contained in:
David Goldman
2019-04-18 11:25:53 -04:00
parent f978cb0ba3
commit 10ecea6269
20 changed files with 291 additions and 223 deletions

View File

@@ -834,7 +834,8 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
void SwiftLangSupport::findInterfaceDocument(StringRef ModuleName,
ArrayRef<const char *> Args,
std::function<void(const InterfaceDocInfo &)> Receiver) {
std::function<void(const InterfaceDocInfo &,
StringRef Error)> Receiver) {
InterfaceDocInfo Info;
CompilerInstance CI;
@@ -846,8 +847,7 @@ void SwiftLangSupport::findInterfaceDocument(StringRef ModuleName,
std::string Error;
if (getASTManager()->initCompilerInvocation(Invocation, Args, CI.getDiags(),
StringRef(), Error)) {
Info.Error = Error;
return Receiver(Info);
return Receiver({}, Error);
}
if (auto IFaceGenRef = IFaceGenContexts.find(ModuleName, Invocation))
@@ -905,5 +905,5 @@ void SwiftLangSupport::findInterfaceDocument(StringRef ModuleName,
}
Info.CompilerArgs = NewArgs;
return Receiver(Info);
return Receiver(Info, "");
}