mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
swift-ide-test: Add an option to allow users to specify a second source file to test with.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user