logic: sonargraph fixes

* updated sonargraph project icon
* fixed Sonargraph SourceGroup to only return indexer commands for requested files
* fixed refresh info generator to ignore non-existing files
This commit is contained in:
mlangkabel
2018-06-04 19:05:54 +02:00
parent 12bf007caf
commit 3cc51e0d01
6 changed files with 47 additions and 15 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

+8 -1
View File
@@ -35,7 +35,14 @@ void IndexerCommandList::shuffle()
std::vector<PairType> sourceFileSizesToCommands;
for (std::shared_ptr<IndexerCommand> command: m_commands)
{
sourceFileSizesToCommands.push_back(std::make_pair(FileSystem::getFileByteSize(command->getSourceFilePath()), command));
if (command->getSourceFilePath().exists())
{
sourceFileSizesToCommands.push_back(std::make_pair(FileSystem::getFileByteSize(command->getSourceFilePath()), command));
}
else
{
sourceFileSizesToCommands.push_back(std::make_pair(1, command));
}
}
std::sort(sourceFileSizesToCommands.begin(), sourceFileSizesToCommands.end(), [](const PairType& p, const PairType& q){ return p.first > q.first; });
+7 -1
View File
@@ -170,7 +170,13 @@ std::set<FilePath> RefreshInfoGenerator::getAllSourceFilePaths(const std::vector
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(allSourceFilePaths, sourceGroup->getAllSourceFilePaths());
for (const FilePath& sourceFilePath : sourceGroup->getAllSourceFilePaths())
{
if (sourceFilePath.exists())
{
allSourceFilePaths.insert(sourceFilePath);
}
}
}
}
@@ -1,5 +1,6 @@
#include "project/SourceGroupCxxSonargraph.h"
#include "data/indexer/IndexerCommand.h"
#include "settings/ApplicationSettings.h"
#include "settings/SourceGroupSettingsCxxSonargraph.h"
#include "utility/messaging/type/MessageStatus.h"
@@ -66,7 +67,13 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxSonargraph::getIndexe
m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage()
))
{
indexerCommands = project->getIndexerCommands(m_settings, ApplicationSettings::getInstance());
for (std::shared_ptr<IndexerCommand> indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance()))
{
if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end())
{
indexerCommands.push_back(indexerCommand);
}
}
}
return indexerCommands;
}
@@ -75,7 +75,13 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJavaSonargraph::getIndex
m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage()
))
{
indexerCommands = project->getIndexerCommands(m_settings, ApplicationSettings::getInstance());
for (std::shared_ptr<IndexerCommand> indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance()))
{
if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end())
{
indexerCommands.push_back(indexerCommand);
}
}
}
if (!indexerCommands.empty())
+17 -11
View File
@@ -31,21 +31,27 @@ public:
void test_refresh_info_for_all_files_has_nothing_to_clear_and_specified_source_files_for_basic_sourcegroup()
{
const FilePath sourceFilePath = m_sourceFolder.getConcatenated(L"main.cpp");
cleanup();
{
const FilePath sourceFilePath = m_sourceFolder.getConcatenated(L"main.cpp");
std::vector<std::shared_ptr<SourceGroup>> sourceGroups;
sourceGroups.push_back(std::shared_ptr<SourceGroupTest>(new SourceGroupTest({ sourceFilePath })));
std::vector<std::shared_ptr<SourceGroup>> sourceGroups;
sourceGroups.push_back(std::shared_ptr<SourceGroupTest>(new SourceGroupTest({ sourceFilePath })));
const RefreshInfo refreshInfo = RefreshInfoGenerator::getRefreshInfoForAllFiles(sourceGroups);
addFileToFileSystem(sourceFilePath);
TS_ASSERT_EQUALS(REFRESH_ALL_FILES, refreshInfo.mode);
TS_ASSERT_EQUALS(0, refreshInfo.nonIndexedFilesToClear.size());
TS_ASSERT_EQUALS(0, refreshInfo.filesToClear.size());
TS_ASSERT_EQUALS(1, refreshInfo.filesToIndex.size());
const RefreshInfo refreshInfo = RefreshInfoGenerator::getRefreshInfoForAllFiles(sourceGroups);
TS_ASSERT(utility::containsElement<FilePath>(
utility::toVector(refreshInfo.filesToIndex), sourceFilePath
));
TS_ASSERT_EQUALS(REFRESH_ALL_FILES, refreshInfo.mode);
TS_ASSERT_EQUALS(0, refreshInfo.nonIndexedFilesToClear.size());
TS_ASSERT_EQUALS(0, refreshInfo.filesToClear.size());
TS_ASSERT_EQUALS(1, refreshInfo.filesToIndex.size());
TS_ASSERT(utility::containsElement<FilePath>(
utility::toVector(refreshInfo.filesToIndex), sourceFilePath
));
}
cleanup();
}
void test_refresh_info_for_updated_files_is_empty_for_empty_storage_and_empty_sourcegroup()