Revert "Enable SourceKit tests if building SourceKit"

This commit is contained in:
Arnold Schwaighofer
2017-04-24 17:59:03 -07:00
committed by GitHub
parent 03c125979b
commit a383adf9df
18 changed files with 32 additions and 98 deletions

View File

@@ -225,9 +225,8 @@ public:
} // end anonymous namespace
static bool makeParserAST(CompilerInstance &CI, StringRef Text,
CompilerInvocation Invocation) {
Invocation.clearInputs();
static bool makeParserAST(CompilerInstance &CI, StringRef Text) {
CompilerInvocation Invocation;
Invocation.setModuleName("main");
Invocation.setInputKind(InputFileKind::IFK_Swift);
@@ -359,7 +358,6 @@ SwiftInterfaceGenContextRef
SwiftInterfaceGenContext::createForSwiftSource(StringRef DocumentName,
StringRef SourceFileName,
ASTUnitRef AstUnit,
CompilerInvocation Invocation,
std::string &ErrMsg) {
SwiftInterfaceGenContextRef IFaceGenCtx{ new SwiftInterfaceGenContext() };
IFaceGenCtx->Impl.DocumentName = DocumentName;
@@ -373,8 +371,7 @@ SwiftInterfaceGenContext::createForSwiftSource(StringRef DocumentName,
AnnotatingPrinter Printer(IFaceGenCtx->Impl.Info, OS);
printSwiftSourceInterface(AstUnit->getPrimarySourceFile(), Printer, Options);
IFaceGenCtx->Impl.Info.Text = OS.str();
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text,
Invocation)) {
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text)) {
ErrMsg = "Error during syntactic parsing";
return nullptr;
}
@@ -437,8 +434,7 @@ SwiftInterfaceGenContext::create(StringRef DocumentName,
return nullptr;
}
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text,
Invocation)) {
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text)) {
ErrMsg = "Error during syntactic parsing";
return nullptr;
}
@@ -486,8 +482,7 @@ SwiftInterfaceGenContext::createForTypeInterface(CompilerInvocation Invocation,
IFaceGenCtx->Impl.DocumentName, ErrorMsg))
return nullptr;
IFaceGenCtx->Impl.Info.Text = OS.str();
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text,
Invocation)) {
if (makeParserAST(IFaceGenCtx->Impl.TextCI, IFaceGenCtx->Impl.Info.Text)) {
ErrorMsg = "Error during syntactic parsing";
return nullptr;
}
@@ -743,26 +738,22 @@ class PrimaryFileInterfaceConsumer : public SwiftASTConsumer {
std::string SourceFileName;
SwiftInterfaceGenMap &Contexts;
std::shared_ptr<EditorConsumer> Consumer;
SwiftInvocationRef ASTInvok;
public:
PrimaryFileInterfaceConsumer(StringRef Name, StringRef SourceFileName,
SwiftInterfaceGenMap &Contexts,
std::shared_ptr<EditorConsumer> Consumer,
SwiftInvocationRef ASTInvok) :
std::shared_ptr<EditorConsumer> Consumer) :
Name(Name), SourceFileName(SourceFileName), Contexts(Contexts),
Consumer(Consumer), ASTInvok(ASTInvok) {}
Consumer(Consumer) {}
void failed(StringRef Error) override {
Consumer->handleRequestError(Error.data());
}
void handlePrimaryAST(ASTUnitRef AstUnit) override {
CompilerInvocation CompInvok;
ASTInvok->applyTo(CompInvok);
std::string Error;
auto IFaceGenRef = SwiftInterfaceGenContext::createForSwiftSource(Name,
SourceFileName, AstUnit, CompInvok, Error);
SourceFileName, AstUnit, Error);
if (!Error.empty())
Consumer->handleRequestError(Error.data());
Contexts.set(Name, IFaceGenRef);
@@ -791,7 +782,7 @@ void SwiftLangSupport::editorOpenSwiftSourceInterface(StringRef Name,
std::make_pair("SourceName", SourceName)});
}
auto AstConsumer = std::make_shared<PrimaryFileInterfaceConsumer>(Name,
SourceName, IFaceGenContexts, Consumer, Invocation);
SourceName, IFaceGenContexts, Consumer);
static const char OncePerASTToken = 0;
getASTManager().processASTAsync(Invocation, AstConsumer, &OncePerASTToken);
}