logic: Added "Empty Python" Sourcegroup to project setup

The respective release of the SourcetrailPythonIndexer project is automatically downloaded from GitHub when the setup script is executed.
This commit is contained in:
mlangkabel
2019-04-02 15:54:17 +02:00
parent 5d672fafc4
commit 045a3a4e50
34 changed files with 450 additions and 29 deletions
+9
View File
@@ -0,0 +1,9 @@
add_files(
LIB_PYTHON
project/SourceGroupFactoryModulePython.h
project/SourceGroupFactoryModulePython.cpp
project/SourceGroupPythonEmpty.h
project/SourceGroupPythonEmpty.cpp
)
@@ -0,0 +1,26 @@
#include "SourceGroupFactoryModulePython.h"
#include "SourceGroupPythonEmpty.h"
#include "SourceGroupSettingsPythonEmpty.h"
bool SourceGroupFactoryModulePython::supports(SourceGroupType type) const
{
switch (type)
{
case SOURCE_GROUP_PYTHON_EMPTY:
return true;
default:
break;
}
return false;
}
std::shared_ptr<SourceGroup> SourceGroupFactoryModulePython::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings) const
{
std::shared_ptr<SourceGroup> sourceGroup;
if (std::shared_ptr<SourceGroupSettingsPythonEmpty> pythonSettings = std::dynamic_pointer_cast<SourceGroupSettingsPythonEmpty>(settings))
{
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupPythonEmpty(pythonSettings));
}
return sourceGroup;
}
@@ -0,0 +1,13 @@
#ifndef SOURCE_GROUP_FACTORY_MODULE_PYTHON_H
#define SOURCE_GROUP_FACTORY_MODULE_PYTHON_H
#include "SourceGroupFactoryModule.h"
class SourceGroupFactoryModulePython: public SourceGroupFactoryModule
{
public:
bool supports(SourceGroupType type) const override;
std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings) const override;
};
#endif // SOURCE_GROUP_FACTORY_MODULE_PYTHON_H
@@ -0,0 +1,66 @@
#include "SourceGroupPythonEmpty.h"
#include "FileManager.h"
#include "IndexerCommandCustom.h"
#include "ProjectSettings.h"
#include "ResourcePaths.h"
#include "SourceGroupSettingsPythonEmpty.h"
#include "SqliteIndexStorage.h"
#include "utility.h"
SourceGroupPythonEmpty::SourceGroupPythonEmpty(std::shared_ptr<SourceGroupSettingsPythonEmpty> settings)
: m_settings(settings)
{
}
std::set<FilePath> SourceGroupPythonEmpty::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
return SourceGroup::filterToContainedFilePaths(
filePaths,
std::set<FilePath>(),
utility::toSet(m_settings->getSourcePathsExpandedAndAbsolute()),
m_settings->getExcludeFiltersExpandedAndAbsolute()
);
}
std::set<FilePath> SourceGroupPythonEmpty::getAllSourceFilePaths() const
{
FileManager fileManager;
fileManager.update(
m_settings->getSourcePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
return fileManager.getAllSourceFilePaths();
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupPythonEmpty::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (const FilePath& sourceFilePath : getAllSourceFilePaths())
{
if (filesToIndex.find(sourceFilePath) != filesToIndex.end())
{
indexerCommands.push_back(std::make_shared<IndexerCommandCustom>(
L"\"" + ResourcePaths::getPythonPath().wstr() + L"SourcetrailPythonIndexer\" --source-file-path=%{SOURCE_FILE_PATH} --database-file-path=%{DATABASE_FILE_PATH}",
m_settings->getProjectSettings()->getProjectFilePath(),
m_settings->getProjectSettings()->getTempDBFilePath(),
std::to_wstring(SqliteIndexStorage::getStorageVersion()),
sourceFilePath,
true
));
}
}
return indexerCommands;
}
std::shared_ptr<SourceGroupSettings> SourceGroupPythonEmpty::getSourceGroupSettings()
{
return m_settings;
}
std::shared_ptr<const SourceGroupSettings> SourceGroupPythonEmpty::getSourceGroupSettings() const
{
return m_settings;
}
@@ -0,0 +1,27 @@
#ifndef SOURCE_GROUP_PYTHON_EMPTY_H
#define SOURCE_GROUP_PYTHON_EMPTY_H
#include <memory>
#include <vector>
#include "SourceGroup.h"
class SourceGroupSettingsPythonEmpty;
class SourceGroupPythonEmpty: public SourceGroup
{
public:
SourceGroupPythonEmpty(std::shared_ptr<SourceGroupSettingsPythonEmpty> settings);
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::set<FilePath> getAllSourceFilePaths() const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
std::shared_ptr<SourceGroupSettingsPythonEmpty> m_settings;
};
#endif // SOURCE_GROUP_PYTHON_EMPTY_H