@@ -821,7 +821,8 @@ const static unsigned OBJC_METHOD_TRACE_FILE_FORMAT_VERSION = 1;
821821class ObjcMethodReferenceCollector : public SourceEntityWalker {
822822 std::string target;
823823 std::string targetVariant;
824- StringRef visitingFilePath;
824+ SmallVector<StringRef, 32 > FilePaths;
825+ unsigned CurrentFileID;
825826 llvm::DenseSet<const clang::ObjCMethodDecl*> results;
826827 bool visitDeclReference (ValueDecl *D, CharSourceRange Range,
827828 TypeDecl *CtorTyRef, ExtensionDecl *ExtTyRef,
@@ -859,7 +860,8 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
859860 }
860861 void setFileBeforeVisiting (SourceFile *SF) {
861862 assert (SF && " need to visit actual source files" );
862- visitingFilePath = SF->getFilename ();
863+ FilePaths.push_back (SF->getFilename ());
864+ CurrentFileID = FilePaths.size ();
863865 }
864866 void serializeAsJson (llvm::raw_ostream &OS) {
865867 llvm::json::OStream out (OS, /* IndentSize=*/ 4 );
@@ -884,7 +886,15 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
884886 }
885887 out.attribute (selectMethodKey (clangD), clangD->getNameAsString ());
886888 out.attribute (" declared_at" , Loc.printToString (SM));
887- out.attribute (" referenced_at" , visitingFilePath);
889+ out.attribute (" referenced_at_file_id" , CurrentFileID);
890+ });
891+ }
892+ });
893+ out.attributeArray (" fileMap" , [&]{
894+ for (unsigned I = 0 , N = FilePaths.size (); I != N; I ++) {
895+ out.object ([&] {
896+ out.attribute (" file_id" , I + 1 );
897+ out.attribute (" file_path" , FilePaths[I]);
888898 });
889899 }
890900 });
0 commit comments