Skip to content

Commit 65386a8

Browse files
author
Vladislav Kalugin
committed
refactoring after review 7
1 parent 2ef7b8e commit 65386a8

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

server/src/building/BuildDatabase.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ fs::path BuildDatabase::newDirForFile(const fs::path &file) const {
534534
}
535535

536536
CollectionUtils::FileSet BuildDatabase::getSourceFilesForTarget(const fs::path &_target) {
537-
LOG_IF_S(WARNING, !hasAutoTarget() && getTargetPath() != _target.c_str()) << "Try get sources for different target";
538537
return CollectionUtils::transformTo<CollectionUtils::FileSet>(
539538
getArchiveObjectFiles(_target),
540539
[this](fs::path const &objectPath) {

server/src/building/BuildDatabase.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ class BuildDatabase {
212212
*/
213213
std::vector<std::shared_ptr<ObjectFileInfo>> getAllCompileCommands() const;
214214

215-
std::vector<std::shared_ptr<TargetInfo>> getRootTargets() const;
215+
virtual std::vector<std::shared_ptr<TargetInfo>> getRootTargets() const;
216216

217-
std::vector<std::shared_ptr<TargetInfo>> getAllTargets() const;
217+
virtual std::vector<std::shared_ptr<TargetInfo>> getAllTargets() const;
218218

219-
std::vector<fs::path> getAllTargetPaths() const;
219+
virtual std::vector<fs::path> getAllTargetPaths() const;
220220

221221
virtual std::vector<fs::path> getTargetPathsForSourceFile(const fs::path &sourceFilePath) const;
222222

@@ -228,10 +228,6 @@ class BuildDatabase {
228228

229229
std::shared_ptr<TargetInfo> getTargetInfo(const fs::path &_target);
230230

231-
virtual bool hasAutoTarget() const = 0;
232-
233-
virtual fs::path getTargetPath() const = 0;
234-
235231
std::shared_ptr<CompilationDatabase> compilationDatabase;
236232

237233
protected:

server/src/building/ProjectBuildDatabase.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class ProjectBuildDatabase : public BuildDatabase {
2020
utbot::ProjectContext _projectContext);
2121

2222
static std::shared_ptr<ProjectBuildDatabase> create(const utbot::ProjectContext &projectContext);
23-
24-
bool hasAutoTarget() const override;
25-
26-
fs::path getTargetPath() const override;
2723
};
2824

2925

server/src/building/ProjectBuildDatabse.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,3 @@ void ProjectBuildDatabase::fillTargetInfoParents() {
233233
targetInfos[library]->parentLinkUnits = std::move(parents);
234234
}
235235
}
236-
237-
238-
bool ProjectBuildDatabase::hasAutoTarget() const {
239-
return true;
240-
}
241-
242-
fs::path ProjectBuildDatabase::getTargetPath() const {
243-
throw CompilationDatabaseException("Incorrect method for project build database");
244-
}

server/src/building/TargetBuildDatabase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ std::shared_ptr<TargetBuildDatabase> TargetBuildDatabase::createForSourceOrTarge
5151
return std::make_shared<TargetBuildDatabase>(std::move(TargetBuildDatabase(baseBuildDatabase, _target)));
5252
}
5353

54+
std::vector<std::shared_ptr<BuildDatabase::TargetInfo>> TargetBuildDatabase::getRootTargets() const {
55+
if (!hasAutoTarget()) {
56+
return {targetInfos.at(target)};
57+
}
58+
return BuildDatabase::getRootTargets();
59+
}
60+
5461
std::vector<fs::path> TargetBuildDatabase::getTargetPathsForSourceFile(const fs::path &sourceFilePath) const {
5562
if (!hasAutoTarget()) {
5663
return {target};

server/src/building/TargetBuildDatabase.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class TargetBuildDatabase : public BuildDatabase {
1414
static std::shared_ptr<TargetBuildDatabase> createForSourceOrTarget(BuildDatabase *baseBuildDatabase,
1515
const std::string &_targetOrSourcePath);
1616

17-
bool hasAutoTarget() const override;
17+
bool hasAutoTarget() const;
1818

19-
fs::path getTargetPath() const override;
19+
fs::path getTargetPath() const;
20+
21+
std::vector<std::shared_ptr<TargetInfo>> getRootTargets() const override;
2022

2123
std::vector<fs::path> getTargetPathsForSourceFile(const fs::path &sourceFilePath) const override;
2224

0 commit comments

Comments
 (0)