swift-ide-test: Add an option to allow users to specify a second source file to test with.

This commit is contained in:
Xi Ge
2016-03-24 17:39:32 -07:00
committed by Michael Ilseman
parent 9970e6904d
commit 3a3295f053

View File

@@ -209,6 +209,9 @@ Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
static llvm::cl::opt<std::string>
SourceFilename("source-filename", llvm::cl::desc("Name of the source file"));
static llvm::cl::opt<std::string>
SecondSourceFilename("second-source-filename", llvm::cl::desc("Name of the second source file"));
static llvm::cl::list<std::string>
InputFilenames(llvm::cl::Positional, llvm::cl::desc("[input files...]"),
llvm::cl::ZeroOrMore);
@@ -537,6 +540,7 @@ removeCodeCompletionTokens(llvm::MemoryBuffer *Input,
static int doCodeCompletion(const CompilerInvocation &InitInvok,
StringRef SourceFilename,
StringRef SecondSourceFileName,
StringRef CodeCompletionToken,
bool CodeCompletionDiagnostics,
bool CodeCompletionKeywords) {
@@ -567,6 +571,7 @@ static int doCodeCompletion(const CompilerInvocation &InitInvok,
CompilerInvocation Invocation(InitInvok);
Invocation.setCodeCompletionPoint(CleanFile.get(), CodeCompletionOffset);
std::unique_ptr<ide::OnDiskCodeCompletionCache> OnDiskCache;
if (!options::CompletionCachePath.empty()) {
OnDiskCache = llvm::make_unique<ide::OnDiskCodeCompletionCache>(
@@ -587,7 +592,9 @@ static int doCodeCompletion(const CompilerInvocation &InitInvok,
*Consumer.get()));
Invocation.setCodeCompletionFactory(CompletionCallbacksFactory.get());
if (!SecondSourceFileName.empty()) {
Invocation.addInputFilename(SecondSourceFileName);
}
CompilerInstance CI;
PrintingDiagnosticConsumer PrintDiags;
@@ -2740,6 +2747,7 @@ int main(int argc, char *argv[]) {
}
ExitCode = doCodeCompletion(InitInvok,
options::SourceFilename,
options::SecondSourceFilename,
options::CodeCompletionToken,
options::CodeCompletionDiagnostics,
options::CodeCompletionKeywords);