logic: Add parent directories of source files in the compilation database automatically to header paths
This commit is contained in:
@@ -6,7 +6,9 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "component/view/DialogView.h"
|
#include "component/view/DialogView.h"
|
||||||
|
#include "data/indexer/IndexerCommandCxxCdb.h"
|
||||||
#include "project/IncludeDirective.h"
|
#include "project/IncludeDirective.h"
|
||||||
#include "project/IncludeValidation.h"
|
#include "project/IncludeValidation.h"
|
||||||
#include "qt/element/QtDirectoryListBox.h"
|
#include "qt/element/QtDirectoryListBox.h"
|
||||||
@@ -21,7 +23,6 @@
|
|||||||
#include "utility/utility.h"
|
#include "utility/utility.h"
|
||||||
#include "utility/utilityFile.h"
|
#include "utility/utilityFile.h"
|
||||||
#include "utility/utilityPathDetection.h"
|
#include "utility/utilityPathDetection.h"
|
||||||
#include "Application.h"
|
|
||||||
|
|
||||||
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
|
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
|
||||||
: QtProjectWizzardContent(window)
|
: QtProjectWizzardContent(window)
|
||||||
@@ -266,15 +267,40 @@ void QtProjectWizzardContentPathsCDBHeader::load()
|
|||||||
if (m_settings->getSourcePaths().empty())
|
if (m_settings->getSourcePaths().empty())
|
||||||
{
|
{
|
||||||
std::shared_ptr<SourceGroupSettingsCxxCdb> cdbSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings);
|
std::shared_ptr<SourceGroupSettingsCxxCdb> cdbSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings);
|
||||||
std::vector<FilePath> sourcePaths;
|
std::set<FilePath> sourcePaths;
|
||||||
for (const FilePath& path : getTopLevelHeaderSearchPaths(cdbSettings))
|
|
||||||
|
const FilePath projectPath = m_settings->getProjectDirectoryPath();
|
||||||
|
const FilePath cdbPath = cdbSettings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||||
|
|
||||||
|
if (!cdbPath.empty() && cdbPath.exists())
|
||||||
{
|
{
|
||||||
if (path.exists() && m_settings->getProjectDirectoryPath().contains(path))
|
for (const FilePath& path : IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath))
|
||||||
{
|
{
|
||||||
sourcePaths.push_back(path);
|
sourcePaths.insert(path.parentDirectory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_settings->setSourcePaths(sourcePaths);
|
|
||||||
|
for (const FilePath& path : getTopLevelHeaderSearchPaths(cdbSettings))
|
||||||
|
{
|
||||||
|
if (path.exists() && projectPath.contains(path))
|
||||||
|
{
|
||||||
|
sourcePaths.insert(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<FilePath> rootPaths;
|
||||||
|
|
||||||
|
FilePath lastPath;
|
||||||
|
for (const FilePath& path : sourcePaths)
|
||||||
|
{
|
||||||
|
if (lastPath.empty() || !lastPath.contains(path)) // don't add subdirectories of already added paths
|
||||||
|
{
|
||||||
|
lastPath = path;
|
||||||
|
rootPaths.push_back(path.relativeTo(projectPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settings->setSourcePaths(rootPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtProjectWizzardContentPathsSource::load();
|
QtProjectWizzardContentPathsSource::load();
|
||||||
|
|||||||
Reference in New Issue
Block a user