logic: reduced memory consumption of indexer commands for empty, Sonargraph and Codeblocks Cxx sourcegroups

* use compressed format of CxxIndexerCommandProvider for these SourceGroups
This commit is contained in:
mlangkabel
2018-09-10 13:58:45 +02:00
parent cdbca77495
commit db85279b8c
8 changed files with 45 additions and 20 deletions
@@ -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<FilePath> SourceGroupCxxCodeblocks::getAllSourceFilePaths() const
return sourceFilePaths;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCodeblocks::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
std::shared_ptr<IndexerCommandProvider> SourceGroupCxxCodeblocks::getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
std::shared_ptr<CxxIndexerCommandProvider> provider = std::make_shared<CxxIndexerCommandProvider>();
if (std::shared_ptr<Codeblocks::Project> project = Codeblocks::Project::load(
m_settings->getCodeblocksProjectPathExpandedAndAbsolute()
))
{
for (std::shared_ptr<IndexerCommand> indexerCommand: project->getIndexerCommands(m_settings, ApplicationSettings::getInstance()))
for (std::shared_ptr<IndexerCommandCxx> 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<std::shared_ptr<IndexerCommand>> SourceGroupCxxCodeblocks::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
return getIndexerCommandProvider(filesToIndex)->consumeAllCommands();
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxxCodeblocks::getSourceGroupSettings()
@@ -17,6 +17,7 @@ public:
bool prepareIndexing() override;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::set<FilePath> getAllSourceFilePaths() const override;
std::shared_ptr<IndexerCommandProvider> getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const override;
private:
+10 -4
View File
@@ -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<FilePath> SourceGroupCxxEmpty::getAllSourceFilePaths() const
return fileManager.getAllSourceFilePaths();
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
std::shared_ptr<IndexerCommandProvider> SourceGroupCxxEmpty::getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const
{
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
@@ -139,12 +140,12 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
compilerFlags.push_back(L"-std=" + languageStandard);
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
std::shared_ptr<CxxIndexerCommandProvider> provider = std::make_shared<CxxIndexerCommandProvider>();
for (const FilePath& sourcePath: getAllSourceFilePaths())
{
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
indexerCommands.push_back(std::make_shared<IndexerCommandCxx>(
provider->addCommand(std::make_shared<IndexerCommandCxx>(
sourcePath,
indexedPaths,
excludeFilters,
@@ -157,7 +158,12 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
}
}
return indexerCommands;
return provider;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
return getIndexerCommandProvider(filesToIndex)->consumeAllCommands();
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxxEmpty::getSourceGroupSettings()
@@ -15,6 +15,7 @@ public:
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::set<FilePath> getAllSourceFilePaths() const override;
std::shared_ptr<IndexerCommandProvider> getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const override;
private:
@@ -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<FilePath> SourceGroupCxxSonargraph::getAllSourceFilePaths() const
return sourceFilePaths;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxSonargraph::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
std::shared_ptr<IndexerCommandProvider> SourceGroupCxxSonargraph::getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
std::shared_ptr<CxxIndexerCommandProvider> provider = std::make_shared<CxxIndexerCommandProvider>();
if (std::shared_ptr<Sonargraph::Project> project = Sonargraph::Project::load(
m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage()
))
{
for (std::shared_ptr<IndexerCommand> indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance()))
{
if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end())
if (std::shared_ptr<IndexerCommandCxx> indexerCommandCxx = std::dynamic_pointer_cast<IndexerCommandCxx>(indexerCommand))
{
indexerCommands.push_back(indexerCommand);
if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end())
{
provider->addCommand(indexerCommandCxx);
}
}
}
}
return indexerCommands;
return provider;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxSonargraph::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
return getIndexerCommandProvider(filesToIndex)->consumeAllCommands();
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxxSonargraph::getSourceGroupSettings()
@@ -17,6 +17,7 @@ public:
bool prepareIndexing() override;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::set<FilePath> getAllSourceFilePaths() const override;
std::shared_ptr<IndexerCommandProvider> getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const override;
private:
@@ -192,7 +192,7 @@ namespace Codeblocks
return paths;
}
std::vector<std::shared_ptr<IndexerCommand>> Project::getIndexerCommands(
std::vector<std::shared_ptr<IndexerCommandCxx>> Project::getIndexerCommands(
std::shared_ptr<const SourceGroupSettingsCxxCodeblocks> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
@@ -240,7 +240,7 @@ namespace Codeblocks
return std::vector<FilePath>();
});
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
std::vector<std::shared_ptr<IndexerCommandCxx>> indexerCommands;
for (std::shared_ptr<Unit> unit : m_units)
{
if (!unit || !unit->getCompile())
@@ -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<FilePath> getAllCxxHeaderSearchPathsCanonical() const;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::vector<std::shared_ptr<IndexerCommandCxx>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettingsCxxCodeblocks> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const;