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:
+11
-9
@@ -1,8 +1,5 @@
|
||||
#include "Application.h"
|
||||
#include "ApplicationStateMonitor.h"
|
||||
#include "ProjectFactoryModuleC.h"
|
||||
#include "ProjectFactoryModuleCpp.h"
|
||||
#include "ProjectFactoryModuleJava.h"
|
||||
|
||||
#include "data/indexer/IndexerFactory.h"
|
||||
#include "data/indexer/IndexerFactoryModuleJava.h"
|
||||
@@ -11,6 +8,11 @@
|
||||
|
||||
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
|
||||
#include "LicenseChecker.h"
|
||||
|
||||
#include "project/SourceGroupFactory.h"
|
||||
#include "project/SourceGroupFactoryModuleC.h"
|
||||
#include "project/SourceGroupFactoryModuleCpp.h"
|
||||
#include "project/SourceGroupFactoryModuleJava.h"
|
||||
#include "qt/network/QtNetworkFactory.h"
|
||||
#include "qt/QtApplication.h"
|
||||
#include "qt/QtCoreApplication.h"
|
||||
@@ -166,9 +168,9 @@ int main(int argc, char *argv[])
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxCdb>());
|
||||
@@ -228,9 +230,9 @@ int main(int argc, char *argv[])
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
|
||||
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxCdb>());
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "data/StorageCache.h"
|
||||
#include "LicenseChecker.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
void Application::createInstance(
|
||||
@@ -105,11 +106,6 @@ Application::~Application()
|
||||
}
|
||||
}
|
||||
|
||||
void Application::addProjectFactoryModule(std::shared_ptr<ProjectFactoryModule> module)
|
||||
{
|
||||
m_projectFactory.addModule(module);
|
||||
}
|
||||
|
||||
const std::shared_ptr<Project> Application::getCurrentProject()
|
||||
{
|
||||
return m_project;
|
||||
@@ -155,10 +151,12 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
m_storageCache->clear();
|
||||
m_storageCache->setSubject(nullptr);
|
||||
|
||||
m_project = m_projectFactory.createProject(projectSettingsFilePath, m_storageCache.get(), getDialogView());
|
||||
m_project = std::make_shared<Project>(std::make_shared<ProjectSettings>(projectSettingsFilePath), m_storageCache.get());
|
||||
|
||||
if (m_project)
|
||||
{
|
||||
m_project->load();
|
||||
|
||||
if (m_hasGUI)
|
||||
{
|
||||
updateTitle();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "component/ComponentManager.h"
|
||||
#include "project/Project.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateWindow.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
@@ -11,8 +12,6 @@
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "Project.h"
|
||||
#include "ProjectFactory.h"
|
||||
|
||||
class DialogView;
|
||||
class IDECommunicationController;
|
||||
@@ -21,7 +20,6 @@ class NetworkFactory;
|
||||
class StorageCache;
|
||||
class Version;
|
||||
class ViewFactory;
|
||||
class ProjectFactoryModule;
|
||||
|
||||
class Application
|
||||
: public MessageListener<MessageActivateWindow>
|
||||
@@ -39,8 +37,6 @@ public:
|
||||
static void loadSettings();
|
||||
static void loadStyle(const FilePath& colorSchemePath);
|
||||
|
||||
void addProjectFactoryModule(std::shared_ptr<ProjectFactoryModule> module);
|
||||
|
||||
~Application();
|
||||
|
||||
const std::shared_ptr<Project> getCurrentProject();
|
||||
@@ -76,7 +72,6 @@ private:
|
||||
void updateTitle();
|
||||
|
||||
const bool m_hasGUI;
|
||||
ProjectFactory m_projectFactory;
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<StorageCache> m_storageCache;
|
||||
|
||||
|
||||
+29
-24
@@ -221,25 +221,45 @@ add_files(
|
||||
data/TaskMergeStorages.h
|
||||
data/TaskShowStatusDialog.cpp
|
||||
data/TaskShowStatusDialog.h
|
||||
|
||||
|
||||
project/Project.cpp
|
||||
project/Project.h
|
||||
project/SourceGroupFactory.cpp
|
||||
project/SourceGroupFactory.h
|
||||
project/SourceGroupFactoryModule.cpp
|
||||
project/SourceGroupFactoryModule.h
|
||||
project/SourceGroup.cpp
|
||||
project/SourceGroup.h
|
||||
|
||||
settings/migration/Migration.cpp
|
||||
settings/migration/Migration.h
|
||||
settings/migration/MigrationDeleteKey.cpp
|
||||
settings/migration/MigrationDeleteKey.h
|
||||
settings/migration/MigrationLambda.cpp
|
||||
settings/migration/MigrationLambda.h
|
||||
settings/migration/MigrationMoveKey.cpp
|
||||
settings/migration/MigrationMoveKey.h
|
||||
settings/migration/SettingsMigrator.cpp
|
||||
settings/migration/SettingsMigrator.h
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
settings/ApplicationSettings.h
|
||||
settings/ColorScheme.cpp
|
||||
settings/ColorScheme.h
|
||||
settings/CxxProjectSettings.cpp
|
||||
settings/CxxProjectSettings.h
|
||||
settings/JavaProjectSettings.cpp
|
||||
settings/JavaProjectSettings.h
|
||||
settings/LanguageType.cpp
|
||||
settings/LanguageType.h
|
||||
settings/ProjectSettings.cpp
|
||||
settings/ProjectSettings.h
|
||||
settings/ProjectType.cpp
|
||||
settings/ProjectType.h
|
||||
settings/Settings.cpp
|
||||
settings/Settings.h
|
||||
settings/SettingsMigrator.cpp
|
||||
settings/SettingsMigrator.h
|
||||
settings/SourceGroupSettings.cpp
|
||||
settings/SourceGroupSettings.h
|
||||
settings/SourceGroupSettingsCxx.cpp
|
||||
settings/SourceGroupSettingsCxx.h
|
||||
settings/SourceGroupSettingsJava.cpp
|
||||
settings/SourceGroupSettingsJava.h
|
||||
settings/SourceGroupType.cpp
|
||||
settings/SourceGroupType.h
|
||||
|
||||
utility/commandline/CommandLineParser.cpp
|
||||
utility/commandline/CommandLineParser.h
|
||||
@@ -400,15 +420,6 @@ add_files(
|
||||
utility/scheduling/TaskScheduler.h
|
||||
utility/scheduling/TaskSetValue.h
|
||||
|
||||
utility/solution/ISolutionParser.cpp
|
||||
utility/solution/ISolutionParser.h
|
||||
utility/solution/SolutionParserCodeBlocks.cpp
|
||||
utility/solution/SolutionParserCodeBlocks.h
|
||||
utility/solution/SolutionParserManager.cpp
|
||||
utility/solution/SolutionParserManager.h
|
||||
utility/solution/SolutionParserUtility.cpp
|
||||
utility/solution/SolutionParserUtility.h
|
||||
|
||||
utility/synchronization/ReaderWriterLock.cpp
|
||||
utility/synchronization/ReaderWriterLock.h
|
||||
utility/synchronization/ScopedReaderLock.cpp
|
||||
@@ -458,10 +469,4 @@ add_files(
|
||||
ApplicationStateMonitor.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
Project.cpp
|
||||
Project.h
|
||||
ProjectFactory.cpp
|
||||
ProjectFactory.h
|
||||
ProjectFactoryModule.cpp
|
||||
ProjectFactoryModule.h
|
||||
)
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class PersistentStorage;
|
||||
class StorageProvider;
|
||||
class ProjectSettings;
|
||||
class StorageAccessProxy;
|
||||
class IndexerCommand;
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
virtual ~Project();
|
||||
|
||||
bool refresh(bool forceRefresh);
|
||||
|
||||
FilePath getProjectSettingsFilePath() const;
|
||||
LanguageType getLanguage() const;
|
||||
std::string getDescription() const;
|
||||
|
||||
std::set<FilePath> getSourceFilePaths() const;
|
||||
|
||||
bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const;
|
||||
void setStateSettingsUpdated();
|
||||
|
||||
protected:
|
||||
Project(StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView);
|
||||
std::shared_ptr<DialogView> getDialogView() const;
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings() = 0;
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const = 0;
|
||||
|
||||
private:
|
||||
enum ProjectStateType
|
||||
{
|
||||
PROJECT_STATE_NOT_LOADED,
|
||||
PROJECT_STATE_EMPTY,
|
||||
PROJECT_STATE_LOADED,
|
||||
PROJECT_STATE_OUTDATED,
|
||||
PROJECT_STATE_OUTVERSIONED,
|
||||
PROJECT_STATE_SETTINGS_UPDATED,
|
||||
PROJECT_STATE_NEEDS_MIGRATION
|
||||
};
|
||||
|
||||
Project(const Project&);
|
||||
|
||||
public: // todo: make private again
|
||||
void load();
|
||||
|
||||
private:
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh);
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
virtual bool prepareRefresh();
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands() = 0;
|
||||
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& sourceFiles);
|
||||
virtual void updateFileManager(FileManager& fileManager) = 0;
|
||||
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
ProjectStateType m_state;
|
||||
FileManager m_fileManager;
|
||||
|
||||
std::shared_ptr<PersistentStorage> m_storage;
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
@@ -1,35 +0,0 @@
|
||||
#include "ProjectFactory.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
#include "Project.h"
|
||||
#include "ProjectFactoryModule.h"
|
||||
|
||||
void ProjectFactory::addModule(std::shared_ptr<ProjectFactoryModule> module)
|
||||
{
|
||||
m_modules[module->getLanguage()] = module;
|
||||
}
|
||||
|
||||
std::shared_ptr<Project> ProjectFactory::createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView)
|
||||
{
|
||||
std::shared_ptr<Project> project;
|
||||
|
||||
std::map<LanguageType, std::shared_ptr<ProjectFactoryModule>>::const_iterator it = m_modules.find(
|
||||
ProjectSettings::getLanguageOfProject(projectSettingsFile)
|
||||
);
|
||||
|
||||
if (it != m_modules.end())
|
||||
{
|
||||
project = it->second->createProject(projectSettingsFile, storageAccessProxy, dialogView);
|
||||
}
|
||||
|
||||
if (project)
|
||||
{
|
||||
project->load();
|
||||
}
|
||||
return project;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef PROJECT_FACTORY_H
|
||||
#define PROJECT_FACTORY_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
class Project;
|
||||
class FilePath;
|
||||
class StorageAccessProxy;
|
||||
class DialogView;
|
||||
class ProjectFactoryModule;
|
||||
|
||||
class ProjectFactory
|
||||
{
|
||||
public:
|
||||
void addModule(std::shared_ptr<ProjectFactoryModule> module);
|
||||
|
||||
std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView);
|
||||
|
||||
private:
|
||||
std::map<LanguageType, std::shared_ptr<ProjectFactoryModule>> m_modules;
|
||||
};
|
||||
|
||||
#endif // PROJECT_FACTORY_H
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "ProjectFactoryModule.h"
|
||||
|
||||
ProjectFactoryModule::~ProjectFactoryModule()
|
||||
{
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef PROJECT_FACTORY_MODULE_H
|
||||
#define PROJECT_FACTORY_MODULE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
class Project;
|
||||
class FilePath;
|
||||
class StorageAccessProxy;
|
||||
class DialogView;
|
||||
|
||||
class ProjectFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~ProjectFactoryModule();
|
||||
virtual LanguageType getLanguage() const = 0;
|
||||
|
||||
virtual std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#endif // PROJECT_FACTORY_MODULE_H
|
||||
@@ -1476,7 +1476,7 @@ std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<Fil
|
||||
|
||||
std::set<FilePath> paths;
|
||||
for (Id id: ids)
|
||||
{
|
||||
{ // TODO: performance optimize: use just one request for all ids!
|
||||
paths.insert(getFileNodePath(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,22 @@
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
TaskCleanStorage::TaskCleanStorage(
|
||||
PersistentStorage* storage, const std::vector<FilePath>& filePaths, std::shared_ptr<DialogView> dialogView
|
||||
PersistentStorage* storage, const std::vector<FilePath>& filePaths
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_filePaths(filePaths)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
}
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -28,10 +31,9 @@ void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
std::shared_ptr<DialogView> dialogView = m_dialogView;
|
||||
m_storage->clearFileElements(m_filePaths, [=](int progress)
|
||||
{
|
||||
if (dialogView != nullptr)
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showProgressDialog("Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
@@ -46,8 +48,10 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
|
||||
void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
blackboard->set("clear_time", utility::duration(m_start));
|
||||
|
||||
m_dialogView->hideProgressDialog();
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->hideProgressDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskCleanStorage::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
@@ -16,8 +16,7 @@ class TaskCleanStorage
|
||||
public:
|
||||
TaskCleanStorage(
|
||||
PersistentStorage* storage,
|
||||
const std::vector<FilePath>& filePaths,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
const std::vector<FilePath>& filePaths
|
||||
);
|
||||
|
||||
private:
|
||||
@@ -28,7 +27,6 @@ private:
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
std::vector<FilePath> m_filePaths;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
TimePoint m_start;
|
||||
};
|
||||
|
||||
@@ -6,15 +6,14 @@
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
TaskFinishParsing::TaskFinishParsing(
|
||||
PersistentStorage* storage,
|
||||
StorageAccess* storageAccess,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
StorageAccess* storageAccess
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_storageAccess(storageAccess)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,21 +30,23 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
TimePoint start = utility::durationStart();
|
||||
|
||||
if (m_dialogView)
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
m_dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
}
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
if (m_dialogView)
|
||||
if (dialogView)
|
||||
{
|
||||
m_dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
}
|
||||
m_storage->buildCaches();
|
||||
|
||||
if (m_dialogView)
|
||||
if (dialogView)
|
||||
{
|
||||
m_dialogView->hideStatusDialog();
|
||||
dialogView->hideStatusDialog();
|
||||
}
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
@@ -71,9 +72,9 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
int sourceFileCount = 0;
|
||||
blackboard->get("source_file_count", sourceFileCount);
|
||||
|
||||
if (m_dialogView)
|
||||
if (dialogView)
|
||||
{
|
||||
m_dialogView->finishedIndexingDialog(
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
time,
|
||||
|
||||
@@ -17,8 +17,7 @@ class TaskFinishParsing
|
||||
public:
|
||||
TaskFinishParsing(
|
||||
PersistentStorage* storage,
|
||||
StorageAccess* storageAccess,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
StorageAccess* storageAccess
|
||||
);
|
||||
|
||||
virtual ~TaskFinishParsing();
|
||||
@@ -31,7 +30,6 @@ private:
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
StorageAccess* m_storageAccess;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_FINISH_PARSING_H
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#include "data/TaskShowStatusDialog.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "Application.h"
|
||||
|
||||
TaskShowStatusDialog::TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
const std::string& message
|
||||
)
|
||||
: m_title(title)
|
||||
, m_message(message)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,9 +22,9 @@ void TaskShowStatusDialog::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (m_dialogView)
|
||||
{
|
||||
m_dialogView->showStatusDialog(m_title, m_message);
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog(m_title, m_message);
|
||||
}
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ class TaskShowStatusDialog
|
||||
public:
|
||||
TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
const std::string& message
|
||||
);
|
||||
|
||||
virtual ~TaskShowStatusDialog();
|
||||
@@ -27,7 +26,6 @@ private:
|
||||
|
||||
const std::string m_title;
|
||||
const std::string m_message;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_SHOW_STATUS_DIALOG_H
|
||||
|
||||
@@ -9,17 +9,16 @@
|
||||
#include "utility/file/FileRegisterStateData.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "ApplicationStateMonitor.h"
|
||||
#include "Application.h"
|
||||
|
||||
TaskBuildIndex::TaskBuildIndex(
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList,
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData
|
||||
)
|
||||
: m_indexerCommandList(indexerCommandList)
|
||||
, m_storageProvider(storageProvider)
|
||||
, m_fileRegisterStateData(fileRegisterStateData)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
m_indexer = IndexerFactory::getInstance()->createCompositeIndexerForAllRegisteredModules();
|
||||
}
|
||||
@@ -57,9 +56,9 @@ Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
int indexedSourceFileCount = 0;
|
||||
blackboard->get("indexed_source_file_count", indexedSourceFileCount);
|
||||
|
||||
if (m_dialogView)
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
m_dialogView->updateIndexingDialog(
|
||||
dialogView->updateIndexingDialog(
|
||||
indexedSourceFileCount, sourceFileCount, indexerCommand->getSourceFilePath().str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
TaskBuildIndex(
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList,
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData
|
||||
);
|
||||
|
||||
protected:
|
||||
@@ -36,7 +35,6 @@ protected:
|
||||
std::shared_ptr<IndexerCommandList> m_indexerCommandList;
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
std::shared_ptr<FileRegisterStateData> m_fileRegisterStateData;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
std::shared_ptr<IndexerBase> m_indexer;
|
||||
};
|
||||
|
||||
@@ -4,13 +4,10 @@
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
TaskParseWrapper::TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
TaskParseWrapper::TaskParseWrapper(PersistentStorage* storage)
|
||||
: m_storage(storage)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,9 +27,9 @@ void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
int sourceFileCount = 0;
|
||||
blackboard->get("source_file_count", sourceFileCount);
|
||||
if (m_dialogView)
|
||||
{
|
||||
m_dialogView->updateIndexingDialog(0, sourceFileCount, "");
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->updateIndexingDialog(0, sourceFileCount, "");
|
||||
}
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -18,10 +18,7 @@ class TaskParseWrapper
|
||||
: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
TaskParseWrapper(PersistentStorage* storage);
|
||||
virtual ~TaskParseWrapper();
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
@@ -33,7 +30,6 @@ private:
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
TimePoint m_start;
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Project.h"
|
||||
#include "project/Project.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
@@ -13,10 +13,14 @@
|
||||
#include "data/TaskShowStatusDialog.h"
|
||||
#include "data/TaskFinishParsing.h"
|
||||
#include "data/TaskInjectStorage.h"
|
||||
#include "project/SourceGroup.h"
|
||||
#include "project/SourceGroupFactory.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FileRegisterStateData.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageClearErrorCount.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
@@ -35,6 +39,13 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
Project::Project(std::shared_ptr<ProjectSettings> settings, StorageAccessProxy* storageAccessProxy)
|
||||
: m_settings(settings)
|
||||
, m_storageAccessProxy(storageAccessProxy)
|
||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
}
|
||||
@@ -94,7 +105,7 @@ bool Project::refresh(bool forceRefresh)
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_dialogView->confirm(question, options);
|
||||
int result = Application::getInstance()->getDialogView()->confirm(question, options);
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
@@ -106,26 +117,28 @@ bool Project::refresh(bool forceRefresh)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
m_dialogView->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
Application::getInstance()->getDialogView()->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageRefresh>()).dispatch();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prepareRefresh())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_state == PROJECT_STATE_NEEDS_MIGRATION)
|
||||
{
|
||||
getProjectSettings()->migrate();
|
||||
m_settings->migrate();
|
||||
}
|
||||
|
||||
getProjectSettings()->reload();
|
||||
m_settings->reload();
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
m_sourceGroups = SourceGroupFactory::getInstance()->createSourceGroups(m_settings->getAllSourceGroupSettings());
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
if (!sourceGroup->prepareRefresh())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (requestIndex(forceRefresh, needsFullRefresh))
|
||||
{
|
||||
@@ -141,27 +154,17 @@ bool Project::refresh(bool forceRefresh)
|
||||
|
||||
FilePath Project::getProjectSettingsFilePath() const
|
||||
{
|
||||
return getProjectSettings()->getFilePath();
|
||||
}
|
||||
|
||||
LanguageType Project::getLanguage() const
|
||||
{
|
||||
return getProjectSettings()->getLanguage();
|
||||
return m_settings->getFilePath();
|
||||
}
|
||||
|
||||
std::string Project::getDescription() const
|
||||
{
|
||||
return getProjectSettings()->getDescription();
|
||||
}
|
||||
|
||||
std::set<FilePath> Project::getSourceFilePaths() const
|
||||
{
|
||||
return m_fileManager.getSourceFilePaths();
|
||||
return m_settings->getDescription();
|
||||
}
|
||||
|
||||
bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const
|
||||
{
|
||||
return getProjectSettings()->equalsExceptNameAndLocation(otherSettings);
|
||||
return m_settings->equalsExceptNameAndLocation(otherSettings);
|
||||
}
|
||||
|
||||
void Project::setStateSettingsUpdated()
|
||||
@@ -172,45 +175,25 @@ void Project::setStateSettingsUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_dialogView(dialogView)
|
||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> Project::getDialogView() const
|
||||
{
|
||||
return m_dialogView;
|
||||
}
|
||||
|
||||
std::vector<FilePath> Project::getSourcePaths() const
|
||||
{
|
||||
return m_fileManager.getSourcePaths();
|
||||
}
|
||||
|
||||
void Project::load()
|
||||
{
|
||||
m_storageAccessProxy->setSubject(nullptr);
|
||||
|
||||
std::shared_ptr<ProjectSettings> projectSettings = getProjectSettings();
|
||||
bool loadedSettings = projectSettings->reload();
|
||||
bool loadedSettings = m_settings->reload();
|
||||
|
||||
if (!loadedSettings)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(projectSettings->getLanguage()));
|
||||
|
||||
const FilePath projectSettingsPath = projectSettings->getFilePath();
|
||||
const FilePath projectSettingsPath = m_settings->getFilePath();
|
||||
const FilePath dbPath = FilePath(projectSettingsPath).replaceExtension("coatidb");
|
||||
|
||||
m_storage = std::make_shared<PersistentStorage>(dbPath);
|
||||
|
||||
bool canLoad = false;
|
||||
|
||||
if (projectSettings->needMigration())
|
||||
if (m_settings->needMigration())
|
||||
{
|
||||
m_state = PROJECT_STATE_NEEDS_MIGRATION;
|
||||
|
||||
@@ -246,6 +229,12 @@ void Project::load()
|
||||
m_storage->buildCaches();
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
|
||||
m_sourceGroups = SourceGroupFactory::getInstance()->createSourceGroups(m_settings->getAllSourceGroupSettings());
|
||||
if (!m_sourceGroups.empty())
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(m_sourceGroups.front()->getLanguage()));
|
||||
}
|
||||
|
||||
MessageFinishedParsing().dispatch();
|
||||
MessageStatus("Finished Loading", false, false).dispatch();
|
||||
}
|
||||
@@ -262,47 +251,58 @@ void Project::load()
|
||||
|
||||
bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
{
|
||||
if (!prepareIndexing())
|
||||
std::set<FilePath> allSourceFilePaths;
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
return false;
|
||||
if (!sourceGroup->prepareIndexing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sourceGroup->fetchAllSourceFilePaths();
|
||||
utility::append(allSourceFilePaths, sourceGroup->getAllSourceFilePaths());
|
||||
}
|
||||
|
||||
const FileManager::FileSets fileSets = m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
|
||||
std::set<FilePath> filesToClean;
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
if (!needsFullRefresh)
|
||||
{
|
||||
utility::append(filesToClean, fileSets.removedFiles);
|
||||
utility::append(filesToClean, fileSets.updatedFiles);
|
||||
utility::append(filesToIndex, fileSets.addedFiles);
|
||||
utility::append(filesToIndex, fileSets.updatedFiles);
|
||||
|
||||
// handle referencing paths
|
||||
const std::set<FilePath> referencingFilePaths = m_storage->getReferencing(utility::concat(
|
||||
fileSets.updatedFiles, fileSets.removedFiles
|
||||
));
|
||||
|
||||
for (const FilePath& path : referencingFilePaths)
|
||||
std::set<FilePath> unchangedFilePaths;
|
||||
std::set<FilePath> changedFilePaths;
|
||||
for (const FileInfo& info: m_storage->getInfoOnAllFiles())
|
||||
{
|
||||
if (fileSets.removedFiles.find(path) == fileSets.removedFiles.end())
|
||||
if (info.path.exists())
|
||||
{
|
||||
filesToClean.insert(path);
|
||||
filesToIndex.insert(path);
|
||||
FileInfo newFileInfo = FileSystem::getFileInfoForPath(info.path);
|
||||
|
||||
if (newFileInfo.lastWriteTime > info.lastWriteTime)
|
||||
{
|
||||
// file has been updated
|
||||
changedFilePaths.insert(info.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
unchangedFilePaths.insert(info.path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// file has been removed
|
||||
changedFilePaths.insert(info.path);
|
||||
}
|
||||
}
|
||||
|
||||
filesToClean = changedFilePaths;
|
||||
|
||||
// handle referencing paths
|
||||
utility::append(filesToClean, m_storage->getReferencing(changedFilePaths));
|
||||
|
||||
|
||||
// handle referenced paths
|
||||
std::set<FilePath> staticSourceFiles = fileSets.allSourceFilePaths;
|
||||
for (const FilePath& path : fileSets.updatedFiles)
|
||||
std::set<FilePath> staticSourceFiles = allSourceFilePaths;
|
||||
for (const FilePath& path: changedFilePaths)
|
||||
{
|
||||
staticSourceFiles.erase(path);
|
||||
}
|
||||
const std::set<FilePath> staticReferencedFilePaths = m_storage->getReferenced(staticSourceFiles);
|
||||
const std::set<FilePath> dynamicReferencedFilePaths = m_storage->getReferenced(utility::concat(
|
||||
fileSets.updatedFiles, fileSets.removedFiles
|
||||
));
|
||||
const std::set<FilePath> dynamicReferencedFilePaths = m_storage->getReferenced(changedFilePaths);
|
||||
|
||||
for (const FilePath& path : dynamicReferencedFilePaths)
|
||||
{
|
||||
@@ -315,12 +315,29 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> staticSourceFilePaths;
|
||||
for (const FilePath& path: allSourceFilePaths)
|
||||
{
|
||||
if (filesToClean.find(path) == filesToClean.end())
|
||||
{
|
||||
staticSourceFilePaths.insert(path);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
sourceGroup->fetchSourceFilePathsToIndex(staticSourceFilePaths);
|
||||
utility::append(filesToIndex, sourceGroup->getSourceFilePathsToIndex());
|
||||
}
|
||||
|
||||
bool fullRefresh = forceRefresh | needsFullRefresh;
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
DialogView::IndexMode mode = m_dialogView->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), fileSets.allSourceFilePaths.size(),
|
||||
DialogView::IndexMode mode = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(),
|
||||
forceRefresh, needsFullRefresh
|
||||
);
|
||||
|
||||
@@ -340,7 +357,7 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
if (fullRefresh)
|
||||
{
|
||||
filesToClean.clear();
|
||||
filesToIndex = fileSets.allSourceFilePaths;
|
||||
filesToIndex = allSourceFilePaths;
|
||||
}
|
||||
|
||||
if (!filesToClean.size() && !filesToIndex.size())
|
||||
@@ -351,12 +368,12 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
|
||||
MessageStatus((fullRefresh ? "Reindexing Project" : "Refreshing Project"), false, true).dispatch();
|
||||
|
||||
buildIndex(filesToClean, filesToIndex, fullRefresh);
|
||||
buildIndex(filesToClean, fullRefresh);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh)
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh)
|
||||
{
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
@@ -374,20 +391,23 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<
|
||||
{
|
||||
taskSequential->addTask(std::make_shared<TaskCleanStorage>(
|
||||
m_storage.get(),
|
||||
utility::toVector(filesToClean),
|
||||
m_dialogView)
|
||||
utility::toVector(filesToClean))
|
||||
);
|
||||
}
|
||||
|
||||
if (!filesToIndex.empty())
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList = std::make_shared<IndexerCommandList>();
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
for (std::shared_ptr<IndexerCommand> command: sourceGroup->getIndexerCommands(fullRefresh))
|
||||
{
|
||||
indexerCommandList->addCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
if (indexerCommandList->size() > 0)
|
||||
{
|
||||
const size_t indexerThreadCount = ApplicationSettings::getInstance()->getIndexerThreadCount();
|
||||
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList = std::make_shared<IndexerCommandList>();
|
||||
for (std::shared_ptr<IndexerCommand> indexerCommand: getIndexerCommands(filesToIndex))
|
||||
{
|
||||
indexerCommandList->addCommand(indexerCommand);
|
||||
}
|
||||
if (indexerThreadCount > 1)
|
||||
{
|
||||
indexerCommandList->shuffle();
|
||||
@@ -402,21 +422,18 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexed_source_file_count", 0));
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexer_count", 0));
|
||||
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
m_dialogView
|
||||
);
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(m_storage.get());
|
||||
taskSequential->addTask(taskParserWrapper);
|
||||
|
||||
std::shared_ptr<TaskGroupParallel> taskParallelIndexing = std::make_shared<TaskGroupParallel>();
|
||||
taskParserWrapper->setTask(taskParallelIndexing);
|
||||
|
||||
// add tasks for indexing and merging
|
||||
for (size_t i = 0; i < indexerThreadCount && i < filesToIndex.size(); i++)
|
||||
for (size_t i = 0; i < indexerThreadCount && i < indexerCommandList->size(); i++)
|
||||
{
|
||||
taskParallelIndexing->addChildTasks(
|
||||
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
|
||||
std::make_shared<TaskBuildIndex>(indexerCommandList, storageProvider, fileRegisterStateData, getDialogView())
|
||||
std::make_shared<TaskBuildIndex>(indexerCommandList, storageProvider, fileRegisterStateData)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -458,7 +475,7 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<
|
||||
|
||||
// add task that notifies the user of what's going on
|
||||
taskSequential->addTask( // we don't need to hide this dialog again, because it's overridden by other dialogs later on.
|
||||
std::make_shared<TaskShowStatusDialog>("Finish Indexing", "Saving\nRemaining Data", m_dialogView)
|
||||
std::make_shared<TaskShowStatusDialog>("Finish Indexing", "Saving\nRemaining Data")
|
||||
);
|
||||
|
||||
// add task that injects the remaining intermediate storages into the persistent storage
|
||||
@@ -469,42 +486,7 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<
|
||||
);
|
||||
}
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), m_storageAccessProxy, m_dialogView));
|
||||
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), m_storageAccessProxy));
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
}
|
||||
|
||||
bool Project::prepareIndexing()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Project::prepareRefresh()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> Project::getIndexerCommands(const std::set<FilePath>& sourceFiles)
|
||||
{
|
||||
struct special_compare : public std::unary_function<FilePath, bool>
|
||||
{
|
||||
explicit special_compare(const FilePath& baseline) : m_baseline(baseline) {}
|
||||
bool operator() (const FilePath& arg)
|
||||
{
|
||||
return arg.str() == m_baseline.str();
|
||||
}
|
||||
const FilePath m_baseline;
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (std::shared_ptr<IndexerCommand> indexerCommand: getIndexerCommands())
|
||||
{
|
||||
if (std::find_if(sourceFiles.begin(), sourceFiles.end(), special_compare(indexerCommand->getSourceFilePath())) != sourceFiles.end())
|
||||
{
|
||||
indexerCommands.push_back(indexerCommand);
|
||||
}
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "project/SourceGroup.h"
|
||||
|
||||
class FilePath;
|
||||
class PersistentStorage;
|
||||
class ProjectSettings;
|
||||
class StorageAccessProxy;
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
Project(std::shared_ptr<ProjectSettings> settings, StorageAccessProxy* storageAccessProxy);
|
||||
virtual ~Project();
|
||||
|
||||
bool refresh(bool forceRefresh);
|
||||
|
||||
FilePath getProjectSettingsFilePath() const;
|
||||
std::string getDescription() const;
|
||||
|
||||
bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const;
|
||||
void setStateSettingsUpdated();
|
||||
|
||||
private:
|
||||
enum ProjectStateType
|
||||
{
|
||||
PROJECT_STATE_NOT_LOADED,
|
||||
PROJECT_STATE_EMPTY,
|
||||
PROJECT_STATE_LOADED,
|
||||
PROJECT_STATE_OUTDATED,
|
||||
PROJECT_STATE_OUTVERSIONED,
|
||||
PROJECT_STATE_SETTINGS_UPDATED,
|
||||
PROJECT_STATE_NEEDS_MIGRATION
|
||||
};
|
||||
|
||||
Project(const Project&);
|
||||
|
||||
public: // todo: make private again
|
||||
void load();
|
||||
|
||||
private:
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh);
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
|
||||
ProjectStateType m_state;
|
||||
std::shared_ptr<PersistentStorage> m_storage;
|
||||
std::vector<std::shared_ptr<SourceGroup>> m_sourceGroups;
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "project/SourceGroup.h"
|
||||
|
||||
SourceGroup::~SourceGroup()
|
||||
{
|
||||
}
|
||||
|
||||
LanguageType SourceGroup::getLanguage() const
|
||||
{
|
||||
return getLanguageTypeForSourceGroupType(getType());
|
||||
}
|
||||
|
||||
bool SourceGroup::prepareRefresh()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SourceGroup::prepareIndexing()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceGroup::fetchSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths)
|
||||
{
|
||||
for (const FilePath& sourceFilePath: m_allSourceFilePaths)
|
||||
{
|
||||
if (staticSourceFilePaths.find(sourceFilePath) == staticSourceFilePaths.end())
|
||||
{
|
||||
m_sourceFilePathsToIndex.insert(sourceFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroup::getAllSourceFilePaths() const
|
||||
{
|
||||
return m_allSourceFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroup::getSourceFilePathsToIndex() const
|
||||
{
|
||||
return m_sourceFilePathsToIndex;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef SOURCE_GROUP_H
|
||||
#define SOURCE_GROUP_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "settings/LanguageType.h"
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
class IndexerCommand;
|
||||
|
||||
class SourceGroup
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroup();
|
||||
|
||||
virtual SourceGroupType getType() const = 0;
|
||||
LanguageType getLanguage() const;
|
||||
|
||||
virtual bool prepareRefresh();
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual void fetchAllSourceFilePaths() = 0;
|
||||
void fetchSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths);
|
||||
|
||||
std::set<FilePath> getAllSourceFilePaths() const;
|
||||
std::set<FilePath> getSourceFilePathsToIndex() const;
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const bool fullRefresh) = 0;
|
||||
|
||||
protected:
|
||||
std::set<FilePath> m_allSourceFilePaths;
|
||||
std::set<FilePath> m_sourceFilePathsToIndex;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_H
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "project/SourceGroupFactory.h"
|
||||
|
||||
#include "project/SourceGroup.h"
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
|
||||
std::shared_ptr<SourceGroupFactory> SourceGroupFactory::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<SourceGroupFactory>(new SourceGroupFactory());
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void SourceGroupFactory::addModule(std::shared_ptr<SourceGroupFactoryModule> module)
|
||||
{
|
||||
m_modules.push_back(module);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<SourceGroup>> SourceGroupFactory::createSourceGroups(std::vector<std::shared_ptr<SourceGroupSettings>> allSourceGroupSettings)
|
||||
{
|
||||
std::vector<std::shared_ptr<SourceGroup>> sourceGroups;
|
||||
for (std::shared_ptr<SourceGroupSettings> sourceGroupSettings: allSourceGroupSettings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup = createSourceGroup(sourceGroupSettings);
|
||||
if (sourceGroup)
|
||||
{
|
||||
sourceGroups.push_back(sourceGroup);
|
||||
}
|
||||
}
|
||||
return sourceGroups;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactory::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
|
||||
for (std::shared_ptr<SourceGroupFactoryModule> module: m_modules)
|
||||
{
|
||||
if (module->supports(settings->getType()))
|
||||
{
|
||||
sourceGroup = module->createSourceGroup(settings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sourceGroup;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupFactory> SourceGroupFactory::s_instance;
|
||||
|
||||
SourceGroupFactory::SourceGroupFactory()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_H
|
||||
#define SOURCE_GROUP_FACTORY_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
class SourceGroup;
|
||||
class SourceGroupSettings;
|
||||
class SourceGroupFactoryModule;
|
||||
|
||||
class SourceGroupFactory
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<SourceGroupFactory> getInstance();
|
||||
|
||||
void addModule(std::shared_ptr<SourceGroupFactoryModule> module);
|
||||
|
||||
std::vector<std::shared_ptr<SourceGroup>> createSourceGroups(std::vector<std::shared_ptr<SourceGroupSettings>> allSourceGroupSettings);
|
||||
std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<SourceGroupFactory> s_instance;
|
||||
SourceGroupFactory();
|
||||
|
||||
std::vector<std::shared_ptr<SourceGroupFactoryModule>> m_modules;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_H
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
SourceGroupFactoryModule::~SourceGroupFactoryModule()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
class SourceGroup;
|
||||
class SourceGroupSettings;
|
||||
|
||||
class SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModule();
|
||||
virtual bool supports(SourceGroupType type) const = 0;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings) = 0;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_H
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/Status.h"
|
||||
#include "utility/utility.h"
|
||||
@@ -37,15 +38,18 @@ bool ApplicationSettings::load(const FilePath& filePath)
|
||||
|
||||
SettingsMigrator migrator;
|
||||
|
||||
migrator.addMigration(1,
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
"source/header_search_paths/header_search_path",
|
||||
"indexing/cxx/header_search_paths/header_search_path");
|
||||
migrator.addMigration(1,
|
||||
"indexing/cxx/header_search_paths/header_search_path"
|
||||
));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
"source/framework_search_paths/framework_search_path",
|
||||
"indexing/cxx/framework_search_paths/framework_search_path");
|
||||
migrator.addMigration(1,
|
||||
"indexing/cxx/framework_search_paths/framework_search_path"
|
||||
));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
"application/indexer_thread_count",
|
||||
"indexing/indexer_thread_count");
|
||||
"indexing/indexer_thread_count"
|
||||
));
|
||||
|
||||
bool migrated = migrator.migrate(this, ApplicationSettings::VERSION);
|
||||
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::~CxxProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType CxxProjectSettings::getProjectType() const
|
||||
{
|
||||
if (!getVisualStudioSolutionPath().empty()) // I think this is crap. VS solution path is not used anymore.. so vs projects are handled like cdb projects
|
||||
{
|
||||
return PROJECT_CXX_VS;
|
||||
}
|
||||
else if (!getCompilationDatabasePath().empty())
|
||||
{
|
||||
return PROJECT_CXX_CDB;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (getLanguage())
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
return PROJECT_C_EMPTY;
|
||||
case LANGUAGE_CPP:
|
||||
return PROJECT_CPP_EMPTY;
|
||||
default:
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
// const CxxProjectSettings* typedOther = dynamic_cast<const CxxProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other)// &&
|
||||
// utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getLanguageStandards() const
|
||||
{
|
||||
std::vector<std::string> standards;
|
||||
|
||||
switch (getLanguage())
|
||||
{
|
||||
case LANGUAGE_CPP:
|
||||
standards.push_back("c++1z");
|
||||
standards.push_back("gnu++1z");
|
||||
|
||||
standards.push_back("c++14");
|
||||
standards.push_back("gnu++14");
|
||||
|
||||
standards.push_back("c++1y");
|
||||
standards.push_back("gnu++1y");
|
||||
|
||||
standards.push_back("c++11");
|
||||
standards.push_back("gnu++11");
|
||||
|
||||
standards.push_back("c++0x");
|
||||
standards.push_back("gnu++0x");
|
||||
|
||||
standards.push_back("c++03");
|
||||
|
||||
standards.push_back("c++98");
|
||||
standards.push_back("gnu++98");
|
||||
break;
|
||||
|
||||
case LANGUAGE_C:
|
||||
standards.push_back("c1x");
|
||||
standards.push_back("gnu1x");
|
||||
standards.push_back("iso9899:201x");
|
||||
|
||||
standards.push_back("c11");
|
||||
standards.push_back("gnu11");
|
||||
standards.push_back("iso9899:2011");
|
||||
|
||||
standards.push_back("c9x");
|
||||
standards.push_back("gnu9x");
|
||||
standards.push_back("iso9899:199x");
|
||||
|
||||
standards.push_back("c99");
|
||||
standards.push_back("gnu99");
|
||||
standards.push_back("iso9899:1999");
|
||||
|
||||
standards.push_back("iso9899:199409");
|
||||
|
||||
standards.push_back("c90");
|
||||
standards.push_back("gnu90");
|
||||
standards.push_back("iso9899:1990");
|
||||
|
||||
standards.push_back("c89");
|
||||
standards.push_back("gnu89");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return standards;
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
return makePathsAbsolute(expandPaths(getHeaderSearchPaths()));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
return makePathsAbsolute(expandPaths(getFrameworkSearchPaths()));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return getValue<bool>("source/use_source_paths_for_header_search", false);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::getHasDefinedUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return isValueDefined("source/use_source_paths_for_header_search");
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getVisualStudioSolutionPath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str());
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getCompilationDatabasePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/compilation_db_path", ""));
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getAbsoluteCompilationDatabasePath() const
|
||||
{
|
||||
return makePathAbsolute(expandPath(getCompilationDatabasePath()));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/compilation_db_path", compilationDatabasePath.str());
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
|
||||
switch (getLanguage())
|
||||
{
|
||||
case LANGUAGE_CPP:
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
break;
|
||||
|
||||
case LANGUAGE_C:
|
||||
defaultValues.push_back(".c");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::string CxxProjectSettings::getDefaultStandard() const
|
||||
{
|
||||
switch (getLanguage())
|
||||
{
|
||||
case LANGUAGE_CPP:
|
||||
return "c++1z";
|
||||
|
||||
case LANGUAGE_C:
|
||||
return "c1x";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#ifndef CXX_PROJECT_SETTINGS_H
|
||||
#define CXX_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class CxxProjectSettings: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
CxxProjectSettings();
|
||||
CxxProjectSettings(const FilePath& projectFilePath);
|
||||
CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~CxxProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
// deprecated
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
bool getHasDefinedUseSourcePathsForHeaderSearch() const;
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
FilePath getAbsoluteCompilationDatabasePath() const;
|
||||
bool setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
};
|
||||
|
||||
#endif // CXX_PROJECT_SETTINGS_H
|
||||
@@ -1,117 +0,0 @@
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::~JavaProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType JavaProjectSettings::getProjectType() const
|
||||
{
|
||||
if (!getMavenProjectFilePath().empty())
|
||||
{
|
||||
return PROJECT_JAVA_MAVEN;
|
||||
}
|
||||
return PROJECT_JAVA_EMPTY;
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
const JavaProjectSettings* typedOther = dynamic_cast<const JavaProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other) &&
|
||||
utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> JavaProjectSettings::getLanguageStandards() const
|
||||
{
|
||||
return std::vector<std::string>(1, "8");
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getAbsoluteClasspaths() const
|
||||
{
|
||||
return makePathsAbsolute(expandPaths(getClasspaths()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setClasspaths(const std::vector<FilePath>& classpaths)
|
||||
{
|
||||
return setPathValues("source/class_paths/class_path", classpaths);
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getMavenProjectFilePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/maven/project_file_path", ""));
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getAbsoluteMavenProjectFilePath() const
|
||||
{
|
||||
return makePathAbsolute(expandPath(getMavenProjectFilePath()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setMavenProjectFilePath(const FilePath& path)
|
||||
{
|
||||
return setValue("source/maven/project_file_path", path.str());
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getMavenDependenciesDirectory() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/maven/dependencies_directory", ""));
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getAbsoluteMavenDependenciesDirectory() const
|
||||
{
|
||||
return makePathAbsolute(expandPath(getMavenDependenciesDirectory()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setMavenDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
return setValue("source/maven/dependencies_directory", path.str());
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::getShouldIndexMavenTests() const
|
||||
{
|
||||
return getValue<bool>("source/maven/should_index_tests", false);
|
||||
}
|
||||
void JavaProjectSettings::setShouldIndexMavenTests(bool value)
|
||||
{
|
||||
setValue<bool>("source/maven/should_index_tests", value);
|
||||
}
|
||||
|
||||
std::vector<std::string> JavaProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".java");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::string JavaProjectSettings::getDefaultStandard() const
|
||||
{
|
||||
return "8";
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#ifndef JAVA_PROJECT_SETTINGS_H
|
||||
#define JAVA_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class JavaProjectSettings
|
||||
: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
JavaProjectSettings();
|
||||
JavaProjectSettings(const FilePath& projectFilePath);
|
||||
JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~JavaProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteClasspaths() const;
|
||||
bool setClasspaths(const std::vector<FilePath>& classpaths);
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getAbsoluteMavenProjectFilePath() const;
|
||||
bool setMavenProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getMavenDependenciesDirectory() const;
|
||||
FilePath getAbsoluteMavenDependenciesDirectory() const;
|
||||
bool setMavenDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
};
|
||||
|
||||
#endif // JAVA_PROJECT_SETTINGS_H
|
||||
@@ -48,21 +48,21 @@ std::string getSymbolNameDelimiterForLanguage(LanguageType t)
|
||||
return "@";
|
||||
}
|
||||
|
||||
LanguageType getLanguageTypeForProjectType(ProjectType t)
|
||||
LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
return LANGUAGE_C;
|
||||
case PROJECT_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_CXX_CDB:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_CXX_VS:
|
||||
case SOURCE_GROUP_CXX_VS:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
return LANGUAGE_JAVA;
|
||||
case PROJECT_JAVA_MAVEN:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return LANGUAGE_JAVA;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "settings/ProjectType.h"
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
enum LanguageType
|
||||
{
|
||||
@@ -17,6 +17,6 @@ std::string languageTypeToString(LanguageType t);
|
||||
LanguageType stringToLanguageType(std::string s);
|
||||
|
||||
std::string getSymbolNameDelimiterForLanguage(LanguageType t);
|
||||
LanguageType getLanguageTypeForProjectType(ProjectType t);
|
||||
LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t);
|
||||
|
||||
#endif // LANGUAGE_TYPE_H
|
||||
|
||||
@@ -1,17 +1,38 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "settings/migration/MigrationDeleteKey.h"
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/UUIDUtility.h"
|
||||
|
||||
const size_t ProjectSettings::VERSION = 1;
|
||||
const size_t ProjectSettings::VERSION = 4;
|
||||
|
||||
LanguageType ProjectSettings::getLanguageOfProject(FilePath projectFilePath)
|
||||
LanguageType ProjectSettings::getLanguageOfProject(const FilePath& filePath)
|
||||
{
|
||||
ProjectSettings tempSettings;
|
||||
tempSettings.load(projectFilePath);
|
||||
return tempSettings.getLanguage();
|
||||
LanguageType languageType = LANGUAGE_UNKNOWN;
|
||||
|
||||
ProjectSettings projectSettings;
|
||||
projectSettings.load(filePath);
|
||||
for (std::shared_ptr<SourceGroupSettings> sourceGroupSettings: projectSettings.getAllSourceGroupSettings())
|
||||
{
|
||||
const LanguageType currentLanguageType = getLanguageTypeForSourceGroupType(sourceGroupSettings->getType());
|
||||
if (languageType == LANGUAGE_UNKNOWN)
|
||||
{
|
||||
languageType = currentLanguageType;
|
||||
}
|
||||
else if (languageType != currentLanguageType)
|
||||
{
|
||||
// language is unknown if source groups have different languages.
|
||||
languageType = LANGUAGE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return languageType;
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings()
|
||||
@@ -32,25 +53,35 @@ ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType ProjectSettings::getProjectType() const
|
||||
{
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
return (
|
||||
getLanguage() == other.getLanguage() &&
|
||||
getStandard() == other.getStandard() &&
|
||||
utility::isPermutation<FilePath>(getSourcePaths(), other.getSourcePaths()) &&
|
||||
utility::isPermutation<FilePath>(getExcludePaths(), other.getExcludePaths()) &&
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions())
|
||||
);
|
||||
}
|
||||
const std::vector<std::shared_ptr<SourceGroupSettings>> allMySettings = getAllSourceGroupSettings();
|
||||
const std::vector<std::shared_ptr<SourceGroupSettings>> allOtherSettings = other.getAllSourceGroupSettings();
|
||||
|
||||
std::vector<std::string> ProjectSettings::getLanguageStandards() const
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
if (allMySettings.size() != allOtherSettings.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<SourceGroupSettings> mySourceGroup: allMySettings)
|
||||
{
|
||||
bool matched = false;
|
||||
for (std::shared_ptr<SourceGroupSettings> otherSourceGroup: allOtherSettings)
|
||||
{
|
||||
if (mySourceGroup->equals(otherSourceGroup))
|
||||
{
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProjectSettings::needMigration() const
|
||||
@@ -96,67 +127,123 @@ void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
{
|
||||
return getValue<std::string>("info/description", "");
|
||||
return getValue<std::string>("description", "");
|
||||
}
|
||||
|
||||
LanguageType ProjectSettings::getLanguage() const
|
||||
std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceGroupSettings() const
|
||||
{
|
||||
return stringToLanguageType(getValue<std::string>("language_settings/language", languageTypeToString(LANGUAGE_UNKNOWN)));
|
||||
std::vector<std::shared_ptr<SourceGroupSettings>> allSettings;
|
||||
for (const std::string& key: m_config->getSublevelKeys("source_groups"))
|
||||
{
|
||||
const std::string id = key.substr(std::string("source_groups/source_group_").length());
|
||||
const SourceGroupType type = stringToSourceGroupType(getValue<std::string>(key + "/type", ""));
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> settings;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::make_shared<SourceGroupSettingsCxx>(id, type, this);
|
||||
cxxSettings->setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path"));
|
||||
cxxSettings->setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path"));
|
||||
cxxSettings->setCompilerFlags(getValues<std::string>(key + "/compiler_flags/compiler_flag", std::vector<std::string>()));
|
||||
cxxSettings->setUseSourcePathsForHeaderSearch(getValue<bool>(key + "/use_source_paths_for_header_search", false));
|
||||
cxxSettings->setHasDefinedUseSourcePathsForHeaderSearch(isValueDefined(key + "/use_source_paths_for_header_search"));
|
||||
if (type == SOURCE_GROUP_CXX_CDB)
|
||||
{
|
||||
cxxSettings->setCompilationDatabasePath(FilePath(getValue<std::string>(key + "/build_file_path/compilation_db_path", "")));
|
||||
}
|
||||
settings = cxxSettings;
|
||||
}
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::make_shared<SourceGroupSettingsJava>(id, type, this);
|
||||
javaSettings->setClasspaths(getPathValues(key + "/class_paths/class_path"));
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
javaSettings->setMavenProjectFilePath(FilePath(getValue<std::string>(key + "/maven/project_file_path", "")));
|
||||
javaSettings->setMavenDependenciesDirectory(FilePath(getValue<std::string>(key + "/maven/dependencies_directory", "")));
|
||||
javaSettings->setShouldIndexMavenTests(getValue<bool>(key + "/maven/should_index_tests", false));
|
||||
}
|
||||
settings = javaSettings;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
settings->setStandard(getValue<std::string>(key + "/standard", ""));
|
||||
settings->setSourcePaths(getPathValues(key + "/source_paths/source_path"));
|
||||
settings->setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path"));
|
||||
settings->setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::string>()));
|
||||
|
||||
allSettings.push_back(settings);
|
||||
}
|
||||
|
||||
return allSettings;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(LanguageType language)
|
||||
void ProjectSettings::setAllSourceGroupSettings(std::vector<std::shared_ptr<SourceGroupSettings>> allSettings)
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", languageTypeToString(language));
|
||||
}
|
||||
for (const std::string& key: m_config->getSublevelKeys("source_groups"))
|
||||
{
|
||||
m_config->removeValues(key);
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getStandard() const
|
||||
{
|
||||
return getValue<std::string>("language_settings/standard", getDefaultStandard());
|
||||
}
|
||||
for (std::shared_ptr<SourceGroupSettings> settings: allSettings)
|
||||
{
|
||||
const std::string key = "source_groups/source_group_" + settings->getId();
|
||||
const SourceGroupType type = settings->getType();
|
||||
|
||||
bool ProjectSettings::setStandard(const std::string& standard)
|
||||
{
|
||||
return setValue<std::string>("language_settings/standard", standard);
|
||||
}
|
||||
setValue(key + "/type", sourceGroupTypeToString(type));
|
||||
setValue(key + "/standard", settings->getStandard());
|
||||
setPathValues(key + "/source_paths/source_path", settings->getSourcePaths());
|
||||
setPathValues(key + "/exclude_paths/exclude_path", settings->getExcludePaths());
|
||||
setValues(key + "/source_extensions/source_extension", settings->getSourceExtensions());
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getSourcePaths() const // TODO: rename to getIndexedPaths
|
||||
{
|
||||
return getPathValues("source/source_paths/source_path");
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
setPathValues(key + "/header_search_paths/header_search_path", cxxSettings->getHeaderSearchPaths());
|
||||
setPathValues(key + "/framework_search_paths/framework_search_path", cxxSettings->getFrameworkSearchPaths());
|
||||
setValues(key + "/compiler_flags/compiler_flag", cxxSettings->getCompilerFlags());
|
||||
if (cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
setValue(key + "/use_source_paths_for_header_search", cxxSettings->getUseSourcePathsForHeaderSearch());
|
||||
}
|
||||
if (type == SOURCE_GROUP_CXX_CDB)
|
||||
{
|
||||
setValue(key + "/build_file_path/compilation_db_path", cxxSettings->getCompilationDatabasePath().str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
|
||||
{
|
||||
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspaths());
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteSourcePaths() const
|
||||
{
|
||||
return makePathsAbsolute(expandPaths(getSourcePaths()));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
|
||||
{
|
||||
return setPathValues("source/source_paths/source_path", sourcePaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getExcludePaths() const
|
||||
{
|
||||
return getPathValues("source/exclude_paths/exclude_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteExcludePaths() const
|
||||
{
|
||||
return makePathsAbsolute(expandPaths(getExcludePaths()));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
{
|
||||
return setPathValues("source/exclude_paths/exclude_path", excludePaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
setValue(key + "/maven/project_file_path", javaSettings->getMavenProjectFilePath().str());
|
||||
setValue(key + "/maven/dependencies_directory", javaSettings->getMavenDependenciesDirectory().str());
|
||||
setValue(key + "/maven/should_index_tests", javaSettings->getShouldIndexMavenTests());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::makePathsAbsolute(const std::vector<FilePath>& paths) const
|
||||
@@ -189,39 +276,86 @@ FilePath ProjectSettings::makePathAbsolute(const FilePath& path) const
|
||||
return getProjectFileLocation().concat(path).canonical();
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDefaultStandard() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
SettingsMigrator ProjectSettings::getMigrations() const
|
||||
{
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
const std::string standard = migration->getValueFromSettings<std::string>(settings, "language_settings/standard", "");
|
||||
|
||||
if (getLanguage() == LANGUAGE_C || getLanguage() == LANGUAGE_CPP)
|
||||
{
|
||||
migrator.addLambdaMigration(1,
|
||||
[](Settings* settings)
|
||||
if (language == "C" && !utility::isPrefix("c", standard))
|
||||
{
|
||||
ProjectSettings* s = dynamic_cast<ProjectSettings*>(settings);
|
||||
migration->setValueInSettings(settings, "language_settings/standard", "c" + standard);
|
||||
}
|
||||
|
||||
if (s->getLanguage() == LANGUAGE_C && !utility::isPrefix("c", s->getStandard()))
|
||||
if (language == "C++" && !utility::isPrefix("c++", standard))
|
||||
{
|
||||
migration->setValueInSettings(settings, "language_settings/standard", "c++" + standard);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
const std::string sourceGroupKey = "source_groups/source_group_" + UUIDUtility::getUUIDString();
|
||||
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("info/description", "description"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("language_settings/standard", sourceGroupKey + "/standard"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests"));
|
||||
|
||||
migrator.addMigration(3, std::make_shared<MigrationLambda>(
|
||||
[=](const Migration* migration, Settings* settings)
|
||||
{
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
|
||||
SourceGroupType type = SOURCE_GROUP_UNKNOWN;
|
||||
if (language == "C" || language == "C++")
|
||||
{
|
||||
const std::string cdbPath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/build_file_path/compilation_db_path", "");
|
||||
if (!cdbPath.empty())
|
||||
{
|
||||
s->setStandard("c" + s->getStandard());
|
||||
type = SOURCE_GROUP_CXX_CDB;
|
||||
}
|
||||
|
||||
if (s->getLanguage() == LANGUAGE_CPP && !utility::isPrefix("c++", s->getStandard()))
|
||||
else if (language == "C")
|
||||
{
|
||||
s->setStandard("c++" + s->getStandard());
|
||||
type = SOURCE_GROUP_C_EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_CPP_EMPTY;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else if (language == "Java")
|
||||
{
|
||||
const std::string mavenProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/maven/project_file_path", "");
|
||||
if (!mavenProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
migration->setValueInSettings(settings, sourceGroupKey + "/type", sourceGroupTypeToString(type));
|
||||
}
|
||||
));
|
||||
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("language_settings/language"));
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("source/build_file_path/vs_solution_path"));
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("source/extensions/header_extensions"));
|
||||
|
||||
return migrator;
|
||||
}
|
||||
|
||||
@@ -4,27 +4,24 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/LanguageType.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class SourceGroupSettings;
|
||||
|
||||
class ProjectSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static LanguageType getLanguageOfProject(FilePath projectFilePath);
|
||||
|
||||
static const size_t VERSION;
|
||||
static LanguageType getLanguageOfProject(const FilePath& filePath);
|
||||
|
||||
ProjectSettings();
|
||||
ProjectSettings(const FilePath& projectFilePath);
|
||||
ProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~ProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
bool needMigration() const;
|
||||
void migrate();
|
||||
@@ -38,31 +35,14 @@ public:
|
||||
void setProjectFileLocation(const FilePath& location);
|
||||
|
||||
std::string getDescription() const;
|
||||
|
||||
LanguageType getLanguage() const;
|
||||
bool setLanguage(LanguageType language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
std::vector<std::shared_ptr<SourceGroupSettings>> getAllSourceGroupSettings() const;
|
||||
void setAllSourceGroupSettings(std::vector<std::shared_ptr<SourceGroupSettings>> allSettings);
|
||||
|
||||
std::vector<FilePath> makePathsAbsolute(const std::vector<FilePath>& paths) const;
|
||||
FilePath makePathAbsolute(const FilePath& path) const;
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
|
||||
SettingsMigrator getMigrations() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "settings/ProjectType.h"
|
||||
|
||||
std::string projectTypeToString(ProjectType v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
return "Empty C Project";
|
||||
case PROJECT_CPP_EMPTY:
|
||||
return "Empty C++ Project";
|
||||
case PROJECT_CXX_CDB:
|
||||
return "C/C++ from Compilation Database";
|
||||
case PROJECT_CXX_VS:
|
||||
return "C/C++ from Visual Studio";
|
||||
case PROJECT_JAVA_EMPTY:
|
||||
return "Empty Java Project";
|
||||
case PROJECT_JAVA_MAVEN:
|
||||
return "Java Project from Maven";
|
||||
case PROJECT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
ProjectType stringToProjectType(std::string v)
|
||||
{
|
||||
if (v == projectTypeToString(PROJECT_C_EMPTY))
|
||||
{
|
||||
return PROJECT_C_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CPP_EMPTY))
|
||||
{
|
||||
return PROJECT_CPP_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CXX_CDB))
|
||||
{
|
||||
return PROJECT_CXX_CDB;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CXX_VS))
|
||||
{
|
||||
return PROJECT_CXX_VS;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_JAVA_EMPTY))
|
||||
{
|
||||
return PROJECT_JAVA_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_JAVA_MAVEN))
|
||||
{
|
||||
return PROJECT_JAVA_MAVEN;
|
||||
}
|
||||
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef PROJECT_TYPE_H
|
||||
#define PROJECT_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum ProjectType
|
||||
{
|
||||
PROJECT_C_EMPTY,
|
||||
PROJECT_CPP_EMPTY,
|
||||
PROJECT_CXX_CDB,
|
||||
PROJECT_CXX_VS,
|
||||
PROJECT_JAVA_EMPTY,
|
||||
PROJECT_JAVA_MAVEN,
|
||||
PROJECT_UNKNOWN
|
||||
};
|
||||
|
||||
std::string projectTypeToString(ProjectType v);
|
||||
ProjectType stringToProjectType(std::string v);
|
||||
|
||||
#endif // PROJECT_TYPE_H
|
||||
@@ -8,7 +8,8 @@
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
#include "settings/SettingsMigrator.h"
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class Settings
|
||||
{
|
||||
@@ -65,6 +66,9 @@ protected:
|
||||
|
||||
private:
|
||||
FilePath m_filePath;
|
||||
|
||||
friend SettingsMigrator;
|
||||
friend Migration;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#include "settings/SettingsMigrator.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
SettingsMigrator::SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrator::~SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrator::addMigration(size_t targetVersion, std::string oldKey, std::string newKey)
|
||||
{
|
||||
Migration migration;
|
||||
migration.targetVersion = targetVersion;
|
||||
migration.oldKey = oldKey;
|
||||
migration.newKey = newKey;
|
||||
|
||||
m_migrations.emplace(targetVersion, migration);
|
||||
}
|
||||
|
||||
void SettingsMigrator::addLambdaMigration(size_t targetVersion, std::function<void(Settings*)> lambda)
|
||||
{
|
||||
Migration migration;
|
||||
migration.targetVersion = targetVersion;
|
||||
migration.lambda = lambda;
|
||||
|
||||
m_migrations.emplace(targetVersion, migration);
|
||||
}
|
||||
|
||||
bool SettingsMigrator::willMigrate(const Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, Migration>::const_iterator, std::multimap<size_t, Migration>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, Migration>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SettingsMigrator::migrate(Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, Migration>::const_iterator, std::multimap<size_t, Migration>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, Migration>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
const Migration& migration = it->second;
|
||||
|
||||
if (!migration.oldKey.size())
|
||||
{
|
||||
migration.lambda(settings);
|
||||
}
|
||||
else if (!settings->isValueDefined(migration.newKey))
|
||||
{
|
||||
settings->setValues<std::string>(
|
||||
migration.newKey,
|
||||
settings->getValues<std::string>(migration.oldKey, std::vector<std::string>())
|
||||
);
|
||||
settings->removeValues(migration.oldKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settings->setVersion(targetVersion);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: m_id(id)
|
||||
, m_type(type)
|
||||
, m_projectSettings(projectSettings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettings::~SourceGroupSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
return (
|
||||
m_id == other->m_id &&
|
||||
m_type == other->m_type &&
|
||||
m_standard == other->m_standard &&
|
||||
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
|
||||
utility::isPermutation(m_excludePaths, other->m_excludePaths) &&
|
||||
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
|
||||
);
|
||||
}
|
||||
|
||||
std::string SourceGroupSettings::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettings::getProjectFileLocation() const
|
||||
{
|
||||
return m_projectSettings->getProjectFileLocation();
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettings::makePathAbsolute(const FilePath& path) const
|
||||
{
|
||||
return m_projectSettings->makePathAbsolute(path);
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupSettings::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettings::getStandard() const
|
||||
{
|
||||
if (m_standard.empty())
|
||||
{
|
||||
return getDefaultStandard();
|
||||
}
|
||||
return m_standard;
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setStandard(const std::string& standard)
|
||||
{
|
||||
m_standard = standard;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getSourcePaths() const
|
||||
{
|
||||
return m_sourcePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getAbsoluteSourcePaths() const
|
||||
{
|
||||
return m_projectSettings->makePathsAbsolute(getSourcePaths());
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
|
||||
{
|
||||
m_sourcePaths = sourcePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getExcludePaths() const
|
||||
{
|
||||
return m_excludePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getAbsoluteExcludePaths() const
|
||||
{
|
||||
return m_projectSettings->makePathsAbsolute(getExcludePaths());
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
{
|
||||
m_excludePaths = excludePaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettings::getSourceExtensions() const
|
||||
{
|
||||
if (m_sourceExtensions.empty())
|
||||
{
|
||||
return getDefaultSourceExtensions();
|
||||
}
|
||||
return m_sourceExtensions;
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setSourceExtensions(const std::vector<std::string>& sourceExtensions)
|
||||
{
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_H
|
||||
#define SOURCE_GROUP_SETTINGS_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
class ProjectSettings;
|
||||
|
||||
class SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettings();
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
std::string getId() const;
|
||||
|
||||
FilePath getProjectFileLocation() const;
|
||||
FilePath makePathAbsolute(const FilePath& path) const;
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const = 0;
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
std::string getStandard() const;
|
||||
void setStandard(const std::string& standard);
|
||||
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
void setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
void setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
protected:
|
||||
const ProjectSettings* m_projectSettings;
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const = 0;
|
||||
virtual std::string getDefaultStandard() const = 0;
|
||||
|
||||
const std::string m_id;
|
||||
const SourceGroupType m_type;
|
||||
|
||||
std::string m_standard;
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_H
|
||||
@@ -0,0 +1,204 @@
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettings(id, type, projectSettings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsCxx::~SourceGroupSettingsCxx()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> otherCxx = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(other);
|
||||
|
||||
return (
|
||||
otherCxx &&
|
||||
SourceGroupSettings::equals(other) &&
|
||||
utility::isPermutation(m_headerSearchPaths, otherCxx->m_headerSearchPaths) &&
|
||||
utility::isPermutation(m_frameworkSearchPaths, otherCxx->m_frameworkSearchPaths) &&
|
||||
utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags) &&
|
||||
m_useSourcePathsForHeaderSearch == otherCxx->m_useSourcePathsForHeaderSearch &&
|
||||
m_hasDefinedUseSourcePathsForHeaderSearch == otherCxx->m_hasDefinedUseSourcePathsForHeaderSearch &&
|
||||
m_compilationDatabasePath == otherCxx->m_compilationDatabasePath
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getAvailableLanguageStandards() const
|
||||
{
|
||||
std::vector<std::string> standards;
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
standards.push_back("c++1z");
|
||||
standards.push_back("gnu++1z");
|
||||
|
||||
standards.push_back("c++14");
|
||||
standards.push_back("gnu++14");
|
||||
|
||||
standards.push_back("c++1y");
|
||||
standards.push_back("gnu++1y");
|
||||
|
||||
standards.push_back("c++11");
|
||||
standards.push_back("gnu++11");
|
||||
|
||||
standards.push_back("c++0x");
|
||||
standards.push_back("gnu++0x");
|
||||
|
||||
standards.push_back("c++03");
|
||||
|
||||
standards.push_back("c++98");
|
||||
standards.push_back("gnu++98");
|
||||
break;
|
||||
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
standards.push_back("c1x");
|
||||
standards.push_back("gnu1x");
|
||||
standards.push_back("iso9899:201x");
|
||||
|
||||
standards.push_back("c11");
|
||||
standards.push_back("gnu11");
|
||||
standards.push_back("iso9899:2011");
|
||||
|
||||
standards.push_back("c9x");
|
||||
standards.push_back("gnu9x");
|
||||
standards.push_back("iso9899:199x");
|
||||
|
||||
standards.push_back("c99");
|
||||
standards.push_back("gnu99");
|
||||
standards.push_back("iso9899:1999");
|
||||
|
||||
standards.push_back("iso9899:199409");
|
||||
|
||||
standards.push_back("c90");
|
||||
standards.push_back("gnu90");
|
||||
standards.push_back("iso9899:1990");
|
||||
|
||||
standards.push_back("c89");
|
||||
standards.push_back("gnu89");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return standards;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsCxx::getHeaderSearchPaths() const
|
||||
{
|
||||
return m_headerSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsCxx::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
return m_projectSettings->makePathsAbsolute(getHeaderSearchPaths());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
m_headerSearchPaths = headerSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsCxx::getFrameworkSearchPaths() const
|
||||
{
|
||||
return m_frameworkSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsCxx::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
return m_projectSettings->makePathsAbsolute(getFrameworkSearchPaths());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
m_frameworkSearchPaths = frameworkSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getCompilerFlags() const
|
||||
{
|
||||
return m_compilerFlags;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
m_compilerFlags = compilerFlags;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return m_useSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
m_useSourcePathsForHeaderSearch = useSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getHasDefinedUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return m_hasDefinedUseSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch)
|
||||
{
|
||||
m_hasDefinedUseSourcePathsForHeaderSearch = hasDefinedUseSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxx::getCompilationDatabasePath() const
|
||||
{
|
||||
return m_compilationDatabasePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxx::getAbsoluteCompilationDatabasePath() const
|
||||
{
|
||||
return m_projectSettings->makePathAbsolute(getCompilationDatabasePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
m_compilationDatabasePath = compilationDatabasePath;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
break;
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
defaultValues.push_back(".c");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getDefaultStandard() const
|
||||
{
|
||||
switch (getType())
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return "c++1z";
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
return "c1x";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_CXX_H
|
||||
#define SOURCE_GROUP_SETTINGS_CXX_H
|
||||
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
|
||||
class SourceGroupSettingsCxx
|
||||
: public SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsCxx();
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
void setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
void setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
// deprecated begin
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
void setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
bool getHasDefinedUseSourcePathsForHeaderSearch() const;
|
||||
void setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch);
|
||||
// deprecated end
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
FilePath getAbsoluteCompilationDatabasePath() const;
|
||||
void setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
|
||||
std::vector<FilePath> m_headerSearchPaths;
|
||||
std::vector<FilePath> m_frameworkSearchPaths;
|
||||
std::vector<std::string> m_compilerFlags;
|
||||
bool m_useSourcePathsForHeaderSearch;
|
||||
bool m_hasDefinedUseSourcePathsForHeaderSearch;
|
||||
FilePath m_compilationDatabasePath;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_CXX_H
|
||||
@@ -0,0 +1,96 @@
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettings(id, type, projectSettings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsJava::~SourceGroupSettingsJava()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> otherJava = std::dynamic_pointer_cast<SourceGroupSettingsJava>(other);
|
||||
|
||||
return (
|
||||
otherJava &&
|
||||
SourceGroupSettings::equals(other) &&
|
||||
utility::isPermutation(m_classpaths, otherJava->m_classpaths) &&
|
||||
m_mavenProjectFilePath == otherJava->m_mavenProjectFilePath &&
|
||||
m_mavenDependenciesDirectory == otherJava->m_mavenDependenciesDirectory &&
|
||||
m_shouldIndexMavenTests == otherJava->m_shouldIndexMavenTests
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsJava::getAvailableLanguageStandards() const
|
||||
{
|
||||
return std::vector<std::string>(1, "8");
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getClasspaths() const
|
||||
{
|
||||
return m_classpaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getAbsoluteClasspaths() const
|
||||
{
|
||||
return m_projectSettings->makePathsAbsolute(getClasspaths());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setClasspaths(const std::vector<FilePath>& classpaths)
|
||||
{
|
||||
m_classpaths = classpaths;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const
|
||||
{
|
||||
return m_mavenProjectFilePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getAbsoluteMavenProjectFilePath() const
|
||||
{
|
||||
return m_projectSettings->makePathAbsolute(getMavenProjectFilePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setMavenProjectFilePath(const FilePath& path)
|
||||
{
|
||||
m_mavenProjectFilePath = path;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenDependenciesDirectory() const
|
||||
{
|
||||
return m_mavenDependenciesDirectory;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getAbsoluteMavenDependenciesDirectory() const
|
||||
{
|
||||
return m_projectSettings->makePathAbsolute(getMavenDependenciesDirectory());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setMavenDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
m_mavenDependenciesDirectory = path;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJava::getShouldIndexMavenTests() const
|
||||
{
|
||||
return m_shouldIndexMavenTests;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setShouldIndexMavenTests(bool value)
|
||||
{
|
||||
m_shouldIndexMavenTests = value;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsJava::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>(1, ".java");
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsJava::getDefaultStandard() const
|
||||
{
|
||||
return "8";
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_JAVA_H
|
||||
#define SOURCE_GROUP_SETTINGS_JAVA_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
|
||||
class SourceGroupSettingsJava
|
||||
: public SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsJava();
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteClasspaths() const;
|
||||
void setClasspaths(const std::vector<FilePath>& classpaths);
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getAbsoluteMavenProjectFilePath() const;
|
||||
void setMavenProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getMavenDependenciesDirectory() const;
|
||||
FilePath getAbsoluteMavenDependenciesDirectory() const;
|
||||
void setMavenDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
|
||||
std::vector<FilePath> m_classpaths;
|
||||
FilePath m_mavenProjectFilePath;
|
||||
FilePath m_mavenDependenciesDirectory;
|
||||
bool m_shouldIndexMavenTests;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_JAVA_H
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "settings/SourceGroupType.h"
|
||||
|
||||
std::string sourceGroupTypeToString(SourceGroupType v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
return "C Source Group";
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
return "C++ Source Group";
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return "C/C++ from Compilation Database";
|
||||
case SOURCE_GROUP_CXX_VS:
|
||||
return "C/C++ from Visual Studio";
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
return "Java Source Group";
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return "Java Source Group from Maven";
|
||||
case SOURCE_GROUP_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
SourceGroupType stringToSourceGroupType(std::string v)
|
||||
{
|
||||
if (v == sourceGroupTypeToString(SOURCE_GROUP_C_EMPTY))
|
||||
{
|
||||
return SOURCE_GROUP_C_EMPTY;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CPP_EMPTY))
|
||||
{
|
||||
return SOURCE_GROUP_CPP_EMPTY;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_CDB))
|
||||
{
|
||||
return SOURCE_GROUP_CXX_CDB;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_VS))
|
||||
{
|
||||
return SOURCE_GROUP_CXX_VS;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_EMPTY))
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_EMPTY;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_MAVEN))
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
|
||||
return SOURCE_GROUP_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef SOURCE_GROUP_TYPE_H
|
||||
#define SOURCE_GROUP_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum SourceGroupType
|
||||
{
|
||||
SOURCE_GROUP_C_EMPTY,
|
||||
SOURCE_GROUP_CPP_EMPTY,
|
||||
SOURCE_GROUP_CXX_CDB,
|
||||
SOURCE_GROUP_CXX_VS,
|
||||
SOURCE_GROUP_JAVA_EMPTY,
|
||||
SOURCE_GROUP_JAVA_MAVEN,
|
||||
SOURCE_GROUP_UNKNOWN
|
||||
};
|
||||
|
||||
std::string sourceGroupTypeToString(SourceGroupType v);
|
||||
SourceGroupType stringToSourceGroupType(std::string v);
|
||||
|
||||
#endif // SOURCE_GROUP_TYPE_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
Migration::~Migration()
|
||||
{
|
||||
}
|
||||
|
||||
bool Migration::isValueDefinedInSettings(const Settings* settings, const std::string& key) const
|
||||
{
|
||||
return settings->isValueDefined(key);
|
||||
}
|
||||
|
||||
void Migration::removeValuesInSettings(Settings* settings, const std::string& key) const
|
||||
{
|
||||
settings->removeValues(key);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef MIGRATION_H
|
||||
#define MIGRATION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class Migration
|
||||
{
|
||||
public:
|
||||
virtual ~Migration();
|
||||
virtual void apply(Settings* settings) const = 0;
|
||||
|
||||
bool isValueDefinedInSettings(const Settings* settings, const std::string& key) const;
|
||||
|
||||
template <typename T>
|
||||
T getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const;
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> getValuesFromSettings(Settings* settings, const std::string& key, std::vector<T> defaultValues) const;
|
||||
|
||||
template<typename T>
|
||||
bool setValueInSettings(Settings* settings, const std::string& key, T value) const;
|
||||
|
||||
template<typename T>
|
||||
bool setValuesInSettings(Settings* settings, const std::string& key, std::vector<T> values) const;
|
||||
|
||||
void removeValuesInSettings(Settings* settings, const std::string& key) const;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T Migration::getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const
|
||||
{
|
||||
return settings->getValue(key, defaultValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> Migration::getValuesFromSettings(Settings* settings, const std::string& key, std::vector<T> defaultValues) const
|
||||
{
|
||||
return settings->getValues(key, defaultValues);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Migration::setValueInSettings(Settings* settings, const std::string& key, T value) const
|
||||
{
|
||||
return settings->setValue(key, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Migration::setValuesInSettings(Settings* settings, const std::string& key, std::vector<T> values) const
|
||||
{
|
||||
return settings->setValues(key, values);
|
||||
}
|
||||
|
||||
#endif // MIGRATION_H
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "settings/migration/MigrationDeleteKey.h"
|
||||
|
||||
MigrationDeleteKey::MigrationDeleteKey(const std::string& key)
|
||||
: m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationDeleteKey::apply(Settings* settings) const
|
||||
{
|
||||
removeValuesInSettings(settings, m_key);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef MIGRATION_DELETE_KEY_H
|
||||
#define MIGRATION_DELETE_KEY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationDeleteKey: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationDeleteKey(const std::string& key);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
const std::string m_key;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_DELETE_KEY_H
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
|
||||
MigrationLambda::MigrationLambda(std::function<void(const Migration*, Settings*)> m_lambda)
|
||||
: m_lambda(m_lambda)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationLambda::apply(Settings* settings) const
|
||||
{
|
||||
m_lambda(this, settings);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef MIGRATION_LAMBDA_H
|
||||
#define MIGRATION_LAMBDA_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationLambda: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationLambda(std::function<void(const Migration*, Settings*)> m_lambda);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
std::function<void(const Migration*, Settings*)> m_lambda;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_LAMBDA_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
|
||||
MigrationMoveKey::MigrationMoveKey(const std::string& oldKey, const std::string& newKey)
|
||||
: m_oldKey(oldKey)
|
||||
, m_newKey(newKey)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationMoveKey::apply(Settings* settings) const
|
||||
{
|
||||
if (!isValueDefinedInSettings(settings, m_newKey))
|
||||
{
|
||||
setValuesInSettings<std::string>(
|
||||
settings,
|
||||
m_newKey,
|
||||
getValuesFromSettings<std::string>(settings, m_oldKey, std::vector<std::string>())
|
||||
);
|
||||
removeValuesInSettings(settings, m_oldKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef MIGRATION_MOVE_KEY_H
|
||||
#define MIGRATION_MOVE_KEY_H
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationMoveKey: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationMoveKey(const std::string& oldKey, const std::string& newKey);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
const std::string m_oldKey;
|
||||
const std::string m_newKey;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_MOVE_KEY_H
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
SettingsMigrator::SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrator::~SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrator::addMigration(size_t targetVersion, std::shared_ptr<Migration> migration)
|
||||
{
|
||||
if (migration)
|
||||
{
|
||||
m_migrations.emplace(targetVersion, migration);
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsMigrator::willMigrate(const Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator, std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SettingsMigrator::migrate(Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator, std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
it->second->apply(settings);
|
||||
}
|
||||
}
|
||||
|
||||
settings->setVersion(targetVersion);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+4
-13
@@ -1,10 +1,11 @@
|
||||
#ifndef SETTNGS_MIGRATOR_H
|
||||
#define SETTNGS_MIGRATOR_H
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class Migration;
|
||||
class Settings;
|
||||
|
||||
class SettingsMigrator
|
||||
@@ -15,23 +16,13 @@ public:
|
||||
SettingsMigrator();
|
||||
virtual ~SettingsMigrator();
|
||||
|
||||
void addMigration(size_t targetVersion, std::string oldKey, std::string newKey);
|
||||
void addLambdaMigration(size_t targetVersion, std::function<void(Settings*)> lambda);
|
||||
void addMigration(size_t targetVersion, std::shared_ptr<Migration> migration);
|
||||
|
||||
bool willMigrate(const Settings* settings, size_t targetVersion) const;
|
||||
bool migrate(Settings* settings, size_t targetVersion) const;
|
||||
|
||||
private:
|
||||
struct Migration
|
||||
{
|
||||
size_t targetVersion;
|
||||
std::string oldKey;
|
||||
std::string newKey;
|
||||
|
||||
std::function<void(Settings*)> lambda;
|
||||
};
|
||||
|
||||
std::multimap<size_t, Migration> m_migrations;
|
||||
std::multimap<size_t, std::shared_ptr<Migration>> m_migrations;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_MIGRATOR_H
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "utility/ConfigManager.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::shared_ptr<ConfigManager> ConfigManager::createEmpty()
|
||||
@@ -222,6 +225,10 @@ void ConfigManager::setValues(const std::string& key, const std::vector<bool>& v
|
||||
|
||||
void ConfigManager::removeValues(const std::string& key)
|
||||
{
|
||||
for (const std::string& sublevelKey: getSublevelKeys(key))
|
||||
{
|
||||
removeValues(sublevelKey);
|
||||
}
|
||||
m_values.erase(key);
|
||||
}
|
||||
|
||||
@@ -232,6 +239,24 @@ bool ConfigManager::isValueDefined(const std::string& key) const
|
||||
return (it != m_values.end());
|
||||
}
|
||||
|
||||
std::vector<std::string> ConfigManager::getSublevelKeys(const std::string& key) const
|
||||
{
|
||||
std::set<std::string> keys;
|
||||
for (std::multimap<std::string, std::string>::const_iterator it = m_values.begin(); it != m_values.end(); it++)
|
||||
{
|
||||
if (utility::isPrefix(key, it->first))
|
||||
{
|
||||
size_t startPos = it->first.find("/", key.size());
|
||||
if (startPos == key.size())
|
||||
{
|
||||
std::string sublevelKey = it->first.substr(0, it->first.find("/", startPos + 1));
|
||||
keys.insert(sublevelKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
return utility::toVector(keys);
|
||||
}
|
||||
|
||||
bool ConfigManager::load(const std::shared_ptr<TextAccess> textAccess)
|
||||
{
|
||||
std::string text = textAccess->getText();
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
void removeValues(const std::string& key);
|
||||
|
||||
bool isValueDefined(const std::string& key) const;
|
||||
std::vector<std::string> getSublevelKeys(const std::string& key) const;
|
||||
|
||||
bool load(const std::shared_ptr<TextAccess> textAccess);
|
||||
void save(const std::string filepath);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
FileManager::FileManager()
|
||||
@@ -15,51 +13,18 @@ FileManager::~FileManager()
|
||||
{
|
||||
}
|
||||
|
||||
void FileManager::setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<FilePath> excludePaths,
|
||||
std::vector<std::string> sourceExtensions
|
||||
void FileManager::update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<std::string>& sourceExtensions
|
||||
){
|
||||
m_sourcePaths = sourcePaths;
|
||||
m_headerPaths = makeCanonical(headerPaths);
|
||||
m_excludePaths = makeCanonical(excludePaths);
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
FileManager::FileSets FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
{
|
||||
m_filesInfos.clear();
|
||||
for (FileInfo oldFileInfo: oldFileInfos)
|
||||
{
|
||||
m_filesInfos.emplace(oldFileInfo.path, oldFileInfo);
|
||||
}
|
||||
m_allSourceFilePaths.clear();
|
||||
|
||||
FileSets fileSets;
|
||||
|
||||
// update old files that have been modified
|
||||
// remove old files that don't exist anymore
|
||||
for (std::map<FilePath, FileInfo>::iterator it = m_filesInfos.begin(); it != m_filesInfos.end(); it++)
|
||||
{
|
||||
const FilePath& filePath = it->first;
|
||||
if (filePath.exists() && !hasSourceFilePath(filePath))
|
||||
{
|
||||
FileInfo newFileInfo = FileSystem::getFileInfoForPath(filePath);
|
||||
|
||||
if (newFileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = newFileInfo.lastWriteTime;
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileSets.removedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions);
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
for (FileInfo fileInfo: FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions))
|
||||
{
|
||||
const FilePath& filePath = fileInfo.path;
|
||||
if (isExcluded(filePath))
|
||||
@@ -67,33 +32,8 @@ FileManager::FileSets FileManager::fetchFilePaths(const std::vector<FileInfo>& o
|
||||
continue;
|
||||
}
|
||||
|
||||
fileSets.allSourceFilePaths.insert(filePath);
|
||||
|
||||
std::map<FilePath, FileInfo>::iterator it = m_filesInfos.find(filePath);
|
||||
if (it != m_filesInfos.end())
|
||||
{
|
||||
fileSets.removedFiles.erase(filePath);
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_filesInfos.insert(std::pair<FilePath, FileInfo>(filePath, fileInfo));
|
||||
fileSets.addedFiles.insert(filePath);
|
||||
}
|
||||
m_allSourceFilePaths.insert(filePath);
|
||||
}
|
||||
|
||||
for (const FilePath& filePath : fileSets.removedFiles)
|
||||
{
|
||||
m_filesInfos.erase(filePath);
|
||||
}
|
||||
|
||||
m_sourceFilePaths = fileSets.allSourceFilePaths;
|
||||
|
||||
return fileSets;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileManager::getSourcePaths() const
|
||||
@@ -101,48 +41,21 @@ std::vector<FilePath> FileManager::getSourcePaths() const
|
||||
return m_sourcePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getSourceFilePaths() const
|
||||
{
|
||||
std::set<FilePath> sourceFilePaths;
|
||||
for (const FileInfo& fileInfo: FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions))
|
||||
{
|
||||
const FilePath& path = fileInfo.path;
|
||||
bool excluded = false;
|
||||
for (FilePath p: m_excludePaths)
|
||||
{
|
||||
if (p == path || p.contains(path))
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!excluded)
|
||||
{
|
||||
sourceFilePaths.emplace(path);
|
||||
}
|
||||
}
|
||||
return sourceFilePaths;
|
||||
}
|
||||
|
||||
bool FileManager::hasSourceFilePath(const FilePath& filePath) const
|
||||
{
|
||||
if (m_sourceFilePaths.find(filePath) != m_sourceFilePaths.end())
|
||||
if (m_allSourceFilePaths.find(filePath) != m_allSourceFilePaths.end())
|
||||
{
|
||||
for (FilePath p: m_excludePaths)
|
||||
{
|
||||
if (p == filePath || p.contains(filePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getAllSourceFilePaths() const
|
||||
{
|
||||
return m_allSourceFilePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileManager::makeCanonical(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
std::vector<FilePath> ret;
|
||||
|
||||
@@ -10,47 +10,33 @@
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
struct FileSets
|
||||
{
|
||||
std::set<FilePath> addedFiles;
|
||||
std::set<FilePath> updatedFiles;
|
||||
std::set<FilePath> removedFiles;
|
||||
std::set<FilePath> allSourceFilePaths;
|
||||
};
|
||||
|
||||
FileManager();
|
||||
virtual ~FileManager();
|
||||
|
||||
void setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<FilePath> excludePaths,
|
||||
std::vector<std::string> sourceExtensions
|
||||
void update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<std::string>& sourceExtensions
|
||||
);
|
||||
|
||||
FileSets fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
// returns a list of source paths (can be directories) specified in the project settings
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
|
||||
// returns a list of paths to all files that reside in the non-excluded source paths
|
||||
std::set<FilePath> getSourceFilePaths() const;
|
||||
|
||||
// checks if file is in non-excluded source directory
|
||||
bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
|
||||
// returns a list of paths to all files that reside in the non-excluded source paths
|
||||
std::set<FilePath> getAllSourceFilePaths() const;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> makeCanonical(const std::vector<FilePath>& filePaths);
|
||||
bool isExcluded(const FilePath& filePath) const;
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_headerPaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
|
||||
std::map<FilePath, FileInfo> m_filesInfos;
|
||||
|
||||
std::set<FilePath> m_sourceFilePaths;
|
||||
std::set<FilePath> m_allSourceFilePaths;
|
||||
};
|
||||
|
||||
#endif // FILE_MANAGER_H
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#include "ISolutionParser.h"
|
||||
|
||||
std::string ISolutionParser::getSolutionPath()
|
||||
{
|
||||
return m_solutionPath;
|
||||
}
|
||||
|
||||
std::string ISolutionParser::getToolID() const
|
||||
{
|
||||
return "NONE";
|
||||
}
|
||||
|
||||
void ISolutionParser::openSolutionFile(const std::string& solutionFilePath)
|
||||
{
|
||||
m_solution = loadFile(solutionFilePath);
|
||||
|
||||
size_t pos = solutionFilePath.find_last_of("/");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
pos = solutionFilePath.find_last_of("\\");
|
||||
}
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
if (pos > 0)
|
||||
{
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
m_solutionPath = solutionFilePath.substr(0, pos);
|
||||
m_solutionName = solutionFilePath.substr(pos);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int ISolutionParser::getSolutionCharCount() const
|
||||
{
|
||||
return m_solution.size();
|
||||
}
|
||||
|
||||
std::string ISolutionParser::loadFile(const std::string& filePath)
|
||||
{
|
||||
std::string file = "";
|
||||
|
||||
std::ifstream ifstream;
|
||||
ifstream.open(filePath);
|
||||
|
||||
if (ifstream.is_open())
|
||||
{
|
||||
file = std::string(std::istreambuf_iterator<char>(ifstream), std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
std::vector<std::string> ISolutionParser::makePathsAbsolute(const std::vector<std::string>& paths)
|
||||
{
|
||||
std::vector<std::string> absolutePaths;
|
||||
|
||||
for (unsigned int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
std::string path = paths[i];
|
||||
|
||||
boost::filesystem::path boostPath(path);
|
||||
if (boostPath.is_relative())
|
||||
{
|
||||
path = m_solutionPath + path;
|
||||
}
|
||||
|
||||
absolutePaths.push_back(path);
|
||||
}
|
||||
|
||||
return absolutePaths;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef I_SOLUTION_PARSER_H
|
||||
#define I_SOLUTION_PARSER_H
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class ISolutionParser
|
||||
{
|
||||
public:
|
||||
ISolutionParser()
|
||||
: m_solutionPath("")
|
||||
, m_solution("")
|
||||
{};
|
||||
virtual ~ISolutionParser(){};
|
||||
|
||||
virtual std::string getToolID() const;
|
||||
|
||||
void openSolutionFile(const std::string& solutionFilePath);
|
||||
unsigned int getSolutionCharCount() const;
|
||||
|
||||
virtual std::string getSolutionName() = 0; // to be overwritten to account for different file endings
|
||||
std::string getSolutionPath();
|
||||
|
||||
virtual std::vector<std::string> getProjects() = 0;
|
||||
virtual std::vector<std::string> getProjectFiles() = 0;
|
||||
virtual std::vector<std::string> getProjectItems() = 0;
|
||||
virtual std::vector<std::string> getCompileFlags() = 0;
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
|
||||
virtual std::string getIdeName() const = 0;
|
||||
virtual std::string getButtonText() const = 0;
|
||||
virtual std::string getDescription() const = 0;
|
||||
virtual std::string getIconPath() const = 0;
|
||||
virtual std::string getFileExtension() const = 0;
|
||||
|
||||
protected:
|
||||
std::string loadFile(const std::string& filePath);
|
||||
|
||||
std::vector<std::string> makePathsAbsolute(const std::vector<std::string>& paths);
|
||||
|
||||
std::string m_solutionName;
|
||||
std::string m_solutionPath;
|
||||
std::string m_solution;
|
||||
};
|
||||
|
||||
#endif // I_SOLUTION_PARSER_H
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "SolutionParserCMake.h"
|
||||
|
||||
SolutionParserCMake::SolutionParserCMake()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SolutionParserCMake::~SolutionParserCMake()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCMake::getProjects()
|
||||
{
|
||||
std::vector<std::string> projects;
|
||||
|
||||
return projects;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef SOLUTION_PARSER_C_MAKE_H
|
||||
#define SOLUTION_PARSER_C_MAKE_H
|
||||
|
||||
#include "ISolutionParser.h"
|
||||
|
||||
class SolutionParserCMake : public ISolutionParser
|
||||
{
|
||||
public:
|
||||
SolutionParserCMake();
|
||||
virtual ~SolutionParserCMake();
|
||||
|
||||
virtual std::vector<std::string> getProjects();
|
||||
virtual std::vector<std::string> getProjectFiles();
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_C_MAKE_H
|
||||
@@ -1,228 +0,0 @@
|
||||
#include "SolutionParserCodeBlocks.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserCodeBlocks::SolutionParserCodeBlocks()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SolutionParserCodeBlocks::~SolutionParserCodeBlocks()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getToolID() const
|
||||
{
|
||||
return "cb";
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getSolutionName()
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
if (m_solutionName.size() > 0)
|
||||
{
|
||||
size_t pos = m_solutionName.find(".cbp");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
result = m_solutionName.substr(0, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = m_solution;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getProjects()
|
||||
{
|
||||
std::vector<std::string> projectFiles;
|
||||
|
||||
projectFiles.push_back(m_solutionName);
|
||||
|
||||
return projectFiles;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getProjectFiles()
|
||||
{
|
||||
std::vector<std::string> projectFiles;
|
||||
std::vector<std::string> projectFilesNames = getProjects();
|
||||
|
||||
projectFiles.push_back(loadFile(m_solutionPath + m_solutionName));
|
||||
|
||||
return projectFiles;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getProjectItems()
|
||||
{
|
||||
std::vector<std::string> projectItems;
|
||||
|
||||
std::vector<std::string> projectFilesNames = getProjects();
|
||||
std::vector<std::string> projectFiles = getProjectFiles();
|
||||
|
||||
std::vector<std::string> validFileExtensions;
|
||||
validFileExtensions.push_back(".c");
|
||||
validFileExtensions.push_back(".cpp");
|
||||
validFileExtensions.push_back(".h");
|
||||
validFileExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFiles.size(); i++)
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(projectFiles[i].c_str(), 0, TIXML_ENCODING_UTF8);
|
||||
|
||||
std::string error = doc.ErrorDesc();
|
||||
|
||||
if (error.length() > 0)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse project file " << i << ": " << error);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> nodes = SolutionParserUtility::getAllTagsByNameWithAttribute(doc.RootElement(), "Unit", "filename");
|
||||
|
||||
if (nodes.size() > 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < nodes.size(); i++)
|
||||
{
|
||||
std::string text = nodes[i]->Attribute("filename");
|
||||
|
||||
if (SolutionParserUtility::checkValidFileExtension(text, validFileExtensions))
|
||||
{
|
||||
if (boost::filesystem::exists(text))
|
||||
{
|
||||
projectItems.push_back(text);
|
||||
continue;
|
||||
}
|
||||
|
||||
text = m_solutionPath + "/" + text;
|
||||
|
||||
projectItems.push_back(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> s(projectItems.begin(), projectItems.end());
|
||||
projectItems.assign(s.begin(), s.end());
|
||||
|
||||
projectItems = SolutionParserUtility::resolveEnvironmentVariables(projectItems);
|
||||
projectItems = makePathsAbsolute(projectItems);
|
||||
|
||||
return projectItems;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getIncludePaths()
|
||||
{
|
||||
std::vector<std::string> includePaths;
|
||||
|
||||
std::vector<std::string> projectFiles = getProjectFiles();
|
||||
|
||||
std::vector<std::string> validExtensions;
|
||||
validExtensions.push_back(".c");
|
||||
validExtensions.push_back(".cpp");
|
||||
validExtensions.push_back(".h");
|
||||
validExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFiles.size(); i++)
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(projectFiles[i].c_str(), 0, TIXML_ENCODING_UTF8);
|
||||
|
||||
std::string error = doc.ErrorDesc();
|
||||
|
||||
if (error.length() > 0)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse project file " << i << ": " << error);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> nodes = SolutionParserUtility::getAllTagsByNameWithAttribute(doc.RootElement(), "Add", "directory");
|
||||
|
||||
if (nodes.size() > 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < nodes.size(); i++)
|
||||
{
|
||||
std::string text = nodes[i]->Attribute("directory");
|
||||
|
||||
includePaths.push_back(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> s(includePaths.begin(), includePaths.end());
|
||||
includePaths.assign(s.begin(), s.end());
|
||||
|
||||
includePaths = SolutionParserUtility::resolveEnvironmentVariables(includePaths);
|
||||
includePaths = makePathsAbsolute(includePaths);
|
||||
|
||||
return includePaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getCompileFlags()
|
||||
{
|
||||
std::vector<std::string> compilerFlags;
|
||||
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
openSolutionFile(solutionFilePath);
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>(getSolutionName(), getSolutionPath());
|
||||
settings->setVisualStudioSolutionPath(solutionFilePath); // why is it called vs solution if it is used for codeblocks as well?
|
||||
|
||||
std::vector<std::string> sourceFiles = getProjectItems();
|
||||
std::vector<FilePath> sourcePaths;
|
||||
for (const std::string& p : sourceFiles)
|
||||
{
|
||||
sourcePaths.push_back(FilePath(p));
|
||||
}
|
||||
|
||||
std::vector<std::string> includePaths = getIncludePaths();
|
||||
std::vector<FilePath> headerPaths;
|
||||
for (const std::string& p : includePaths)
|
||||
{
|
||||
headerPaths.push_back(FilePath(p));
|
||||
}
|
||||
|
||||
settings->setSourcePaths(sourcePaths);
|
||||
settings->setHeaderSearchPaths(headerPaths);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getIdeName() const
|
||||
{
|
||||
return "Code Blocks";
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getButtonText() const
|
||||
{
|
||||
return "from Code\nBlocks Project";
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getDescription() const
|
||||
{
|
||||
return "idunno";
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getIconPath() const
|
||||
{
|
||||
return "icon/project_vs_256_256.png";
|
||||
}
|
||||
|
||||
std::string SolutionParserCodeBlocks::getFileExtension() const
|
||||
{
|
||||
return ".cbp";
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef SOLUTION_PARSER_CODE_BLOCKS_H
|
||||
#define SOLUTION_PARSER_CODE_BLOCKS_H
|
||||
|
||||
#include "ISolutionParser.h"
|
||||
|
||||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
class SolutionParserCodeBlocks : public ISolutionParser
|
||||
{
|
||||
public:
|
||||
SolutionParserCodeBlocks();
|
||||
virtual ~SolutionParserCodeBlocks();
|
||||
|
||||
virtual std::string getToolID() const;
|
||||
|
||||
virtual std::string getSolutionName();
|
||||
|
||||
virtual std::vector<std::string> getProjects();
|
||||
virtual std::vector<std::string> getProjectFiles();
|
||||
virtual std::vector<std::string> getProjectItems();
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
virtual std::string getIdeName() const;
|
||||
virtual std::string getButtonText() const;
|
||||
virtual std::string getDescription() const;
|
||||
virtual std::string getIconPath() const;
|
||||
virtual std::string getFileExtension() const;
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_CODE_BLOCKS_H
|
||||
@@ -1,143 +0,0 @@
|
||||
#include "SolutionParserManager.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserManager::SolutionParserManager()
|
||||
: m_solutionParsers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SolutionParserManager::~SolutionParserManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SolutionParserManager::pushSolutionParser(const std::shared_ptr<ISolutionParser>& solutionParser)
|
||||
{
|
||||
m_solutionParsers.push_back(solutionParser);
|
||||
}
|
||||
|
||||
bool SolutionParserManager::canParseSolution(const std::string& ideId) const
|
||||
{
|
||||
std::string lIdeId = ideId;
|
||||
boost::algorithm::to_lower(lIdeId);
|
||||
|
||||
for (unsigned int i = 0; i < m_solutionParsers.size(); i++)
|
||||
{
|
||||
std::string parserIdeId = m_solutionParsers[i]->getToolID();
|
||||
boost::algorithm::to_lower(parserIdeId);
|
||||
|
||||
if (lIdeId == parserIdeId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> SolutionParserManager::getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const
|
||||
{
|
||||
std::string lIdeId = ideId;
|
||||
boost::algorithm::to_lower(lIdeId);
|
||||
|
||||
for (unsigned int i = 0; i < m_solutionParsers.size(); i++)
|
||||
{
|
||||
std::string parserIdeId = m_solutionParsers[i]->getToolID();
|
||||
boost::algorithm::to_lower(parserIdeId);
|
||||
|
||||
if (lIdeId == parserIdeId)
|
||||
{
|
||||
return m_solutionParsers[i]->getProjectSettings(solutionFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_ERROR_STREAM(<< "Solution type is unknown");
|
||||
|
||||
return std::shared_ptr<ProjectSettings>();
|
||||
}
|
||||
|
||||
unsigned int SolutionParserManager::getParserCount() const
|
||||
{
|
||||
return m_solutionParsers.size();
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getParserName(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getIdeName();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getParserButtonText(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getButtonText();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getParserDescription(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getDescription();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getParserFileEnding(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getFileExtension();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getParserIdeId(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getToolID();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string SolutionParserManager::getIconPath(const unsigned int idx) const
|
||||
{
|
||||
if (checkIndex(idx))
|
||||
{
|
||||
return m_solutionParsers[idx]->getIconPath();
|
||||
}
|
||||
|
||||
LOG_WARNING_STREAM(<< "Index is out of range, was " << idx << ". Max is " << m_solutionParsers.size() - 1);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool SolutionParserManager::checkIndex(const unsigned int idx) const
|
||||
{
|
||||
return (idx < m_solutionParsers.size());
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef SOLUTION_PARSER_MANAGER_H
|
||||
#define SOLUTION_PARSER_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ISolutionParser.h"
|
||||
|
||||
class SolutionParserManager
|
||||
{
|
||||
public:
|
||||
SolutionParserManager();
|
||||
~SolutionParserManager();
|
||||
|
||||
void pushSolutionParser(const std::shared_ptr<ISolutionParser>& solutionParser);
|
||||
|
||||
bool canParseSolution(const std::string& ideId) const;
|
||||
|
||||
std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const;
|
||||
|
||||
unsigned int getParserCount() const;
|
||||
|
||||
std::string getParserName(const unsigned int idx) const;
|
||||
std::string getParserButtonText(const unsigned int idx) const;
|
||||
std::string getParserDescription(const unsigned int idx) const;
|
||||
std::string getParserFileEnding(const unsigned int idx) const;
|
||||
std::string getParserIdeId(const unsigned int idx) const;
|
||||
std::string getIconPath(const unsigned int idx) const;
|
||||
|
||||
private:
|
||||
bool checkIndex(const unsigned int idx) const;
|
||||
|
||||
std::vector<std::shared_ptr<ISolutionParser>> m_solutionParsers;
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_MANAGER_H
|
||||
@@ -1,328 +0,0 @@
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
#include "boost/filesystem/path.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
std::vector<std::string> SolutionParserUtility::m_ideMacros;
|
||||
std::map<std::string, std::string> SolutionParserUtility::m_ideMacroValues;
|
||||
|
||||
TiXmlElement* SolutionParserUtility::getFirstTagByName(TiXmlElement* root, const std::string& tag)
|
||||
{
|
||||
TiXmlElement* element = root;
|
||||
|
||||
while (element)
|
||||
{
|
||||
if (element == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
std::string value = element->Value();
|
||||
|
||||
if (value == tag) // "ClInclude") // || value == "ClCompile")
|
||||
{
|
||||
if (element->Parent() != NULL)
|
||||
{
|
||||
return element; // ->Parent()->ToElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (element->FirstChildElement() != NULL)
|
||||
{
|
||||
element = element->FirstChildElement();
|
||||
}
|
||||
else if (element->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (element == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
|
||||
{
|
||||
TiXmlElement* newElement = element->Parent()->ToElement();
|
||||
|
||||
if (newElement == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
element = newElement;
|
||||
}
|
||||
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->Parent()->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TiXmlElement* SolutionParserUtility::getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute)
|
||||
{
|
||||
TiXmlElement* element = root;
|
||||
|
||||
while (element)
|
||||
{
|
||||
if (element == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
std::string value = element->Value();
|
||||
|
||||
bool hasAttribute = false;
|
||||
if (element->Attribute(attribute.c_str()) != NULL)
|
||||
{
|
||||
hasAttribute = true;
|
||||
}
|
||||
|
||||
if (value == tag && hasAttribute) // "ClInclude") // || value == "ClCompile")
|
||||
{
|
||||
if (element->Parent() != NULL)
|
||||
{
|
||||
return element; // ->Parent()->ToElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (element->FirstChildElement() != NULL)
|
||||
{
|
||||
element = element->FirstChildElement();
|
||||
}
|
||||
else if (element->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
|
||||
{
|
||||
TiXmlElement* newElement = element->Parent()->ToElement();
|
||||
|
||||
element = newElement;
|
||||
}
|
||||
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->Parent()->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> SolutionParserUtility::getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute)
|
||||
{
|
||||
std::vector<TiXmlElement*> nodes;
|
||||
|
||||
TiXmlElement* element = root;
|
||||
|
||||
while (element)
|
||||
{
|
||||
std::string value = element->Value();
|
||||
|
||||
bool hasAttribute = false;
|
||||
if (element->Attribute(attribute.c_str()) != NULL)
|
||||
{
|
||||
hasAttribute = true;
|
||||
}
|
||||
|
||||
if (value == tag && hasAttribute)
|
||||
{
|
||||
nodes.push_back(element);
|
||||
}
|
||||
|
||||
if (element->FirstChildElement() != NULL)
|
||||
{
|
||||
element = element->FirstChildElement();
|
||||
}
|
||||
else if (element->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
|
||||
{
|
||||
TiXmlElement* newElement = element->Parent()->ToElement();
|
||||
|
||||
element = newElement;
|
||||
}
|
||||
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->Parent()->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
bool SolutionParserUtility::checkValidFileExtension(const std::string& file, const std::vector<std::string>& validExtensions)
|
||||
{
|
||||
for (unsigned int i = 0; i < validExtensions.size(); i++)
|
||||
{
|
||||
size_t pos = file.find(validExtensions[i]);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserUtility::resolveEnvironmentVariables(const std::vector<std::string>& paths)
|
||||
{
|
||||
std::vector<std::string> resolvedPaths;
|
||||
|
||||
for (unsigned int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
std::string resolvedPath = "";
|
||||
|
||||
try
|
||||
{
|
||||
resolvedPath = findAndResolveEnvironmentVariable(paths[i]);
|
||||
|
||||
resolvedPaths.push_back(resolvedPath);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to resolve environment variable, exception was: \"" << e.what() << "\"");
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedPaths;
|
||||
}
|
||||
|
||||
std::string SolutionParserUtility::findAndResolveEnvironmentVariable(const std::string& path)
|
||||
{
|
||||
std::string resolvedPath;
|
||||
|
||||
size_t pos = path.find("$(");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
size_t endPos = path.substr(pos).find(")");
|
||||
|
||||
std::string envVariable = path.substr(pos + 2, (endPos - 2) - pos);
|
||||
|
||||
std::string envPath = "";
|
||||
|
||||
std::string macro = checkIsIdeMacro(envVariable);
|
||||
if (macro != "")
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Encountered IDE macro \"" << macro << "\"");
|
||||
|
||||
if (m_ideMacroValues.find(macro) == m_ideMacroValues.end())
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Could not resolve IDE macro \"" << macro << "\"");
|
||||
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
envPath = m_ideMacroValues[macro];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
envPath = getenv(envVariable.c_str());
|
||||
}
|
||||
|
||||
std::string prePath = path.substr(0, pos);
|
||||
std::string postPath = path.substr(endPos + 1);
|
||||
|
||||
resolvedPath = prePath + envPath + postPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
resolvedPath = path;
|
||||
}
|
||||
|
||||
return resolvedPath;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserUtility::makePathsCanonical(const std::vector<std::string>& paths)
|
||||
{
|
||||
std::vector<std::string> canonicalPaths;
|
||||
|
||||
int errorCount = 0;
|
||||
|
||||
for (unsigned int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::filesystem::path canonicalPath = boost::filesystem::canonical(boost::filesystem::path(paths[i]));
|
||||
canonicalPaths.push_back(canonicalPath.string());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string what = e.what();
|
||||
LOG_WARNING_STREAM(<< e.what());
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCount > 0)
|
||||
{
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Detected " << errorCount << " invalid include file paths. Check if the include paths of your VS project exist.";
|
||||
MessageStatus(errorMessage.str(), true).dispatch();
|
||||
}
|
||||
|
||||
return canonicalPaths;
|
||||
}
|
||||
|
||||
std::string SolutionParserUtility::makePathCanonical(const std::string& path)
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
try
|
||||
{
|
||||
boost::filesystem::path canonicalPath = boost::filesystem::canonical(boost::filesystem::path(path));
|
||||
result = canonicalPath.string();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string what = e.what();
|
||||
LOG_WARNING_STREAM(<< e.what());
|
||||
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Could not make path \"" << path << "\" canonical. Check if it really exists.";
|
||||
MessageStatus(errorMessage.str(), true).dispatch();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string SolutionParserUtility::checkIsIdeMacro(const std::string& text)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_ideMacros.size(); i++)
|
||||
{
|
||||
if (text == m_ideMacros[i])
|
||||
{
|
||||
return m_ideMacros[i];
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef SOLUTION_PARSER_UTILITY_H
|
||||
#define SOLUTION_PARSER_UTILITY_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
class SolutionParserUtility
|
||||
{
|
||||
public:
|
||||
static TiXmlElement* getFirstTagByName(TiXmlElement* root, const std::string& tag);
|
||||
|
||||
static TiXmlElement* getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
|
||||
static std::vector<TiXmlElement*> getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
|
||||
|
||||
static bool checkValidFileExtension(const std::string& file, const std::vector<std::string>& validExtensions);
|
||||
|
||||
static std::vector<std::string> resolveEnvironmentVariables(const std::vector<std::string>& paths);
|
||||
static std::string findAndResolveEnvironmentVariable(const std::string& path);
|
||||
static std::vector<std::string> makePathsCanonical(const std::vector<std::string>& paths);
|
||||
static std::string makePathCanonical(const std::string& path);
|
||||
|
||||
static std::string checkIsIdeMacro(const std::string& text); // returns matching macro or empty string if no match was found
|
||||
|
||||
static std::vector<std::string> m_ideMacros;
|
||||
static std::map<std::string, std::string> m_ideMacroValues; // to replace macros with known values
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_UTILITY_H
|
||||
@@ -147,22 +147,6 @@ namespace utility
|
||||
return text.size() >= postfix.size() && text.rfind(postfix) == (text.size() - postfix.size());
|
||||
}
|
||||
|
||||
std::string switchCases(std::string s)
|
||||
{
|
||||
for (char& c: s)
|
||||
{
|
||||
if (islower(c))
|
||||
{
|
||||
c = toupper(c);
|
||||
}
|
||||
else if (isupper(c))
|
||||
{
|
||||
c = tolower(c);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string toUpperCase(const std::string& in)
|
||||
{
|
||||
std::string out;
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace utility
|
||||
bool isPrefix(const std::string& prefix, const std::string& text);
|
||||
bool isPostfix(const std::string& postfix, const std::string& text);
|
||||
|
||||
std::string switchCases(std::string s);
|
||||
std::string toUpperCase(const std::string& in);
|
||||
std::string toLowerCase(const std::string& in);
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b);
|
||||
|
||||
@@ -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
|
||||
@@ -148,8 +148,6 @@ add_files(
|
||||
qt/window/project_wizzard/QtProjectWizzard.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContent.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContent.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentBuildFile.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentData.cpp
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "utility/messaging/type/MessageActivateFile.h"
|
||||
#include "utility/messaging/type/MessageProjectEdit.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "Project.h"
|
||||
#include "project/Project.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "Application.h"
|
||||
|
||||
QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
||||
: QPushButton(parent)
|
||||
|
||||
@@ -415,7 +415,14 @@ void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::s
|
||||
void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
wizzard->newProjectFromCDB(filePath, headerPaths);
|
||||
|
||||
std::vector<FilePath> headerFilePaths(headerPaths.size());
|
||||
for (const std::string& s: headerPaths)
|
||||
{
|
||||
headerFilePaths.push_back(FilePath(s));
|
||||
}
|
||||
|
||||
wizzard->newProjectFromCDB(FilePath(filePath), headerFilePaths);
|
||||
}
|
||||
|
||||
void QtMainWindow::openProject()
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <QSysInfo>
|
||||
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentExtensions.h"
|
||||
@@ -16,8 +15,8 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
@@ -28,6 +27,7 @@
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/UUIDUtility.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
@@ -46,9 +46,6 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
|
||||
m_appSettings.setScrollSpeed(appSettings->getScrollSpeed());
|
||||
m_appSettings.setCoatiPort(appSettings->getCoatiPort());
|
||||
m_appSettings.setPluginPort(appSettings->getPluginPort());
|
||||
|
||||
m_parserManager = std::make_shared<SolutionParserManager>();
|
||||
|
||||
}
|
||||
|
||||
void QtProjectWizzard::showWindow()
|
||||
@@ -73,129 +70,69 @@ void QtProjectWizzard::hideWindow()
|
||||
|
||||
void QtProjectWizzard::newProject()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSelect>();
|
||||
QtProjectWizzardWindow* window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentSelect(window);
|
||||
}
|
||||
);
|
||||
window->setPreferredSize(QSize(570, 380));
|
||||
|
||||
connect(dynamic_cast<QtProjectWizzardContentSelect*>(window->content()),
|
||||
SIGNAL(selected(ProjectType)),
|
||||
this, SLOT(selectedProjectType(ProjectType)));
|
||||
SIGNAL(selected(SourceGroupType)),
|
||||
this, SLOT(selectedProjectType(SourceGroupType)));
|
||||
|
||||
window->setNextEnabled(false);
|
||||
window->setPreviousEnabled(false);
|
||||
window->updateSubTitle("Type Selection");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const FilePath& solutionPath)
|
||||
{
|
||||
if (m_parserManager->canParseSolution(ideId))
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
|
||||
|
||||
// this looks rather hacky.. calling the edit project and then setting the title.
|
||||
editProject(settings);
|
||||
|
||||
QWidget* widget = m_windowStack.getTopWindow();
|
||||
|
||||
if (widget)
|
||||
{
|
||||
QtProjectWizzardWindow* window = dynamic_cast<QtProjectWizzardWindow*>(widget);
|
||||
|
||||
std::string title = "NEW PROJECT FROM ";
|
||||
title += utility::toUpperCase(ideId);
|
||||
title += " SOLUTION";
|
||||
|
||||
window->updateTitle(QString(title.c_str()));
|
||||
window->updateNextButton("Create");
|
||||
window->setPreviousVisible(m_windowStack.getWindowCount() > 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Unknown solution type");
|
||||
MessageStatus("Unable to parse given solution", true).dispatch();
|
||||
}
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
void QtProjectWizzard::newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths)
|
||||
void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths)
|
||||
{
|
||||
FilePath fp(filePath);
|
||||
m_projectSettings = std::make_shared<ProjectSettings>();
|
||||
|
||||
std::vector<FilePath> hp;
|
||||
for (size_t i = 0; i < headerPaths.size(); i++)
|
||||
{
|
||||
hp.push_back(FilePath(headerPaths[i]));
|
||||
}
|
||||
std::shared_ptr<SourceGroupSettingsCxx> sourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(UUIDUtility::getUUIDString(), SOURCE_GROUP_CXX_VS, m_projectSettings.get());
|
||||
m_projectSettings->setProjectName(filePath.withoutExtension().fileName());
|
||||
m_projectSettings->setProjectFileLocation(filePath.parentDirectory());
|
||||
sourceGroupSettings->setCompilationDatabasePath(filePath);
|
||||
sourceGroupSettings->setSourcePaths(headerPaths);
|
||||
m_sourceGroupSettings = sourceGroupSettings;
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>();
|
||||
settings->setLanguage(LanguageType::LANGUAGE_CPP);
|
||||
settings->setProjectName(fp.withoutExtension().fileName());
|
||||
settings->setProjectFileLocation(fp.parentDirectory());
|
||||
settings->setCompilationDatabasePath(fp);
|
||||
settings->setSourcePaths(hp);
|
||||
m_settings = settings;
|
||||
emptyProjectCDBVS();
|
||||
}
|
||||
|
||||
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
if (m_parserManager->canParseSolution(ideId))
|
||||
{
|
||||
QtProjectWizzardWindow* window = dynamic_cast<QtProjectWizzardWindow*>(m_windowStack.getTopWindow());
|
||||
if (window)
|
||||
{
|
||||
window->content()->save();
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> otherCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(settings);
|
||||
std::shared_ptr<CxxProjectSettings> ownCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (otherCxxSettings && ownCxxSettings)
|
||||
{
|
||||
ownCxxSettings->setSourcePaths(otherCxxSettings->getSourcePaths());
|
||||
ownCxxSettings->setHeaderSearchPaths(otherCxxSettings->getHeaderSearchPaths());
|
||||
ownCxxSettings->setVisualStudioSolutionPath(FilePath(solutionPath));
|
||||
}
|
||||
if (window)
|
||||
{
|
||||
window->content()->load();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Unknown solution type");
|
||||
MessageStatus("Unable to parse given solution", true).dispatch();
|
||||
}
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(const FilePath& settingsPath)
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> settings;
|
||||
switch (ProjectSettings::getLanguageOfProject(settingsPath))
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
case LANGUAGE_CPP:
|
||||
settings = std::make_shared<CxxProjectSettings>(settingsPath);
|
||||
break;
|
||||
case LANGUAGE_JAVA:
|
||||
settings = std::make_shared<JavaProjectSettings>(settingsPath);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings)
|
||||
{
|
||||
settings->reload();
|
||||
editProject(settings);
|
||||
}
|
||||
std::shared_ptr<ProjectSettings> settings = std::make_shared<ProjectSettings>(settingsPath);
|
||||
settings->reload();
|
||||
editProject(settings);
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(std::shared_ptr<ProjectSettings> settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
m_projectSettings = settings;
|
||||
|
||||
{
|
||||
const std::vector<std::shared_ptr<SourceGroupSettings>> allSourceGroupSettings = m_projectSettings->getAllSourceGroupSettings();
|
||||
if (!allSourceGroupSettings.empty())
|
||||
{
|
||||
// Todo: regard the rest of the source groups once we can have more than one in a project.
|
||||
m_sourceGroupSettings = allSourceGroupSettings.front();
|
||||
}
|
||||
}
|
||||
m_editing = true;
|
||||
|
||||
switch (m_settings->getLanguage())
|
||||
switch (getLanguageTypeForSourceGroupType(m_sourceGroupSettings->getType()))
|
||||
{
|
||||
case LANGUAGE_JAVA:
|
||||
showSummaryJava();
|
||||
@@ -218,12 +155,12 @@ void QtProjectWizzard::showPreferences()
|
||||
{
|
||||
summary->setIsForm(true);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPreferences(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPreferences(window));
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(window));
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(window));
|
||||
}
|
||||
|
||||
window->setup();
|
||||
@@ -264,15 +201,15 @@ bool QtProjectWizzard::applicationSettingsContainVisualStudioHeaderSearchPaths()
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
|
||||
{
|
||||
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent(
|
||||
std::function<QtProjectWizzardContent*(QtProjectWizzardWindow*)> func
|
||||
){
|
||||
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
|
||||
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
window->setContent(new T(m_settings, window));
|
||||
window->setContent(func(window));
|
||||
window->setPreferredSize(QSize(580, 340));
|
||||
window->setup();
|
||||
|
||||
@@ -281,25 +218,6 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
|
||||
return window;
|
||||
}
|
||||
|
||||
template<>
|
||||
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent<QtProjectWizzardContentSelect>()
|
||||
{
|
||||
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
|
||||
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
QtProjectWizzardContentSelect* content = new QtProjectWizzardContentSelect(m_settings, window, m_parserManager);
|
||||
|
||||
window->setContent(content);
|
||||
window->setPreferredSize(QSize(570, 380));
|
||||
window->setup();
|
||||
|
||||
m_windowStack.pushWindow(window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithSummary(
|
||||
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func
|
||||
){
|
||||
@@ -308,7 +226,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithSummary(
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(m_settings, window);
|
||||
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(window);
|
||||
|
||||
window->setContent(summary);
|
||||
window->setPreferredSize(QSize(750, 500));
|
||||
@@ -341,43 +259,41 @@ void QtProjectWizzard::windowStackChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::selectedProjectType(ProjectType projectType)
|
||||
void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType)
|
||||
{
|
||||
LanguageType languageType = getLanguageTypeForProjectType(projectType);
|
||||
switch (projectType)
|
||||
m_projectSettings = std::make_shared<ProjectSettings>();
|
||||
|
||||
const std::string sourceGroupId = UUIDUtility::getUUIDString();
|
||||
|
||||
switch (sourceGroupType)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case PROJECT_CPP_EMPTY:
|
||||
m_settings = std::make_shared<CxxProjectSettings>();
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
m_sourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
|
||||
{
|
||||
std::vector<std::string> flags;
|
||||
flags.push_back("-fms-extensions");
|
||||
flags.push_back("-fms-compatibility");
|
||||
flags.push_back("-fms-compatibility-version=19");
|
||||
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings)->setCompilerFlags(flags);
|
||||
}
|
||||
m_settings->setLanguage(languageType);
|
||||
emptyProject();
|
||||
break;
|
||||
case PROJECT_CXX_CDB:
|
||||
m_settings = std::make_shared<CxxProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
m_sourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
emptyProjectCDB();
|
||||
break;
|
||||
case PROJECT_CXX_VS:
|
||||
m_settings = std::make_shared<CxxProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
case SOURCE_GROUP_CXX_VS:
|
||||
m_sourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, sourceGroupType, m_projectSettings.get()); // maybe use a different type here
|
||||
emptyProjectCDBVS();
|
||||
break;
|
||||
case PROJECT_JAVA_EMPTY:
|
||||
m_settings = std::make_shared<JavaProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
m_sourceGroupSettings = std::make_shared<SourceGroupSettingsJava>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
emptyProject();
|
||||
break;
|
||||
case PROJECT_JAVA_MAVEN:
|
||||
m_settings = std::make_shared<JavaProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
m_sourceGroupSettings = std::make_shared<SourceGroupSettingsJava>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
emptyProjectJavaMaven();
|
||||
break;
|
||||
}
|
||||
@@ -385,17 +301,67 @@ void QtProjectWizzard::selectedProjectType(ProjectType projectType)
|
||||
|
||||
void QtProjectWizzard::emptyProject()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentData>();
|
||||
window->updateSubTitle("Project Data");
|
||||
QtProjectWizzardWindow* window;
|
||||
|
||||
if (m_settings->getLanguage() == LANGUAGE_JAVA)
|
||||
{
|
||||
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJava()));
|
||||
}
|
||||
else
|
||||
switch (m_sourceGroupSettings->getType())
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentData(m_projectSettings, m_sourceGroupSettings, window);
|
||||
}
|
||||
);
|
||||
connect(window, SIGNAL(next()), this, SLOT(sourcePaths()));
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentData(m_projectSettings, m_sourceGroupSettings, window);
|
||||
}
|
||||
);
|
||||
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJava()));
|
||||
break;
|
||||
}
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectCDBVS()
|
||||
{
|
||||
QtProjectWizzardWindow* window = window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentDataCDBVS(m_projectSettings, m_sourceGroupSettings, window);
|
||||
}
|
||||
);
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectCDB()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentDataCDB(m_projectSettings, m_sourceGroupSettings, window);
|
||||
}
|
||||
);
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectJavaMaven()
|
||||
{
|
||||
QtProjectWizzardWindow* window = window = createWindowWithContent(
|
||||
[this](QtProjectWizzardWindow* window)
|
||||
{
|
||||
return new QtProjectWizzardContentData(m_projectSettings, m_sourceGroupSettings, window);
|
||||
}
|
||||
);
|
||||
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJavaMaven()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::sourcePaths()
|
||||
@@ -403,9 +369,9 @@ void QtProjectWizzard::sourcePaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -420,9 +386,9 @@ void QtProjectWizzard::headerSearchPaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -449,9 +415,9 @@ void QtProjectWizzard::frameworkSearchPaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -461,38 +427,14 @@ void QtProjectWizzard::frameworkSearchPaths()
|
||||
window->updateSubTitle("Framework Search Paths");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectCDBVS()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentDataCDBVS>();
|
||||
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectCDB()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentDataCDB>();
|
||||
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::emptyProjectJavaMaven()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentData>();
|
||||
|
||||
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJavaMaven()));
|
||||
window->updateSubTitle("Project Data");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::headerPathsCDB()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentCDBSource(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentCDBSource(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -507,9 +449,9 @@ void QtProjectWizzard::sourcePathsJava()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -521,16 +463,16 @@ void QtProjectWizzard::sourcePathsJava()
|
||||
|
||||
void QtProjectWizzard::sourcePathsJavaMaven()
|
||||
{
|
||||
std::dynamic_pointer_cast<JavaProjectSettings>(m_settings)->setMavenDependenciesDirectory(
|
||||
"./coati_dependencies/" + utility::replace(m_settings->getProjectName(), " ", "_") + "/maven"
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_sourceGroupSettings)->setMavenDependenciesDirectory(
|
||||
"./coati_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/maven"
|
||||
);
|
||||
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -545,9 +487,9 @@ void QtProjectWizzard::advancedSettingsCxx()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentFlags(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentFlags(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -562,9 +504,9 @@ void QtProjectWizzard::advancedSettingsJava()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -581,49 +523,48 @@ void QtProjectWizzard::showSummary()
|
||||
{
|
||||
summary->setIsForm(true);
|
||||
|
||||
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(m_settings, window);
|
||||
const bool isCDB = buildFile->getType() == PROJECT_CXX_CDB || buildFile->getType() == PROJECT_CXX_VS;
|
||||
const bool isCDB = m_sourceGroupSettings->getType() == SOURCE_GROUP_CXX_CDB || m_sourceGroupSettings->getType() == SOURCE_GROUP_CXX_CDB;
|
||||
|
||||
if (!isCDB)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
|
||||
summary->addContent(new QtProjectWizzardContentData(m_projectSettings, m_sourceGroupSettings, window, m_editing));
|
||||
summary->addSpace();
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_sourceGroupSettings, window));
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
}
|
||||
else
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentDataCDB(m_settings, window, m_editing));
|
||||
summary->addContent(new QtProjectWizzardContentDataCDB(m_projectSettings, m_sourceGroupSettings, window, m_editing));
|
||||
summary->addSpace();
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window, isCDB));
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_sourceGroupSettings, window, isCDB));
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings);
|
||||
if (!isCDB && cxxSettings && cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentSimple(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentSimple(m_sourceGroupSettings, window));
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(window));
|
||||
summary->addSpace();
|
||||
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_settings, window, isCDB));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_sourceGroupSettings, window, isCDB));
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(window));
|
||||
summary->addSpace();
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentFlags(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentFlags(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
|
||||
@@ -652,33 +593,33 @@ void QtProjectWizzard::showSummaryJava()
|
||||
summary->setIsForm(true);
|
||||
|
||||
bool isMaven = false;
|
||||
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_sourceGroupSettings);
|
||||
if (javaSettings)
|
||||
{
|
||||
isMaven = javaSettings->getAbsoluteMavenProjectFilePath().exists();
|
||||
}
|
||||
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
|
||||
summary->addContent(new QtProjectWizzardContentData(m_projectSettings, m_sourceGroupSettings, window, m_editing));
|
||||
summary->addSpace();
|
||||
|
||||
if (isMaven)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_sourceGroupSettings, window));
|
||||
}
|
||||
else
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_sourceGroupSettings, window));
|
||||
}
|
||||
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_sourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_sourceGroupSettings, window));
|
||||
|
||||
window->setup();
|
||||
|
||||
@@ -701,10 +642,11 @@ void QtProjectWizzard::showSummaryJava()
|
||||
|
||||
void QtProjectWizzard::createProject()
|
||||
{
|
||||
FilePath path = m_settings->getFilePath();
|
||||
FilePath path = m_projectSettings->getFilePath();
|
||||
|
||||
m_settings->setVersion(ProjectSettings::VERSION);
|
||||
m_settings->save(path);
|
||||
m_projectSettings->setVersion(ProjectSettings::VERSION);
|
||||
m_projectSettings->setAllSourceGroupSettings({m_sourceGroupSettings});
|
||||
m_projectSettings->save(path);
|
||||
|
||||
bool forceRefreshProject = false;
|
||||
if (m_editing)
|
||||
@@ -714,7 +656,7 @@ void QtProjectWizzard::createProject()
|
||||
Application* application = Application::getInstance().get();
|
||||
if (application->getCurrentProject() != NULL)
|
||||
{
|
||||
settingsChanged = !(application->getCurrentProject()->settingsEqualExceptNameAndLocation(*(m_settings.get())));
|
||||
settingsChanged = !(application->getCurrentProject()->settingsEqualExceptNameAndLocation(*(m_projectSettings.get())));
|
||||
}
|
||||
|
||||
bool appSettingsChanged = !(m_appSettings == *ApplicationSettings::getInstance().get());
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "utility/solution/SolutionParserManager.h"
|
||||
|
||||
class QtProjectWizzardContentSummary;
|
||||
class QtProjectWizzardWindow;
|
||||
|
||||
@@ -33,8 +31,8 @@ public:
|
||||
public slots:
|
||||
void newProject();
|
||||
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
|
||||
void newProjectFromSolution(const std::string& ideId, const FilePath& solutionPath);
|
||||
void newProjectFromCDB(const FilePath& filePath, const std::vector<FilePath>& headerPaths);
|
||||
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
|
||||
void editProject(const FilePath& settingsPath);
|
||||
@@ -44,30 +42,32 @@ public slots:
|
||||
private:
|
||||
static bool applicationSettingsContainVisualStudioHeaderSearchPaths();
|
||||
|
||||
template<typename T>
|
||||
QtProjectWizzardWindow* createWindowWithContent();
|
||||
QtProjectWizzardWindow* createWindowWithContent(
|
||||
std::function<QtProjectWizzardContent*(QtProjectWizzardWindow*)> func);
|
||||
|
||||
QtProjectWizzardWindow* createWindowWithSummary(
|
||||
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func);
|
||||
|
||||
QtWindowStack m_windowStack;
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
std::shared_ptr<ProjectSettings> m_projectSettings;
|
||||
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
|
||||
ApplicationSettings m_appSettings;
|
||||
|
||||
bool m_editing;
|
||||
|
||||
std::shared_ptr<SolutionParserManager> m_parserManager;
|
||||
|
||||
private slots:
|
||||
void cancelWizzard();
|
||||
void finishWizzard();
|
||||
|
||||
void windowStackChanged();
|
||||
|
||||
void selectedProjectType(ProjectType type);
|
||||
void selectedProjectType(SourceGroupType sourceGroupType);
|
||||
|
||||
void emptyProject();
|
||||
void emptyProjectCDBVS();
|
||||
void emptyProjectCDB();
|
||||
void emptyProjectJavaMaven();
|
||||
|
||||
void sourcePaths();
|
||||
void headerSearchPaths();
|
||||
@@ -75,10 +75,6 @@ private slots:
|
||||
void headerSearchPathsDone();
|
||||
void frameworkSearchPaths();
|
||||
|
||||
void emptyProjectCDBVS();
|
||||
void emptyProjectCDB();
|
||||
void emptyProjectJavaMaven();
|
||||
|
||||
void headerPathsCDB();
|
||||
|
||||
void sourcePathsJava();
|
||||
@@ -94,7 +90,4 @@ private slots:
|
||||
void savePreferences();
|
||||
};
|
||||
|
||||
template<>
|
||||
QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent<QtProjectWizzardContentSelect>();
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_H
|
||||
|
||||
@@ -37,9 +37,8 @@ void QtHelpButton::handleHelpPress()
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(QtProjectWizzardWindow* window)
|
||||
: QWidget(window)
|
||||
, m_settings(settings)
|
||||
, m_window(window)
|
||||
, m_isInForm(false)
|
||||
, m_showFilesFunctor(std::bind(&QtProjectWizzardContent::showFilesDialog, this, std::placeholders::_1))
|
||||
|
||||
@@ -35,7 +35,7 @@ class QtProjectWizzardContent
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContent(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContent(QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void populate(QGridLayout* layout, int& row);
|
||||
virtual void windowReady();
|
||||
@@ -61,7 +61,6 @@ protected:
|
||||
QtHelpButton* addHelpButton(QString helpString, QGridLayout* layout, int row) const;
|
||||
QPushButton* addFilesButton(QString name, QGridLayout* layout, int row) const;
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
QtProjectWizzardWindow* m_window;
|
||||
|
||||
std::shared_ptr<QtTextEditDialog> m_filesDialog;
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/element/QtLocationPicker.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_type(PROJECT_UNKNOWN)
|
||||
{
|
||||
m_type = m_settings->getProjectType();
|
||||
}
|
||||
|
||||
ProjectType QtProjectWizzardContentBuildFile::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
QString name;
|
||||
QString filter;
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case PROJECT_CPP_EMPTY:
|
||||
name = "Build Text";
|
||||
filter = "Text (*.txt)";
|
||||
return;
|
||||
case PROJECT_CXX_VS:
|
||||
case PROJECT_CXX_CDB:
|
||||
name = "Compilation Database";
|
||||
filter = "JSON Compilation Database (*.json)";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
QLabel* label = createFormLabel(name);
|
||||
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL);
|
||||
|
||||
m_picker = new QtLocationPicker(this);
|
||||
m_picker->setFileFilter(filter);
|
||||
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
|
||||
|
||||
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentBuildFile::load()
|
||||
{
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case PROJECT_CPP_EMPTY:
|
||||
return;
|
||||
case PROJECT_CXX_VS:
|
||||
case PROJECT_CXX_CDB:
|
||||
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentBuildFile::save()
|
||||
{
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case PROJECT_CPP_EMPTY:
|
||||
break;
|
||||
case PROJECT_CXX_VS:
|
||||
case PROJECT_CXX_CDB:
|
||||
{
|
||||
FilePath path = m_picker->getText().toStdString();
|
||||
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
|
||||
if (!absPath.exists() || absPath.extension() != ".json")
|
||||
{
|
||||
return;
|
||||
}
|
||||
cxxSettings->setCompilationDatabasePath(path);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentBuildFile::check()
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
case PROJECT_CPP_EMPTY:
|
||||
break;
|
||||
case PROJECT_CXX_VS:
|
||||
case PROJECT_CXX_CDB:
|
||||
{
|
||||
FilePath path = m_picker->getText().toStdString();
|
||||
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
|
||||
if (!absPath.exists() || absPath.extension() != ".json")
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Please enter a valid compilation database file (*.json).");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef QT_PROJECT_WIZZARD_CONTENT_BUILD_FILE_H
|
||||
#define QT_PROJECT_WIZZARD_CONTENT_BUILD_FILE_H
|
||||
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSelect.h"
|
||||
|
||||
class QtLocationPicker;
|
||||
class QPushButton;
|
||||
|
||||
class QtProjectWizzardContentBuildFile
|
||||
: public QtProjectWizzardContent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void refreshVisualStudioSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentBuildFile(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
ProjectType getType() const;
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
virtual bool check() override;
|
||||
|
||||
private:
|
||||
QtLocationPicker* m_picker;
|
||||
|
||||
ProjectType m_type;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_BUILD_FILE_H
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "data/indexer/IndexerCxxCdb.h"
|
||||
|
||||
QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
: QtProjectWizzardContent(window)
|
||||
, m_settings(settings)
|
||||
, m_text(nullptr)
|
||||
{
|
||||
}
|
||||
@@ -29,10 +30,10 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
{
|
||||
m_fileNames.clear();
|
||||
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
const FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
std::vector<FilePath> filePaths = IndexerCxxCdb::getSourceFilesFromCDB(cxxSettings->getAbsoluteCompilationDatabasePath());
|
||||
|
||||
@@ -9,7 +9,7 @@ class QtProjectWizzardContentCDBSource
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentCDBSource(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentCDBSource(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
virtual QString getFileNamesDescription() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettings> m_settings;
|
||||
QLabel* m_text;
|
||||
std::vector<std::string> m_fileNames;
|
||||
};
|
||||
|
||||
@@ -3,15 +3,19 @@
|
||||
#include <QFormLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "utility/messaging/type/MessageIDECreateCDB.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
QtProjectWizzardContentData::QtProjectWizzardContentData(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, bool disableNameEditing
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window,
|
||||
bool disableNameEditing
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
: QtProjectWizzardContent(window)
|
||||
, m_projectSettings(projectSettings)
|
||||
, m_sourceGroupSettings(sourceGroupSettings)
|
||||
, m_disableNameEditing(disableNameEditing)
|
||||
, m_projectName(nullptr)
|
||||
, m_projectFileLocation(nullptr)
|
||||
@@ -49,13 +53,13 @@ void QtProjectWizzardContentData::load()
|
||||
{
|
||||
if (m_projectName)
|
||||
{
|
||||
m_projectName->setText(QString::fromStdString(m_settings->getProjectName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_settings->getProjectFileLocation().str()));
|
||||
m_projectName->setText(QString::fromStdString(m_projectSettings->getProjectName()));
|
||||
m_projectFileLocation->setText(QString::fromStdString(m_projectSettings->getProjectFileLocation().str()));
|
||||
}
|
||||
|
||||
if (m_language)
|
||||
{
|
||||
LanguageType type = m_settings->getLanguage();
|
||||
LanguageType type = getLanguageTypeForSourceGroupType(m_sourceGroupSettings->getType());
|
||||
|
||||
if (type == LANGUAGE_UNKNOWN)
|
||||
{
|
||||
@@ -66,13 +70,13 @@ void QtProjectWizzardContentData::load()
|
||||
m_language->setText(languageTypeToString(type).c_str());
|
||||
|
||||
m_standard->clear();
|
||||
std::vector<std::string> standards = m_settings->getLanguageStandards();
|
||||
std::vector<std::string> standards = m_sourceGroupSettings->getAvailableLanguageStandards();
|
||||
for (size_t i = 0; i < standards.size(); i++)
|
||||
{
|
||||
m_standard->insertItem(i, standards[i].c_str());
|
||||
}
|
||||
|
||||
m_standard->setCurrentText(QString::fromStdString(m_settings->getStandard()));
|
||||
m_standard->setCurrentText(QString::fromStdString(m_sourceGroupSettings->getStandard()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,13 +84,13 @@ void QtProjectWizzardContentData::save()
|
||||
{
|
||||
if (m_projectName)
|
||||
{
|
||||
m_settings->setProjectName(m_projectName->text().toStdString());
|
||||
m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
|
||||
m_projectSettings->setProjectName(m_projectName->text().toStdString());
|
||||
m_projectSettings->setProjectFileLocation(m_projectFileLocation->getText().toStdString());
|
||||
}
|
||||
|
||||
if (m_standard)
|
||||
{
|
||||
m_settings->setStandard(m_standard->currentText().toStdString());
|
||||
m_sourceGroupSettings->setStandard(m_standard->currentText().toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,8 +192,12 @@ void QtProjectWizzardContentData::addBuildFilePicker(
|
||||
|
||||
|
||||
QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, bool disableNameEditing)
|
||||
: QtProjectWizzardContentData(settings, window, disableNameEditing)
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window,
|
||||
bool disableNameEditing
|
||||
)
|
||||
: QtProjectWizzardContentData(projectSettings, sourceGroupSettings, window, disableNameEditing)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -219,7 +227,7 @@ void QtProjectWizzardContentDataCDB::populate(QGridLayout* layout, int& row)
|
||||
void QtProjectWizzardContentDataCDB::load()
|
||||
{
|
||||
QtProjectWizzardContentData::load();
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_buildFilePicker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
|
||||
@@ -231,13 +239,13 @@ void QtProjectWizzardContentDataCDB::save()
|
||||
QtProjectWizzardContentData::save();
|
||||
|
||||
FilePath path = m_buildFilePicker->getText().toStdString();
|
||||
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
|
||||
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path)); // maybe we can use SourceGroupSettings for this... that's where the the cdb path is stored.
|
||||
if (!absPath.exists() || absPath.extension() != ".json")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setCompilationDatabasePath(path);
|
||||
@@ -252,7 +260,7 @@ bool QtProjectWizzardContentDataCDB::check()
|
||||
}
|
||||
|
||||
FilePath path = m_buildFilePicker->getText().toStdString();
|
||||
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
|
||||
FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path));
|
||||
if (!absPath.exists() || absPath.extension() != ".json")
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
@@ -266,7 +274,7 @@ bool QtProjectWizzardContentDataCDB::check()
|
||||
|
||||
void QtProjectWizzardContentDataCDB::pickedCDBPath()
|
||||
{
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
FilePath projectPath = m_projectSettings->getProjectFileLocation();
|
||||
if (m_projectFileLocation)
|
||||
{
|
||||
projectPath = FilePath(m_projectFileLocation->getText().toStdString());
|
||||
@@ -285,8 +293,12 @@ void QtProjectWizzardContentDataCDB::pickedCDBPath()
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContentDataCDBVS::QtProjectWizzardContentDataCDBVS(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContentDataCDB(settings, window, false)
|
||||
QtProjectWizzardContentDataCDBVS::QtProjectWizzardContentDataCDBVS(
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentDataCDB(projectSettings, sourceGroupSettings, window, false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ class QtProjectWizzardContentData
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentData(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, bool disableNameEditing = false);
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window,
|
||||
bool disableNameEditing = false);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
@@ -28,6 +31,9 @@ protected:
|
||||
virtual void addLanguageAndStandard(QGridLayout* layout, int& row);
|
||||
virtual void addBuildFilePicker(QGridLayout* layout, int& row, const QString& name, const QString& filter);
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_projectSettings;
|
||||
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
|
||||
|
||||
bool m_disableNameEditing;
|
||||
QLineEdit* m_projectName;
|
||||
QtLocationPicker* m_projectFileLocation;
|
||||
@@ -46,7 +52,10 @@ class QtProjectWizzardContentDataCDB
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentDataCDB(
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, bool disableNameEditing = false);
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window,
|
||||
bool disableNameEditing = false);
|
||||
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
@@ -65,7 +74,10 @@ class QtProjectWizzardContentDataCDBVS
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentDataCDBVS(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentDataCDBVS(
|
||||
std::shared_ptr<ProjectSettings> projectSettings,
|
||||
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
|
||||
QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user