mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs.
This commit is contained in:
@@ -442,53 +442,6 @@ SwiftInterfaceGenContext::create(StringRef DocumentName,
|
||||
return IFaceGenCtx;
|
||||
}
|
||||
|
||||
SwiftInterfaceGenContextRef
|
||||
SwiftInterfaceGenContext::createForTypeInterface(CompilerInvocation Invocation,
|
||||
StringRef TypeUSR,
|
||||
std::string &ErrorMsg) {
|
||||
SwiftInterfaceGenContextRef IFaceGenCtx{ new SwiftInterfaceGenContext() };
|
||||
IFaceGenCtx->Impl.IsModule = false;
|
||||
IFaceGenCtx->Impl.ModuleOrHeaderName = TypeUSR;
|
||||
IFaceGenCtx->Impl.Invocation = Invocation;
|
||||
CompilerInstance &CI = IFaceGenCtx->Impl.Instance;
|
||||
SourceTextInfo &Info = IFaceGenCtx->Impl.Info;
|
||||
|
||||
// Display diagnostics to stderr.
|
||||
CI.addDiagnosticConsumer(&IFaceGenCtx->Impl.DiagConsumer);
|
||||
|
||||
if (CI.setup(Invocation)) {
|
||||
ErrorMsg = "Error during invocation setup";
|
||||
return nullptr;
|
||||
}
|
||||
CI.performSema();
|
||||
ASTContext &Ctx = CI.getASTContext();
|
||||
CloseClangModuleFiles scopedCloseFiles(*Ctx.getClangModuleLoader());
|
||||
|
||||
// Load standard library so that Clang importer can use it.
|
||||
auto *Stdlib = getModuleByFullName(Ctx, Ctx.StdlibModuleName);
|
||||
if (!Stdlib) {
|
||||
ErrorMsg = "Could not load the stdlib module";
|
||||
return nullptr;
|
||||
}
|
||||
auto *Module = CI.getMainModule();
|
||||
if (!Module) {
|
||||
ErrorMsg = "Could not load the main module";
|
||||
return nullptr;
|
||||
}
|
||||
SmallString<128> Text;
|
||||
llvm::raw_svector_ostream OS(Text);
|
||||
AnnotatingPrinter Printer(Info, OS);
|
||||
if (ide::printTypeInterface(Module, TypeUSR, Printer,
|
||||
IFaceGenCtx->Impl.DocumentName, ErrorMsg))
|
||||
return nullptr;
|
||||
IFaceGenCtx->Impl.Info.Text = OS.str();
|
||||
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text)) {
|
||||
ErrorMsg = "Error during syntactic parsing";
|
||||
return nullptr;
|
||||
}
|
||||
return IFaceGenCtx;
|
||||
}
|
||||
|
||||
SwiftInterfaceGenContext::SwiftInterfaceGenContext()
|
||||
: Impl(*new Implementation) {
|
||||
}
|
||||
@@ -640,45 +593,11 @@ SwiftInterfaceGenMap::find(StringRef ModuleName,
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
//===----------------------------------------------------------------------===//
|
||||
// EditorOpenTypeInterface
|
||||
//===----------------------------------------------------------------------===//
|
||||
void SwiftLangSupport::editorOpenTypeInterface(EditorConsumer &Consumer,
|
||||
ArrayRef<const char *> Args,
|
||||
StringRef TypeUSR) {
|
||||
CompilerInstance CI;
|
||||
// Display diagnostics to stderr.
|
||||
PrintingDiagnosticConsumer PrintDiags;
|
||||
CI.addDiagnosticConsumer(&PrintDiags);
|
||||
|
||||
CompilerInvocation Invocation;
|
||||
std::string Error;
|
||||
if (getASTManager().initCompilerInvocation(Invocation, Args, CI.getDiags(),
|
||||
StringRef(), Error)) {
|
||||
Consumer.handleRequestError(Error.c_str());
|
||||
return;
|
||||
}
|
||||
Invocation.getClangImporterOptions().ImportForwardDeclarations = true;
|
||||
|
||||
std::string ErrMsg;
|
||||
auto IFaceGenRef = SwiftInterfaceGenContext::createForTypeInterface(
|
||||
Invocation,
|
||||
TypeUSR,
|
||||
ErrMsg);
|
||||
if (!IFaceGenRef) {
|
||||
Consumer.handleRequestError(ErrMsg.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
IFaceGenRef->reportEditorInfo(Consumer);
|
||||
// reportEditorInfo requires exclusive access to the AST, so don't add this
|
||||
// to the service cache until it has returned.
|
||||
IFaceGenContexts.set(TypeUSR, IFaceGenRef);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// EditorOpenInterface
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
|
||||
StringRef Name,
|
||||
StringRef ModuleName,
|
||||
|
||||
Reference in New Issue
Block a user