logic: Allow duplicate indexing of source files if the indexer command is different

This commit is contained in:
Eberhard Graether
2017-11-09 17:24:28 +01:00
parent ae37145d22
commit ead9f9a634
10 changed files with 24 additions and 19 deletions
+11 -1
View File
@@ -4,11 +4,21 @@
#include <random>
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
void IndexerCommandList::addCommand(std::shared_ptr<IndexerCommand> command)
{
std::lock_guard<std::mutex> lock(m_commandsMutex);
m_commands.push_back(command);
std::string commandHash = command->getSourceFilePath().str() + std::to_string(command->getByteSize(1));
if (m_commandIndex.insert(commandHash).second == true) // Don't add duplicate indexer commands
{
m_commands.push_back(command);
}
else
{
LOG_WARNING_STREAM(<< "Duplicate indexer command was ignored: " << commandHash);
}
}
size_t IndexerCommandList::size() const
@@ -23,6 +23,8 @@ public:
private:
std::deque<std::shared_ptr<IndexerCommand>> m_commands;
std::mutex m_commandsMutex;
std::set<std::string> m_commandIndex;
};
#endif // INDEXER_COMMAND_LIST_H
+1 -2
View File
@@ -420,11 +420,10 @@ void Project::buildIndex(
));
}
std::set<FilePath> filesToIndexTemp = filesToIndex;
std::shared_ptr<IndexerCommandList> indexerCommandList = std::make_shared<IndexerCommandList>();
for (const std::shared_ptr<SourceGroup>& sourceGroup : m_sourceGroups)
{
for (const std::shared_ptr<IndexerCommand>& command : sourceGroup->getIndexerCommands(&filesToIndexTemp, fullRefresh))
for (const std::shared_ptr<IndexerCommand>& command : sourceGroup->getIndexerCommands(filesToIndex, fullRefresh))
{
indexerCommandList->addCommand(command);
}
+1 -1
View File
@@ -30,7 +30,7 @@ public:
std::set<FilePath> getSourceFilePathsToIndex() const;
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh) = 0;
const std::set<FilePath>& filesToIndex, bool fullRefresh) = 0;
protected:
std::set<FilePath> getIndexedPaths();
+2 -4
View File
@@ -48,7 +48,7 @@ bool SourceGroupCxxCdb::prepareRefresh()
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh)
const std::set<FilePath>& filesToIndex, bool fullRefresh)
{
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
@@ -100,7 +100,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical();
}
if (filesToIndex->find(sourcePath) != filesToIndex->end() &&
if (filesToIndex.find(sourcePath) != filesToIndex.end() &&
sourceFilePathsToIndex.find(sourcePath) != sourceFilePathsToIndex.end())
{
std::vector<std::string> currentCompilerFlags = compilerFlags;
@@ -116,8 +116,6 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
frameworkSearchPaths,
m_settings->getShouldApplyAnonymousTypedefTransformation()
));
filesToIndex->erase(sourcePath);
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ public:
virtual bool prepareRefresh();
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh);
const std::set<FilePath>& filesToIndex, bool fullRefresh);
private:
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx();
+2 -4
View File
@@ -19,7 +19,7 @@ SourceGroupType SourceGroupCxxEmpty::getType() const
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh)
const std::set<FilePath>& filesToIndex, bool fullRefresh)
{
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
@@ -59,7 +59,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (const FilePath& sourcePath: sourceFilePathsToIndex)
{
if (filesToIndex->find(sourcePath) != filesToIndex->end())
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
indexerCommands.push_back(std::make_shared<IndexerCommandCxxManual>(
sourcePath,
@@ -71,8 +71,6 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
compilerFlags,
m_settings->getShouldApplyAnonymousTypedefTransformation()
));
filesToIndex->erase(sourcePath);
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ public:
virtual SourceGroupType getType() const;
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh);
const std::set<FilePath>& filesToIndex, bool fullRefresh);
private:
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx();
+2 -4
View File
@@ -31,7 +31,7 @@ bool SourceGroupJava::prepareIndexing()
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh)
const std::set<FilePath>& filesToIndex, bool fullRefresh)
{
const std::string languageStandard = getSourceGroupSettingsJava()->getStandard();
@@ -44,12 +44,10 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (const FilePath& sourcePath: sourceFilePathsToIndex)
{
if (filesToIndex->find(sourcePath) != filesToIndex->end())
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
indexerCommands.push_back(
std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludedPaths, languageStandard, classPath));
filesToIndex->erase(sourcePath);
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ public:
virtual bool prepareIndexing();
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::set<FilePath>* filesToIndex, bool fullRefresh);
const std::set<FilePath>& filesToIndex, bool fullRefresh);
protected:
virtual std::vector<FilePath> doGetClassPath();