@@ -88,10 +88,11 @@ bool Synchronizer::isProbablyOutdatedWrappers(const fs::path &srcFilePath) const
8888}
8989
9090CollectionUtils::FileSet Synchronizer::getOutdatedSourcePaths () const {
91- auto allFiles = getTargetSourceFiles ();
92- auto outdatedSources = CollectionUtils::filterOut (getTargetSourceFiles (), [this ](fs::path const &sourcePath) {
93- return !isProbablyOutdatedWrappers (sourcePath);
94- });
91+ auto allFiles = testGen->getTargetSourceFiles ();
92+ auto outdatedSources = CollectionUtils::filterOut (testGen->getTargetSourceFiles (),
93+ [this ](fs::path const &sourcePath) {
94+ return !isProbablyOutdatedWrappers (sourcePath);
95+ });
9596 return outdatedSources;
9697}
9798
@@ -199,15 +200,14 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
199200 for (const StubOperator &outdatedStub : outdatedStubs) {
200201 fs::path stubPath = outdatedStub.getStubPath (testGen->projectContext );
201202 Tests const &methodDescription = stubFilesMap[stubPath];
203+ tests::Tests tests = StubGen::mergeSourceFileIntoStub (
204+ methodDescription, sourceFilesMap.at (outdatedStub.getSourceFilePath ()));
202205 if (outdatedStub.isHeader ()) {
203- std::string code = sourceToHeaderRewriter.generateStubHeader (outdatedStub.getSourceFilePath ());
206+ std::string code = sourceToHeaderRewriter.generateStubHeader (tests, outdatedStub.getSourceFilePath ());
204207 testGen->synchronizedStubs .emplace_back (stubPath, code);
205208 } else {
206- tests::Tests newStubFile = StubGen::mergeSourceFileIntoStub (
207- methodDescription, sourceFilesMap.at (outdatedStub.getSourceFilePath ()));
208209 printer::StubsPrinter stubsPrinter (Paths::getSourceLanguage (stubPath));
209- Stubs stubFile =
210- stubsPrinter.genStubFile (newStubFile, typesHandler, testGen->projectContext );
210+ Stubs stubFile = stubsPrinter.genStubFile (tests, typesHandler, testGen->projectContext );
211211 testGen->synchronizedStubs .emplace_back (stubFile);
212212 }
213213 }
@@ -227,7 +227,7 @@ Synchronizer::createStubsCompilationDatabase(StubSet &stubFiles,
227227void Synchronizer::synchronizeWrappers (const CollectionUtils::FileSet &outdatedSourcePaths,
228228 const types::TypesHandler &typesHandler) const {
229229 auto sourceFilesNeedToRegenerateWrappers = outdatedSourcePaths;
230- for (fs::path const &sourceFilePath : getTargetSourceFiles ()) {
230+ for (fs::path const &sourceFilePath: testGen-> getTargetSourceFiles ()) {
231231 if (!CollectionUtils::contains (sourceFilesNeedToRegenerateWrappers, sourceFilePath)) {
232232 auto wrapperFilePath =
233233 Paths::getWrapperFilePath (testGen->projectContext , sourceFilePath);
@@ -247,27 +247,19 @@ void Synchronizer::synchronizeWrappers(const CollectionUtils::FileSet &outdatedS
247247 });
248248}
249249
250- const CollectionUtils::FileSet &Synchronizer::getTargetSourceFiles () const {
251- return testGen->getTargetBuildDatabase ()->compilationDatabase ->getAllFiles ();
252- }
253-
254- const CollectionUtils::FileSet &Synchronizer::getProjectSourceFiles () const {
255- return testGen->getProjectBuildDatabase ()->compilationDatabase ->getAllFiles ();
256- }
257-
258250StubSet Synchronizer::getStubsFiles () const {
259251 return getStubSetFromSources (testGen->getProjectBuildDatabase ()->compilationDatabase ->getAllFiles ());
260252}
261253
262254void Synchronizer::prepareDirectory (const fs::path &stubDirectory) {
263255 fs::create_directories (stubDirectory);
264- for (const auto &entry : fs::recursive_directory_iterator (stubDirectory)) {
256+ for (const auto &entry: fs::recursive_directory_iterator (stubDirectory)) {
265257 if (entry.is_regular_file ()) {
266258 fs::path stubPath = entry.path ();
267259 if (!Paths::isHeaderFile (stubPath)) {
268260 fs::path sourcePath =
269- Paths::stubPathToSourcePath (testGen->projectContext , stubPath);
270- if (!CollectionUtils::contains (getProjectSourceFiles (), sourcePath)) {
261+ Paths::stubPathToSourcePath (testGen->projectContext , stubPath);
262+ if (!CollectionUtils::contains (testGen-> getProjectSourceFiles (), sourcePath)) {
271263 LOG_S (DEBUG) << " Found extra file in stub directory: " << stubPath
272264 << " . Removing it." ;
273265 fs::remove (stubPath);
0 commit comments