@@ -88,10 +88,11 @@ bool Synchronizer::isProbablyOutdatedWrappers(const fs::path &srcFilePath) const
88
88
}
89
89
90
90
CollectionUtils::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
+ });
95
96
return outdatedSources;
96
97
}
97
98
@@ -199,15 +200,14 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
199
200
for (const StubOperator &outdatedStub : outdatedStubs) {
200
201
fs::path stubPath = outdatedStub.getStubPath (testGen->projectContext );
201
202
Tests const &methodDescription = stubFilesMap[stubPath];
203
+ tests::Tests tests = StubGen::mergeSourceFileIntoStub (
204
+ methodDescription, sourceFilesMap.at (outdatedStub.getSourceFilePath ()));
202
205
if (outdatedStub.isHeader ()) {
203
- std::string code = sourceToHeaderRewriter.generateStubHeader (outdatedStub.getSourceFilePath ());
206
+ std::string code = sourceToHeaderRewriter.generateStubHeader (tests, outdatedStub.getSourceFilePath ());
204
207
testGen->synchronizedStubs .emplace_back (stubPath, code);
205
208
} else {
206
- tests::Tests newStubFile = StubGen::mergeSourceFileIntoStub (
207
- methodDescription, sourceFilesMap.at (outdatedStub.getSourceFilePath ()));
208
209
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 );
211
211
testGen->synchronizedStubs .emplace_back (stubFile);
212
212
}
213
213
}
@@ -227,7 +227,7 @@ Synchronizer::createStubsCompilationDatabase(StubSet &stubFiles,
227
227
void Synchronizer::synchronizeWrappers (const CollectionUtils::FileSet &outdatedSourcePaths,
228
228
const types::TypesHandler &typesHandler) const {
229
229
auto sourceFilesNeedToRegenerateWrappers = outdatedSourcePaths;
230
- for (fs::path const &sourceFilePath : getTargetSourceFiles ()) {
230
+ for (fs::path const &sourceFilePath: testGen-> getTargetSourceFiles ()) {
231
231
if (!CollectionUtils::contains (sourceFilesNeedToRegenerateWrappers, sourceFilePath)) {
232
232
auto wrapperFilePath =
233
233
Paths::getWrapperFilePath (testGen->projectContext , sourceFilePath);
@@ -247,27 +247,19 @@ void Synchronizer::synchronizeWrappers(const CollectionUtils::FileSet &outdatedS
247
247
});
248
248
}
249
249
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
-
258
250
StubSet Synchronizer::getStubsFiles () const {
259
251
return getStubSetFromSources (testGen->getProjectBuildDatabase ()->compilationDatabase ->getAllFiles ());
260
252
}
261
253
262
254
void Synchronizer::prepareDirectory (const fs::path &stubDirectory) {
263
255
fs::create_directories (stubDirectory);
264
- for (const auto &entry : fs::recursive_directory_iterator (stubDirectory)) {
256
+ for (const auto &entry: fs::recursive_directory_iterator (stubDirectory)) {
265
257
if (entry.is_regular_file ()) {
266
258
fs::path stubPath = entry.path ();
267
259
if (!Paths::isHeaderFile (stubPath)) {
268
260
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)) {
271
263
LOG_S (DEBUG) << " Found extra file in stub directory: " << stubPath
272
264
<< " . Removing it." ;
273
265
fs::remove (stubPath);
0 commit comments