logic: Added SourceGroupCustomCommand to use with SourcetrailDB binaries

* Added new Source Group type SourceGroupCustomCommand to UI and ProjectSettings
* The Source Group executes a specified command on every source file
* The variables $SOURCE_PATH, $PROJECT_PATH, $DB_PATH, $STORAGE_VERSION can be passed
* The commands are executed after all other source groups finished indexing
* The command is executed with working directory set to project directory
* Errors during command execution are shown as status update and in the Status View
* SourceGroupCustomCommand cannot be partially cleared, when one file needs clearing the project must be fully re-indexed
This commit is contained in:
Eberhard Graether
2018-12-11 14:05:26 +01:00
parent 21d947ed6c
commit 6d5a3c047d
101 changed files with 1108 additions and 235 deletions
+31
View File
@@ -2,6 +2,7 @@
#include <fstream>
#include "IndexerCommandCustom.h"
#include "IndexerCommandCxx.h"
#include "IndexerCommandJava.h"
#include "JavaEnvironmentFactory.h"
@@ -9,6 +10,7 @@
#include "SourceGroupCxxCdb.h"
#include "SourceGroupCxxCodeblocks.h"
#include "SourceGroupCxxSonargraph.h"
#include "SourceGroupCustomCommand.h"
#include "SourceGroupJavaEmpty.h"
#include "SourceGroupJavaGradle.h"
#include "SourceGroupJavaMaven.h"
@@ -18,6 +20,7 @@
#include "SourceGroupSettingsCxxCdb.h"
#include "SourceGroupSettingsCxxCodeblocks.h"
#include "SourceGroupSettingsCxxSonargraph.h"
#include "SourceGroupSettingsCustomCommand.h"
#include "SourceGroupSettingsJavaEmpty.h"
#include "SourceGroupSettingsJavaGradle.h"
#include "SourceGroupSettingsJavaMaven.h"
@@ -389,6 +392,22 @@ public:
applicationSettings->setJreSystemLibraryPaths(storedJreSystemLibraryPaths);
}
void test_source_group_custom_command_generates_expected_output()
{
const std::wstring projectName = L"custom_command";
ProjectSettings projectSettings;
projectSettings.setProjectFilePath(L"non_existent_project", getInputDirectoryPath(projectName));
std::shared_ptr<SourceGroupSettingsCustomCommand> sourceGroupSettings = std::make_shared<SourceGroupSettingsCustomCommand>("fake_id", &projectSettings);
sourceGroupSettings->setCustomCommand(L"echo \"Hello World\"");
sourceGroupSettings->setSourcePaths({ getInputDirectoryPath(projectName).concatenate(L"/src") });
sourceGroupSettings->setSourceExtensions({ L".txt" });
sourceGroupSettings->setExcludeFilterStrings({ L"**/excluded/**" });
generateAndCompareExpectedOutput(projectName, std::make_shared<SourceGroupCustomCommand>(sourceGroupSettings));
}
// Special Tests
void test_sourcegroup_java_sonargraph_with_cpp_modules_does_not_generate_output()
@@ -546,6 +565,10 @@ private:
{
return indexerCommandJavaToString(indexerCommandJava, baseDirectory);
}
if (std::shared_ptr<const IndexerCommandCustom> indexerCommandCustom = std::dynamic_pointer_cast<const IndexerCommandCustom>(indexerCommand))
{
return indexerCommandCustomToString(indexerCommandCustom, baseDirectory);
}
return L"Unsupported indexer command type: " + utility::decodeFromUtf8(indexerCommandTypeToString(indexerCommand->getIndexerCommandType()));
}
return L"No IndexerCommand provided.";
@@ -586,4 +609,12 @@ private:
}
return result;
}
std::wstring indexerCommandCustomToString(std::shared_ptr<const IndexerCommandCustom> indexerCommand, const FilePath& baseDirectory)
{
std::wstring result;
result += L"SourceFilePath: \"" + indexerCommand->getSourceFilePath().getRelativeTo(baseDirectory).wstr() + L"\"\n";
result += L"\tCustom Command: \"" + indexerCommand->getCustomCommand() + L"\"\n";
return result;
}
};