CompilationDatabaseProject: Simplify a bit

Change-Id: I83b6d2e77a4a5585af3c816aba1a7710d8d24ad6
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-07-19 16:11:59 +02:00
parent b0262115dd
commit e7dcbb6b44
3 changed files with 5 additions and 8 deletions

View File

@@ -3,12 +3,10 @@
#pragma once #pragma once
namespace CompilationDatabaseProjectManager { namespace CompilationDatabaseProjectManager::Constants {
namespace Constants {
const char COMPILATIONDATABASEMIMETYPE[] = "text/x-compilation-database-project"; const char COMPILATIONDATABASEMIMETYPE[] = "text/x-compilation-database-project";
const char COMPILATIONDATABASEPROJECT_ID[] = "CompilationDatabase.CompilationDatabaseEditor"; const char COMPILATIONDATABASEPROJECT_ID[] = "CompilationDatabase.CompilationDatabaseEditor";
const char COMPILATIONDATABASEPROJECT_FILES_SUFFIX[] = ".files"; const char COMPILATIONDATABASEPROJECT_FILES_SUFFIX[] = ".files";
} // Constants } // CompilationDatabaseProjectManager::Constants
} // CompilationDatabaseProjectManager

View File

@@ -438,7 +438,7 @@ CompilationDatabaseProject::CompilationDatabaseProject(const FilePath &projectFi
{projectFile.stringAppended(Constants::COMPILATIONDATABASEPROJECT_FILES_SUFFIX)}); {projectFile.stringAppended(Constants::COMPILATIONDATABASEPROJECT_FILES_SUFFIX)});
} }
FilePath CompilationDatabaseProject::rootPathFromSettings() const static FilePath rootPathFromSettings(Project *project)
{ {
FilePath rootPath; FilePath rootPath;
#ifndef WITH_TESTS #ifndef WITH_TESTS
@@ -446,7 +446,7 @@ FilePath CompilationDatabaseProject::rootPathFromSettings() const
namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString()); namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString());
#endif #endif
if (rootPath.isEmpty()) if (rootPath.isEmpty())
rootPath = projectDirectory(); rootPath = project->projectDirectory();
return rootPath; return rootPath;
} }
@@ -464,7 +464,7 @@ void CompilationDatabaseBuildSystem::reparseProject()
QTC_CHECK(isParsing()); QTC_CHECK(isParsing());
m_parser->stop(); m_parser->stop();
} }
const FilePath rootPath = static_cast<CompilationDatabaseProject *>(project())->rootPathFromSettings(); const FilePath rootPath = rootPathFromSettings(project());
m_parser = new CompilationDbParser(project()->displayName(), m_parser = new CompilationDbParser(project()->displayName(),
projectFilePath(), projectFilePath(),
rootPath, rootPath,

View File

@@ -15,7 +15,6 @@ class CompilationDatabaseProject final : public ProjectExplorer::Project
public: public:
explicit CompilationDatabaseProject(const Utils::FilePath &filename); explicit CompilationDatabaseProject(const Utils::FilePath &filename);
Utils::FilePath rootPathFromSettings() const;
private: private:
void configureAsExampleProject(ProjectExplorer::Kit *kit) final; void configureAsExampleProject(ProjectExplorer::Kit *kit) final;