logic: source groups for project settings
* project can not have multiple source groups with different types * language of a project is now inferred from source groups * setting global NameHierarchy delimiter of first sourceGroup in project * added project settings migrations for source groups * Add Settings Migration classes (MoveKey, DeleteKey, Lambda) * Update sample projects with migrations * added method to config to retrieve sublevel key names * implemented recursive removing of keys in settings * moved project files out of top level * removed solution parsing code as it is not used anymore fortune cookie message = The secret of getting ahead is getting started.
This commit is contained in:
@@ -73,14 +73,14 @@ add_files(
|
||||
data/parser/cxx/PreprocessorCallbacks.h
|
||||
data/parser/cxx/utilityCxxAstVisitor.cpp
|
||||
data/parser/cxx/utilityCxxAstVisitor.h
|
||||
|
||||
project/SourceGroupCxx.cpp
|
||||
project/SourceGroupCxx.h
|
||||
project/SourceGroupFactoryModuleCpp.cpp
|
||||
project/SourceGroupFactoryModuleCpp.h
|
||||
project/SourceGroupFactoryModuleC.cpp
|
||||
project/SourceGroupFactoryModuleC.h
|
||||
|
||||
utility/CompilationDatabase.cpp
|
||||
utility/CompilationDatabase.h
|
||||
|
||||
CxxProject.cpp
|
||||
CxxProject.h
|
||||
ProjectFactoryModuleCpp.cpp
|
||||
ProjectFactoryModuleCpp.h
|
||||
ProjectFactoryModuleC.cpp
|
||||
ProjectFactoryModuleC.h
|
||||
)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef CXX_PROJECT_H
|
||||
#define CXX_PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "Project.h"
|
||||
|
||||
class CxxProject: public Project
|
||||
{
|
||||
public:
|
||||
CxxProject(
|
||||
std::shared_ptr<CxxProjectSettings> projectSettings,
|
||||
StorageAccessProxy* storageAccessProxy,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
virtual ~CxxProject();
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings();
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
CxxProject(const CxxProject&);
|
||||
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands();
|
||||
|
||||
virtual void updateFileManager(FileManager& fileManager);
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> m_projectSettings;
|
||||
|
||||
|
||||
friend Project;
|
||||
};
|
||||
|
||||
#endif // CXX_PROJECT_H
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "ProjectFactoryModuleC.h"
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
#include "CxxProject.h"
|
||||
|
||||
ProjectFactoryModuleC::~ProjectFactoryModuleC()
|
||||
{
|
||||
}
|
||||
|
||||
LanguageType ProjectFactoryModuleC::getLanguage() const
|
||||
{
|
||||
return LANGUAGE_C;
|
||||
}
|
||||
|
||||
std::shared_ptr<Project> ProjectFactoryModuleC::createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
{
|
||||
return std::shared_ptr<CxxProject>(new CxxProject(
|
||||
std::make_shared<CxxProjectSettings>(projectSettingsFile), storageAccessProxy, dialogView));
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef PROJECT_FACTORY_MODULE_C_H
|
||||
#define PROJECT_FACTORY_MODULE_C_H
|
||||
|
||||
#include "ProjectFactoryModule.h"
|
||||
|
||||
class ProjectFactoryModuleC: public ProjectFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~ProjectFactoryModuleC();
|
||||
virtual LanguageType getLanguage() const;
|
||||
|
||||
virtual std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
};
|
||||
|
||||
#endif // PROJECT_FACTORY_MODULE_C_H
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "ProjectFactoryModuleCpp.h"
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
#include "CxxProject.h"
|
||||
|
||||
ProjectFactoryModuleCpp::~ProjectFactoryModuleCpp()
|
||||
{
|
||||
}
|
||||
|
||||
LanguageType ProjectFactoryModuleCpp::getLanguage() const
|
||||
{
|
||||
return LANGUAGE_CPP;
|
||||
}
|
||||
|
||||
std::shared_ptr<Project> ProjectFactoryModuleCpp::createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
{
|
||||
return std::shared_ptr<CxxProject>(new CxxProject(
|
||||
std::make_shared<CxxProjectSettings>(projectSettingsFile), storageAccessProxy, dialogView));
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef PROJECT_FACTORY_MODULE_CPP_H
|
||||
#define PROJECT_FACTORY_MODULE_CPP_H
|
||||
|
||||
#include "ProjectFactoryModule.h"
|
||||
|
||||
class ProjectFactoryModuleCpp: public ProjectFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~ProjectFactoryModuleCpp();
|
||||
virtual LanguageType getLanguage() const;
|
||||
|
||||
virtual std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
};
|
||||
|
||||
#endif // PROJECT_FACTORY_MODULE_CPP_H
|
||||
@@ -1,13 +1,12 @@
|
||||
#include "CxxProject.h"
|
||||
#include "project/SourceGroupCxx.h"
|
||||
|
||||
#include "clang/Tooling/Tooling.h"
|
||||
#include "clang/Tooling/CompilationDatabase.h"
|
||||
#include "clang/Tooling/JSONCompilationDatabase.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "data/indexer/IndexerCommandCxxManual.h"
|
||||
#include "data/indexer/IndexerCxxCdb.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
@@ -15,31 +14,23 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
CxxProject::CxxProject(
|
||||
std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: Project(storageAccessProxy, dialogView)
|
||||
, m_projectSettings(projectSettings)
|
||||
SourceGroupCxx::SourceGroupCxx(std::shared_ptr<SourceGroupSettingsCxx> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
CxxProject::~CxxProject()
|
||||
SourceGroupCxx::~SourceGroupCxx()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> CxxProject::getProjectSettings()
|
||||
SourceGroupType SourceGroupCxx::getType() const
|
||||
{
|
||||
return m_projectSettings;
|
||||
return m_settings->getType();
|
||||
}
|
||||
|
||||
const std::shared_ptr<ProjectSettings> CxxProject::getProjectSettings() const
|
||||
bool SourceGroupCxx::prepareRefresh()
|
||||
{
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
bool CxxProject::prepareRefresh()
|
||||
{
|
||||
FilePath cdbPath = m_projectSettings->getAbsoluteCompilationDatabasePath();
|
||||
FilePath cdbPath = m_settings->getAbsoluteCompilationDatabasePath();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
@@ -58,18 +49,36 @@ bool CxxProject::prepareRefresh()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
void SourceGroupCxx::fetchAllSourceFilePaths()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
|
||||
FilePath cdbPath = m_settings->getAbsoluteCompilationDatabasePath();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
sourcePaths = IndexerCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePaths = m_settings->getAbsoluteSourcePaths();
|
||||
}
|
||||
|
||||
m_sourceFilePathsToIndex.clear();
|
||||
FileManager fileManager;
|
||||
fileManager.update(sourcePaths, m_settings->getAbsoluteExcludePaths(), m_settings->getSourceExtensions());
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxx::getIndexerCommands(const bool fullRefresh)
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
std::string languageStandard = m_projectSettings->getStandard();
|
||||
|
||||
std::vector<FilePath> systemHeaderSearchPaths;
|
||||
utility::append(systemHeaderSearchPaths, m_projectSettings->getAbsoluteHeaderSearchPaths());
|
||||
utility::append(systemHeaderSearchPaths, m_settings->getAbsoluteHeaderSearchPaths());
|
||||
utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
for (const FilePath& sourcePath : getSourcePaths())
|
||||
for (const FilePath& sourcePath: m_settings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (sourcePath.isDirectory())
|
||||
{
|
||||
@@ -78,10 +87,10 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
}
|
||||
|
||||
// Add all subdirectories of the header search paths
|
||||
if (m_projectSettings->getUseSourcePathsForHeaderSearch())
|
||||
if (m_settings->getUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
std::vector<FilePath> headerSearchSubPaths;
|
||||
for (const FilePath& sourcePath : getSourcePaths())
|
||||
for (const FilePath& sourcePath : m_settings->getAbsoluteSourcePaths())
|
||||
{
|
||||
utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(sourcePath));
|
||||
}
|
||||
@@ -90,13 +99,13 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
}
|
||||
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
utility::append(frameworkSearchPaths, m_projectSettings->getAbsoluteFrameworkSearchPaths());
|
||||
utility::append(frameworkSearchPaths, m_settings->getAbsoluteFrameworkSearchPaths());
|
||||
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
std::vector<std::string> compilerFlags = m_projectSettings->getCompilerFlags();
|
||||
const std::vector<std::string> compilerFlags = m_settings->getCompilerFlags();
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteSourcePaths())
|
||||
for (FilePath p: m_settings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
@@ -105,7 +114,7 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteExcludePaths())
|
||||
for (FilePath p: m_settings->getAbsoluteExcludePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
@@ -115,7 +124,9 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
FilePath cdbPath = m_projectSettings->getAbsoluteCompilationDatabasePath();
|
||||
const std::set<FilePath>& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex());
|
||||
|
||||
FilePath cdbPath = m_settings->getAbsoluteCompilationDatabasePath();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
std::string error;
|
||||
@@ -123,29 +134,32 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error));
|
||||
for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands())
|
||||
{
|
||||
std::vector<std::string> currentCompilerFlags = compilerFlags;
|
||||
currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end());
|
||||
if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end())
|
||||
{
|
||||
std::vector<std::string> currentCompilerFlags = compilerFlags;
|
||||
currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end());
|
||||
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
|
||||
FilePath(command.Filename),
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
FilePath(command.Directory),
|
||||
currentCompilerFlags,
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths
|
||||
));
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
|
||||
FilePath(command.Filename),
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
FilePath(command.Directory),
|
||||
currentCompilerFlags,
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const FilePath& sourcePath: getSourceFilePaths())
|
||||
for (const FilePath& sourcePath: sourceFilePathsToIndex)
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxManual>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
languageStandard,
|
||||
m_settings->getStandard(),
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths,
|
||||
compilerFlags
|
||||
@@ -155,25 +169,3 @@ std::vector<std::shared_ptr<IndexerCommand>> CxxProject::getIndexerCommands()
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
void CxxProject::updateFileManager(FileManager& fileManager)
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
|
||||
std::vector<std::string> sourceExtensions;
|
||||
|
||||
FilePath cdbPath = m_projectSettings->getAbsoluteCompilationDatabasePath();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
sourcePaths = IndexerCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceExtensions = m_projectSettings->getSourceExtensions();
|
||||
}
|
||||
|
||||
std::vector<FilePath> excludePaths = m_projectSettings->getAbsoluteExcludePaths();
|
||||
|
||||
fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef SOURCE_GROUP_CXX_H
|
||||
#define SOURCE_GROUP_CXX_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "project/SourceGroup.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
class SourceGroupCxx: public SourceGroup
|
||||
{
|
||||
public:
|
||||
SourceGroupCxx(std::shared_ptr<SourceGroupSettingsCxx> settings);
|
||||
virtual ~SourceGroupCxx();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
virtual void fetchAllSourceFilePaths();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const bool fullRefresh);
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettingsCxx> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_CXX_H
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "project/SourceGroupFactoryModuleC.h"
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
SourceGroupFactoryModuleC::~SourceGroupFactoryModuleC()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleC::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleC::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxx(cxxSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleC: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleC();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "project/SourceGroupFactoryModuleCpp.h"
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
SourceGroupFactoryModuleCpp::~SourceGroupFactoryModuleCpp()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleCpp::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleCpp::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxx(cxxSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleCpp: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleCpp();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
Reference in New Issue
Block a user