diff --git a/bin/app/data/ProjectSettings_template.xml b/bin/app/data/ProjectSettings_template.xml index a45d4e79..fcefec73 100644 --- a/bin/app/data/ProjectSettings_template.xml +++ b/bin/app/data/ProjectSettings_template.xml @@ -9,46 +9,46 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/app/user/projects/javaparser/javaparser.coatiproject b/bin/app/user/projects/javaparser/javaparser.coatiproject index 1fd4cb3a..d32070df 100644 --- a/bin/app/user/projects/javaparser/javaparser.coatiproject +++ b/bin/app/user/projects/javaparser/javaparser.coatiproject @@ -1,34 +1,32 @@ - - - WHAT IS THIS?\n - \tJavaParser is an open-source Java project for parsing Java code and\n - \tgenerating an Abstract Syntax Tree (AST). Additionally it supports a\n - \tvisitor pattern to traverse the generated AST. For more information on\n - \tthis project please visit javaparser.org\n - \n - LET'S GET STARTED!\n - \tHave you ever wondered what a parser for a real programming language\n - \tmay look like? Go ahead and find out!\n - \n - \tIf you ask yourself where to start, click the symbol linked below.\n - \n - [com\ts\tp\tngithub\ts\tp\tnjavaparser\ts\tp\tnast\ts\tp\tnbody\ts\tp\tnClassOrInterfaceDeclaration\ts\tp] // <- start here!\n\n - - - - Java - 8 - - - - .java - - - ./src/main/java - ./target/generated-sources/javacc - - - 1 + + WHAT IS THIS?\n + \tJavaParser is an open-source Java project for parsing Java code and\n + \tgenerating an Abstract Syntax Tree (AST). Additionally it supports a\n + \tvisitor pattern to traverse the generated AST. For more information on\n + \tthis project please visit javaparser.org\n + \n + LET'S GET STARTED!\n + \tHave you ever wondered what a parser for a real programming language\n + \tmay look like? Go ahead and find out!\n + \n + \tIf you ask yourself where to start, click the symbol linked below.\n + \n + [com\ts\tp\tngithub\ts\tp\tnjavaparser\ts\tp\tnast\ts\tp\tnbody\ts\tp\tnClassOrInterfaceDeclaration\ts\tp] // <- start here!\n\n + + + + Java Source Group + + .java + + + ./src/main/java + ./target/generated-sources/javacc + + 8 + + + 4 diff --git a/bin/app/user/projects/tictactoe/tictactoe.coatiproject b/bin/app/user/projects/tictactoe/tictactoe.coatiproject index 9b2248a7..b29d67c8 100644 --- a/bin/app/user/projects/tictactoe/tictactoe.coatiproject +++ b/bin/app/user/projects/tictactoe/tictactoe.coatiproject @@ -1,22 +1,20 @@ - - C++ - c++1z - - - - .h - .hpp - .cpp - .cxx - .cc - .c - - - ./src - - 0 - - 1 + + + + .cpp + .cxx + .cc + .c + + + ./src + + c++1z + C++ Source Group + 0 + + + 4 diff --git a/bin/app/user/projects/tutorial/tutorial.coatiproject b/bin/app/user/projects/tutorial/tutorial.coatiproject index c8b77f79..99600fef 100644 --- a/bin/app/user/projects/tutorial/tutorial.coatiproject +++ b/bin/app/user/projects/tutorial/tutorial.coatiproject @@ -1,34 +1,31 @@ - - - WHAT IS THIS?\n - \tThis is a tutorial and it is one of the fastest ways to get to know Coati.\n - \n - WHERE AM I?\n - \tYou're looking at Coati's Code View which usually displays source code,\n - \tbut every time a new project is loaded it gives a quick summary to\n - \testimate the project's size. This is a fairly small project. It only\n - \tcontains a few hundred lines of code as you can see by the numbers below.\n - \n - LET'S GET STARTED!\n - \tTo keep things simple just click the "main" symbol below to start the tour.\n - \n - [main\tsint\tp()](); // <- start here\n\n - - - - C++ - c++1z - - - - .h - .cpp - - - ./src - - - 1 + + WHAT IS THIS?\n + \tThis is a tutorial and it is one of the fastest ways to get to know Coati.\n + \n + WHERE AM I?\n + \tYou're looking at Coati's Code View which usually displays source code,\n + \tbut every time a new project is loaded it gives a quick summary to\n + \testimate the project's size. This is a fairly small project. It only\n + \tcontains a few hundred lines of code as you can see by the numbers below.\n + \n + LET'S GET STARTED!\n + \tTo keep things simple just click the "main" symbol below to start the tour.\n + \n + [main\tsint\tp()](); // <- start here\n\n + + + + C++ Source Group + + .cpp + + + ./src + + c++1z + + + 4 diff --git a/bin/test/data/SettingsTestSuite/settings.xml b/bin/test/data/SettingsTestSuite/settings.xml index dff68ad6..fe8f7f44 100644 --- a/bin/test/data/SettingsTestSuite/settings.xml +++ b/bin/test/data/SettingsTestSuite/settings.xml @@ -5,15 +5,17 @@ 3.1416 Hello World! - - - data - - - data/ - src/ - - - + + + C++ Source Group + + data + + + data/ + src/ + + + diff --git a/bin/test/data/log/test_log.txt b/bin/test/data/log/test_log.txt index c900aa2f..5432087a 100644 --- a/bin/test/data/log/test_log.txt +++ b/bin/test/data/log/test_log.txt @@ -1,4 +1,3 @@ -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml Token.cpp ERROR: Location Id was not referenced by this Token. Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class Edge.cpp ERROR: Nodes are not plain copies. diff --git a/src/app/main.cpp b/src/app/main.cpp index 9c2c4a6f..a26ea7ad 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -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()); - Application::getInstance()->addProjectFactoryModule(std::make_shared()); - Application::getInstance()->addProjectFactoryModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); IndexerFactory::getInstance()->addModule(std::make_shared()); IndexerFactory::getInstance()->addModule(std::make_shared()); @@ -228,9 +230,9 @@ int main(int argc, char *argv[]) prefillCxxHeaderPaths(); prefillCxxFrameworkPaths(); - Application::getInstance()->addProjectFactoryModule(std::make_shared()); - Application::getInstance()->addProjectFactoryModule(std::make_shared()); - Application::getInstance()->addProjectFactoryModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); IndexerFactory::getInstance()->addModule(std::make_shared()); IndexerFactory::getInstance()->addModule(std::make_shared()); diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index cd75a7d1..55515bcc 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -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 module) -{ - m_projectFactory.addModule(module); -} - const std::shared_ptr 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(std::make_shared(projectSettingsFilePath), m_storageCache.get()); if (m_project) { + m_project->load(); + if (m_hasGUI) { updateTitle(); diff --git a/src/lib/Application.h b/src/lib/Application.h index a75d9ea0..868eacc2 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -4,6 +4,7 @@ #include #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 @@ -39,8 +37,6 @@ public: static void loadSettings(); static void loadStyle(const FilePath& colorSchemePath); - void addProjectFactoryModule(std::shared_ptr module); - ~Application(); const std::shared_ptr getCurrentProject(); @@ -76,7 +72,6 @@ private: void updateTitle(); const bool m_hasGUI; - ProjectFactory m_projectFactory; std::shared_ptr m_project; std::shared_ptr m_storageCache; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index af22d9b6..a7c3941e 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -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 ) diff --git a/src/lib/Project.h b/src/lib/Project.h deleted file mode 100644 index ce567e3c..00000000 --- a/src/lib/Project.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef PROJECT_H -#define PROJECT_H - -#include -#include -#include - -#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 getSourceFilePaths() const; - - bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const; - void setStateSettingsUpdated(); - -protected: - Project(StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView); - std::shared_ptr getDialogView() const; - std::vector getSourcePaths() const; - - virtual std::shared_ptr getProjectSettings() = 0; - virtual const std::shared_ptr 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& filesToClean, const std::set& filesToIndex, bool fullRefresh); - - virtual bool prepareIndexing(); - virtual bool prepareRefresh(); - virtual std::vector> getIndexerCommands() = 0; - std::vector> getIndexerCommands(const std::set& sourceFiles); - virtual void updateFileManager(FileManager& fileManager) = 0; - - StorageAccessProxy* const m_storageAccessProxy; - std::shared_ptr m_dialogView; - - ProjectStateType m_state; - FileManager m_fileManager; - - std::shared_ptr m_storage; -}; - -#endif // PROJECT_H diff --git a/src/lib/ProjectFactory.cpp b/src/lib/ProjectFactory.cpp deleted file mode 100644 index dde690a3..00000000 --- a/src/lib/ProjectFactory.cpp +++ /dev/null @@ -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 module) -{ - m_modules[module->getLanguage()] = module; -} - -std::shared_ptr ProjectFactory::createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView) -{ - std::shared_ptr project; - - std::map>::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; -} diff --git a/src/lib/ProjectFactory.h b/src/lib/ProjectFactory.h deleted file mode 100644 index 74a8f764..00000000 --- a/src/lib/ProjectFactory.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PROJECT_FACTORY_H -#define PROJECT_FACTORY_H - -#include -#include - -#include "settings/LanguageType.h" - -class Project; -class FilePath; -class StorageAccessProxy; -class DialogView; -class ProjectFactoryModule; - -class ProjectFactory -{ -public: - void addModule(std::shared_ptr module); - - std::shared_ptr createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView); - -private: - std::map> m_modules; -}; - -#endif // PROJECT_FACTORY_H diff --git a/src/lib/ProjectFactoryModule.cpp b/src/lib/ProjectFactoryModule.cpp deleted file mode 100644 index 6a4d909c..00000000 --- a/src/lib/ProjectFactoryModule.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "ProjectFactoryModule.h" - -ProjectFactoryModule::~ProjectFactoryModule() -{ -} diff --git a/src/lib/ProjectFactoryModule.h b/src/lib/ProjectFactoryModule.h deleted file mode 100644 index 1beedf6b..00000000 --- a/src/lib/ProjectFactoryModule.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PROJECT_FACTORY_MODULE_H -#define PROJECT_FACTORY_MODULE_H - -#include - -#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 createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView - ) = 0; -}; - -#endif // PROJECT_FACTORY_MODULE_H diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index 2d4a2bc4..eed7d424 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -1476,7 +1476,7 @@ std::set PersistentStorage::getReferencedByIncludes(const std::set paths; for (Id id: ids) - { + { // TODO: performance optimize: use just one request for all ids! paths.insert(getFileNodePath(id)); } diff --git a/src/lib/data/TaskCleanStorage.cpp b/src/lib/data/TaskCleanStorage.cpp index 60535bc0..1ea9df2c 100644 --- a/src/lib/data/TaskCleanStorage.cpp +++ b/src/lib/data/TaskCleanStorage.cpp @@ -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& filePaths, std::shared_ptr dialogView + PersistentStorage* storage, const std::vector& filePaths ) : m_storage(storage) , m_filePaths(filePaths) - , m_dialogView(dialogView) { } void TaskCleanStorage::doEnter(std::shared_ptr blackboard) { - m_dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files"); + if (std::shared_ptr 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) Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr blackboard) { - std::shared_ptr dialogView = m_dialogView; m_storage->clearFileElements(m_filePaths, [=](int progress) { - if (dialogView != nullptr) + if (std::shared_ptr 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 blackboar void TaskCleanStorage::doExit(std::shared_ptr blackboard) { blackboard->set("clear_time", utility::duration(m_start)); - - m_dialogView->hideProgressDialog(); + if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) + { + dialogView->hideProgressDialog(); + } } void TaskCleanStorage::doReset(std::shared_ptr blackboard) diff --git a/src/lib/data/TaskCleanStorage.h b/src/lib/data/TaskCleanStorage.h index f987303c..afb4d38d 100644 --- a/src/lib/data/TaskCleanStorage.h +++ b/src/lib/data/TaskCleanStorage.h @@ -16,8 +16,7 @@ class TaskCleanStorage public: TaskCleanStorage( PersistentStorage* storage, - const std::vector& filePaths, - std::shared_ptr dialogView + const std::vector& filePaths ); private: @@ -28,7 +27,6 @@ private: PersistentStorage* m_storage; std::vector m_filePaths; - std::shared_ptr m_dialogView; TimePoint m_start; }; diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 009bb138..51d0495c 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -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 + StorageAccess* storageAccess ) : m_storage(storage) , m_storageAccess(storageAccess) - , m_dialogView(dialogView) { } @@ -31,21 +30,23 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa { TimePoint start = utility::durationStart(); - if (m_dialogView) + std::shared_ptr 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 blackboa int sourceFileCount = 0; blackboard->get("source_file_count", sourceFileCount); - if (m_dialogView) + if (dialogView) { - m_dialogView->finishedIndexingDialog( + dialogView->finishedIndexingDialog( indexedSourceFileCount, sourceFileCount, time, diff --git a/src/lib/data/TaskFinishParsing.h b/src/lib/data/TaskFinishParsing.h index 861ca6ed..97ef33fa 100644 --- a/src/lib/data/TaskFinishParsing.h +++ b/src/lib/data/TaskFinishParsing.h @@ -17,8 +17,7 @@ class TaskFinishParsing public: TaskFinishParsing( PersistentStorage* storage, - StorageAccess* storageAccess, - std::shared_ptr dialogView + StorageAccess* storageAccess ); virtual ~TaskFinishParsing(); @@ -31,7 +30,6 @@ private: PersistentStorage* m_storage; StorageAccess* m_storageAccess; - std::shared_ptr m_dialogView; }; #endif // TASK_FINISH_PARSING_H diff --git a/src/lib/data/TaskShowStatusDialog.cpp b/src/lib/data/TaskShowStatusDialog.cpp index d29baf9d..b84722dc 100644 --- a/src/lib/data/TaskShowStatusDialog.cpp +++ b/src/lib/data/TaskShowStatusDialog.cpp @@ -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 + const std::string& message ) : m_title(title) , m_message(message) - , m_dialogView(dialogView) { } @@ -23,9 +22,9 @@ void TaskShowStatusDialog::doEnter(std::shared_ptr blackboard) Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr blackboard) { - if (m_dialogView) - { - m_dialogView->showStatusDialog(m_title, m_message); + if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) + { + dialogView->showStatusDialog(m_title, m_message); } return STATE_SUCCESS; } diff --git a/src/lib/data/TaskShowStatusDialog.h b/src/lib/data/TaskShowStatusDialog.h index 352a6ad4..f779c9f1 100644 --- a/src/lib/data/TaskShowStatusDialog.h +++ b/src/lib/data/TaskShowStatusDialog.h @@ -13,8 +13,7 @@ class TaskShowStatusDialog public: TaskShowStatusDialog( const std::string& title, - const std::string& message, - std::shared_ptr 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 m_dialogView; }; #endif // TASK_SHOW_STATUS_DIALOG_H diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index 7db0b82c..c5480ee3 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -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, std::shared_ptr storageProvider, - std::shared_ptr fileRegisterStateData, - std::shared_ptr dialogView + std::shared_ptr 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) int indexedSourceFileCount = 0; blackboard->get("indexed_source_file_count", indexedSourceFileCount); - if (m_dialogView) + if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) { - m_dialogView->updateIndexingDialog( + dialogView->updateIndexingDialog( indexedSourceFileCount, sourceFileCount, indexerCommand->getSourceFilePath().str() ); } diff --git a/src/lib/data/indexer/TaskBuildIndex.h b/src/lib/data/indexer/TaskBuildIndex.h index 1831604f..7f2a4c5b 100644 --- a/src/lib/data/indexer/TaskBuildIndex.h +++ b/src/lib/data/indexer/TaskBuildIndex.h @@ -21,8 +21,7 @@ public: TaskBuildIndex( std::shared_ptr indexerCommandList, std::shared_ptr storageProvider, - std::shared_ptr fileRegisterStateData, - std::shared_ptr dialogView + std::shared_ptr fileRegisterStateData ); protected: @@ -36,7 +35,6 @@ protected: std::shared_ptr m_indexerCommandList; std::shared_ptr m_storageProvider; std::shared_ptr m_fileRegisterStateData; - std::shared_ptr m_dialogView; std::shared_ptr m_indexer; }; diff --git a/src/lib/data/parser/TaskParseWrapper.cpp b/src/lib/data/parser/TaskParseWrapper.cpp index 4dc96fd7..407367f0 100644 --- a/src/lib/data/parser/TaskParseWrapper.cpp +++ b/src/lib/data/parser/TaskParseWrapper.cpp @@ -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 -) +TaskParseWrapper::TaskParseWrapper(PersistentStorage* storage) : m_storage(storage) - , m_dialogView(dialogView) { } @@ -30,9 +27,9 @@ void TaskParseWrapper::doEnter(std::shared_ptr blackboard) { int sourceFileCount = 0; blackboard->get("source_file_count", sourceFileCount); - if (m_dialogView) - { - m_dialogView->updateIndexingDialog(0, sourceFileCount, ""); + if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) + { + dialogView->updateIndexingDialog(0, sourceFileCount, ""); } m_start = utility::durationStart(); diff --git a/src/lib/data/parser/TaskParseWrapper.h b/src/lib/data/parser/TaskParseWrapper.h index 39cf2b89..70691c6c 100644 --- a/src/lib/data/parser/TaskParseWrapper.h +++ b/src/lib/data/parser/TaskParseWrapper.h @@ -18,10 +18,7 @@ class TaskParseWrapper : public TaskDecorator { public: - TaskParseWrapper( - PersistentStorage* storage, - std::shared_ptr dialogView - ); + TaskParseWrapper(PersistentStorage* storage); virtual ~TaskParseWrapper(); virtual void setTask(std::shared_ptr task); @@ -33,7 +30,6 @@ private: virtual void doReset(std::shared_ptr blackboard); PersistentStorage* m_storage; - std::shared_ptr m_dialogView; TimePoint m_start; std::shared_ptr m_taskRunner; diff --git a/src/lib/Project.cpp b/src/lib/project/Project.cpp similarity index 73% rename from src/lib/Project.cpp rename to src/lib/project/Project.cpp index e760c5ff..55635fc6 100644 --- a/src/lib/Project.cpp +++ b/src/lib/project/Project.cpp @@ -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 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 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 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()).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: 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 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) - : m_storageAccessProxy(storageAccessProxy) - , m_dialogView(dialogView) - , m_state(PROJECT_STATE_NOT_LOADED) -{ -} - -std::shared_ptr Project::getDialogView() const -{ - return m_dialogView; -} - -std::vector Project::getSourcePaths() const -{ - return m_fileManager.getSourcePaths(); -} - void Project::load() { m_storageAccessProxy->setSubject(nullptr); - std::shared_ptr 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(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 allSourceFilePaths; + for (std::shared_ptr 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 filesToClean; - std::set 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 referencingFilePaths = m_storage->getReferencing(utility::concat( - fileSets.updatedFiles, fileSets.removedFiles - )); - - for (const FilePath& path : referencingFilePaths) + std::set unchangedFilePaths; + std::set 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 staticSourceFiles = fileSets.allSourceFilePaths; - for (const FilePath& path : fileSets.updatedFiles) + std::set staticSourceFiles = allSourceFilePaths; + for (const FilePath& path: changedFilePaths) { staticSourceFiles.erase(path); } const std::set staticReferencedFilePaths = m_storage->getReferenced(staticSourceFiles); - const std::set dynamicReferencedFilePaths = m_storage->getReferenced(utility::concat( - fileSets.updatedFiles, fileSets.removedFiles - )); + const std::set dynamicReferencedFilePaths = m_storage->getReferenced(changedFilePaths); for (const FilePath& path : dynamicReferencedFilePaths) { @@ -315,12 +315,29 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh) } } + std::set staticSourceFilePaths; + for (const FilePath& path: allSourceFilePaths) + { + if (filesToClean.find(path) == filesToClean.end()) + { + staticSourceFilePaths.insert(path); + } + } + + std::set filesToIndex; + + for (std::shared_ptr 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& filesToClean, const std::set& filesToIndex, bool fullRefresh) +void Project::buildIndex(const std::set& filesToClean, bool fullRefresh) { MessageClearErrorCount().dispatch(); @@ -374,20 +391,23 @@ void Project::buildIndex(const std::set& filesToClean, const std::set< { taskSequential->addTask(std::make_shared( m_storage.get(), - utility::toVector(filesToClean), - m_dialogView) + utility::toVector(filesToClean)) ); } - if (!filesToIndex.empty()) + std::shared_ptr indexerCommandList = std::make_shared(); + for (std::shared_ptr sourceGroup: m_sourceGroups) + { + for (std::shared_ptr command: sourceGroup->getIndexerCommands(fullRefresh)) + { + indexerCommandList->addCommand(command); + } + } + + if (indexerCommandList->size() > 0) { const size_t indexerThreadCount = ApplicationSettings::getInstance()->getIndexerThreadCount(); - std::shared_ptr indexerCommandList = std::make_shared(); - for (std::shared_ptr indexerCommand: getIndexerCommands(filesToIndex)) - { - indexerCommandList->addCommand(indexerCommand); - } if (indexerThreadCount > 1) { indexerCommandList->shuffle(); @@ -402,21 +422,18 @@ void Project::buildIndex(const std::set& filesToClean, const std::set< taskSequential->addTask(std::make_shared>("indexed_source_file_count", 0)); taskSequential->addTask(std::make_shared>("indexer_count", 0)); - std::shared_ptr taskParserWrapper = std::make_shared( - m_storage.get(), - m_dialogView - ); + std::shared_ptr taskParserWrapper = std::make_shared(m_storage.get()); taskSequential->addTask(taskParserWrapper); std::shared_ptr taskParallelIndexing = std::make_shared(); 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::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask( - std::make_shared(indexerCommandList, storageProvider, fileRegisterStateData, getDialogView()) + std::make_shared(indexerCommandList, storageProvider, fileRegisterStateData) ) ); } @@ -458,7 +475,7 @@ void Project::buildIndex(const std::set& 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("Finish Indexing", "Saving\nRemaining Data", m_dialogView) + std::make_shared("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& filesToClean, const std::set< ); } - taskSequential->addTask(std::make_shared(m_storage.get(), m_storageAccessProxy, m_dialogView)); + taskSequential->addTask(std::make_shared(m_storage.get(), m_storageAccessProxy)); Task::dispatch(taskSequential); } - -bool Project::prepareIndexing() -{ - return true; -} - -bool Project::prepareRefresh() -{ - return true; -} - -std::vector> Project::getIndexerCommands(const std::set& sourceFiles) -{ - struct special_compare : public std::unary_function - { - 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> indexerCommands; - for (std::shared_ptr indexerCommand: getIndexerCommands()) - { - if (std::find_if(sourceFiles.begin(), sourceFiles.end(), special_compare(indexerCommand->getSourceFilePath())) != sourceFiles.end()) - { - indexerCommands.push_back(indexerCommand); - } - } - - return indexerCommands; -} - diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h new file mode 100644 index 00000000..fe7ff5e9 --- /dev/null +++ b/src/lib/project/Project.h @@ -0,0 +1,60 @@ +#ifndef PROJECT_H +#define PROJECT_H + +#include +#include +#include +#include + +#include "project/SourceGroup.h" + +class FilePath; +class PersistentStorage; +class ProjectSettings; +class StorageAccessProxy; + +class Project +{ +public: + Project(std::shared_ptr 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& filesToClean, bool fullRefresh); + + std::shared_ptr m_settings; + StorageAccessProxy* const m_storageAccessProxy; + + ProjectStateType m_state; + std::shared_ptr m_storage; + std::vector> m_sourceGroups; +}; + +#endif // PROJECT_H diff --git a/src/lib/project/SourceGroup.cpp b/src/lib/project/SourceGroup.cpp new file mode 100644 index 00000000..aa290ec2 --- /dev/null +++ b/src/lib/project/SourceGroup.cpp @@ -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& staticSourceFilePaths) +{ + for (const FilePath& sourceFilePath: m_allSourceFilePaths) + { + if (staticSourceFilePaths.find(sourceFilePath) == staticSourceFilePaths.end()) + { + m_sourceFilePathsToIndex.insert(sourceFilePath); + } + } +} + +std::set SourceGroup::getAllSourceFilePaths() const +{ + return m_allSourceFilePaths; +} + +std::set SourceGroup::getSourceFilePathsToIndex() const +{ + return m_sourceFilePathsToIndex; +} diff --git a/src/lib/project/SourceGroup.h b/src/lib/project/SourceGroup.h new file mode 100644 index 00000000..9fe4abde --- /dev/null +++ b/src/lib/project/SourceGroup.h @@ -0,0 +1,38 @@ +#ifndef SOURCE_GROUP_H +#define SOURCE_GROUP_H + +#include +#include +#include + +#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& staticSourceFilePaths); + + std::set getAllSourceFilePaths() const; + std::set getSourceFilePathsToIndex() const; + + virtual std::vector> getIndexerCommands(const bool fullRefresh) = 0; + +protected: + std::set m_allSourceFilePaths; + std::set m_sourceFilePathsToIndex; +}; + +#endif // SOURCE_GROUP_H diff --git a/src/lib/project/SourceGroupFactory.cpp b/src/lib/project/SourceGroupFactory.cpp new file mode 100644 index 00000000..3187d02a --- /dev/null +++ b/src/lib/project/SourceGroupFactory.cpp @@ -0,0 +1,55 @@ +#include "project/SourceGroupFactory.h" + +#include "project/SourceGroup.h" +#include "project/SourceGroupFactoryModule.h" +#include "settings/SourceGroupSettings.h" + +std::shared_ptr SourceGroupFactory::getInstance() +{ + if (!s_instance) + { + s_instance = std::shared_ptr(new SourceGroupFactory()); + } + return s_instance; +} + +void SourceGroupFactory::addModule(std::shared_ptr module) +{ + m_modules.push_back(module); +} + +std::vector> SourceGroupFactory::createSourceGroups(std::vector> allSourceGroupSettings) +{ + std::vector> sourceGroups; + for (std::shared_ptr sourceGroupSettings: allSourceGroupSettings) + { + std::shared_ptr sourceGroup = createSourceGroup(sourceGroupSettings); + if (sourceGroup) + { + sourceGroups.push_back(sourceGroup); + } + } + return sourceGroups; +} + +std::shared_ptr SourceGroupFactory::createSourceGroup(std::shared_ptr settings) +{ + std::shared_ptr sourceGroup; + + for (std::shared_ptr module: m_modules) + { + if (module->supports(settings->getType())) + { + sourceGroup = module->createSourceGroup(settings); + break; + } + } + + return sourceGroup; +} + +std::shared_ptr SourceGroupFactory::s_instance; + +SourceGroupFactory::SourceGroupFactory() +{ +} diff --git a/src/lib/project/SourceGroupFactory.h b/src/lib/project/SourceGroupFactory.h new file mode 100644 index 00000000..463f8755 --- /dev/null +++ b/src/lib/project/SourceGroupFactory.h @@ -0,0 +1,30 @@ +#ifndef SOURCE_GROUP_FACTORY_H +#define SOURCE_GROUP_FACTORY_H + +#include +#include + +#include "settings/SourceGroupType.h" + +class SourceGroup; +class SourceGroupSettings; +class SourceGroupFactoryModule; + +class SourceGroupFactory +{ +public: + static std::shared_ptr getInstance(); + + void addModule(std::shared_ptr module); + + std::vector> createSourceGroups(std::vector> allSourceGroupSettings); + std::shared_ptr createSourceGroup(std::shared_ptr settings); + +private: + static std::shared_ptr s_instance; + SourceGroupFactory(); + + std::vector> m_modules; +}; + +#endif // SOURCE_GROUP_FACTORY_H diff --git a/src/lib/project/SourceGroupFactoryModule.cpp b/src/lib/project/SourceGroupFactoryModule.cpp new file mode 100644 index 00000000..889e4be4 --- /dev/null +++ b/src/lib/project/SourceGroupFactoryModule.cpp @@ -0,0 +1,5 @@ +#include "project/SourceGroupFactoryModule.h" + +SourceGroupFactoryModule::~SourceGroupFactoryModule() +{ +} diff --git a/src/lib/project/SourceGroupFactoryModule.h b/src/lib/project/SourceGroupFactoryModule.h new file mode 100644 index 00000000..5a3a71aa --- /dev/null +++ b/src/lib/project/SourceGroupFactoryModule.h @@ -0,0 +1,19 @@ +#ifndef SOURCE_GROUP_FACTORY_MODULE_H +#define SOURCE_GROUP_FACTORY_MODULE_H + +#include + +#include "settings/SourceGroupType.h" + +class SourceGroup; +class SourceGroupSettings; + +class SourceGroupFactoryModule +{ +public: + virtual ~SourceGroupFactoryModule(); + virtual bool supports(SourceGroupType type) const = 0; + virtual std::shared_ptr createSourceGroup(std::shared_ptr settings) = 0; +}; + +#endif // SOURCE_GROUP_FACTORY_MODULE_H diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 400d9d4a..7f3ab016 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -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( "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( "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( "application/indexer_thread_count", - "indexing/indexer_thread_count"); + "indexing/indexer_thread_count" + )); bool migrated = migrator.migrate(this, ApplicationSettings::VERSION); diff --git a/src/lib/settings/CxxProjectSettings.cpp b/src/lib/settings/CxxProjectSettings.cpp deleted file mode 100644 index 89b40ba9..00000000 --- a/src/lib/settings/CxxProjectSettings.cpp +++ /dev/null @@ -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(&other); - return( - ProjectSettings::equalsExceptNameAndLocation(other)// && - // utility::isPermutation(getClasspaths(), typedOther->getClasspaths()) - ); - } - return false; -} - -std::vector CxxProjectSettings::getLanguageStandards() const -{ - std::vector 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 CxxProjectSettings::getHeaderSearchPaths() const -{ - return getPathValues("source/header_search_paths/header_search_path"); -} - -std::vector CxxProjectSettings::getAbsoluteHeaderSearchPaths() const -{ - return makePathsAbsolute(expandPaths(getHeaderSearchPaths())); -} - -bool CxxProjectSettings::setHeaderSearchPaths(const std::vector& headerSearchPaths) -{ - return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths); -} - -std::vector CxxProjectSettings::getFrameworkSearchPaths() const -{ - return getPathValues("source/framework_search_paths/framework_search_path"); -} - -std::vector CxxProjectSettings::getAbsoluteFrameworkSearchPaths() const -{ - return makePathsAbsolute(expandPaths(getFrameworkSearchPaths())); -} - -bool CxxProjectSettings::setFrameworkSearchPaths(const std::vector& frameworkSearchPaths) -{ - return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths); -} - -std::vector CxxProjectSettings::getCompilerFlags() const -{ - std::vector defaultValues; - return getValues("source/compiler_flags/compiler_flag", defaultValues); -} - -bool CxxProjectSettings::setCompilerFlags(const std::vector& compilerFlags) -{ - return setValues("source/compiler_flags/compiler_flag", compilerFlags); -} - -bool CxxProjectSettings::getUseSourcePathsForHeaderSearch() const -{ - return getValue("source/use_source_paths_for_header_search", false); -} - -bool CxxProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch) -{ - return setValue("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("source/build_file_path/vs_solution_path", "")); -} - -bool CxxProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath) -{ - return setValue("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str()); -} - -FilePath CxxProjectSettings::getCompilationDatabasePath() const -{ - return FilePath(getValue("source/build_file_path/compilation_db_path", "")); -} - -FilePath CxxProjectSettings::getAbsoluteCompilationDatabasePath() const -{ - return makePathAbsolute(expandPath(getCompilationDatabasePath())); -} - -bool CxxProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath) -{ - return setValue("source/build_file_path/compilation_db_path", compilationDatabasePath.str()); -} - -std::vector CxxProjectSettings::getDefaultSourceExtensions() const -{ - std::vector 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 ""; -} diff --git a/src/lib/settings/CxxProjectSettings.h b/src/lib/settings/CxxProjectSettings.h deleted file mode 100644 index 4cc99eec..00000000 --- a/src/lib/settings/CxxProjectSettings.h +++ /dev/null @@ -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 getLanguageStandards() const; - - std::vector getHeaderSearchPaths() const; - std::vector getAbsoluteHeaderSearchPaths() const; - bool setHeaderSearchPaths(const std::vector& headerSearchPaths); - - std::vector getFrameworkSearchPaths() const; - std::vector getAbsoluteFrameworkSearchPaths() const; - bool setFrameworkSearchPaths(const std::vector& frameworkSearchPaths); - - std::vector getCompilerFlags() const; - bool setCompilerFlags(const std::vector& 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 getDefaultSourceExtensions() const; - virtual std::string getDefaultStandard() const; -}; - -#endif // CXX_PROJECT_SETTINGS_H diff --git a/src/lib/settings/JavaProjectSettings.cpp b/src/lib/settings/JavaProjectSettings.cpp deleted file mode 100644 index cec35b81..00000000 --- a/src/lib/settings/JavaProjectSettings.cpp +++ /dev/null @@ -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(&other); - return( - ProjectSettings::equalsExceptNameAndLocation(other) && - utility::isPermutation(getClasspaths(), typedOther->getClasspaths()) - ); - } - return false; -} - -std::vector JavaProjectSettings::getLanguageStandards() const -{ - return std::vector(1, "8"); -} - -std::vector JavaProjectSettings::getClasspaths() const -{ - return getPathValues("source/class_paths/class_path"); -} - -std::vector JavaProjectSettings::getAbsoluteClasspaths() const -{ - return makePathsAbsolute(expandPaths(getClasspaths())); -} - -bool JavaProjectSettings::setClasspaths(const std::vector& classpaths) -{ - return setPathValues("source/class_paths/class_path", classpaths); -} - -FilePath JavaProjectSettings::getMavenProjectFilePath() const -{ - return FilePath(getValue("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("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("source/maven/should_index_tests", false); -} -void JavaProjectSettings::setShouldIndexMavenTests(bool value) -{ - setValue("source/maven/should_index_tests", value); -} - -std::vector JavaProjectSettings::getDefaultSourceExtensions() const -{ - std::vector defaultValues; - defaultValues.push_back(".java"); - return defaultValues; -} - -std::string JavaProjectSettings::getDefaultStandard() const -{ - return "8"; -} diff --git a/src/lib/settings/JavaProjectSettings.h b/src/lib/settings/JavaProjectSettings.h deleted file mode 100644 index 3636f654..00000000 --- a/src/lib/settings/JavaProjectSettings.h +++ /dev/null @@ -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 getLanguageStandards() const; - - std::vector getClasspaths() const; - std::vector getAbsoluteClasspaths() const; - bool setClasspaths(const std::vector& 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 getDefaultSourceExtensions() const; - virtual std::string getDefaultStandard() const; -}; - -#endif // JAVA_PROJECT_SETTINGS_H diff --git a/src/lib/settings/LanguageType.cpp b/src/lib/settings/LanguageType.cpp index 01bb7365..da32ae67 100644 --- a/src/lib/settings/LanguageType.cpp +++ b/src/lib/settings/LanguageType.cpp @@ -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; diff --git a/src/lib/settings/LanguageType.h b/src/lib/settings/LanguageType.h index c3cdd574..0ecd7f71 100644 --- a/src/lib/settings/LanguageType.h +++ b/src/lib/settings/LanguageType.h @@ -3,7 +3,7 @@ #include -#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 diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 83669f80..fcf0ecad 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -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: 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(getSourcePaths(), other.getSourcePaths()) && - utility::isPermutation(getExcludePaths(), other.getExcludePaths()) && - utility::isPermutation(getSourceExtensions(), other.getSourceExtensions()) - ); -} + const std::vector> allMySettings = getAllSourceGroupSettings(); + const std::vector> allOtherSettings = other.getAllSourceGroupSettings(); -std::vector ProjectSettings::getLanguageStandards() const -{ - return std::vector(); + if (allMySettings.size() != allOtherSettings.size()) + { + return false; + } + + for (std::shared_ptr mySourceGroup: allMySettings) + { + bool matched = false; + for (std::shared_ptr 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("info/description", ""); + return getValue("description", ""); } -LanguageType ProjectSettings::getLanguage() const +std::vector> ProjectSettings::getAllSourceGroupSettings() const { - return stringToLanguageType(getValue("language_settings/language", languageTypeToString(LANGUAGE_UNKNOWN))); + std::vector> 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(key + "/type", "")); + + std::shared_ptr settings; + + switch (type) + { + case SOURCE_GROUP_C_EMPTY: + case SOURCE_GROUP_CPP_EMPTY: + case SOURCE_GROUP_CXX_CDB: + { + std::shared_ptr cxxSettings = std::make_shared(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(key + "/compiler_flags/compiler_flag", std::vector())); + cxxSettings->setUseSourcePathsForHeaderSearch(getValue(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(key + "/build_file_path/compilation_db_path", ""))); + } + settings = cxxSettings; + } + break; + case SOURCE_GROUP_JAVA_EMPTY: + case SOURCE_GROUP_JAVA_MAVEN: + { + std::shared_ptr javaSettings = std::make_shared(id, type, this); + javaSettings->setClasspaths(getPathValues(key + "/class_paths/class_path")); + if (type == SOURCE_GROUP_JAVA_MAVEN) + { + javaSettings->setMavenProjectFilePath(FilePath(getValue(key + "/maven/project_file_path", ""))); + javaSettings->setMavenDependenciesDirectory(FilePath(getValue(key + "/maven/dependencies_directory", ""))); + javaSettings->setShouldIndexMavenTests(getValue(key + "/maven/should_index_tests", false)); + } + settings = javaSettings; + } + break; + default: + continue; + } + + settings->setStandard(getValue(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())); + + allSettings.push_back(settings); + } + + return allSettings; } -bool ProjectSettings::setLanguage(LanguageType language) +void ProjectSettings::setAllSourceGroupSettings(std::vector> allSettings) { - return setValue("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("language_settings/standard", getDefaultStandard()); -} + for (std::shared_ptr 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("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 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 cxxSettings = std::dynamic_pointer_cast(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 javaSettings = std::dynamic_pointer_cast(settings)) + { + setPathValues(key + "/class_paths/class_path", javaSettings->getClasspaths()); -std::vector ProjectSettings::getAbsoluteSourcePaths() const -{ - return makePathsAbsolute(expandPaths(getSourcePaths())); -} - -bool ProjectSettings::setSourcePaths(const std::vector& sourcePaths) -{ - return setPathValues("source/source_paths/source_path", sourcePaths); -} - -std::vector ProjectSettings::getExcludePaths() const -{ - return getPathValues("source/exclude_paths/exclude_path"); -} - -std::vector ProjectSettings::getAbsoluteExcludePaths() const -{ - return makePathsAbsolute(expandPaths(getExcludePaths())); -} - -bool ProjectSettings::setExcludePaths(const std::vector& excludePaths) -{ - return setPathValues("source/exclude_paths/exclude_path", excludePaths); -} - -std::vector ProjectSettings::getSourceExtensions() const -{ - return getValues("source/extensions/source_extensions", getDefaultSourceExtensions()); -} - -bool ProjectSettings::setSourceExtensions(const std::vector &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 ProjectSettings::makePathsAbsolute(const std::vector& paths) const @@ -189,39 +276,86 @@ FilePath ProjectSettings::makePathAbsolute(const FilePath& path) const return getProjectFileLocation().concat(path).canonical(); } -std::vector ProjectSettings::getDefaultSourceExtensions() const -{ - return std::vector(); -} - -std::string ProjectSettings::getDefaultStandard() const -{ - return ""; -} - SettingsMigrator ProjectSettings::getMigrations() const { SettingsMigrator migrator; + migrator.addMigration(1, std::make_shared( + [](const Migration* migration, Settings* settings) + { + const std::string language = migration->getValueFromSettings(settings, "language_settings/language", ""); + const std::string standard = migration->getValueFromSettings(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(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("info/description", "description")); + migrator.addMigration(2, std::make_shared("language_settings/standard", sourceGroupKey + "/standard")); + migrator.addMigration(2, std::make_shared("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path")); + migrator.addMigration(2, std::make_shared("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path")); + migrator.addMigration(2, std::make_shared("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension")); + migrator.addMigration(2, std::make_shared("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path")); + migrator.addMigration(2, std::make_shared("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search")); + migrator.addMigration(2, std::make_shared("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path")); + migrator.addMigration(2, std::make_shared("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag")); + migrator.addMigration(2, std::make_shared("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path")); + migrator.addMigration(2, std::make_shared("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path")); + migrator.addMigration(2, std::make_shared("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path")); + migrator.addMigration(2, std::make_shared("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory")); + migrator.addMigration(2, std::make_shared("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests")); + + migrator.addMigration(3, std::make_shared( + [=](const Migration* migration, Settings* settings) + { + const std::string language = migration->getValueFromSettings(settings, "language_settings/language", ""); + + SourceGroupType type = SOURCE_GROUP_UNKNOWN; + if (language == "C" || language == "C++") + { + const std::string cdbPath = migration->getValueFromSettings(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(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("language_settings/language")); + migrator.addMigration(4, std::make_shared("source/build_file_path/vs_solution_path")); + migrator.addMigration(4, std::make_shared("source/extensions/header_extensions")); return migrator; } diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h index 1669430d..24b2349a 100644 --- a/src/lib/settings/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -4,27 +4,24 @@ #include #include -#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 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 getSourcePaths() const; - std::vector getAbsoluteSourcePaths() const; - bool setSourcePaths(const std::vector& sourcePaths); - - std::vector getExcludePaths() const; - std::vector getAbsoluteExcludePaths() const; - bool setExcludePaths(const std::vector& excludePaths); - - std::vector getSourceExtensions() const; - bool setSourceExtensions(const std::vector& sourceExtensions); + std::vector> getAllSourceGroupSettings() const; + void setAllSourceGroupSettings(std::vector> allSettings); std::vector makePathsAbsolute(const std::vector& paths) const; FilePath makePathAbsolute(const FilePath& path) const; private: - virtual std::vector getDefaultSourceExtensions() const; - virtual std::string getDefaultStandard() const; - SettingsMigrator getMigrations() const; }; diff --git a/src/lib/settings/ProjectType.cpp b/src/lib/settings/ProjectType.cpp deleted file mode 100644 index 81d9ab39..00000000 --- a/src/lib/settings/ProjectType.cpp +++ /dev/null @@ -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; -} diff --git a/src/lib/settings/ProjectType.h b/src/lib/settings/ProjectType.h deleted file mode 100644 index cb8845c7..00000000 --- a/src/lib/settings/ProjectType.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PROJECT_TYPE_H -#define PROJECT_TYPE_H - -#include - -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 diff --git a/src/lib/settings/Settings.h b/src/lib/settings/Settings.h index fa82c49f..33f192c2 100644 --- a/src/lib/settings/Settings.h +++ b/src/lib/settings/Settings.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 diff --git a/src/lib/settings/SettingsMigrator.cpp b/src/lib/settings/SettingsMigrator.cpp deleted file mode 100644 index 8c7d1091..00000000 --- a/src/lib/settings/SettingsMigrator.cpp +++ /dev/null @@ -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 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::const_iterator, std::multimap::const_iterator> ret; - ret = m_migrations.equal_range(originVersion); - - for (std::multimap::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::const_iterator, std::multimap::const_iterator> ret; - ret = m_migrations.equal_range(originVersion); - - for (std::multimap::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( - migration.newKey, - settings->getValues(migration.oldKey, std::vector()) - ); - settings->removeValues(migration.oldKey); - } - } - } - - settings->setVersion(targetVersion); - - return true; - } - - return false; -} diff --git a/src/lib/settings/SourceGroupSettings.cpp b/src/lib/settings/SourceGroupSettings.cpp new file mode 100644 index 00000000..a1dbfe43 --- /dev/null +++ b/src/lib/settings/SourceGroupSettings.cpp @@ -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 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 SourceGroupSettings::getSourcePaths() const +{ + return m_sourcePaths; +} + +std::vector SourceGroupSettings::getAbsoluteSourcePaths() const +{ + return m_projectSettings->makePathsAbsolute(getSourcePaths()); +} + +void SourceGroupSettings::setSourcePaths(const std::vector& sourcePaths) +{ + m_sourcePaths = sourcePaths; +} + +std::vector SourceGroupSettings::getExcludePaths() const +{ + return m_excludePaths; +} + +std::vector SourceGroupSettings::getAbsoluteExcludePaths() const +{ + return m_projectSettings->makePathsAbsolute(getExcludePaths()); +} + +void SourceGroupSettings::setExcludePaths(const std::vector& excludePaths) +{ + m_excludePaths = excludePaths; +} + +std::vector SourceGroupSettings::getSourceExtensions() const +{ + if (m_sourceExtensions.empty()) + { + return getDefaultSourceExtensions(); + } + return m_sourceExtensions; +} + +void SourceGroupSettings::setSourceExtensions(const std::vector& sourceExtensions) +{ + m_sourceExtensions = sourceExtensions; +} diff --git a/src/lib/settings/SourceGroupSettings.h b/src/lib/settings/SourceGroupSettings.h new file mode 100644 index 00000000..e5c9be91 --- /dev/null +++ b/src/lib/settings/SourceGroupSettings.h @@ -0,0 +1,59 @@ +#ifndef SOURCE_GROUP_SETTINGS_H +#define SOURCE_GROUP_SETTINGS_H + +#include +#include + +#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 other) const; + + std::string getId() const; + + FilePath getProjectFileLocation() const; + FilePath makePathAbsolute(const FilePath& path) const; + + virtual std::vector getAvailableLanguageStandards() const = 0; + virtual SourceGroupType getType() const; + + std::string getStandard() const; + void setStandard(const std::string& standard); + + std::vector getSourcePaths() const; + std::vector getAbsoluteSourcePaths() const; + void setSourcePaths(const std::vector& sourcePaths); + + std::vector getExcludePaths() const; + std::vector getAbsoluteExcludePaths() const; + void setExcludePaths(const std::vector& excludePaths); + + std::vector getSourceExtensions() const; + void setSourceExtensions(const std::vector& sourceExtensions); + +protected: + const ProjectSettings* m_projectSettings; + +private: + virtual std::vector getDefaultSourceExtensions() const = 0; + virtual std::string getDefaultStandard() const = 0; + + const std::string m_id; + const SourceGroupType m_type; + + std::string m_standard; + std::vector m_sourcePaths; + std::vector m_excludePaths; + std::vector m_sourceExtensions; +}; + +#endif // SOURCE_GROUP_SETTINGS_H diff --git a/src/lib/settings/SourceGroupSettingsCxx.cpp b/src/lib/settings/SourceGroupSettingsCxx.cpp new file mode 100644 index 00000000..b2d50323 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxx.cpp @@ -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 other) const +{ + std::shared_ptr otherCxx = std::dynamic_pointer_cast(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 SourceGroupSettingsCxx::getAvailableLanguageStandards() const +{ + std::vector 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 SourceGroupSettingsCxx::getHeaderSearchPaths() const +{ + return m_headerSearchPaths; +} + +std::vector SourceGroupSettingsCxx::getAbsoluteHeaderSearchPaths() const +{ + return m_projectSettings->makePathsAbsolute(getHeaderSearchPaths()); +} + +void SourceGroupSettingsCxx::setHeaderSearchPaths(const std::vector& headerSearchPaths) +{ + m_headerSearchPaths = headerSearchPaths; +} + +std::vector SourceGroupSettingsCxx::getFrameworkSearchPaths() const +{ + return m_frameworkSearchPaths; +} + +std::vector SourceGroupSettingsCxx::getAbsoluteFrameworkSearchPaths() const +{ + return m_projectSettings->makePathsAbsolute(getFrameworkSearchPaths()); +} + +void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector& frameworkSearchPaths) +{ + m_frameworkSearchPaths = frameworkSearchPaths; +} + +std::vector SourceGroupSettingsCxx::getCompilerFlags() const +{ + return m_compilerFlags; +} + +void SourceGroupSettingsCxx::setCompilerFlags(const std::vector& 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 SourceGroupSettingsCxx::getDefaultSourceExtensions() const +{ + std::vector 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 ""; +} diff --git a/src/lib/settings/SourceGroupSettingsCxx.h b/src/lib/settings/SourceGroupSettingsCxx.h new file mode 100644 index 00000000..8af3795c --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxx.h @@ -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 other) const; + + virtual std::vector getAvailableLanguageStandards() const; + + std::vector getHeaderSearchPaths() const; + std::vector getAbsoluteHeaderSearchPaths() const; + void setHeaderSearchPaths(const std::vector& headerSearchPaths); + + std::vector getFrameworkSearchPaths() const; + std::vector getAbsoluteFrameworkSearchPaths() const; + void setFrameworkSearchPaths(const std::vector& frameworkSearchPaths); + + std::vector getCompilerFlags() const; + void setCompilerFlags(const std::vector& 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 getDefaultSourceExtensions() const; + virtual std::string getDefaultStandard() const; + + std::vector m_headerSearchPaths; + std::vector m_frameworkSearchPaths; + std::vector m_compilerFlags; + bool m_useSourcePathsForHeaderSearch; + bool m_hasDefinedUseSourcePathsForHeaderSearch; + FilePath m_compilationDatabasePath; +}; + +#endif // SOURCE_GROUP_SETTINGS_CXX_H diff --git a/src/lib/settings/SourceGroupSettingsJava.cpp b/src/lib/settings/SourceGroupSettingsJava.cpp new file mode 100644 index 00000000..c0d43c17 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJava.cpp @@ -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 other) const +{ + std::shared_ptr otherJava = std::dynamic_pointer_cast(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 SourceGroupSettingsJava::getAvailableLanguageStandards() const +{ + return std::vector(1, "8"); +} + +std::vector SourceGroupSettingsJava::getClasspaths() const +{ + return m_classpaths; +} + +std::vector SourceGroupSettingsJava::getAbsoluteClasspaths() const +{ + return m_projectSettings->makePathsAbsolute(getClasspaths()); +} + +void SourceGroupSettingsJava::setClasspaths(const std::vector& 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 SourceGroupSettingsJava::getDefaultSourceExtensions() const +{ + return std::vector(1, ".java"); +} + +std::string SourceGroupSettingsJava::getDefaultStandard() const +{ + return "8"; +} diff --git a/src/lib/settings/SourceGroupSettingsJava.h b/src/lib/settings/SourceGroupSettingsJava.h new file mode 100644 index 00000000..55e33396 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJava.h @@ -0,0 +1,45 @@ +#ifndef SOURCE_GROUP_SETTINGS_JAVA_H +#define SOURCE_GROUP_SETTINGS_JAVA_H + +#include +#include + +#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 other) const; + + virtual std::vector getAvailableLanguageStandards() const; + + std::vector getClasspaths() const; + std::vector getAbsoluteClasspaths() const; + void setClasspaths(const std::vector& 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 getDefaultSourceExtensions() const; + virtual std::string getDefaultStandard() const; + + std::vector m_classpaths; + FilePath m_mavenProjectFilePath; + FilePath m_mavenDependenciesDirectory; + bool m_shouldIndexMavenTests; +}; + +#endif // SOURCE_GROUP_SETTINGS_JAVA_H diff --git a/src/lib/settings/SourceGroupType.cpp b/src/lib/settings/SourceGroupType.cpp new file mode 100644 index 00000000..f55b0c29 --- /dev/null +++ b/src/lib/settings/SourceGroupType.cpp @@ -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; +} diff --git a/src/lib/settings/SourceGroupType.h b/src/lib/settings/SourceGroupType.h new file mode 100644 index 00000000..3dc80f2e --- /dev/null +++ b/src/lib/settings/SourceGroupType.h @@ -0,0 +1,20 @@ +#ifndef SOURCE_GROUP_TYPE_H +#define SOURCE_GROUP_TYPE_H + +#include + +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 diff --git a/src/lib/settings/migration/Migration.cpp b/src/lib/settings/migration/Migration.cpp new file mode 100644 index 00000000..64d14191 --- /dev/null +++ b/src/lib/settings/migration/Migration.cpp @@ -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); +} diff --git a/src/lib/settings/migration/Migration.h b/src/lib/settings/migration/Migration.h new file mode 100644 index 00000000..2327d41b --- /dev/null +++ b/src/lib/settings/migration/Migration.h @@ -0,0 +1,56 @@ +#ifndef MIGRATION_H +#define MIGRATION_H + +#include +#include + +#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 + T getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const; + + template + std::vector getValuesFromSettings(Settings* settings, const std::string& key, std::vector defaultValues) const; + + template + bool setValueInSettings(Settings* settings, const std::string& key, T value) const; + + template + bool setValuesInSettings(Settings* settings, const std::string& key, std::vector values) const; + + void removeValuesInSettings(Settings* settings, const std::string& key) const; +}; + +template +T Migration::getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const +{ + return settings->getValue(key, defaultValue); +} + +template +std::vector Migration::getValuesFromSettings(Settings* settings, const std::string& key, std::vector defaultValues) const +{ + return settings->getValues(key, defaultValues); +} + +template +bool Migration::setValueInSettings(Settings* settings, const std::string& key, T value) const +{ + return settings->setValue(key, value); +} + +template +bool Migration::setValuesInSettings(Settings* settings, const std::string& key, std::vector values) const +{ + return settings->setValues(key, values); +} + +#endif // MIGRATION_H diff --git a/src/lib/settings/migration/MigrationDeleteKey.cpp b/src/lib/settings/migration/MigrationDeleteKey.cpp new file mode 100644 index 00000000..106eab80 --- /dev/null +++ b/src/lib/settings/migration/MigrationDeleteKey.cpp @@ -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); +} diff --git a/src/lib/settings/migration/MigrationDeleteKey.h b/src/lib/settings/migration/MigrationDeleteKey.h new file mode 100644 index 00000000..dbea3830 --- /dev/null +++ b/src/lib/settings/migration/MigrationDeleteKey.h @@ -0,0 +1,18 @@ +#ifndef MIGRATION_DELETE_KEY_H +#define MIGRATION_DELETE_KEY_H + +#include + +#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 diff --git a/src/lib/settings/migration/MigrationLambda.cpp b/src/lib/settings/migration/MigrationLambda.cpp new file mode 100644 index 00000000..3ee9d03a --- /dev/null +++ b/src/lib/settings/migration/MigrationLambda.cpp @@ -0,0 +1,11 @@ +#include "settings/migration/MigrationLambda.h" + +MigrationLambda::MigrationLambda(std::function m_lambda) + : m_lambda(m_lambda) +{ +} + +void MigrationLambda::apply(Settings* settings) const +{ + m_lambda(this, settings); +} diff --git a/src/lib/settings/migration/MigrationLambda.h b/src/lib/settings/migration/MigrationLambda.h new file mode 100644 index 00000000..bd4ea6c2 --- /dev/null +++ b/src/lib/settings/migration/MigrationLambda.h @@ -0,0 +1,18 @@ +#ifndef MIGRATION_LAMBDA_H +#define MIGRATION_LAMBDA_H + +#include + +#include "settings/migration/Migration.h" + +class MigrationLambda: public Migration +{ +public: + MigrationLambda(std::function m_lambda); + virtual void apply(Settings* settings) const; + +private: + std::function m_lambda; +}; + +#endif // MIGRATION_LAMBDA_H diff --git a/src/lib/settings/migration/MigrationMoveKey.cpp b/src/lib/settings/migration/MigrationMoveKey.cpp new file mode 100644 index 00000000..44d2a651 --- /dev/null +++ b/src/lib/settings/migration/MigrationMoveKey.cpp @@ -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( + settings, + m_newKey, + getValuesFromSettings(settings, m_oldKey, std::vector()) + ); + removeValuesInSettings(settings, m_oldKey); + } +} diff --git a/src/lib/settings/migration/MigrationMoveKey.h b/src/lib/settings/migration/MigrationMoveKey.h new file mode 100644 index 00000000..566d8f87 --- /dev/null +++ b/src/lib/settings/migration/MigrationMoveKey.h @@ -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 diff --git a/src/lib/settings/migration/SettingsMigrator.cpp b/src/lib/settings/migration/SettingsMigrator.cpp new file mode 100644 index 00000000..50272426 --- /dev/null +++ b/src/lib/settings/migration/SettingsMigrator.cpp @@ -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) +{ + 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>::const_iterator, std::multimap>::const_iterator> ret; + ret = m_migrations.equal_range(originVersion); + + for (std::multimap>::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>::const_iterator, std::multimap>::const_iterator> ret; + ret = m_migrations.equal_range(originVersion); + + for (std::multimap>::const_iterator it = ret.first; it != ret.second; it++) + { + it->second->apply(settings); + } + } + + settings->setVersion(targetVersion); + return true; + } + + return false; +} diff --git a/src/lib/settings/SettingsMigrator.h b/src/lib/settings/migration/SettingsMigrator.h similarity index 53% rename from src/lib/settings/SettingsMigrator.h rename to src/lib/settings/migration/SettingsMigrator.h index e4a58cdd..d6939b04 100644 --- a/src/lib/settings/SettingsMigrator.h +++ b/src/lib/settings/migration/SettingsMigrator.h @@ -1,10 +1,11 @@ #ifndef SETTNGS_MIGRATOR_H #define SETTNGS_MIGRATOR_H -#include #include +#include #include +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 lambda); + void addMigration(size_t targetVersion, std::shared_ptr 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 lambda; - }; - - std::multimap m_migrations; + std::multimap> m_migrations; }; #endif // SETTINGS_MIGRATOR_H diff --git a/src/lib/utility/ConfigManager.cpp b/src/lib/utility/ConfigManager.cpp index 78ccfa4a..dab15676 100644 --- a/src/lib/utility/ConfigManager.cpp +++ b/src/lib/utility/ConfigManager.cpp @@ -1,9 +1,12 @@ #include "utility/ConfigManager.h" +#include + #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::createEmpty() @@ -222,6 +225,10 @@ void ConfigManager::setValues(const std::string& key, const std::vector& 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 ConfigManager::getSublevelKeys(const std::string& key) const +{ + std::set keys; + for (std::multimap::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) { std::string text = textAccess->getText(); diff --git a/src/lib/utility/ConfigManager.h b/src/lib/utility/ConfigManager.h index 6361b384..1a57e688 100644 --- a/src/lib/utility/ConfigManager.h +++ b/src/lib/utility/ConfigManager.h @@ -41,6 +41,7 @@ public: void removeValues(const std::string& key); bool isValueDefined(const std::string& key) const; + std::vector getSublevelKeys(const std::string& key) const; bool load(const std::shared_ptr textAccess); void save(const std::string filepath); diff --git a/src/lib/utility/file/FileManager.cpp b/src/lib/utility/file/FileManager.cpp index c9920dac..2734a7a6 100644 --- a/src/lib/utility/file/FileManager.cpp +++ b/src/lib/utility/file/FileManager.cpp @@ -1,10 +1,8 @@ #include "utility/file/FileManager.h" -#include #include #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 sourcePaths, - std::vector headerPaths, - std::vector excludePaths, - std::vector sourceExtensions +void FileManager::update( + const std::vector& sourcePaths, + const std::vector& excludePaths, + const std::vector& sourceExtensions ){ m_sourcePaths = sourcePaths; - m_headerPaths = makeCanonical(headerPaths); m_excludePaths = makeCanonical(excludePaths); m_sourceExtensions = sourceExtensions; -} -FileManager::FileSets FileManager::fetchFilePaths(const std::vector& 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::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 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& o continue; } - fileSets.allSourceFilePaths.insert(filePath); - - std::map::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)); - 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 FileManager::getSourcePaths() const @@ -101,48 +41,21 @@ std::vector FileManager::getSourcePaths() const return m_sourcePaths; } -std::set FileManager::getSourceFilePaths() const -{ - std::set 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 FileManager::getAllSourceFilePaths() const +{ + return m_allSourceFilePaths; +} + std::vector FileManager::makeCanonical(const std::vector& filePaths) { std::vector ret; diff --git a/src/lib/utility/file/FileManager.h b/src/lib/utility/file/FileManager.h index 95a6481f..f1673ff8 100644 --- a/src/lib/utility/file/FileManager.h +++ b/src/lib/utility/file/FileManager.h @@ -10,47 +10,33 @@ class FileManager { public: - struct FileSets - { - std::set addedFiles; - std::set updatedFiles; - std::set removedFiles; - std::set allSourceFilePaths; - }; - FileManager(); virtual ~FileManager(); - void setPaths( - std::vector sourcePaths, - std::vector headerPaths, - std::vector excludePaths, - std::vector sourceExtensions + void update( + const std::vector& sourcePaths, + const std::vector& excludePaths, + const std::vector& sourceExtensions ); - FileSets fetchFilePaths(const std::vector& oldFileInfos); - // returns a list of source paths (can be directories) specified in the project settings std::vector getSourcePaths() const; - // returns a list of paths to all files that reside in the non-excluded source paths - std::set 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 getAllSourceFilePaths() const; + private: std::vector makeCanonical(const std::vector& filePaths); bool isExcluded(const FilePath& filePath) const; std::vector m_sourcePaths; - std::vector m_headerPaths; std::vector m_excludePaths; std::vector m_sourceExtensions; - std::map m_filesInfos; - - std::set m_sourceFilePaths; + std::set m_allSourceFilePaths; }; #endif // FILE_MANAGER_H diff --git a/src/lib/utility/solution/ISolutionParser.cpp b/src/lib/utility/solution/ISolutionParser.cpp deleted file mode 100644 index bffb5291..00000000 --- a/src/lib/utility/solution/ISolutionParser.cpp +++ /dev/null @@ -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(ifstream), std::istreambuf_iterator()); - } - - return file; -} - -std::vector ISolutionParser::makePathsAbsolute(const std::vector& paths) -{ - std::vector 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; -} diff --git a/src/lib/utility/solution/ISolutionParser.h b/src/lib/utility/solution/ISolutionParser.h deleted file mode 100644 index 916202ed..00000000 --- a/src/lib/utility/solution/ISolutionParser.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef I_SOLUTION_PARSER_H -#define I_SOLUTION_PARSER_H - -#include -#include - -#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 getProjects() = 0; - virtual std::vector getProjectFiles() = 0; - virtual std::vector getProjectItems() = 0; - virtual std::vector getCompileFlags() = 0; - - virtual std::shared_ptr 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 makePathsAbsolute(const std::vector& paths); - - std::string m_solutionName; - std::string m_solutionPath; - std::string m_solution; -}; - -#endif // I_SOLUTION_PARSER_H diff --git a/src/lib/utility/solution/SolutionParserCMake.cpp b/src/lib/utility/solution/SolutionParserCMake.cpp deleted file mode 100644 index d7a81a3a..00000000 --- a/src/lib/utility/solution/SolutionParserCMake.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "SolutionParserCMake.h" - -SolutionParserCMake::SolutionParserCMake() -{ - -} - -SolutionParserCMake::~SolutionParserCMake() -{ - -} - -std::vector SolutionParserCMake::getProjects() -{ - std::vector projects; - - return projects; -} \ No newline at end of file diff --git a/src/lib/utility/solution/SolutionParserCMake.h b/src/lib/utility/solution/SolutionParserCMake.h deleted file mode 100644 index 27f561cf..00000000 --- a/src/lib/utility/solution/SolutionParserCMake.h +++ /dev/null @@ -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 getProjects(); - virtual std::vector getProjectFiles(); -}; - -#endif // SOLUTION_PARSER_C_MAKE_H \ No newline at end of file diff --git a/src/lib/utility/solution/SolutionParserCodeBlocks.cpp b/src/lib/utility/solution/SolutionParserCodeBlocks.cpp deleted file mode 100644 index 443c5a68..00000000 --- a/src/lib/utility/solution/SolutionParserCodeBlocks.cpp +++ /dev/null @@ -1,228 +0,0 @@ -#include "SolutionParserCodeBlocks.h" - -#include - -#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 SolutionParserCodeBlocks::getProjects() -{ - std::vector projectFiles; - - projectFiles.push_back(m_solutionName); - - return projectFiles; -} - -std::vector SolutionParserCodeBlocks::getProjectFiles() -{ - std::vector projectFiles; - std::vector projectFilesNames = getProjects(); - - projectFiles.push_back(loadFile(m_solutionPath + m_solutionName)); - - return projectFiles; -} - -std::vector SolutionParserCodeBlocks::getProjectItems() -{ - std::vector projectItems; - - std::vector projectFilesNames = getProjects(); - std::vector projectFiles = getProjectFiles(); - - std::vector 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 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 s(projectItems.begin(), projectItems.end()); - projectItems.assign(s.begin(), s.end()); - - projectItems = SolutionParserUtility::resolveEnvironmentVariables(projectItems); - projectItems = makePathsAbsolute(projectItems); - - return projectItems; -} - -std::vector SolutionParserCodeBlocks::getIncludePaths() -{ - std::vector includePaths; - - std::vector projectFiles = getProjectFiles(); - - std::vector 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 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 s(includePaths.begin(), includePaths.end()); - includePaths.assign(s.begin(), s.end()); - - includePaths = SolutionParserUtility::resolveEnvironmentVariables(includePaths); - includePaths = makePathsAbsolute(includePaths); - - return includePaths; -} - -std::vector SolutionParserCodeBlocks::getCompileFlags() -{ - std::vector compilerFlags; - - return compilerFlags; -} - -std::shared_ptr SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath) -{ - openSolutionFile(solutionFilePath); - - std::shared_ptr settings = std::make_shared(getSolutionName(), getSolutionPath()); - settings->setVisualStudioSolutionPath(solutionFilePath); // why is it called vs solution if it is used for codeblocks as well? - - std::vector sourceFiles = getProjectItems(); - std::vector sourcePaths; - for (const std::string& p : sourceFiles) - { - sourcePaths.push_back(FilePath(p)); - } - - std::vector includePaths = getIncludePaths(); - std::vector 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"; -} diff --git a/src/lib/utility/solution/SolutionParserCodeBlocks.h b/src/lib/utility/solution/SolutionParserCodeBlocks.h deleted file mode 100644 index 827c28fd..00000000 --- a/src/lib/utility/solution/SolutionParserCodeBlocks.h +++ /dev/null @@ -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 getProjects(); - virtual std::vector getProjectFiles(); - virtual std::vector getProjectItems(); - virtual std::vector getIncludePaths(); - virtual std::vector getCompileFlags(); - - virtual std::shared_ptr 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 diff --git a/src/lib/utility/solution/SolutionParserManager.cpp b/src/lib/utility/solution/SolutionParserManager.cpp deleted file mode 100644 index e0f6c4ff..00000000 --- a/src/lib/utility/solution/SolutionParserManager.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "SolutionParserManager.h" - -#include - -#include "utility/logging/logging.h" - -SolutionParserManager::SolutionParserManager() - : m_solutionParsers() -{ - -} - -SolutionParserManager::~SolutionParserManager() -{ - -} - -void SolutionParserManager::pushSolutionParser(const std::shared_ptr& 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 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(); -} - -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()); -} diff --git a/src/lib/utility/solution/SolutionParserManager.h b/src/lib/utility/solution/SolutionParserManager.h deleted file mode 100644 index a0f70d7d..00000000 --- a/src/lib/utility/solution/SolutionParserManager.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef SOLUTION_PARSER_MANAGER_H -#define SOLUTION_PARSER_MANAGER_H - -#include - -#include "ISolutionParser.h" - -class SolutionParserManager -{ -public: - SolutionParserManager(); - ~SolutionParserManager(); - - void pushSolutionParser(const std::shared_ptr& solutionParser); - - bool canParseSolution(const std::string& ideId) const; - - std::shared_ptr 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> m_solutionParsers; -}; - -#endif // SOLUTION_PARSER_MANAGER_H diff --git a/src/lib/utility/solution/SolutionParserUtility.cpp b/src/lib/utility/solution/SolutionParserUtility.cpp deleted file mode 100644 index f038b0d0..00000000 --- a/src/lib/utility/solution/SolutionParserUtility.cpp +++ /dev/null @@ -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 SolutionParserUtility::m_ideMacros; -std::map 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 SolutionParserUtility::getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute) -{ - std::vector 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& 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 SolutionParserUtility::resolveEnvironmentVariables(const std::vector& paths) -{ - std::vector 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 SolutionParserUtility::makePathsCanonical(const std::vector& paths) -{ - std::vector 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 ""; -} diff --git a/src/lib/utility/solution/SolutionParserUtility.h b/src/lib/utility/solution/SolutionParserUtility.h deleted file mode 100644 index 4d7f31d3..00000000 --- a/src/lib/utility/solution/SolutionParserUtility.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SOLUTION_PARSER_UTILITY_H -#define SOLUTION_PARSER_UTILITY_H - -#include -#include -#include - -#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 getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute); - - static bool checkValidFileExtension(const std::string& file, const std::vector& validExtensions); - - static std::vector resolveEnvironmentVariables(const std::vector& paths); - static std::string findAndResolveEnvironmentVariable(const std::string& path); - static std::vector makePathsCanonical(const std::vector& 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 m_ideMacros; - static std::map m_ideMacroValues; // to replace macros with known values -}; - -#endif // SOLUTION_PARSER_UTILITY_H diff --git a/src/lib/utility/utilityString.cpp b/src/lib/utility/utilityString.cpp index 3ae750b1..7d9150ab 100644 --- a/src/lib/utility/utilityString.cpp +++ b/src/lib/utility/utilityString.cpp @@ -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; diff --git a/src/lib/utility/utilityString.h b/src/lib/utility/utilityString.h index 67d969ba..da681e8f 100644 --- a/src/lib/utility/utilityString.h +++ b/src/lib/utility/utilityString.h @@ -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); diff --git a/src/lib_cxx/CMakeLists.txt b/src/lib_cxx/CMakeLists.txt index 4d8fa7c1..484e063e 100644 --- a/src/lib_cxx/CMakeLists.txt +++ b/src/lib_cxx/CMakeLists.txt @@ -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 ) diff --git a/src/lib_cxx/CxxProject.h b/src/lib_cxx/CxxProject.h deleted file mode 100644 index 5741596c..00000000 --- a/src/lib_cxx/CxxProject.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef CXX_PROJECT_H -#define CXX_PROJECT_H - -#include - -#include "settings/CxxProjectSettings.h" -#include "Project.h" - -class CxxProject: public Project -{ -public: - CxxProject( - std::shared_ptr projectSettings, - StorageAccessProxy* storageAccessProxy, - std::shared_ptr dialogView - ); - virtual ~CxxProject(); - -protected: - virtual std::shared_ptr getProjectSettings(); - virtual const std::shared_ptr getProjectSettings() const; - -private: - CxxProject(const CxxProject&); - - virtual bool prepareRefresh(); - - virtual std::vector> getIndexerCommands(); - - virtual void updateFileManager(FileManager& fileManager); - - std::shared_ptr m_projectSettings; - - - friend Project; -}; - -#endif // CXX_PROJECT_H diff --git a/src/lib_cxx/ProjectFactoryModuleC.cpp b/src/lib_cxx/ProjectFactoryModuleC.cpp deleted file mode 100644 index 0a3f18d3..00000000 --- a/src/lib_cxx/ProjectFactoryModuleC.cpp +++ /dev/null @@ -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 ProjectFactoryModuleC::createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView -) -{ - return std::shared_ptr(new CxxProject( - std::make_shared(projectSettingsFile), storageAccessProxy, dialogView)); -} diff --git a/src/lib_cxx/ProjectFactoryModuleC.h b/src/lib_cxx/ProjectFactoryModuleC.h deleted file mode 100644 index a6e36ff2..00000000 --- a/src/lib_cxx/ProjectFactoryModuleC.h +++ /dev/null @@ -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 createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView - ); -}; - -#endif // PROJECT_FACTORY_MODULE_C_H diff --git a/src/lib_cxx/ProjectFactoryModuleCpp.cpp b/src/lib_cxx/ProjectFactoryModuleCpp.cpp deleted file mode 100644 index 2cb12594..00000000 --- a/src/lib_cxx/ProjectFactoryModuleCpp.cpp +++ /dev/null @@ -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 ProjectFactoryModuleCpp::createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView -) -{ - return std::shared_ptr(new CxxProject( - std::make_shared(projectSettingsFile), storageAccessProxy, dialogView)); -} diff --git a/src/lib_cxx/ProjectFactoryModuleCpp.h b/src/lib_cxx/ProjectFactoryModuleCpp.h deleted file mode 100644 index 6366c41c..00000000 --- a/src/lib_cxx/ProjectFactoryModuleCpp.h +++ /dev/null @@ -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 createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView - ); -}; - -#endif // PROJECT_FACTORY_MODULE_CPP_H diff --git a/src/lib_cxx/CxxProject.cpp b/src/lib_cxx/project/SourceGroupCxx.cpp similarity index 52% rename from src/lib_cxx/CxxProject.cpp rename to src/lib_cxx/project/SourceGroupCxx.cpp index f770a96e..4d4169cd 100644 --- a/src/lib_cxx/CxxProject.cpp +++ b/src/lib_cxx/project/SourceGroupCxx.cpp @@ -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 projectSettings, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView -) - : Project(storageAccessProxy, dialogView) - , m_projectSettings(projectSettings) +SourceGroupCxx::SourceGroupCxx(std::shared_ptr settings) + : m_settings(settings) { } -CxxProject::~CxxProject() +SourceGroupCxx::~SourceGroupCxx() { } -std::shared_ptr CxxProject::getProjectSettings() +SourceGroupType SourceGroupCxx::getType() const { - return m_projectSettings; + return m_settings->getType(); } -const std::shared_ptr 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> CxxProject::getIndexerCommands() +void SourceGroupCxx::fetchAllSourceFilePaths() +{ + std::vector 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> SourceGroupCxx::getIndexerCommands(const bool fullRefresh) { std::shared_ptr appSettings = ApplicationSettings::getInstance(); - std::string languageStandard = m_projectSettings->getStandard(); - std::vector 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> CxxProject::getIndexerCommands() } // Add all subdirectories of the header search paths - if (m_projectSettings->getUseSourcePathsForHeaderSearch()) + if (m_settings->getUseSourcePathsForHeaderSearch()) { std::vector 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> CxxProject::getIndexerCommands() } std::vector frameworkSearchPaths; - utility::append(frameworkSearchPaths, m_projectSettings->getAbsoluteFrameworkSearchPaths()); + utility::append(frameworkSearchPaths, m_settings->getAbsoluteFrameworkSearchPaths()); utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded()); - std::vector compilerFlags = m_projectSettings->getCompilerFlags(); + const std::vector compilerFlags = m_settings->getCompilerFlags(); std::set indexedPaths; - for (FilePath p: m_projectSettings->getAbsoluteSourcePaths()) + for (FilePath p: m_settings->getAbsoluteSourcePaths()) { if (p.exists()) { @@ -105,7 +114,7 @@ std::vector> CxxProject::getIndexerCommands() } std::set excludedPaths; - for (FilePath p: m_projectSettings->getAbsoluteExcludePaths()) + for (FilePath p: m_settings->getAbsoluteExcludePaths()) { if (p.exists()) { @@ -115,7 +124,9 @@ std::vector> CxxProject::getIndexerCommands() std::vector> indexerCommands; - FilePath cdbPath = m_projectSettings->getAbsoluteCompilationDatabasePath(); + const std::set& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex()); + + FilePath cdbPath = m_settings->getAbsoluteCompilationDatabasePath(); if (cdbPath.exists()) { std::string error; @@ -123,29 +134,32 @@ std::vector> CxxProject::getIndexerCommands() (clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error)); for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands()) { - std::vector currentCompilerFlags = compilerFlags; - currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end()); + if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end()) + { + std::vector currentCompilerFlags = compilerFlags; + currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end()); - indexerCommands.push_back(std::make_shared( - FilePath(command.Filename), - indexedPaths, - excludedPaths, - FilePath(command.Directory), - currentCompilerFlags, - systemHeaderSearchPaths, - frameworkSearchPaths - )); + indexerCommands.push_back(std::make_shared( + 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( sourcePath, indexedPaths, excludedPaths, - languageStandard, + m_settings->getStandard(), systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags @@ -155,25 +169,3 @@ std::vector> CxxProject::getIndexerCommands() return indexerCommands; } - -void CxxProject::updateFileManager(FileManager& fileManager) -{ - std::vector sourcePaths = m_projectSettings->getAbsoluteSourcePaths(); - std::vector headerPaths = sourcePaths; - - std::vector sourceExtensions; - - FilePath cdbPath = m_projectSettings->getAbsoluteCompilationDatabasePath(); - if (cdbPath.exists()) - { - sourcePaths = IndexerCxxCdb::getSourceFilesFromCDB(cdbPath); - } - else - { - sourceExtensions = m_projectSettings->getSourceExtensions(); - } - - std::vector excludePaths = m_projectSettings->getAbsoluteExcludePaths(); - - fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions); -} diff --git a/src/lib_cxx/project/SourceGroupCxx.h b/src/lib_cxx/project/SourceGroupCxx.h new file mode 100644 index 00000000..4fb63216 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupCxx.h @@ -0,0 +1,29 @@ +#ifndef SOURCE_GROUP_CXX_H +#define SOURCE_GROUP_CXX_H + +#include +#include + +#include "project/SourceGroup.h" +#include "settings/SourceGroupSettingsCxx.h" +#include "utility/file/FileManager.h" + +class SourceGroupCxx: public SourceGroup +{ +public: + SourceGroupCxx(std::shared_ptr settings); + virtual ~SourceGroupCxx(); + + virtual SourceGroupType getType() const; + + virtual bool prepareRefresh(); + + virtual void fetchAllSourceFilePaths(); + + virtual std::vector> getIndexerCommands(const bool fullRefresh); + +private: + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_CXX_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp new file mode 100644 index 00000000..1fde5cdf --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp @@ -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 SourceGroupFactoryModuleC::createSourceGroup(std::shared_ptr settings) +{ + std::shared_ptr sourceGroup; + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupCxx(cxxSettings)); + } + return sourceGroup; +} diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleC.h b/src/lib_cxx/project/SourceGroupFactoryModuleC.h new file mode 100644 index 00000000..130c8225 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleC.h @@ -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 createSourceGroup(std::shared_ptr settings); +}; + +#endif // SOURCE_GROUP_FACTORY_MODULE_C_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp new file mode 100644 index 00000000..bf88f7ae --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp @@ -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 SourceGroupFactoryModuleCpp::createSourceGroup(std::shared_ptr settings) +{ + std::shared_ptr sourceGroup; + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupCxx(cxxSettings)); + } + return sourceGroup; +} diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h new file mode 100644 index 00000000..89d49e07 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h @@ -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 createSourceGroup(std::shared_ptr settings); +}; + +#endif // SOURCE_GROUP_FACTORY_MODULE_CPP_H diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index e6476598..1e67a01f 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -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 diff --git a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp index 2a24fbae..f2b79a51 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp +++ b/src/lib_gui/qt/element/QtCodeFileTitleButton.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) diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index f7227ff4..d6f45afe 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -415,7 +415,14 @@ void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::s void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector& headerPaths) { QtProjectWizzard* wizzard = createWindow(); - wizzard->newProjectFromCDB(filePath, headerPaths); + + std::vector headerFilePaths(headerPaths.size()); + for (const std::string& s: headerPaths) + { + headerFilePaths.push_back(FilePath(s)); + } + + wizzard->newProjectFromCDB(FilePath(filePath), headerFilePaths); } void QtMainWindow::openProject() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 1360dbe4..3972b01c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -5,7 +5,6 @@ #include #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(); - } void QtProjectWizzard::showWindow() @@ -73,129 +70,69 @@ void QtProjectWizzard::hideWindow() void QtProjectWizzard::newProject() { - QtProjectWizzardWindow* window = createWindowWithContent(); + QtProjectWizzardWindow* window = createWindowWithContent( + [this](QtProjectWizzardWindow* window) + { + return new QtProjectWizzardContentSelect(window); + } + ); + window->setPreferredSize(QSize(570, 380)); connect(dynamic_cast(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 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(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& headerPaths) +void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::vector& headerPaths) { - FilePath fp(filePath); + m_projectSettings = std::make_shared(); - std::vector hp; - for (size_t i = 0; i < headerPaths.size(); i++) - { - hp.push_back(FilePath(headerPaths[i])); - } + std::shared_ptr sourceGroupSettings = std::make_shared(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 settings = std::make_shared(); - 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(m_windowStack.getTopWindow()); - if (window) - { - window->content()->save(); - } - - std::shared_ptr settings = m_parserManager->getProjectSettings(ideId, solutionPath); - - std::shared_ptr otherCxxSettings = std::dynamic_pointer_cast(settings); - std::shared_ptr ownCxxSettings = std::dynamic_pointer_cast(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 settings; - switch (ProjectSettings::getLanguageOfProject(settingsPath)) - { - case LANGUAGE_C: - case LANGUAGE_CPP: - settings = std::make_shared(settingsPath); - break; - case LANGUAGE_JAVA: - settings = std::make_shared(settingsPath); - break; - default: - return; - } - - if (settings) - { - settings->reload(); - editProject(settings); - } + std::shared_ptr settings = std::make_shared(settingsPath); + settings->reload(); + editProject(settings); } void QtProjectWizzard::editProject(std::shared_ptr settings) { - m_settings = settings; + m_projectSettings = settings; + + { + const std::vector> 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 -QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent() -{ +QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent( + std::function 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() -{ - 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 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(); + + const std::string sourceGroupId = UUIDUtility::getUUIDString(); + + switch (sourceGroupType) { - case PROJECT_C_EMPTY: - case PROJECT_CPP_EMPTY: - m_settings = std::make_shared(); + case SOURCE_GROUP_C_EMPTY: + case SOURCE_GROUP_CPP_EMPTY: + m_sourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); if (applicationSettingsContainVisualStudioHeaderSearchPaths()) { std::vector flags; flags.push_back("-fms-extensions"); flags.push_back("-fms-compatibility"); flags.push_back("-fms-compatibility-version=19"); - std::dynamic_pointer_cast(m_settings)->setCompilerFlags(flags); + std::dynamic_pointer_cast(m_sourceGroupSettings)->setCompilerFlags(flags); } - m_settings->setLanguage(languageType); emptyProject(); break; - case PROJECT_CXX_CDB: - m_settings = std::make_shared(); - m_settings->setLanguage(languageType); + case SOURCE_GROUP_CXX_CDB: + m_sourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); emptyProjectCDB(); break; - case PROJECT_CXX_VS: - m_settings = std::make_shared(); - m_settings->setLanguage(languageType); + case SOURCE_GROUP_CXX_VS: + m_sourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); // maybe use a different type here emptyProjectCDBVS(); break; - case PROJECT_JAVA_EMPTY: - m_settings = std::make_shared(); - m_settings->setLanguage(languageType); + case SOURCE_GROUP_JAVA_EMPTY: + m_sourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); emptyProject(); break; - case PROJECT_JAVA_MAVEN: - m_settings = std::make_shared(); - m_settings->setLanguage(languageType); + case SOURCE_GROUP_JAVA_MAVEN: + m_sourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); emptyProjectJavaMaven(); break; } @@ -385,17 +301,67 @@ void QtProjectWizzard::selectedProjectType(ProjectType projectType) void QtProjectWizzard::emptyProject() { - QtProjectWizzardWindow* window = createWindowWithContent(); - 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(); - - connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB())); - window->updateSubTitle("Project Data"); -} - -void QtProjectWizzard::emptyProjectCDB() -{ - QtProjectWizzardWindow* window = createWindowWithContent(); - - connect(window, SIGNAL(next()), this, SLOT(headerPathsCDB())); - window->updateSubTitle("Project Data"); -} - -void QtProjectWizzard::emptyProjectJavaMaven() -{ - QtProjectWizzardWindow* window = createWindowWithContent(); - - 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(m_settings)->setMavenDependenciesDirectory( - "./coati_dependencies/" + utility::replace(m_settings->getProjectName(), " ", "_") + "/maven" + std::dynamic_pointer_cast(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 cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(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 javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(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()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h index 1584722a..4eb94fef 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h @@ -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& headerPaths); + void newProjectFromSolution(const std::string& ideId, const FilePath& solutionPath); + void newProjectFromCDB(const FilePath& filePath, const std::vector& 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 - QtProjectWizzardWindow* createWindowWithContent(); + QtProjectWizzardWindow* createWindowWithContent( + std::function func); QtProjectWizzardWindow* createWindowWithSummary( std::function func); QtWindowStack m_windowStack; - std::shared_ptr m_settings; + std::shared_ptr m_projectSettings; + std::shared_ptr m_sourceGroupSettings; ApplicationSettings m_appSettings; bool m_editing; - std::shared_ptr 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(); - #endif // QT_PROJECT_WIZZARD_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp index 9d33fa04..bc25e129 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp @@ -37,9 +37,8 @@ void QtHelpButton::handleHelpPress() } -QtProjectWizzardContent::QtProjectWizzardContent(std::shared_ptr 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)) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h index c5cdb5b5..09d59ab2 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h @@ -35,7 +35,7 @@ class QtProjectWizzardContent Q_OBJECT public: - QtProjectWizzardContent(std::shared_ptr 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 m_settings; QtProjectWizzardWindow* m_window; std::shared_ptr m_filesDialog; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.cpp deleted file mode 100644 index c0d14504..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h" - -#include -#include - -#include "utility/ResourcePaths.h" - -#include "qt/element/QtIconButton.h" -#include "qt/element/QtLocationPicker.h" -#include "settings/CxxProjectSettings.h" - -QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile( - std::shared_ptr 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 cxxSettings = std::dynamic_pointer_cast(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 cxxSettings = std::dynamic_pointer_cast(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; -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h deleted file mode 100644 index b086d6bb..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentBuildFile.h +++ /dev/null @@ -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 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 diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp index 94d857d0..86830b97 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp @@ -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 settings, QtProjectWizzardWindow* window + std::shared_ptr 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 excludePaths = m_settings->getAbsoluteExcludePaths(); - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { std::vector filePaths = IndexerCxxCdb::getSourceFilesFromCDB(cxxSettings->getAbsoluteCompilationDatabasePath()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h index fd3e0517..1f184e4a 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h @@ -9,7 +9,7 @@ class QtProjectWizzardContentCDBSource Q_OBJECT public: - QtProjectWizzardContentCDBSource(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentCDBSource(std::shared_ptr 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 m_settings; QLabel* m_text; std::vector m_fileNames; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp index 27793e5b..ef152fd8 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp @@ -3,15 +3,19 @@ #include #include -#include "settings/CxxProjectSettings.h" - +#include "settings/SourceGroupSettingsCxx.h" #include "utility/messaging/type/MessageIDECreateCDB.h" #include "utility/logging/logging.h" QtProjectWizzardContentData::QtProjectWizzardContentData( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool disableNameEditing + std::shared_ptr projectSettings, + std::shared_ptr 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 standards = m_settings->getLanguageStandards(); + std::vector 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 settings, QtProjectWizzardWindow* window, bool disableNameEditing) - : QtProjectWizzardContentData(settings, window, disableNameEditing) + std::shared_ptr projectSettings, + std::shared_ptr 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 cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(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 cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(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 settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContentDataCDB(settings, window, false) +QtProjectWizzardContentDataCDBVS::QtProjectWizzardContentDataCDBVS( + std::shared_ptr projectSettings, + std::shared_ptr sourceGroupSettings, + QtProjectWizzardWindow* window +) + : QtProjectWizzardContentDataCDB(projectSettings, sourceGroupSettings, window, false) { } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h index cec79253..9815ecb7 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h @@ -14,7 +14,10 @@ class QtProjectWizzardContentData public: QtProjectWizzardContentData( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool disableNameEditing = false); + std::shared_ptr projectSettings, + std::shared_ptr 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 m_projectSettings; + std::shared_ptr m_sourceGroupSettings; + bool m_disableNameEditing; QLineEdit* m_projectName; QtLocationPicker* m_projectFileLocation; @@ -46,7 +52,10 @@ class QtProjectWizzardContentDataCDB public: QtProjectWizzardContentDataCDB( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool disableNameEditing = false); + std::shared_ptr projectSettings, + std::shared_ptr 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 settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentDataCDBVS( + std::shared_ptr projectSettings, + std::shared_ptr sourceGroupSettings, + QtProjectWizzardWindow* window); virtual void populate(QGridLayout* layout, int& row) override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp index 373b9aee..213788ab 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp @@ -2,12 +2,14 @@ #include +#include "settings/SourceGroupSettings.h" #include "qt/element/QtDirectoryListBox.h" QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContent(settings, window) + : QtProjectWizzardContent(window) + , m_settings(settings) { } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h index 80e574d1..f83ced4e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h @@ -11,7 +11,7 @@ class QtProjectWizzardContentExtensions Q_OBJECT public: - QtProjectWizzardContentExtensions(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentExtensions(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -20,6 +20,8 @@ public: virtual void save() override; private: + std::shared_ptr m_settings; + QtDirectoryListBox* m_sourceList; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp index c3e20af7..89354f63 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp @@ -3,10 +3,11 @@ #include #include "qt/element/QtDirectoryListBox.h" -#include "settings/CxxProjectSettings.h" +#include "settings/SourceGroupSettingsCxx.h" -QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContent(settings, window) +QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window) + : QtProjectWizzardContent(window) + , m_settings(settings) { } @@ -25,7 +26,7 @@ void QtProjectWizzardContentFlags::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentFlags::load() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { m_list->setStringList(cxxSettings->getCompilerFlags()); @@ -34,7 +35,7 @@ void QtProjectWizzardContentFlags::load() void QtProjectWizzardContentFlags::save() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { cxxSettings->setCompilerFlags(m_list->getStringList()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h index 2295d862..ff1fd8d3 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h @@ -11,7 +11,7 @@ class QtProjectWizzardContentFlags Q_OBJECT public: - QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -20,6 +20,8 @@ public: virtual void save() override; private: + std::shared_ptr m_settings; + QtDirectoryListBox* m_list; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index 26e28ed4..c3bdb58e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -9,15 +9,16 @@ #include "component/view/DialogView.h" #include "qt/element/QtLocationPicker.h" #include "settings/ApplicationSettings.h" -#include "settings/JavaProjectSettings.h" +#include "settings/SourceGroupSettingsJava.h" #include "utility/file/FileManager.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/utilityMaven.h" #include "utility/ScopedFunctor.h" #include "Application.h" -QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContent(settings, window) +QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window) + : QtProjectWizzardContent(window) + , m_settings(settings) , m_makePathRelativeToProjectFileLocation(true) { } @@ -68,7 +69,7 @@ void QtProjectWizzardContentPath::setHelpString(const QString& help) } QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPath(settings, window) { @@ -101,7 +102,7 @@ void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& void QtProjectWizzardContentPathSourceMaven::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { m_picker->setText(QString::fromStdString(javaSettings->getMavenProjectFilePath().str())); @@ -111,7 +112,7 @@ void QtProjectWizzardContentPathSourceMaven::load() void QtProjectWizzardContentPathSourceMaven::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { javaSettings->setMavenProjectFilePath(m_picker->getText().toStdString()); @@ -121,7 +122,7 @@ void QtProjectWizzardContentPathSourceMaven::save() std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() const { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); const FilePath mavenProjectRoot = javaSettings->getAbsoluteMavenProjectFilePath().parentDirectory(); @@ -150,16 +151,15 @@ std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() ); FileManager fileManager; - fileManager.setPaths( + fileManager.update( sourceDirectories, - std::vector(), // we don't need to specify header paths here m_settings->getAbsoluteExcludePaths(), m_settings->getSourceExtensions() ); const FilePath projectPath = m_settings->getProjectFileLocation(); - for (FilePath path: fileManager.getSourceFilePaths()) + for (FilePath path: fileManager.getAllSourceFilePaths()) { if (projectPath.exists()) { @@ -175,7 +175,7 @@ std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() } QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPath(settings, window) { @@ -189,7 +189,7 @@ QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDepende void QtProjectWizzardContentPathDependenciesMaven::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { m_picker->setText(QString::fromStdString(javaSettings->getMavenDependenciesDirectory().str())); @@ -198,7 +198,7 @@ void QtProjectWizzardContentPathDependenciesMaven::load() void QtProjectWizzardContentPathDependenciesMaven::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { javaSettings->setMavenDependenciesDirectory(m_picker->getText().toStdString()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h index ba89d0a1..27083279 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h @@ -16,7 +16,7 @@ class QtProjectWizzardContentPath Q_OBJECT public: - QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtSettingsWindow implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -27,6 +27,8 @@ protected: void setTitleString(const QString& title); void setHelpString(const QString& help); + std::shared_ptr m_settings; + QtLocationPicker* m_picker; bool m_makePathRelativeToProjectFileLocation; @@ -40,7 +42,7 @@ class QtProjectWizzardContentPathSourceMaven : public QtProjectWizzardContentPath { public: - QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtSettingsWindow implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -59,7 +61,7 @@ class QtProjectWizzardContentPathDependenciesMaven : public QtProjectWizzardContentPath { public: - QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void load() override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 0e324d6d..2306225f 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -8,16 +8,17 @@ #include "qt/element/QtDirectoryListBox.h" #include "qt/window/QtSelectPathsDialog.h" #include "settings/ApplicationSettings.h" -#include "settings/CxxProjectSettings.h" -#include "settings/JavaProjectSettings.h" +#include "settings/SourceGroupSettingsCxx.h" +#include "settings/SourceGroupSettingsJava.h" #include "utility/CompilationDatabase.h" #include "utility/file/FileManager.h" #include "utility/file/FileSystem.h" #include "utility/utility.h" #include "utility/utilityPathDetection.h" -QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContent(settings, window) +QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window) + : QtProjectWizzardContent(window) + , m_settings(settings) , m_makePathsRelativeToProjectFileLocation(true) { } @@ -142,7 +143,7 @@ void QtProjectWizzardContentPaths::detectionClicked() QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPaths(settings, window) { @@ -173,9 +174,8 @@ void QtProjectWizzardContentPathsSource::save() std::vector QtProjectWizzardContentPathsSource::getFileNames() const { FileManager fileManager; - fileManager.setPaths( - m_settings->getAbsoluteSourcePaths(), - std::vector(), // we don't need to specify header paths here + fileManager.update( + m_settings->getAbsoluteSourcePaths(), m_settings->getAbsoluteExcludePaths(), m_settings->getSourceExtensions() ); @@ -183,7 +183,7 @@ std::vector QtProjectWizzardContentPathsSource::getFileNames() cons const FilePath projectPath = m_settings->getProjectFileLocation(); std::vector list; - for (FilePath path: fileManager.getSourceFilePaths()) + for (FilePath path: fileManager.getAllSourceFilePaths()) { if (projectPath.exists()) { @@ -207,7 +207,7 @@ QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const } QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPathsSource(settings, window) { @@ -274,7 +274,7 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked() utility::CompilationDatabase cdb( - dynamic_cast(m_settings.get())->getAbsoluteCompilationDatabasePath().str()); + dynamic_cast(m_settings.get())->getAbsoluteCompilationDatabasePath().str()); std::vector cdbHeaderPaths = cdb.getAllHeaderPaths(); std::vector sourcePaths = m_settings->getSourcePaths(); @@ -300,7 +300,7 @@ void QtProjectWizzardContentPathsCDBHeader::savedFilesDialog() } QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPaths(settings, window) { @@ -323,7 +323,7 @@ void QtProjectWizzardContentPathsExclude::save() QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB + std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB ) : QtProjectWizzardContentPaths(settings, window) { @@ -345,7 +345,7 @@ QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSear void QtProjectWizzardContentPathsHeaderSearch::load() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { m_list->setList(cxxSettings->getHeaderSearchPaths()); @@ -354,7 +354,7 @@ void QtProjectWizzardContentPathsHeaderSearch::load() void QtProjectWizzardContentPathsHeaderSearch::save() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { cxxSettings->setHeaderSearchPaths(m_list->getList()); @@ -367,9 +367,9 @@ bool QtProjectWizzardContentPathsHeaderSearch::isScrollAble() const } QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHeaderSearchGlobal( - std::shared_ptr settings, QtProjectWizzardWindow* window + QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPaths(settings, window) + : QtProjectWizzardContentPaths(std::shared_ptr(), window) { setTitleString("Global Include Paths"); setHelpString( @@ -397,7 +397,7 @@ void QtProjectWizzardContentPathsHeaderSearchGlobal::save() QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFrameworkSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB + std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB ) : QtProjectWizzardContentPaths(settings, window) { @@ -412,7 +412,7 @@ QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFramewo void QtProjectWizzardContentPathsFrameworkSearch::load() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { m_list->setList(cxxSettings->getFrameworkSearchPaths()); @@ -421,7 +421,7 @@ void QtProjectWizzardContentPathsFrameworkSearch::load() void QtProjectWizzardContentPathsFrameworkSearch::save() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { cxxSettings->setFrameworkSearchPaths(m_list->getList()); @@ -434,9 +434,9 @@ bool QtProjectWizzardContentPathsFrameworkSearch::isScrollAble() const } QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsFrameworkSearchGlobal( - std::shared_ptr settings, QtProjectWizzardWindow* window + QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPaths(settings, window) + : QtProjectWizzardContentPaths(std::shared_ptr(), window) { setTitleString("Global Framework Search Paths"); setHelpString( @@ -465,7 +465,7 @@ void QtProjectWizzardContentPathsFrameworkSearchGlobal::save() QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) : QtProjectWizzardContentPaths(settings, window) { @@ -480,7 +480,7 @@ QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava( void QtProjectWizzardContentPathsClassJava::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { m_list->setList(javaSettings->getClasspaths()); @@ -489,7 +489,7 @@ void QtProjectWizzardContentPathsClassJava::load() void QtProjectWizzardContentPathsClassJava::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { javaSettings->setClasspaths(m_list->getList()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 666bbc9b..6206fa90 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -17,7 +17,7 @@ signals: void showSourceFiles(); public: - QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtSettingsWindow implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -30,6 +30,8 @@ protected: void addDetection(QGridLayout* layout, int row); + std::shared_ptr m_settings; + QtDirectoryListBox* m_list; QString m_showFilesString; @@ -52,7 +54,7 @@ class QtProjectWizzardContentPathsSource : public QtProjectWizzardContentPaths { public: - QtProjectWizzardContentPathsSource(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsSource(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void load() override; @@ -69,7 +71,7 @@ class QtProjectWizzardContentPathsCDBHeader Q_OBJECT public: - QtProjectWizzardContentPathsCDBHeader(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsCDBHeader(std::shared_ptr settings, QtProjectWizzardWindow* window); virtual void populate(QGridLayout* layout, int& row) override; @@ -85,7 +87,7 @@ class QtProjectWizzardContentPathsExclude : public QtProjectWizzardContentPaths { public: - QtProjectWizzardContentPathsExclude(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsExclude(std::shared_ptr settings, QtProjectWizzardWindow* window); virtual void load() override; virtual void save() override; @@ -97,7 +99,7 @@ class QtProjectWizzardContentPathsHeaderSearch { public: QtProjectWizzardContentPathsHeaderSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); + std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); // QtProjectWizzardContent implementation virtual void load() override; @@ -110,7 +112,7 @@ class QtProjectWizzardContentPathsHeaderSearchGlobal : public QtProjectWizzardContentPaths { public: - QtProjectWizzardContentPathsHeaderSearchGlobal(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsHeaderSearchGlobal(QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void load() override; @@ -123,7 +125,7 @@ class QtProjectWizzardContentPathsFrameworkSearch { public: QtProjectWizzardContentPathsFrameworkSearch( - std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); + std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); // QtProjectWizzardContent implementation virtual void load() override; @@ -136,7 +138,7 @@ class QtProjectWizzardContentPathsFrameworkSearchGlobal : public QtProjectWizzardContentPaths { public: - QtProjectWizzardContentPathsFrameworkSearchGlobal(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsFrameworkSearchGlobal(QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void load() override; @@ -147,7 +149,7 @@ class QtProjectWizzardContentPathsClassJava : public QtProjectWizzardContentPaths { public: - QtProjectWizzardContentPathsClassJava(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathsClassJava(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void load() override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index 43899476..855803b6 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -8,9 +8,9 @@ #include "utility/utilityApp.h" QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences( - std::shared_ptr settings, QtProjectWizzardWindow* window + QtProjectWizzardWindow* window ) - : QtProjectWizzardContent(settings, window) + : QtProjectWizzardContent(window) , m_oldColorSchemeIndex(-1) { std::vector colorSchemePaths = diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h index 3afcb109..b70f9d58 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h @@ -16,7 +16,7 @@ class QtProjectWizzardContentPreferences Q_OBJECT public: - QtProjectWizzardContentPreferences(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPreferences(QtProjectWizzardWindow* window); ~QtProjectWizzardContentPreferences(); // QtProjectWizzardContent implementation diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index b2d5527b..5e421c75 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -9,15 +9,10 @@ #include "utility/ResourcePaths.h" #include "utility/utilityString.h" -#include "utility/solution/SolutionParserManager.h" - QtProjectWizzardContentSelect::QtProjectWizzardContentSelect( - std::shared_ptr settings, - QtProjectWizzardWindow* window, - std::weak_ptr solutionParserManager + QtProjectWizzardWindow* window ) - : QtProjectWizzardContent(settings, window) - , m_solutionParserManager(solutionParserManager) + : QtProjectWizzardContent(window) { } @@ -25,40 +20,40 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) { struct ProjectInfo { - ProjectInfo(ProjectType type) :type(type) {} - const ProjectType type; + ProjectInfo(SourceGroupType type) :type(type) {} + const SourceGroupType type; }; // define which kind of projects are available for each language std::map> projectInfos; - projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_C_EMPTY)); - projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_CDB)); - projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_VS)); - projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CPP_EMPTY)); - projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_CDB)); - projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_VS)); - projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_EMPTY)); - projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_MAVEN)); + projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_C_EMPTY)); + projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_CXX_CDB)); + projectInfos[LANGUAGE_C].push_back(ProjectInfo(SOURCE_GROUP_CXX_VS)); + projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CPP_EMPTY)); + projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CXX_CDB)); + projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(SOURCE_GROUP_CXX_VS)); + projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(SOURCE_GROUP_JAVA_EMPTY)); + projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(SOURCE_GROUP_JAVA_MAVEN)); // define which icons should be used for which kind of project - m_projectTypeIconName[PROJECT_C_EMPTY] = "empty_icon"; - m_projectTypeIconName[PROJECT_CPP_EMPTY] = "empty_icon"; - m_projectTypeIconName[PROJECT_CXX_CDB] = "cdb_icon"; - m_projectTypeIconName[PROJECT_CXX_VS] = "vs_icon"; - m_projectTypeIconName[PROJECT_JAVA_EMPTY] = "empty_icon"; - m_projectTypeIconName[PROJECT_JAVA_MAVEN] = "mvn_icon"; + m_projectTypeIconName[SOURCE_GROUP_C_EMPTY] = "empty_icon"; + m_projectTypeIconName[SOURCE_GROUP_CPP_EMPTY] = "empty_icon"; + m_projectTypeIconName[SOURCE_GROUP_CXX_CDB] = "cdb_icon"; + m_projectTypeIconName[SOURCE_GROUP_CXX_VS] = "vs_icon"; + m_projectTypeIconName[SOURCE_GROUP_JAVA_EMPTY] = "empty_icon"; + m_projectTypeIconName[SOURCE_GROUP_JAVA_MAVEN] = "mvn_icon"; // define descriptions for each kind of project - m_projectTypeDescriptions[PROJECT_C_EMPTY] = "Create a new Coati project by defining which C files will be indexed."; - m_projectTypeDescriptions[PROJECT_CPP_EMPTY] = "Create a new Coati project by defining which C++ files will be indexed."; - m_projectTypeDescriptions[PROJECT_CXX_CDB] = "Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and " + m_projectTypeDescriptions[SOURCE_GROUP_C_EMPTY] = "Create a new Coati project by defining which C files will be indexed."; + m_projectTypeDescriptions[SOURCE_GROUP_CPP_EMPTY] = "Create a new Coati project by defining which C++ files will be indexed."; + m_projectTypeDescriptions[SOURCE_GROUP_CXX_CDB] = "Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and " "CMake projects. Have a look at the " "documentation to find out more."; - m_projectTypeDescriptions[PROJECT_CXX_VS] = "Create a new project from an existing Visual Studio Solution file. " + m_projectTypeDescriptions[SOURCE_GROUP_CXX_VS] = "Create a new project from an existing Visual Studio Solution file. " "Note: Requires a running Visual Studio instance with the " "Visual Studio plugin installed."; - m_projectTypeDescriptions[PROJECT_JAVA_EMPTY] = "Create a new Coati project by defining which Java files will be indexed."; - m_projectTypeDescriptions[PROJECT_JAVA_MAVEN] = "Create a new project from an existing Maven project."; + m_projectTypeDescriptions[SOURCE_GROUP_JAVA_EMPTY] = "Create a new Coati project by defining which Java files will be indexed."; + m_projectTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new project from an existing Maven project."; QVBoxLayout* vlayout = new QVBoxLayout(); vlayout->setContentsMargins(0, 30, 0, 0); @@ -115,10 +110,10 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) for (auto projectIt: languageIt.second) { QToolButton* b = createProjectButton( - utility::insertLineBreaksAtBlankSpaces(projectTypeToString(projectIt.type), 15).c_str(), + utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToString(projectIt.type), 15).c_str(), (ResourcePaths::getGuiPath() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str() ); - b->setProperty("project_type", int(projectIt.type)); + b->setProperty("source_group_type", int(projectIt.type)); projectButtons->addButton(b); hlayout->addWidget(b); } @@ -131,15 +126,15 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) connect(it.second, static_cast(&QButtonGroup::buttonClicked), [this](QAbstractButton* button) { - ProjectType selectedProject = PROJECT_UNKNOWN; + SourceGroupType selectedType = SOURCE_GROUP_UNKNOWN; bool ok = false; - int projectTypeInt = button->property("project_type").toInt(&ok); + int selectedTypeInt = button->property("source_group_type").toInt(&ok); if (ok) { - selectedProject = ProjectType(projectTypeInt); + selectedType = SourceGroupType(selectedTypeInt); } - m_description->setText(m_projectTypeDescriptions[selectedProject].c_str()); + m_description->setText(m_projectTypeDescriptions[selectedType].c_str()); m_window->setNextEnabled(true); } @@ -175,22 +170,22 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentSelect::save() { - ProjectType type; + SourceGroupType selectedType; for (auto it: m_buttons) { if (QAbstractButton* b = it.second->checkedButton()) { bool ok = false; - int projectType = b->property("project_type").toInt(&ok); + int selectedTypeInt = b->property("source_group_type").toInt(&ok); if (ok) { - type = ProjectType(projectType); + selectedType = SourceGroupType(selectedTypeInt); break; } } } - emit selected(type); + emit selected(selectedType); } bool QtProjectWizzardContentSelect::check() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h index 65624ca7..72c96ba3 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h @@ -2,6 +2,7 @@ #define QT_PROJECT_WIZZARD_CONTENT_SELECT_H #include "qt/window/project_wizzard/QtProjectWizzardContent.h" +#include "settings/SourceGroupType.h" class QButtonGroup; class SolutionParserManager; @@ -12,10 +13,7 @@ class QtProjectWizzardContentSelect Q_OBJECT public: - QtProjectWizzardContentSelect( - std::shared_ptr settings, - QtProjectWizzardWindow* window, - std::weak_ptr solutionParserManager); + QtProjectWizzardContentSelect(QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -24,7 +22,7 @@ public: virtual bool check() override; signals: - void selected(ProjectType); + void selected(SourceGroupType); private: QButtonGroup* m_languages; @@ -33,10 +31,9 @@ private: QLabel* m_title; QLabel* m_description; - std::map m_projectTypeIconName; - std::map m_projectTypeDescriptions; + std::map m_projectTypeIconName; + std::map m_projectTypeDescriptions; - std::weak_ptr m_solutionParserManager; std::vector m_solutionDescription; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp index 7d4f888a..2e5415b0 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp @@ -3,10 +3,11 @@ #include #include -#include "settings/CxxProjectSettings.h" +#include "settings/SourceGroupSettingsCxx.h" -QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContent(settings, window) +QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window) + : QtProjectWizzardContent(window) + , m_settings(settings) , m_checkBox(nullptr) { } @@ -34,7 +35,7 @@ void QtProjectWizzardContentSimple::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentSimple::load() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { m_checkBox->setChecked(cxxSettings->getUseSourcePathsForHeaderSearch()); @@ -43,7 +44,7 @@ void QtProjectWizzardContentSimple::load() void QtProjectWizzardContentSimple::save() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); if (cxxSettings) { cxxSettings->setUseSourcePathsForHeaderSearch(m_checkBox->isChecked()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h index 7af17fea..a1950c9f 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h @@ -12,7 +12,7 @@ class QtProjectWizzardContentSimple Q_OBJECT public: - QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -21,6 +21,8 @@ public: virtual void save() override; private: + std::shared_ptr m_settings; + QCheckBox* m_checkBox; QLabel* m_title; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp index a3840899..ac2e9b32 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp @@ -1,9 +1,9 @@ #include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h" QtProjectWizzardContentSummary::QtProjectWizzardContentSummary( - std::shared_ptr settings, QtProjectWizzardWindow* window + QtProjectWizzardWindow* window ) - : QtProjectWizzardContent(settings, window) + : QtProjectWizzardContent(window) , m_isForm(false) { } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h index 671f158e..1848e698 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h @@ -11,7 +11,7 @@ class QtProjectWizzardContentSummary Q_OBJECT public: - QtProjectWizzardContentSummary(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentSummary(QtProjectWizzardWindow* window); void addContent(QtProjectWizzardContent* content); void addSpace(); diff --git a/src/lib_java/CMakeLists.txt b/src/lib_java/CMakeLists.txt index 492e6a8e..edcbed73 100644 --- a/src/lib_java/CMakeLists.txt +++ b/src/lib_java/CMakeLists.txt @@ -16,11 +16,11 @@ add_files( data/parser/java/JavaEnvironmentFactory.cpp data/parser/java/JavaEnvironmentFactory.h + project/SourceGroupJava.cpp + project/SourceGroupJava.h + project/SourceGroupFactoryModuleJava.cpp + project/SourceGroupFactoryModuleJava.h + utility/utilityMaven.cpp utility/utilityMaven.h - - JavaProject.cpp - JavaProject.h - ProjectFactoryModuleJava.cpp - ProjectFactoryModuleJava.h ) diff --git a/src/lib_java/JavaProject.h b/src/lib_java/JavaProject.h deleted file mode 100644 index f097df51..00000000 --- a/src/lib_java/JavaProject.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef JAVA_PROJECT_H -#define JAVA_PROJECT_H - -#include - -#include "settings/JavaProjectSettings.h" -#include "Project.h" - -class JavaProject: public Project -{ -public: - JavaProject( - std::shared_ptr projectSettings, - StorageAccessProxy* storageAccessProxy, - std::shared_ptr dialogView - ); - virtual ~JavaProject(); - -protected: - virtual std::shared_ptr getProjectSettings(); - virtual const std::shared_ptr getProjectSettings() const; - -private: - JavaProject(const JavaProject&); - - virtual bool prepareIndexing(); - - virtual std::vector> getIndexerCommands(); - - virtual void updateFileManager(FileManager& fileManager); - - void fetchRootDirectories(); - - std::shared_ptr m_projectSettings; - std::shared_ptr> m_rootDirectories; - - friend Project; -}; - -#endif // JAVA_PROJECT_H diff --git a/src/lib_java/ProjectFactoryModuleJava.cpp b/src/lib_java/ProjectFactoryModuleJava.cpp deleted file mode 100644 index 5d013969..00000000 --- a/src/lib_java/ProjectFactoryModuleJava.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ProjectFactoryModuleJava.h" - -#include "settings/LanguageType.h" -#include "JavaProject.h" - -ProjectFactoryModuleJava::~ProjectFactoryModuleJava() -{ -} - -LanguageType ProjectFactoryModuleJava::getLanguage() const -{ - return LANGUAGE_JAVA; -} - -std::shared_ptr ProjectFactoryModuleJava::createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView -) -{ - return std::shared_ptr(new JavaProject( - std::make_shared(projectSettingsFile), storageAccessProxy, dialogView)); -} diff --git a/src/lib_java/ProjectFactoryModuleJava.h b/src/lib_java/ProjectFactoryModuleJava.h deleted file mode 100644 index 65a12393..00000000 --- a/src/lib_java/ProjectFactoryModuleJava.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef PROJECT_FACTORY_MODULE_JAVA_H -#define PROJECT_FACTORY_MODULE_JAVA_H - -#include "ProjectFactoryModule.h" - -class ProjectFactoryModuleJava: public ProjectFactoryModule -{ -public: - virtual ~ProjectFactoryModuleJava(); - virtual LanguageType getLanguage() const; - - virtual std::shared_ptr createProject( - const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView - ); -}; - -#endif // PROJECT_FACTORY_MODULE_JAVA_H diff --git a/src/lib_java/project/SourceGroupFactoryModuleJava.cpp b/src/lib_java/project/SourceGroupFactoryModuleJava.cpp new file mode 100644 index 00000000..9246126c --- /dev/null +++ b/src/lib_java/project/SourceGroupFactoryModuleJava.cpp @@ -0,0 +1,30 @@ +#include "project/SourceGroupFactoryModuleJava.h" + +#include "project/SourceGroupJava.h" + +SourceGroupFactoryModuleJava::~SourceGroupFactoryModuleJava() +{ +} + +bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const +{ + switch (type) + { + case SOURCE_GROUP_JAVA_EMPTY: + case SOURCE_GROUP_JAVA_MAVEN: + return true; + default: + break; + } + return false; +} + +std::shared_ptr SourceGroupFactoryModuleJava::createSourceGroup(std::shared_ptr settings) +{ + std::shared_ptr sourceGroup; + if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupJava(javaSettings)); + } + return sourceGroup; +} diff --git a/src/lib_java/project/SourceGroupFactoryModuleJava.h b/src/lib_java/project/SourceGroupFactoryModuleJava.h new file mode 100644 index 00000000..0d82bd34 --- /dev/null +++ b/src/lib_java/project/SourceGroupFactoryModuleJava.h @@ -0,0 +1,14 @@ +#ifndef SOURCE_GROUP_FACTORY_MODULE_JAVA_H +#define SOURCE_GROUP_FACTORY_MODULE_JAVA_H + +#include "project/SourceGroupFactoryModule.h" + +class SourceGroupFactoryModuleJava: public SourceGroupFactoryModule +{ +public: + virtual ~SourceGroupFactoryModuleJava(); + virtual bool supports(SourceGroupType type) const; + virtual std::shared_ptr createSourceGroup(std::shared_ptr settings); +}; + +#endif // SOURCE_GROUP_FACTORY_MODULE_JAVA_H diff --git a/src/lib_java/JavaProject.cpp b/src/lib_java/project/SourceGroupJava.cpp similarity index 58% rename from src/lib_java/JavaProject.cpp rename to src/lib_java/project/SourceGroupJava.cpp index e897716a..87e3dc81 100644 --- a/src/lib_java/JavaProject.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -1,48 +1,116 @@ -#include "JavaProject.h" +#include "project/SourceGroupJava.h" #include "component/view/DialogView.h" #include "data/indexer/IndexerCommandJava.h" #include "data/parser/java/JavaEnvironmentFactory.h" #include "data/parser/java/JavaEnvironment.h" +#include "settings/ApplicationSettings.h" #include "utility/file/FileRegister.h" #include "utility/file/FileSystem.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/text/TextAccess.h" +#include "utility/ScopedFunctor.h" #include "utility/ResourcePaths.h" #include "utility/utilityMaven.h" #include "utility/utilityString.h" +#include "utility/utility.h" #include "Application.h" -#include "settings/ApplicationSettings.h" -#include "utility/tracing.h" -#include "utility/ScopedFunctor.h" -JavaProject::JavaProject( - std::shared_ptr projectSettings, StorageAccessProxy* storageAccessProxy, std::shared_ptr dialogView -) - : Project(storageAccessProxy, dialogView) - , m_projectSettings(projectSettings) +SourceGroupJava::SourceGroupJava(std::shared_ptr settings) + : m_settings(settings) { } -JavaProject::~JavaProject() +SourceGroupJava::~SourceGroupJava() { } -std::shared_ptr JavaProject::getProjectSettings() +SourceGroupType SourceGroupJava::getType() const { - return m_projectSettings; + return m_settings->getType(); } -const std::shared_ptr JavaProject::getProjectSettings() const +bool SourceGroupJava::prepareIndexing() { - return m_projectSettings; + if (!prepareJavaEnvironment()) + { + return false; + } + + if (!prepareMavenData()) + { + return false; + } + + return true; } -bool JavaProject::prepareIndexing() +void SourceGroupJava::fetchAllSourceFilePaths() { - m_rootDirectories.reset(); + std::vector sourcePaths; + if (m_settings->getAbsoluteMavenProjectFilePath().exists()) + { + if (Application::getInstance()->hasGUI()) + { + Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories"); + } + const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); + const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory(); + sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests()); + + if (Application::getInstance()->hasGUI()) + { + Application::getInstance()->getDialogView()->hideStatusDialog(); + } + } + 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> SourceGroupJava::getIndexerCommands(const bool fullRefresh) +{ + std::vector classPath = getClassPath(); + + std::set indexedPaths; + for (FilePath p: m_settings->getAbsoluteSourcePaths()) + { + if (p.exists()) + { + indexedPaths.insert(p); + } + } + + std::set excludedPaths; + for (FilePath p: m_settings->getAbsoluteExcludePaths()) + { + if (p.exists()) + { + excludedPaths.insert(p); + } + } + + std::vector> indexerCommands; + + const std::set& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex()); + for (const FilePath& sourcePath: sourceFilePathsToIndex) + { + indexerCommands.push_back(std::make_shared(sourcePath, indexedPaths, excludedPaths, classPath)); + } + + return indexerCommands; +} + +bool SourceGroupJava::prepareJavaEnvironment() +{ std::string errorString; if (!JavaEnvironmentFactory::getInstance()) { @@ -86,19 +154,23 @@ bool JavaProject::prepareIndexing() Application::getInstance()->handleDialog(dialogMessage); return false; } + return true; +} - if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists()) +bool SourceGroupJava::prepareMavenData() +{ + if (m_settings->getAbsoluteMavenProjectFilePath().exists()) { const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); - const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory(); + const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory(); if (Application::getInstance()->hasGUI()) { - ScopedFunctor dialogHider([this](){ - getDialogView()->hideStatusDialog(); + ScopedFunctor dialogHider([](){ + Application::getInstance()->getDialogView()->hideStatusDialog(); }); - getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files"); + Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files"); bool success = utility::mavenGenerateSources( mavenPath, projectRootPath ); @@ -115,21 +187,22 @@ bool JavaProject::prepareIndexing() return false; } - getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies"); + Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies"); } utility::mavenCopyDependencies( - mavenPath, projectRootPath, m_projectSettings->getAbsoluteMavenDependenciesDirectory() + mavenPath, projectRootPath, m_settings->getAbsoluteMavenDependenciesDirectory() ); } return true; } -std::vector> JavaProject::getIndexerCommands() + +std::vector SourceGroupJava::getClassPath() { std::vector classPath; - for (const FilePath& p: m_projectSettings->getAbsoluteClasspaths()) + for (const FilePath& p: m_settings->getAbsoluteClasspaths()) { if (p.exists()) { @@ -137,11 +210,11 @@ std::vector> JavaProject::getIndexerCommands() } } - if (m_projectSettings->getAbsoluteMavenDependenciesDirectory().exists()) + if (m_settings->getAbsoluteMavenDependenciesDirectory().exists()) { const std::vector dependencies = FileSystem::getFileNamesFromDirectory( - m_projectSettings->getAbsoluteMavenDependenciesDirectory().str(), - std::vector(1, ".jar") + m_settings->getAbsoluteMavenDependenciesDirectory().str(), + utility::createVectorFromElements(".jar") ); for (const std::string& dependency: dependencies) { @@ -149,20 +222,7 @@ std::vector> JavaProject::getIndexerCommands() } } - if (!m_rootDirectories) - { - if (Application::getInstance()->hasGUI()) - { - getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories"); - } - fetchRootDirectories(); - if (Application::getInstance()->hasGUI()) - { - getDialogView()->hideStatusDialog(); - } - } - - for (FilePath rootDirectory: *(m_rootDirectories.get())) + for (FilePath rootDirectory: fetchRootDirectories()) { if (rootDirectory.exists()) { @@ -170,76 +230,20 @@ std::vector> JavaProject::getIndexerCommands() } } - std::set indexedPaths; - for (FilePath p: m_projectSettings->getAbsoluteSourcePaths()) - { - if (p.exists()) - { - indexedPaths.insert(p); - } - } - - std::set excludedPaths; - for (FilePath p: m_projectSettings->getAbsoluteExcludePaths()) - { - if (p.exists()) - { - excludedPaths.insert(p); - } - } - - std::vector> indexerCommands; - for (const FilePath& sourcePath: getSourceFilePaths()) - { - indexerCommands.push_back(std::make_shared(sourcePath, indexedPaths, excludedPaths, classPath)); - } - - return indexerCommands; + return classPath; } -void JavaProject::updateFileManager(FileManager& fileManager) +std::set SourceGroupJava::fetchRootDirectories() { - std::vector sourcePaths; - if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists()) + if (Application::getInstance()->hasGUI()) { - - if (Application::getInstance()->hasGUI()) - { - getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories"); - } - - const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); - const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory(); - sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_projectSettings->getShouldIndexMavenTests()); - - - if (Application::getInstance()->hasGUI()) - { - getDialogView()->hideStatusDialog(); - } + Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories"); } - else - { - sourcePaths = m_projectSettings->getAbsoluteSourcePaths(); - } - std::vector headerPaths = sourcePaths; - std::vector sourceExtensions = m_projectSettings->getSourceExtensions(); - std::vector excludePaths = m_projectSettings->getAbsoluteExcludePaths(); - fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions); -} + std::set rootDirectories; -void JavaProject::fetchRootDirectories() -{ - m_rootDirectories = std::make_shared>(); - - FileManager fileManager; - updateFileManager(fileManager); - - FileManager::FileSets fileSets = fileManager.fetchFilePaths(std::vector()); std::shared_ptr javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment(); - - for (FilePath filePath: fileSets.addedFiles) + for (FilePath filePath: m_allSourceFilePaths) { std::shared_ptr textAccess = TextAccess::createFromFile(filePath.str()); @@ -267,7 +271,14 @@ void JavaProject::fetchRootDirectories() if (success) { - m_rootDirectories->insert(rootPath); + rootDirectories.insert(rootPath); } } + + if (Application::getInstance()->hasGUI()) + { + Application::getInstance()->getDialogView()->hideStatusDialog(); + } + + return rootDirectories; } diff --git a/src/lib_java/project/SourceGroupJava.h b/src/lib_java/project/SourceGroupJava.h new file mode 100644 index 00000000..8d9f7f26 --- /dev/null +++ b/src/lib_java/project/SourceGroupJava.h @@ -0,0 +1,35 @@ +#ifndef SOURCE_GROUP_JAVA_H +#define SOURCE_GROUP_JAVA_H + +#include +#include + +#include "settings/SourceGroupSettingsJava.h" +#include "project/SourceGroup.h" +#include "utility/file/FileManager.h" + +class SourceGroupJava: public SourceGroup +{ +public: + SourceGroupJava(std::shared_ptr settings); + virtual ~SourceGroupJava(); + + virtual SourceGroupType getType() const; + + virtual bool prepareIndexing(); + + virtual void fetchAllSourceFilePaths(); + + virtual std::vector> getIndexerCommands(const bool fullRefresh); + +private: + bool prepareJavaEnvironment(); + bool prepareMavenData(); + + std::vector getClassPath(); + std::set fetchRootDirectories(); + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_JAVA_H diff --git a/src/test/FileManagerTestSuite.h b/src/test/FileManagerTestSuite.h index a0821f08..f53a402f 100644 --- a/src/test/FileManagerTestSuite.h +++ b/src/test/FileManagerTestSuite.h @@ -17,9 +17,9 @@ public: sourceExtensions.push_back(".c"); FileManager fm; - fm.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions); - FileManager::FileSets fileSets = fm.fetchFilePaths(std::vector()); + fm.update(sourcePaths, excludePaths, sourceExtensions); + std::set filePaths = fm.getAllSourceFilePaths(); - TS_ASSERT_EQUALS(fileSets.addedFiles.size(), 2); + TS_ASSERT_EQUALS(filePaths.size(), 2); } }; diff --git a/src/test/SettingsMigratorTestSuite.h b/src/test/SettingsMigratorTestSuite.h index d6b0deef..2a518b26 100644 --- a/src/test/SettingsMigratorTestSuite.h +++ b/src/test/SettingsMigratorTestSuite.h @@ -1,7 +1,9 @@ #include #include "settings/Settings.h" -#include "settings/SettingsMigrator.h" +#include "settings/migration/SettingsMigrator.h" +#include "settings/migration/MigrationLambda.h" +#include "settings/migration/MigrationMoveKey.h" class SettingsMigratorTestSuite : public CxxTest::TestSuite { @@ -47,7 +49,7 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "int"); + migrator.addMigration(1, std::make_shared("value", "int")); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -73,7 +75,7 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "sub/int"); + migrator.addMigration(1, std::make_shared("value", "sub/int")); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -105,7 +107,7 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "values/value", "vals/value"); + migrator.addMigration(1, std::make_shared("values/value", "vals/value")); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -137,7 +139,7 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "values/value", "values/val"); + migrator.addMigration(1, std::make_shared("values/value", "values/val")); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -161,8 +163,8 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "int"); - migrator.addMigration(2, "int", "val"); + migrator.addMigration(1, std::make_shared("value", "int")); + migrator.addMigration(2, std::make_shared("int", "val")); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -187,8 +189,8 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "int"); - migrator.addMigration(2, "int", "val"); + migrator.addMigration(1, std::make_shared("value", "int")); + migrator.addMigration(2, std::make_shared("int", "val")); migrator.migrate(&settingsBefore, 2); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -212,8 +214,8 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "int"); - migrator.addMigration(2, "int", "val"); + migrator.addMigration(1, std::make_shared("value", "int")); + migrator.addMigration(2, std::make_shared("int", "val")); migrator.migrate(&settingsBefore, 2); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -239,8 +241,8 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "val"); - migrator.addMigration(1, "element", "ele"); + migrator.addMigration(1, std::make_shared("value", "val")); + migrator.addMigration(1, std::make_shared("element", "ele")); migrator.migrate(&settingsBefore, 2); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -272,10 +274,10 @@ public: ); SettingsMigrator migrator; - migrator.addMigration(1, "value", "int/val"); - migrator.addMigration(1, "element", "ele"); - migrator.addMigration(2, "int/val", "int"); - migrator.addMigration(3, "ele", "elements/element"); + migrator.addMigration(1, std::make_shared("value", "int/val")); + migrator.addMigration(1, std::make_shared("element", "ele")); + migrator.addMigration(2, std::make_shared("int/val", "int")); + migrator.addMigration(3, std::make_shared("ele", "elements/element")); migrator.migrate(&settingsBefore, 3); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -299,14 +301,13 @@ public: ); SettingsMigrator migrator; - migrator.addLambdaMigration( - 1, - [](Settings* settings) + migrator.addMigration( + 1, std::make_shared( + [](const Migration* migration, Settings* settings) { - TestSettings* test = dynamic_cast(settings); - test->set("value", test->get("value") * 2); + migration->setValueInSettings(settings, "value", migration->getValueFromSettings(settings, "value", 0) * 2); } - ); + )); migrator.migrate(&settingsBefore, 1); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -330,22 +331,20 @@ public: ); SettingsMigrator migrator; - migrator.addLambdaMigration( - 1, - [](Settings* settings) + migrator.addMigration( + 1, std::make_shared( + [](const Migration* migration, Settings* settings) { - TestSettings* test = dynamic_cast(settings); - test->set("value", test->get("value") * 2); + migration->setValueInSettings(settings, "value", migration->getValueFromSettings(settings, "value", 0) * 2); } - ); - migrator.addLambdaMigration( - 2, - [](Settings* settings) + )); + migrator.addMigration( + 2, std::make_shared( + [](const Migration* migration, Settings* settings) { - TestSettings* test = dynamic_cast(settings); - test->set("value", test->get("value") - 1); + migration->setValueInSettings(settings, "value", migration->getValueFromSettings(settings, "value", 0) - 1); } - ); + )); migrator.migrate(&settingsBefore, 2); TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText()); @@ -372,16 +371,6 @@ private: return ""; } - - int get(const std::string& key) - { - return getValue(key, 0); - } - - void set(const std::string& key, int value) - { - setValue(key, value); - } }; TestSettings createSettings(const std::string& text) diff --git a/src/test/SettingsTestSuite.h b/src/test/SettingsTestSuite.h index 221dfee4..a9913fc6 100644 --- a/src/test/SettingsTestSuite.h +++ b/src/test/SettingsTestSuite.h @@ -1,8 +1,8 @@ #include #include "settings/ProjectSettings.h" -#include "settings/CxxProjectSettings.h" #include "settings/Settings.h" +#include "settings/SourceGroupSettingsCxx.h" class SettingsTestSuite : public CxxTest::TestSuite { @@ -115,9 +115,10 @@ public: void test_load_source_path_from_file() { - ProjectSettings settings; - settings.load(FilePath("data/SettingsTestSuite/settings.xml")); - std::vector paths = settings.getSourcePaths(); + ProjectSettings projectSettings; + projectSettings.load(FilePath("data/SettingsTestSuite/settings.xml")); + std::shared_ptr sourceGroupSettings = std::dynamic_pointer_cast(projectSettings.getAllSourceGroupSettings().front()); + std::vector paths = sourceGroupSettings->getSourcePaths(); TS_ASSERT_EQUALS(paths.size(), 1); TS_ASSERT_EQUALS(paths[0].str(), "data"); @@ -125,9 +126,10 @@ public: void test_load_header_search_paths_from_file() { - CxxProjectSettings settings; - settings.load(FilePath("data/SettingsTestSuite/settings.xml")); - std::vector paths = settings.getHeaderSearchPaths(); + ProjectSettings projectSettings; + projectSettings.load(FilePath("data/SettingsTestSuite/settings.xml")); + std::shared_ptr sourceGroupSettings = std::dynamic_pointer_cast(projectSettings.getAllSourceGroupSettings().front()); + std::vector paths = sourceGroupSettings->getHeaderSearchPaths(); TS_ASSERT_EQUALS(paths.size(), 2); TS_ASSERT_EQUALS(paths[0].str(), "data/");