diff --git a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp index 3476e332..51305e28 100644 --- a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp @@ -1,6 +1,7 @@ #include "project/SourceGroupCxxCodeblocks.h" -#include "data/indexer/IndexerCommand.h" +#include "data/indexer/CxxIndexerCommandProvider.h" +#include "data/indexer/IndexerCommandCxx.h" #include "settings/ApplicationSettings.h" #include "settings/SourceGroupSettingsCxxCodeblocks.h" #include "utility/messaging/type/MessageStatus.h" @@ -76,22 +77,28 @@ std::set SourceGroupCxxCodeblocks::getAllSourceFilePaths() const return sourceFilePaths; } -std::vector> SourceGroupCxxCodeblocks::getIndexerCommands(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxCodeblocks::getIndexerCommandProvider(const std::set& filesToIndex) const { - std::vector> indexerCommands; + std::shared_ptr provider = std::make_shared(); + if (std::shared_ptr project = Codeblocks::Project::load( m_settings->getCodeblocksProjectPathExpandedAndAbsolute() )) { - for (std::shared_ptr indexerCommand: project->getIndexerCommands(m_settings, ApplicationSettings::getInstance())) + for (std::shared_ptr indexerCommand: project->getIndexerCommands(m_settings, ApplicationSettings::getInstance())) { if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) { - indexerCommands.push_back(indexerCommand); + provider->addCommand(indexerCommand); } } } - return indexerCommands; + return provider; +} + +std::vector> SourceGroupCxxCodeblocks::getIndexerCommands(const std::set& filesToIndex) const +{ + return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxCodeblocks::getSourceGroupSettings() diff --git a/src/lib_cxx/project/SourceGroupCxxCodeblocks.h b/src/lib_cxx/project/SourceGroupCxxCodeblocks.h index 2ace02e7..9293b404 100644 --- a/src/lib_cxx/project/SourceGroupCxxCodeblocks.h +++ b/src/lib_cxx/project/SourceGroupCxxCodeblocks.h @@ -17,6 +17,7 @@ public: bool prepareIndexing() override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; + std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; std::vector> getIndexerCommands(const std::set& filesToIndex) const override; private: diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp index c9835778..6cff7b6d 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp @@ -1,5 +1,6 @@ #include "project/SourceGroupCxxEmpty.h" +#include "data/indexer/CxxIndexerCommandProvider.h" #include "data/indexer/IndexerCommandCxx.h" #include "settings/ApplicationSettings.h" #include "settings/SourceGroupSettingsCEmpty.h" @@ -65,7 +66,7 @@ std::set SourceGroupCxxEmpty::getAllSourceFilePaths() const return fileManager.getAllSourceFilePaths(); } -std::vector> SourceGroupCxxEmpty::getIndexerCommands(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxEmpty::getIndexerCommandProvider(const std::set& filesToIndex) const { std::shared_ptr appSettings = ApplicationSettings::getInstance(); @@ -139,12 +140,12 @@ std::vector> SourceGroupCxxEmpty::getIndexerComm compilerFlags.push_back(L"-std=" + languageStandard); - std::vector> indexerCommands; + std::shared_ptr provider = std::make_shared(); for (const FilePath& sourcePath: getAllSourceFilePaths()) { if (filesToIndex.find(sourcePath) != filesToIndex.end()) { - indexerCommands.push_back(std::make_shared( + provider->addCommand(std::make_shared( sourcePath, indexedPaths, excludeFilters, @@ -157,7 +158,12 @@ std::vector> SourceGroupCxxEmpty::getIndexerComm } } - return indexerCommands; + return provider; +} + +std::vector> SourceGroupCxxEmpty::getIndexerCommands(const std::set& filesToIndex) const +{ + return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxEmpty::getSourceGroupSettings() diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.h b/src/lib_cxx/project/SourceGroupCxxEmpty.h index 8065b646..c5cf8236 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.h +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.h @@ -15,6 +15,7 @@ public: std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; + std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; std::vector> getIndexerCommands(const std::set& filesToIndex) const override; private: diff --git a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp index f3294f82..8d023ce7 100644 --- a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp +++ b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp @@ -1,6 +1,7 @@ #include "project/SourceGroupCxxSonargraph.h" -#include "data/indexer/IndexerCommand.h" +#include "data/indexer/CxxIndexerCommandProvider.h" +#include "data/indexer/IndexerCommandCxx.h" #include "settings/ApplicationSettings.h" #include "settings/SourceGroupSettingsCxxSonargraph.h" #include "utility/messaging/type/MessageStatus.h" @@ -64,22 +65,30 @@ std::set SourceGroupCxxSonargraph::getAllSourceFilePaths() const return sourceFilePaths; } -std::vector> SourceGroupCxxSonargraph::getIndexerCommands(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxSonargraph::getIndexerCommandProvider(const std::set& filesToIndex) const { - std::vector> indexerCommands; + std::shared_ptr provider = std::make_shared(); if (std::shared_ptr project = Sonargraph::Project::load( m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage() )) { for (std::shared_ptr indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance())) { - if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) + if (std::shared_ptr indexerCommandCxx = std::dynamic_pointer_cast(indexerCommand)) { - indexerCommands.push_back(indexerCommand); + if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) + { + provider->addCommand(indexerCommandCxx); + } } } } - return indexerCommands; + return provider; +} + +std::vector> SourceGroupCxxSonargraph::getIndexerCommands(const std::set& filesToIndex) const +{ + return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxSonargraph::getSourceGroupSettings() diff --git a/src/lib_cxx/project/SourceGroupCxxSonargraph.h b/src/lib_cxx/project/SourceGroupCxxSonargraph.h index a8431454..e00804cd 100644 --- a/src/lib_cxx/project/SourceGroupCxxSonargraph.h +++ b/src/lib_cxx/project/SourceGroupCxxSonargraph.h @@ -17,6 +17,7 @@ public: bool prepareIndexing() override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; + std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; std::vector> getIndexerCommands(const std::set& filesToIndex) const override; private: diff --git a/src/lib_cxx/utility/codeblocks/CodeblocksProject.cpp b/src/lib_cxx/utility/codeblocks/CodeblocksProject.cpp index 061c5dfe..510116f6 100644 --- a/src/lib_cxx/utility/codeblocks/CodeblocksProject.cpp +++ b/src/lib_cxx/utility/codeblocks/CodeblocksProject.cpp @@ -192,7 +192,7 @@ namespace Codeblocks return paths; } - std::vector> Project::getIndexerCommands( + std::vector> Project::getIndexerCommands( std::shared_ptr sourceGroupSettings, std::shared_ptr appSettings) const { @@ -240,7 +240,7 @@ namespace Codeblocks return std::vector(); }); - std::vector> indexerCommands; + std::vector> indexerCommands; for (std::shared_ptr unit : m_units) { if (!unit || !unit->getCompile()) diff --git a/src/lib_cxx/utility/codeblocks/CodeblocksProject.h b/src/lib_cxx/utility/codeblocks/CodeblocksProject.h index 2eaa0250..a2050b1c 100644 --- a/src/lib_cxx/utility/codeblocks/CodeblocksProject.h +++ b/src/lib_cxx/utility/codeblocks/CodeblocksProject.h @@ -8,7 +8,7 @@ class ApplicationSettings; class FilePath; -class IndexerCommand; +class IndexerCommandCxx; class SourceGroupSettingsCxxCodeblocks; class SourceGroupSettingsWithSourceExtensions; class TextAccess; @@ -32,7 +32,7 @@ namespace Codeblocks ) const; std::set getAllCxxHeaderSearchPathsCanonical() const; - std::vector> getIndexerCommands( + std::vector> getIndexerCommands( std::shared_ptr sourceGroupSettings, std::shared_ptr appSettings) const;