@@ -38,7 +38,7 @@ static UIdent getUIDForDependencyKind(bool isClangModule) {
3838
3939class SKIndexDataConsumer : public IndexDataConsumer {
4040public:
41- SKIndexDataConsumer (IndexingConsumer &C) : impl(C) {}
41+ SKIndexDataConsumer (IndexingConsumer &C, IndexSourceOptions Opts ) : impl(C), Opts(Opts ) {}
4242
4343private:
4444 void failed (StringRef error) override { impl.failed (error); }
@@ -51,6 +51,8 @@ class SKIndexDataConsumer : public IndexDataConsumer {
5151 return Logger::isLoggingEnabledForLevel (Logger::Level::Warning);
5252 }
5353
54+ virtual bool indexLocals () override { return Opts.IndexLocals ; }
55+
5456 bool startDependency (StringRef name, StringRef path, bool isClangModule, bool isSystem) override {
5557 auto kindUID = getUIDForDependencyKind (isClangModule);
5658 return impl.startDependency (kindUID, name, path, isSystem);
@@ -61,7 +63,7 @@ class SKIndexDataConsumer : public IndexDataConsumer {
6163 }
6264
6365 Action startSourceEntity (const IndexSymbol &symbol) override {
64- if (symbol.symInfo .Kind == SymbolKind::Parameter)
66+ if (! indexLocals () && symbol.symInfo .Kind == SymbolKind::Parameter)
6567 return Skip;
6668
6769 // report any parent relations to this reference
@@ -204,13 +206,15 @@ class SKIndexDataConsumer : public IndexDataConsumer {
204206
205207private:
206208 IndexingConsumer &impl;
209+ IndexSourceOptions Opts;
207210};
208211
209212static void indexModule (llvm::MemoryBuffer *Input,
210213 StringRef ModuleName,
211214 IndexingConsumer &IdxConsumer,
212215 CompilerInstance &CI,
213- ArrayRef<const char *> Args) {
216+ ArrayRef<const char *> Args,
217+ IndexSourceOptions Opts) {
214218 ASTContext &Ctx = CI.getASTContext ();
215219 std::unique_ptr<ImplicitSerializedModuleLoader> Loader;
216220 ModuleDecl *Mod = nullptr ;
@@ -245,7 +249,7 @@ static void indexModule(llvm::MemoryBuffer *Input,
245249 Mod->setHasResolvedImports ();
246250 }
247251
248- SKIndexDataConsumer IdxDataConsumer (IdxConsumer);
252+ SKIndexDataConsumer IdxDataConsumer (IdxConsumer, Opts );
249253 index::indexModule (Mod, IdxDataConsumer);
250254}
251255
@@ -277,7 +281,8 @@ void trace::initTraceInfo(trace::SwiftInvocation &SwiftArgs,
277281
278282void SwiftLangSupport::indexSource (StringRef InputFile,
279283 IndexingConsumer &IdxConsumer,
280- ArrayRef<const char *> OrigArgs) {
284+ ArrayRef<const char *> OrigArgs,
285+ IndexSourceOptions Opts) {
281286 std::string Error;
282287 auto InputBuf =
283288 ASTMgr->getMemoryBuffer (InputFile, llvm::vfs::getRealFileSystem (), Error);
@@ -333,7 +338,7 @@ void SwiftLangSupport::indexSource(StringRef InputFile,
333338 }
334339
335340 indexModule (InputBuf.get (), llvm::sys::path::stem (Filename),
336- IdxConsumer, CI, Args);
341+ IdxConsumer, CI, Args, Opts );
337342 return ;
338343 }
339344
@@ -365,7 +370,7 @@ void SwiftLangSupport::indexSource(StringRef InputFile,
365370 return ;
366371 }
367372
368- SKIndexDataConsumer IdxDataConsumer (IdxConsumer);
373+ SKIndexDataConsumer IdxDataConsumer (IdxConsumer, Opts );
369374 index::indexSourceFile (CI.getPrimarySourceFile (), IdxDataConsumer);
370375}
371376
0 commit comments