logic: added project setup support for Sonargraph projects (Java and CMake-JSON modules supported)

* added classes for loading a Sonargraph project
* added Sonargraph options to project setup wizard
* added test for generating indexer commands from Sonargraph modules
* fixed sqlite storage crashing in constructor when parent directory of provided path does not exist
* removed unused FileRegister from Java indexing
* removed unused info from IndexerCommandJava
* refactored loading and saving of SourceGroupSettings
* extracted sourcepaths settings to own class that can be re-used
* merged CDB wizard contentents for source file and indexed paths
* unified wizard content for sonargraph project path
* removed include filters from default source groups
* extracted generation of RefreshInfo from Project to RefreshInfoGenerator
* added tests for RefreshInfoGenerator
* added language and standard selection to sonargraph project setup
* added auto-detection for indexed header paths of sonargraph cmake json modules
* Sonargraph::Project can enable/disable support for specific modules
* warn if sonargraph project contains no matching modules
* indexed headers can be detected from sonargraph project
This commit is contained in:
mlangkabel
2018-05-18 16:07:57 +02:00
parent e55ae5ba31
commit 7b735cfd17
164 changed files with 24770 additions and 1684 deletions
+44 -2
View File
@@ -283,12 +283,14 @@ add_files(
project/Project.cpp
project/Project.h
project/RefreshInfo.h
project/RefreshInfoGenerator.h
project/RefreshInfoGenerator.cpp
project/SourceGroup.cpp
project/SourceGroup.h
project/SourceGroupFactory.cpp
project/SourceGroupFactory.h
project/SourceGroupFactoryModule.cpp
project/SourceGroupFactoryModule.h
project/SourceGroup.cpp
project/SourceGroup.h
settings/migration/SettingsMigration.cpp
settings/migration/SettingsMigration.h
@@ -318,6 +320,8 @@ add_files(
settings/SourceGroupSettingsCxxCdb.h
settings/SourceGroupSettingsCxxEmpty.cpp
settings/SourceGroupSettingsCxxEmpty.h
settings/SourceGroupSettingsCxxSonargraph.cpp
settings/SourceGroupSettingsCxxSonargraph.h
settings/SourceGroupSettingsJava.cpp
settings/SourceGroupSettingsJava.h
settings/SourceGroupSettingsJavaEmpty.cpp
@@ -326,6 +330,18 @@ add_files(
settings/SourceGroupSettingsJavaGradle.h
settings/SourceGroupSettingsJavaMaven.cpp
settings/SourceGroupSettingsJavaMaven.h
settings/SourceGroupSettingsJavaSonargraph.cpp
settings/SourceGroupSettingsJavaSonargraph.h
settings/SourceGroupSettingsWithClasspath.cpp
settings/SourceGroupSettingsWithClasspath.h
settings/SourceGroupSettingsWithExcludeFilters.cpp
settings/SourceGroupSettingsWithExcludeFilters.h
settings/SourceGroupSettingsWithIndexedHeaderPaths.cpp
settings/SourceGroupSettingsWithIndexedHeaderPaths.h
settings/SourceGroupSettingsWithSonargraphProjectPath.cpp
settings/SourceGroupSettingsWithSonargraphProjectPath.h
settings/SourceGroupSettingsWithSourcePaths.cpp
settings/SourceGroupSettingsWithSourcePaths.h
settings/SourceGroupStatusType.cpp
settings/SourceGroupStatusType.h
settings/SourceGroupType.cpp
@@ -499,6 +515,31 @@ add_files(
utility/scheduling/TaskScheduler.cpp
utility/scheduling/TaskScheduler.h
utility/scheduling/TaskSetValue.h
utility/sonargraph/SonargraphProject.cpp
utility/sonargraph/SonargraphProject.h
utility/sonargraph/SonargraphSoftwareSystem.cpp
utility/sonargraph/SonargraphSoftwareSystem.h
utility/sonargraph/SonargraphSourceRootPath.cpp
utility/sonargraph/SonargraphSourceRootPath.h
utility/sonargraph/SonargraphXsdAbstractModule.cpp
utility/sonargraph/SonargraphXsdAbstractModule.h
utility/sonargraph/SonargraphXsdAbstractSystemExtension.cpp
utility/sonargraph/SonargraphXsdAbstractSystemExtension.h
utility/sonargraph/SonargraphXsdCmakeJsonModule.cpp
utility/sonargraph/SonargraphXsdCmakeJsonModule.h
utility/sonargraph/SonargraphXsdCppSystemSettings.cpp
utility/sonargraph/SonargraphXsdCppSystemSettings.h
utility/sonargraph/SonargraphXsdJavaModule.cpp
utility/sonargraph/SonargraphXsdJavaModule.h
utility/sonargraph/SonargraphXsdRootPath.cpp
utility/sonargraph/SonargraphXsdRootPath.h
utility/sonargraph/SonargraphXsdRootPathWithFiles.cpp
utility/sonargraph/SonargraphXsdRootPathWithFiles.h
utility/sonargraph/SonargraphXsdSourceRootPath.cpp
utility/sonargraph/SonargraphXsdSourceRootPath.h
utility/sonargraph/utilitySonargraph.cpp
utility/sonargraph/utilitySonargraph.h
utility/synchronization/ReaderWriterLock.cpp
utility/synchronization/ReaderWriterLock.h
@@ -517,6 +558,7 @@ add_files(
utility/AppPath.h
utility/ConfigManager.cpp
utility/ConfigManager.h
utility/Optional.h
utility/OrderedCache.h
utility/OsType.h
utility/Property.h
+6 -11
View File
@@ -16,13 +16,9 @@ public:
virtual IndexerCommandType getSupportedIndexerCommandType() const;
virtual std::shared_ptr<IntermediateStorage> index(
std::shared_ptr<IndexerCommand> indexerCommand,
std::shared_ptr<FileRegister> fileRegister);
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand);
virtual std::shared_ptr<IntermediateStorage> doIndex(
std::shared_ptr<T> indexerCommand,
std::shared_ptr<FileRegister> fileRegister) = 0;
virtual std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<T> indexerCommand) = 0;
};
template <typename T>
@@ -37,11 +33,10 @@ IndexerCommandType Indexer<T>::getSupportedIndexerCommandType() const
}
template <typename T>
std::shared_ptr<IntermediateStorage> Indexer<T>::index(
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
std::shared_ptr<IntermediateStorage> Indexer<T>::index(std::shared_ptr<IndexerCommand> indexerCommand)
{
std::shared_ptr<T> castedCommand = std::dynamic_pointer_cast<T>(indexerCommand);
if (!castedCommand)
std::shared_ptr<T> castCommand = std::dynamic_pointer_cast<T>(indexerCommand);
if (!castCommand)
{
LOG_ERROR("Trying to process " + indexerCommandTypeToString(indexerCommand->getIndexerCommandType()) +
" indexer command with indexer that supports \"" + indexerCommandTypeToString(getSupportedIndexerCommandType()) + "\".");
@@ -49,7 +44,7 @@ std::shared_ptr<IntermediateStorage> Indexer<T>::index(
return std::shared_ptr<IntermediateStorage>();
}
return doIndex(castedCommand, fileRegister);
return doIndex(castCommand);
}
#endif // INDEXER_H
-4
View File
@@ -5,10 +5,6 @@ IndexerBase::IndexerBase()
{
}
IndexerBase::~IndexerBase()
{
}
void IndexerBase::interrupt()
{
m_interrupted = true;
+2 -4
View File
@@ -14,13 +14,11 @@ class IndexerBase
{
public:
IndexerBase();
virtual ~IndexerBase();
virtual ~IndexerBase() = default;
virtual IndexerCommandType getSupportedIndexerCommandType() const = 0;
virtual std::shared_ptr<IntermediateStorage> index(
std::shared_ptr<IndexerCommand> indexerCommand,
std::shared_ptr<FileRegister> fileRegister) = 0;
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand) = 0;
virtual void interrupt();
+2 -31
View File
@@ -3,47 +3,18 @@
#include "utility/utilityString.h"
IndexerCommand::IndexerCommand(
const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters
const FilePath& sourceFilePath
)
: m_sourceFilePath(sourceFilePath)
, m_indexedPaths(indexedPaths)
, m_excludeFilters(excludeFilters)
{
}
IndexerCommand::~IndexerCommand()
{
}
size_t IndexerCommand::getByteSize(size_t stringSize) const
{
size_t size = utility::encodeToUtf8(m_sourceFilePath.wstr()).size();
for (const FilePath& path: m_indexedPaths)
{
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
}
for (const FilePathFilter& filter : m_excludeFilters)
{
size += stringSize + utility::encodeToUtf8(filter.wstr()).size();
}
return size;
return utility::encodeToUtf8(m_sourceFilePath.wstr()).size();
}
const FilePath& IndexerCommand::getSourceFilePath() const
{
return m_sourceFilePath;
}
const std::set<FilePath>& IndexerCommand::getIndexedPaths() const
{
return m_indexedPaths;
}
const std::set<FilePathFilter>& IndexerCommand::getExcludeFilters() const
{
return m_excludeFilters;
}
+2 -6
View File
@@ -11,21 +11,17 @@
class IndexerCommand
{
public:
IndexerCommand(const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths, const std::set<FilePathFilter>& excludeFilters);
virtual ~IndexerCommand();
IndexerCommand(const FilePath& sourceFilePath);
virtual ~IndexerCommand() = default;
virtual IndexerCommandType getIndexerCommandType() const = 0;
virtual size_t getByteSize(size_t stringSize) const;
const FilePath& getSourceFilePath() const;
const std::set<FilePath>& getIndexedPaths() const;
const std::set<FilePathFilter>& getExcludeFilters() const;
private:
FilePath m_sourceFilePath;
std::set<FilePath> m_indexedPaths;
std::set<FilePathFilter> m_excludeFilters;
};
#endif // INDEXER_COMMAND_H
+2 -3
View File
@@ -18,13 +18,12 @@ void IndexerComposite::addIndexer(std::shared_ptr<IndexerBase> indexer)
m_indexers.emplace(indexer->getSupportedIndexerCommandType(), indexer);
}
std::shared_ptr<IntermediateStorage> IndexerComposite::index(
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
std::shared_ptr<IntermediateStorage> IndexerComposite::index(std::shared_ptr<IndexerCommand> indexerCommand)
{
auto it = m_indexers.find(indexerCommand->getIndexerCommandType());
if (it != m_indexers.end())
{
return it->second->index(indexerCommand, fileRegister);
return it->second->index(indexerCommand);
}
LOG_ERROR("No indexer found that supports \"" + indexerCommandTypeToString(indexerCommand->getIndexerCommandType()) + "\".");
+1 -4
View File
@@ -15,10 +15,7 @@ public:
void addIndexer(std::shared_ptr<IndexerBase> indexer);
virtual std::shared_ptr<IntermediateStorage> index(
std::shared_ptr<IndexerCommand> indexerCommand,
std::shared_ptr<FileRegister> fileRegister
);
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand);
virtual void interrupt();
@@ -48,12 +48,8 @@ void InterprocessIndexer::work()
LOG_INFO_STREAM(<< m_processId << " updating indexer status with currently indexed filepath");
m_interprocessIndexingStatusManager.startIndexingSourceFile(indexerCommand->getSourceFilePath());
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(
indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludeFilters()
);
LOG_INFO_STREAM(<< m_processId << " starting to index current file");
std::shared_ptr<IntermediateStorage> result = indexer->index(indexerCommand, fileRegister);
std::shared_ptr<IntermediateStorage> result = indexer->index(indexerCommand);
LOG_INFO_STREAM(<< m_processId << " pushing index to shared memory");
m_interprocessIntermediateStorageManager.pushIntermediateStorage(result);
@@ -10,14 +10,15 @@
void SharedIndexerCommand::fromLocal(IndexerCommand* indexerCommand)
{
setSourceFilePath(indexerCommand->getSourceFilePath());
setIndexedPaths(indexerCommand->getIndexedPaths());
setExcludeFilters(indexerCommand->getExcludeFilters());
if (dynamic_cast<IndexerCommandCxxCdb*>(indexerCommand) != nullptr)
{
IndexerCommandCxxCdb* cmd = dynamic_cast<IndexerCommandCxxCdb*>(indexerCommand);
setType(CXX_CDB);
setIndexedPaths(cmd->getIndexedPaths());
setExcludeFilters(cmd->getExcludeFilters());
setIncludeFilters(cmd->getIncludeFilters());
setWorkingDirectory(cmd->getWorkingDirectory());
setCompilerFlags(cmd->getCompilerFlags());
setSystemHeaderSearchPaths(cmd->getSystemHeaderSearchPaths());
@@ -28,6 +29,9 @@ void SharedIndexerCommand::fromLocal(IndexerCommand* indexerCommand)
IndexerCommandCxxEmpty* cmd = dynamic_cast<IndexerCommandCxxEmpty*>(indexerCommand);
setType(CXX_EMPTY);
setIndexedPaths(cmd->getIndexedPaths());
setExcludeFilters(cmd->getExcludeFilters());
setIncludeFilters(cmd->getIncludeFilters());
setWorkingDirectory(cmd->getWorkingDirectory());
setLanguageStandard(cmd->getLanguageStandard());
setCompilerFlags(cmd->getCompilerFlags());
@@ -59,6 +63,7 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
indexerCommand.getSourceFilePath(),
indexerCommand.getIndexedPaths(),
indexerCommand.getExcludeFilters(),
indexerCommand.getIncludeFilters(),
indexerCommand.getWorkingDirectory(),
indexerCommand.getCompilerFlags(),
indexerCommand.getSystemHeaderSearchPaths(),
@@ -72,11 +77,12 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
indexerCommand.getSourceFilePath(),
indexerCommand.getIndexedPaths(),
indexerCommand.getExcludeFilters(),
indexerCommand.getIncludeFilters(),
indexerCommand.getWorkingDirectory(),
indexerCommand.getLanguageStandard(),
indexerCommand.getSystemHeaderSearchPaths(),
indexerCommand.getFrameworkSearchhPaths(),
indexerCommand.getCompilerFlags()
indexerCommand.getCompilerFlags(),
indexerCommand.getLanguageStandard()
);
return command;
}
@@ -84,8 +90,6 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
{
return std::make_shared<IndexerCommandJava>(
indexerCommand.getSourceFilePath(),
indexerCommand.getIndexedPaths(),
indexerCommand.getExcludeFilters(),
indexerCommand.getLanguageStandard(),
indexerCommand.getClassPaths()
);
@@ -105,6 +109,7 @@ SharedIndexerCommand::SharedIndexerCommand(SharedMemory::Allocator* allocator)
, m_sourceFilePath("", allocator)
, m_indexedPaths(allocator)
, m_excludeFilters(allocator)
, m_includeFilters(allocator)
, m_workingDirectory("", allocator)
, m_languageStandard("", allocator)
, m_compilerFlags(allocator)
@@ -176,6 +181,30 @@ void SharedIndexerCommand::setExcludeFilters(const std::set<FilePathFilter>& exc
}
}
std::set<FilePathFilter> SharedIndexerCommand::getIncludeFilters() const
{
std::set<FilePathFilter> result;
for (unsigned int i = 0; i < m_includeFilters.size(); i++)
{
result.insert(FilePathFilter(utility::decodeFromUtf8(m_includeFilters[i].c_str())));
}
return result;
}
void SharedIndexerCommand::setIncludeFilters(const std::set<FilePathFilter>& includeFilters)
{
m_includeFilters.clear();
for (const FilePathFilter& includeFilter : includeFilters)
{
SharedMemory::String path(m_includeFilters.get_allocator());
path = utility::encodeToUtf8(includeFilter.wstr()).c_str();
m_includeFilters.push_back(path);
}
}
FilePath SharedIndexerCommand::getWorkingDirectory() const
{
return FilePath(utility::decodeFromUtf8(m_workingDirectory.c_str()));
@@ -27,6 +27,9 @@ public:
std::set<FilePathFilter> getExcludeFilters() const;
void setExcludeFilters(const std::set<FilePathFilter>& excludeFilters);
std::set<FilePathFilter> getIncludeFilters() const;
void setIncludeFilters(const std::set<FilePathFilter>& includeFilters);
FilePath getWorkingDirectory() const;
void setWorkingDirectory(const FilePath& workingDirectory);
@@ -63,6 +66,7 @@ private:
SharedMemory::String m_sourceFilePath;
SharedMemory::Vector<SharedMemory::String> m_indexedPaths;
SharedMemory::Vector<SharedMemory::String> m_excludeFilters;
SharedMemory::Vector<SharedMemory::String> m_includeFilters;
// cxx
SharedMemory::String m_workingDirectory;
+6 -6
View File
@@ -306,7 +306,7 @@ void PersistentStorage::clearCaches()
m_fullTextSearchCodec = "";
}
std::set<FilePath> PersistentStorage::getReferenced(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferenced(const std::set<FilePath>& filePaths) const
{
TRACE();
std::set<FilePath> referenced;
@@ -317,7 +317,7 @@ std::set<FilePath> PersistentStorage::getReferenced(const std::set<FilePath>& fi
return referenced;
}
std::set<FilePath> PersistentStorage::getReferencing(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferencing(const std::set<FilePath>& filePaths) const
{
TRACE();
std::set<FilePath> referencing;
@@ -2261,7 +2261,7 @@ std::set<Id> PersistentStorage::getReferencing(
}
std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<FilePath>& filePaths) const
{
const std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
@@ -2274,7 +2274,7 @@ std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<Fil
return paths;
}
std::set<FilePath> PersistentStorage::getReferencedByImports(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferencedByImports(const std::set<FilePath>& filePaths) const
{
const std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
@@ -2287,7 +2287,7 @@ std::set<FilePath> PersistentStorage::getReferencedByImports(const std::set<File
return paths;
}
std::set<FilePath> PersistentStorage::getReferencingByIncludes(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferencingByIncludes(const std::set<FilePath>& filePaths) const
{
const std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
@@ -2300,7 +2300,7 @@ std::set<FilePath> PersistentStorage::getReferencingByIncludes(const std::set<Fi
return paths;
}
std::set<FilePath> PersistentStorage::getReferencingByImports(const std::set<FilePath>& filePaths)
std::set<FilePath> PersistentStorage::getReferencingByImports(const std::set<FilePath>& filePaths) const
{
const std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
+6 -6
View File
@@ -58,8 +58,8 @@ public:
void clear();
void clearCaches();
std::set<FilePath> getReferenced(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferencing(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferenced(const std::set<FilePath>& filePaths) const;
std::set<FilePath> getReferencing(const std::set<FilePath>& filePaths) const;
void clearFileElements(const std::vector<FilePath>& filePaths, std::function<void(int)> updateStatusCallback);
@@ -165,11 +165,11 @@ private:
std::set<Id> getReferenced(const std::set<Id>& filePaths, std::unordered_map<Id, std::set<Id>> idToReferencingIdMap) const;
std::set<Id> getReferencing(const std::set<Id>& filePaths, std::unordered_map<Id, std::set<Id>> idToReferencingIdMap) const;
std::set<FilePath> getReferencedByIncludes(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferencedByImports(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferencedByIncludes(const std::set<FilePath>& filePaths) const;
std::set<FilePath> getReferencedByImports(const std::set<FilePath>& filePaths) const;
std::set<FilePath> getReferencingByIncludes(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferencingByImports(const std::set<FilePath>& filePaths);
std::set<FilePath> getReferencingByIncludes(const std::set<FilePath>& filePaths) const;
std::set<FilePath> getReferencingByImports(const std::set<FilePath>& filePaths) const;
void addNodesToGraph(const std::vector<Id>& nodeIds, Graph* graph, bool addChildCount) const;
void addEdgesToGraph(const std::vector<Id>& edgeIds, Graph* graph) const;
@@ -14,10 +14,6 @@ SqliteBookmarkStorage::SqliteBookmarkStorage(const FilePath& dbFilePath)
{
}
SqliteBookmarkStorage::~SqliteBookmarkStorage()
{
}
size_t SqliteBookmarkStorage::getStaticVersion() const
{
return s_storageVersion;
@@ -29,15 +25,17 @@ void SqliteBookmarkStorage::migrateIfNecessary()
migrator.addMigration(2, std::make_shared<SqliteStorageMigrationLambda>([](const SqliteStorageMigration* migration, SqliteStorage* storage){
std::string separator = "::";
if (std::shared_ptr<Project> currentProject = Application::getInstance()->getCurrentProject())
if (Application::getInstance())
{
LanguageType currentLanguage = ProjectSettings::getLanguageOfProject(currentProject->getProjectSettingsFilePath());
if (currentLanguage == LANGUAGE_JAVA)
if (std::shared_ptr<Project> currentProject = Application::getInstance()->getCurrentProject())
{
separator = ".";
LanguageType currentLanguage = ProjectSettings::getLanguageOfProject(currentProject->getProjectSettingsFilePath());
if (currentLanguage == LANGUAGE_JAVA)
{
separator = ".";
}
}
}
migration->executeStatementInStorage(storage, "UPDATE bookmarked_node SET serialized_node_name = '" + separator + "\tm' || serialized_node_name");
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_source_node_name = '" + separator + "\tm' || serialized_source_node_name");
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_target_node_name = '" + separator + "\tm' || serialized_target_node_name");
@@ -13,7 +13,6 @@ class SqliteBookmarkStorage
{
public:
SqliteBookmarkStorage(const FilePath& dbFilePath);
virtual ~SqliteBookmarkStorage();
virtual size_t getStaticVersion() const;
@@ -16,10 +16,6 @@ SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
{
}
SqliteIndexStorage::~SqliteIndexStorage()
{
}
size_t SqliteIndexStorage::getStaticVersion() const
{
return s_storageVersion;
@@ -33,7 +33,6 @@ class SqliteIndexStorage
{
public:
SqliteIndexStorage(const FilePath& dbFilePath);
virtual ~SqliteIndexStorage();
virtual size_t getStaticVersion() const;
@@ -1,5 +1,6 @@
#include "data/storage/sqlite/SqliteStorage.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/TimeStamp.h"
#include "utility/utilityString.h"
@@ -7,6 +8,11 @@
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
: m_dbFilePath(dbFilePath.getCanonical())
{
if (!m_dbFilePath.getParentDirectory().empty() && !m_dbFilePath.getParentDirectory().exists())
{
FileSystem::createDirectory(m_dbFilePath.getParentDirectory());
}
m_database.open(utility::encodeToUtf8(m_dbFilePath.wstr()).c_str());
executeStatement("PRAGMA foreign_keys=ON;");
+5 -202
View File
@@ -13,10 +13,12 @@
#include "data/TaskInjectStorage.h"
#include "data/TaskMergeStorages.h"
#include "data/TaskShowUnknownProgressDialog.h"
#include "project/RefreshInfoGenerator.h"
#include "project/SourceGroup.h"
#include "project/SourceGroupFactory.h"
#include "settings/ApplicationSettings.h"
#include "settings/ProjectSettings.h"
#include "settings/SourceGroupStatusType.h"
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
@@ -275,8 +277,6 @@ void Project::refresh(RefreshMode refreshMode, DialogView* dialogView)
{
return;
}
sourceGroup->fetchAllSourceFilePaths();
}
if (needsFullRefresh || fullRefresh)
@@ -314,13 +314,13 @@ RefreshInfo Project::getRefreshInfo(RefreshMode mode) const
return RefreshInfo();
case REFRESH_UPDATED_FILES:
return getRefreshInfoForUpdatedFiles();
return RefreshInfoGenerator::getRefreshInfoForUpdatedFiles(m_sourceGroups, m_storage);
case REFRESH_UPDATED_AND_INCOMPLETE_FILES:
return getRefreshInfoForIncompleteFiles();
return RefreshInfoGenerator::getRefreshInfoForIncompleteFiles(m_sourceGroups, m_storage);
case REFRESH_ALL_FILES:
return getRefreshInfoForAllFiles();
return RefreshInfoGenerator::getRefreshInfoForAllFiles(m_sourceGroups);
}
}
@@ -474,203 +474,6 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView)
m_state = PROJECT_STATE_LOADED;
}
std::set<FilePath> Project::getAllSourceFilePaths() const
{
std::set<FilePath> allSourceFilePaths;
for (const std::shared_ptr<SourceGroup>& sourceGroup: m_sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(allSourceFilePaths, sourceGroup->getAllSourceFilePaths());
}
}
return allSourceFilePaths;
}
RefreshInfo Project::getRefreshInfoForUpdatedFiles() const
{
std::set<FilePath> unchangedFilePaths;
std::set<FilePath> changedFilePaths;
{
std::set<FilePath> alreadyIndexedPaths;
const std::vector<FileInfo> fileInfos = m_storage->getFileInfoForAllIndexedFiles();
for (const std::shared_ptr<SourceGroup>& sourceGroup : m_sourceGroups)
{
if (sourceGroup->getStatus() != SOURCE_GROUP_STATUS_ENABLED)
{
continue;
}
std::set<FilePath> indexedPaths = sourceGroup->getIndexedPaths();
std::set<FilePathFilter> excludeFilters = sourceGroup->getExcludeFilters();
for (const FileInfo& info : fileInfos)
{
bool isInIndexedPaths = false;
for (const FilePath& indexedPath : indexedPaths)
{
if (indexedPath == info.path || indexedPath.contains(info.path))
{
isInIndexedPaths = true;
break;
}
}
if (isInIndexedPaths)
{
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(info.path))
{
isInIndexedPaths = false;
break;
}
}
}
if (isInIndexedPaths)
{
alreadyIndexedPaths.insert(info.path);
}
}
}
// checking source and header files
for (const FileInfo& info : fileInfos)
{
if (alreadyIndexedPaths.find(info.path) != alreadyIndexedPaths.end() && info.path.exists())
{
if (didFileChange(info))
{
changedFilePaths.insert(info.path);
}
else
{
unchangedFilePaths.insert(info.path);
}
}
else // file has been removed
{
changedFilePaths.insert(info.path);
}
}
}
std::set<FilePath> filesToClear = changedFilePaths;
// handle referencing paths
utility::append(filesToClear, m_storage->getReferencing(changedFilePaths));
// handle referenced paths
const std::set<FilePath> allSourceFilePaths = getAllSourceFilePaths();
std::set<FilePath> staticSourceFiles = allSourceFilePaths;
for (const FilePath& path: changedFilePaths)
{
staticSourceFiles.erase(path);
}
const std::set<FilePath> staticReferencedFilePaths = m_storage->getReferenced(staticSourceFiles);
const std::set<FilePath> dynamicReferencedFilePaths = m_storage->getReferenced(changedFilePaths);
for (const FilePath& path : dynamicReferencedFilePaths)
{
if (staticReferencedFilePaths.find(path) == staticReferencedFilePaths.end() &&
staticSourceFiles.find(path) == staticSourceFiles.end())
{
// file may not be referenced anymore and will be reindexed if still needed
filesToClear.insert(path);
}
}
for (const FilePath& path: unchangedFilePaths)
{
staticSourceFiles.erase(path);
}
const std::set<FilePath> filesToAdd = staticSourceFiles;
std::set<FilePath> staticSourceFilePaths;
for (const FilePath& path: allSourceFilePaths)
{
if (filesToClear.find(path) == filesToClear.end() && filesToAdd.find(path) == filesToAdd.end())
{
staticSourceFilePaths.insert(path);
}
}
RefreshInfo info;
info.mode = REFRESH_UPDATED_FILES;
info.filesToClear = filesToClear;
for (const std::shared_ptr<SourceGroup>& sourceGroup: m_sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(info.filesToIndex, sourceGroup->getSourceFilePathsToIndex(staticSourceFilePaths));
}
}
return info;
}
RefreshInfo Project::getRefreshInfoForIncompleteFiles() const
{
RefreshInfo info = getRefreshInfoForUpdatedFiles();
info.mode = REFRESH_UPDATED_AND_INCOMPLETE_FILES;
std::set<FilePath> incompleteFiles;
for (const FilePath& path: m_storage->getIncompleteFiles())
{
if (info.filesToClear.find(path) == info.filesToClear.end())
{
incompleteFiles.insert(path);
}
}
if (!incompleteFiles.empty())
{
utility::append(incompleteFiles, m_storage->getReferencing(incompleteFiles));
std::set<FilePath> staticSourceFilePaths = getAllSourceFilePaths();
for (const FilePath& path: incompleteFiles)
{
staticSourceFilePaths.erase(path);
if (m_storage->getFilePathIndexed(path))
{
info.filesToClear.insert(path);
}
else
{
info.nonIndexedFilesToClear.insert(path);
}
}
for (const std::shared_ptr<SourceGroup>& sourceGroup: m_sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(info.filesToIndex, sourceGroup->getSourceFilePathsToIndex(staticSourceFilePaths));
}
}
}
return info;
}
RefreshInfo Project::getRefreshInfoForAllFiles() const
{
RefreshInfo info;
info.mode = REFRESH_ALL_FILES;
info.filesToIndex = getAllSourceFilePaths();
return info;
}
bool Project::hasCxxSourceGroup() const
{
for (const std::shared_ptr<SourceGroup>& sourceGroup: m_sourceGroups)
-6
View File
@@ -50,12 +50,6 @@ private:
Project(const Project&);
std::set<FilePath> getAllSourceFilePaths() const;
RefreshInfo getRefreshInfoForUpdatedFiles() const;
RefreshInfo getRefreshInfoForIncompleteFiles() const;
RefreshInfo getRefreshInfoForAllFiles() const;
bool hasCxxSourceGroup() const;
bool didFileChange(const FileInfo& info) const;
+205
View File
@@ -0,0 +1,205 @@
#include "project/RefreshInfoGenerator.h"
#include "data/storage/PersistentStorage.h"
#include "project/RefreshInfo.h"
#include "project/SourceGroup.h"
#include "settings/SourceGroupStatusType.h"
#include "utility/file/FileInfo.h"
#include "utility/file/FileSystem.h"
#include "utility/text/TextAccess.h"
#include "utility/utility.h"
RefreshInfo RefreshInfoGenerator::getRefreshInfoForUpdatedFiles(
const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups, std::shared_ptr<const PersistentStorage> storage)
{
const std::set<FilePath> allSourceFilePathsFromSourcegroups = getAllSourceFilePaths(sourceGroups);
std::set<FilePath> unchangedFilePaths;
std::set<FilePath> changedFilePaths;
{
const std::vector<FileInfo> fileInfosFromStorage = storage->getFileInfoForAllIndexedFiles();
std::set<FilePath> alreadyIndexedPaths;
{
const std::set<FilePath> filePathsFromStorage = utility::toSet(utility::convert<FileInfo, FilePath>(
fileInfosFromStorage, [](const FileInfo& info) { return info.path; }
));
for (std::shared_ptr<SourceGroup> sourceGroup : sourceGroups)
{
utility::append(alreadyIndexedPaths, sourceGroup->filterToContainedFilePaths(filePathsFromStorage));
}
}
// checking source and header files
for (const FileInfo& info : fileInfosFromStorage)
{
if (alreadyIndexedPaths.find(info.path) != alreadyIndexedPaths.end() && info.path.exists())
{
if (didFileChange(info, storage))
{
changedFilePaths.insert(info.path);
}
else
{
unchangedFilePaths.insert(info.path);
}
}
else // file has been removed
{
changedFilePaths.insert(info.path);
}
}
}
std::set<FilePath> filesToClear = changedFilePaths;
// handle referencing paths
utility::append(filesToClear, storage->getReferencing(changedFilePaths));
// handle referenced paths
std::set<FilePath> staticSourceFiles = allSourceFilePathsFromSourcegroups;
for (const FilePath& path : changedFilePaths)
{
staticSourceFiles.erase(path);
}
const std::set<FilePath> staticReferencedFilePaths = storage->getReferenced(staticSourceFiles);
const std::set<FilePath> dynamicReferencedFilePaths = storage->getReferenced(changedFilePaths);
for (const FilePath& path : dynamicReferencedFilePaths)
{
if (staticReferencedFilePaths.find(path) == staticReferencedFilePaths.end() &&
staticSourceFiles.find(path) == staticSourceFiles.end())
{
// file may not be referenced anymore and will be reindexed if still needed
filesToClear.insert(path);
}
}
for (const FilePath& path : unchangedFilePaths)
{
staticSourceFiles.erase(path);
}
const std::set<FilePath> filesToAdd = staticSourceFiles;
std::set<FilePath> staticSourceFilePaths;
for (const FilePath& path : allSourceFilePathsFromSourcegroups)
{
if (filesToClear.find(path) == filesToClear.end() && filesToAdd.find(path) == filesToAdd.end())
{
staticSourceFilePaths.insert(path);
}
}
RefreshInfo info;
info.mode = REFRESH_UPDATED_FILES;
info.filesToClear = filesToClear;
for (const std::shared_ptr<SourceGroup>& sourceGroup : sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(info.filesToIndex, sourceGroup->filterToContainedSourceFilePath(staticSourceFilePaths));
}
}
return info;
}
RefreshInfo RefreshInfoGenerator::getRefreshInfoForIncompleteFiles(const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups, std::shared_ptr<const PersistentStorage> storage)
{
RefreshInfo info = getRefreshInfoForUpdatedFiles(sourceGroups, storage);
info.mode = REFRESH_UPDATED_AND_INCOMPLETE_FILES;
std::set<FilePath> incompleteFiles;
for (const FilePath& path : storage->getIncompleteFiles())
{
if (info.filesToClear.find(path) == info.filesToClear.end())
{
incompleteFiles.insert(path);
}
}
if (!incompleteFiles.empty())
{
utility::append(incompleteFiles, storage->getReferencing(incompleteFiles));
std::set<FilePath> staticSourceFilePaths = getAllSourceFilePaths(sourceGroups);
for (const FilePath& path : incompleteFiles)
{
staticSourceFilePaths.erase(path);
if (storage->getFilePathIndexed(path))
{
info.filesToClear.insert(path);
}
else
{
info.nonIndexedFilesToClear.insert(path);
}
}
for (const std::shared_ptr<const SourceGroup>& sourceGroup : sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(info.filesToIndex, sourceGroup->filterToContainedSourceFilePath(staticSourceFilePaths));
}
}
}
return info;
}
RefreshInfo RefreshInfoGenerator::getRefreshInfoForAllFiles(const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups)
{
RefreshInfo info;
info.mode = REFRESH_ALL_FILES;
info.filesToIndex = getAllSourceFilePaths(sourceGroups);
return info;
}
std::set<FilePath> RefreshInfoGenerator::getAllSourceFilePaths(const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups)
{
std::set<FilePath> allSourceFilePaths;
for (const std::shared_ptr<const SourceGroup>& sourceGroup : sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
utility::append(allSourceFilePaths, sourceGroup->getAllSourceFilePaths());
}
}
return allSourceFilePaths;
}
bool RefreshInfoGenerator::didFileChange(const FileInfo& info, std::shared_ptr<const PersistentStorage> storage)
{
FileInfo diskFileInfo = FileSystem::getFileInfoForPath(info.path);
if (diskFileInfo.lastWriteTime > info.lastWriteTime)
{
std::shared_ptr<TextAccess> storedFileContent = storage->getFileContent(info.path);
std::shared_ptr<TextAccess> diskFileContent = TextAccess::createFromFile(diskFileInfo.path);
const std::vector<std::string>& diskFileLines = diskFileContent->getAllLines();
const std::vector<std::string>& storedFileLines = storedFileContent->getAllLines();
if (diskFileLines.size() == storedFileLines.size())
{
for (size_t i = 0; i < diskFileLines.size(); i++)
{
if (diskFileLines[i] != storedFileLines[i])
{
return true;
}
}
return false;
}
return true;
}
return false;
}
+41
View File
@@ -0,0 +1,41 @@
#ifndef REFRESH_INFO_GENERATOR_H
#define REFRESH_INFO_GENERATOR_H
#include <memory>
#include <set>
#include <vector>
struct FileInfo;
class FilePath;
class PersistentStorage;
struct RefreshInfo;
class SourceGroup;
class RefreshInfoGenerator
{
public:
static RefreshInfo getRefreshInfoForUpdatedFiles(
const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups,
std::shared_ptr<const PersistentStorage> storage
);
static RefreshInfo getRefreshInfoForIncompleteFiles(
const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups,
std::shared_ptr<const PersistentStorage> storage
);
static RefreshInfo getRefreshInfoForAllFiles(
const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups
);
private:
static std::set<FilePath> getAllSourceFilePaths(
const std::vector<std::shared_ptr<SourceGroup>>& sourceGroups
);
static bool didFileChange(
const FileInfo& info, std::shared_ptr<const PersistentStorage> storage
);
};
#endif // REFRESH_INFO_GENERATOR_H
+15 -55
View File
@@ -1,13 +1,16 @@
#include "project/SourceGroup.h"
#include "settings/SourceGroupSettings.h"
#include "utility/file/FileManager.h"
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
SourceGroup::~SourceGroup()
SourceGroupType SourceGroup::getType() const
{
return getSourceGroupSettings()->getType();
}
LanguageType SourceGroup::getLanguage() const
{
return getSourceGroupSettings()->getLanguage();
}
SourceGroupStatusType SourceGroup::getStatus() const
@@ -15,68 +18,25 @@ SourceGroupStatusType SourceGroup::getStatus() const
return getSourceGroupSettings()->getStatus();
}
LanguageType SourceGroup::getLanguage() const
{
return getLanguageTypeForSourceGroupType(getType());
}
bool SourceGroup::prepareIndexing()
{
return true;
}
void SourceGroup::fetchAllSourceFilePaths()
std::set<FilePath> SourceGroup::filterToContainedSourceFilePath(const std::set<FilePath>& sourceFilePaths) const
{
FileManager fileManager;
fileManager.update(
getAllSourcePaths(),
getSourceGroupSettings()->getExcludeFiltersExpandedAndAbsolute(),
getSourceGroupSettings()->getSourceExtensions()
);
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
}
std::set<FilePath> SourceGroup::getIndexedPaths() const
{
return findAndAddSymlinkedDirectories(getSourceGroupSettings()->getSourcePathsExpandedAndAbsolute());
}
std::set<FilePathFilter> SourceGroup::getExcludeFilters() const
{
return utility::toSet(getSourceGroupSettings()->getExcludeFiltersExpandedAndAbsolute());
}
std::set<FilePath> SourceGroup::getAllSourceFilePaths() const
{
return m_allSourceFilePaths;
}
std::set<FilePath> SourceGroup::getSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths) const
{
std::set<FilePath> sourceFilePathsToIndex;
for (const FilePath& sourceFilePath: m_allSourceFilePaths)
std::set<FilePath> filteredSourceFilePaths;
for (const FilePath& sourceFilePath: getAllSourceFilePaths())
{
if (staticSourceFilePaths.find(sourceFilePath) == staticSourceFilePaths.end())
if (sourceFilePaths.find(sourceFilePath) == sourceFilePaths.end())
{
sourceFilePathsToIndex.insert(sourceFilePath);
filteredSourceFilePaths.insert(sourceFilePath);
}
}
return sourceFilePathsToIndex;
return filteredSourceFilePaths;
}
std::set<FilePath> SourceGroup::findAndAddSymlinkedDirectories(const std::vector<FilePath>& paths) const
bool SourceGroup::containsSourceFilePath(const FilePath& sourceFilePath) const
{
std::set<FilePath> resultPaths;
for (const FilePath& path: paths)
{
if (path.exists())
{
resultPaths.insert(path);
}
}
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(paths);
resultPaths.insert(symLinkPaths.begin(), symLinkPaths.end());
return resultPaths;
return !filterToContainedSourceFilePath({ sourceFilePath }).empty();
}
+12 -23
View File
@@ -5,43 +5,32 @@
#include <set>
#include <vector>
#include "settings/LanguageType.h"
#include "settings/SourceGroupStatusType.h"
#include "settings/SourceGroupType.h"
#include "utility/file/FilePath.h"
#include "utility/file/FilePathFilter.h"
class IndexerCommand;
class FilePath;
class SourceGroupSettings;
enum LanguageType;
enum SourceGroupStatusType;
enum SourceGroupType;
class SourceGroup
{
public:
virtual ~SourceGroup();
virtual SourceGroupType getType() const = 0;
SourceGroupStatusType getStatus() const;
LanguageType getLanguage() const;
virtual ~SourceGroup() = default;
virtual bool prepareIndexing();
void fetchAllSourceFilePaths();
virtual std::set<FilePath> getIndexedPaths() const;
std::set<FilePathFilter> getExcludeFilters() const;
std::set<FilePath> getAllSourceFilePaths() const;
std::set<FilePath> getSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths) const;
virtual std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const = 0;
virtual std::set<FilePath> getAllSourceFilePaths() const = 0;
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const = 0;
std::set<FilePath> m_allSourceFilePaths;
SourceGroupType getType() const;
LanguageType getLanguage() const;
SourceGroupStatusType getStatus() const;
std::set<FilePath> filterToContainedSourceFilePath(const std::set<FilePath>& staticSourceFilePaths) const;
bool containsSourceFilePath(const FilePath& sourceFilePath) const;
protected:
std::set<FilePath> findAndAddSymlinkedDirectories(const std::vector<FilePath>& paths) const;
private:
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() = 0;
virtual std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const = 0;
virtual std::vector<FilePath> getAllSourcePaths() const = 0;
};
#endif // SOURCE_GROUP_H
+4
View File
@@ -43,6 +43,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_CDB:
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_SONARGRAPH:
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_VS:
return LANGUAGE_CPP;
case SOURCE_GROUP_JAVA_EMPTY:
@@ -51,6 +53,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
return LANGUAGE_JAVA;
case SOURCE_GROUP_JAVA_GRADLE:
return LANGUAGE_JAVA;
case SOURCE_GROUP_JAVA_SONARGRAPH:
return LANGUAGE_JAVA;
default:
break;
}
+8
View File
@@ -5,9 +5,11 @@
#include "settings/migration/SettingsMigrationMoveKey.h"
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "settings/SourceGroupSettingsCxxEmpty.h"
#include "settings/SourceGroupSettingsCxxSonargraph.h"
#include "settings/SourceGroupSettingsJavaEmpty.h"
#include "settings/SourceGroupSettingsJavaMaven.h"
#include "settings/SourceGroupSettingsJavaGradle.h"
#include "settings/SourceGroupSettingsJavaSonargraph.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityUuid.h"
@@ -150,6 +152,9 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
case SOURCE_GROUP_CXX_CDB:
settings = std::make_shared<SourceGroupSettingsCxxCdb>(id, this);
break;
case SOURCE_GROUP_CXX_SONARGRAPH:
settings = std::make_shared<SourceGroupSettingsCxxSonargraph>(id, this);
break;
case SOURCE_GROUP_JAVA_EMPTY:
settings = std::make_shared<SourceGroupSettingsJavaEmpty>(id, this);
break;
@@ -159,6 +164,9 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
case SOURCE_GROUP_JAVA_GRADLE:
settings = std::make_shared<SourceGroupSettingsJavaGradle>(id, this);
break;
case SOURCE_GROUP_JAVA_SONARGRAPH:
settings = std::make_shared<SourceGroupSettingsJavaSonargraph>(id, this);
break;
default:
continue;
}
+29 -161
View File
@@ -1,7 +1,7 @@
#include "settings/SourceGroupSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
const size_t SourceGroupSettings::s_version = 1;
const std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
@@ -15,13 +15,6 @@ SourceGroupSettings::SourceGroupSettings(
, m_type(type)
, m_status(SOURCE_GROUP_STATUS_ENABLED)
, m_standard("")
, m_sourcePaths(std::vector<FilePath>())
, m_excludeFilters(std::vector<std::wstring>())
, m_sourceExtensions(std::vector<std::wstring>())
{
}
SourceGroupSettings::~SourceGroupSettings()
{
}
@@ -29,30 +22,23 @@ void SourceGroupSettings::load(std::shared_ptr<const ConfigManager> config)
{
const std::string key = s_keyPrefix + getId();
const std::string name = getValue<std::string>(key + "/name", "", config);
const std::string name = config->getValueOrDefault<std::string>(key + "/name", "");
if (!name.empty())
{
setName(name);
}
setStatus(stringToSourceGroupStatusType(
getValue(key + "/status", sourceGroupStatusTypeToString(SOURCE_GROUP_STATUS_ENABLED), config)));
setStandard(getValue<std::string>(key + "/standard", "", config));
setSourcePaths(getPathValues(key + "/source_paths/source_path", config));
setExcludeFilterStrings(getValues(key + "/exclude_filters/exclude_filter", std::vector<std::wstring>(), config));
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::wstring>(), config));
setStatus(stringToSourceGroupStatusType(config->getValueOrDefault(key + "/status", sourceGroupStatusTypeToString(SOURCE_GROUP_STATUS_ENABLED))));
setStandard(config->getValueOrDefault<std::string>(key + "/standard", ""));
}
void SourceGroupSettings::save(std::shared_ptr<ConfigManager> config)
{
const std::string key = s_keyPrefix + getId();
setValue(key + "/status", sourceGroupStatusTypeToString(getStatus()), config);
setValue(key + "/name", getName(), config);
setValue(key + "/standard", getStandard(), config);
setPathValues(key + "/source_paths/source_path", getSourcePaths(), config);
setValues(key + "/exclude_filters/exclude_filter", getExcludeFilterStrings(), config);
setValues(key + "/source_extensions/source_extension", getSourceExtensions(), config);
config->setValue(key + "/status", sourceGroupStatusTypeToString(getStatus()));
config->setValue(key + "/name", getName());
config->setValue(key + "/standard", getStandard());
}
bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -62,10 +48,7 @@ bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) con
m_name == other->m_name &&
m_type == other->m_type &&
m_status == other->m_status &&
m_standard == other->m_standard &&
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
utility::isPermutation(m_excludeFilters, other->m_excludeFilters) &&
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
m_standard == other->m_standard
);
}
@@ -79,6 +62,16 @@ void SourceGroupSettings::setId(const std::string& id)
m_id = id;
}
SourceGroupType SourceGroupSettings::getType() const
{
return m_type;
}
LanguageType SourceGroupSettings::getLanguage() const
{
return getLanguageTypeForSourceGroupType(getType());
}
std::string SourceGroupSettings::getName() const
{
return m_name;
@@ -89,6 +82,16 @@ void SourceGroupSettings::setName(const std::string& name)
m_name = name;
}
SourceGroupStatusType SourceGroupSettings::getStatus() const
{
return m_status;
}
void SourceGroupSettings::setStatus(SourceGroupStatusType status)
{
m_status = status;
}
FilePath SourceGroupSettings::getProjectDirectoryPath() const
{
return m_projectSettings->getProjectDirectoryPath();
@@ -104,21 +107,6 @@ std::vector<FilePath> SourceGroupSettings::makePathsExpandedAndAbsolute(const st
return m_projectSettings->makePathsExpandedAndAbsolute(paths);
}
SourceGroupType SourceGroupSettings::getType() const
{
return m_type;
}
SourceGroupStatusType SourceGroupSettings::getStatus() const
{
return m_status;
}
void SourceGroupSettings::setStatus(SourceGroupStatusType status)
{
m_status = status;
}
std::string SourceGroupSettings::getStandard() const
{
if (m_standard.empty())
@@ -132,123 +120,3 @@ void SourceGroupSettings::setStandard(const std::string& standard)
{
m_standard = standard;
}
std::vector<FilePath> SourceGroupSettings::getSourcePaths() const
{
return m_sourcePaths;
}
std::vector<FilePath> SourceGroupSettings::getSourcePathsExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getSourcePaths());
}
void SourceGroupSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
{
m_sourcePaths = sourcePaths;
}
std::vector<std::wstring> SourceGroupSettings::getExcludeFilterStrings() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettings::getExcludeFiltersExpandedAndAbsolute() const
{
std::vector<FilePathFilter> result;
for (const std::wstring& filterString : m_excludeFilters)
{
if (!filterString.empty())
{
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
{
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
}
)
);
}
else
{
result.push_back(FilePathFilter(filterString));
}
}
else
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
}
}
return result;
}
void SourceGroupSettings::setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters)
{
m_excludeFilters = excludeFilters;
}
std::vector<std::wstring> SourceGroupSettings::getSourceExtensions() const
{
if (m_sourceExtensions.empty())
{
return getDefaultSourceExtensions();
}
return m_sourceExtensions;
}
void SourceGroupSettings::setSourceExtensions(const std::vector<std::wstring>& sourceExtensions)
{
m_sourceExtensions = sourceExtensions;
}
std::vector<FilePath> SourceGroupSettings::getPathValues(
const std::string& key, std::shared_ptr<const ConfigManager> config)
{
std::vector<FilePath> paths;
for (const std::wstring& value : getValues<std::wstring>(key, {}, config))
{
paths.push_back(FilePath(value));
}
return paths;
}
bool SourceGroupSettings::setPathValues(
const std::string& key, const std::vector<FilePath>& paths, std::shared_ptr<ConfigManager> config)
{
std::vector<std::wstring> values;
for (const FilePath& path : paths)
{
values.push_back(path.wstr());
}
return setValues(key, values, config);
}
+10 -88
View File
@@ -4,11 +4,12 @@
#include <memory>
#include <vector>
#include "settings/ProjectSettings.h"
#include "settings/LanguageType.h"
#include "settings/SourceGroupStatusType.h"
#include "settings/SourceGroupType.h"
#include "utility/file/FilePathFilter.h"
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettings
@@ -18,7 +19,7 @@ public:
static const std::string s_keyPrefix;
SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettings();
virtual ~SourceGroupSettings() = default;
virtual void load(std::shared_ptr<const ConfigManager> config);
virtual void save(std::shared_ptr<ConfigManager> config);
@@ -28,54 +29,28 @@ public:
std::string getId() const;
void setId(const std::string& id);
SourceGroupType getType() const;
LanguageType getLanguage() const;
std::string getName() const;
void setName(const std::string& name);
SourceGroupStatusType getStatus() const;
void setStatus(SourceGroupStatusType status);
FilePath getProjectDirectoryPath() const;
FilePath makePathExpandedAndAbsolute(const FilePath& path) const;
std::vector<FilePath> makePathsExpandedAndAbsolute(const std::vector<FilePath>& paths) const;
virtual std::vector<std::string> getAvailableLanguageStandards() const = 0;
virtual SourceGroupType getType() const;
SourceGroupStatusType getStatus() const;
void setStatus(SourceGroupStatusType status);
std::string getStandard() const;
void setStandard(const std::string& standard);
std::vector<FilePath> getSourcePaths() const;
std::vector<FilePath> getSourcePathsExpandedAndAbsolute() const;
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
std::vector<std::wstring> getExcludeFilterStrings() const;
std::vector<FilePathFilter> getExcludeFiltersExpandedAndAbsolute() const;
void setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters);
std::vector<std::wstring> getSourceExtensions() const;
void setSourceExtensions(const std::vector<std::wstring>& sourceExtensions);
protected:
template<typename T>
static T getValue(const std::string& key, T defaultValue, std::shared_ptr<const ConfigManager> config);
template<typename T>
static std::vector<T> getValues(const std::string& key, std::vector<T> defaultValues, std::shared_ptr<const ConfigManager> config);
static std::vector<FilePath> getPathValues(const std::string& key, std::shared_ptr<const ConfigManager> config);
template<typename T>
static bool setValue(const std::string& key, T value, std::shared_ptr<ConfigManager> config);
template<typename T>
static bool setValues(const std::string& key, std::vector<T> values, std::shared_ptr<ConfigManager> config);
static bool setPathValues(const std::string& key, const std::vector<FilePath>& paths, std::shared_ptr<ConfigManager> config);
const ProjectSettings* m_projectSettings;
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const = 0;
virtual std::string getDefaultStandard() const = 0;
std::string m_id;
@@ -84,59 +59,6 @@ private:
SourceGroupStatusType m_status;
std::string m_standard;
std::vector<FilePath> m_sourcePaths;
std::vector<std::wstring> m_excludeFilters;
std::vector<std::wstring> m_sourceExtensions;
};
template<typename T>
T SourceGroupSettings::getValue(const std::string& key, T defaultValue, std::shared_ptr<const ConfigManager> config)
{
if (config)
{
T value;
if (config->getValue(key, value))
{
return value;
}
}
return defaultValue;
}
template<typename T>
std::vector<T> SourceGroupSettings::getValues(const std::string& key, std::vector<T> defaultValues, std::shared_ptr<const ConfigManager> config)
{
if (config)
{
std::vector<T> values;
if (config->getValues(key, values))
{
return values;
}
}
return defaultValues;
}
template<typename T>
bool SourceGroupSettings::setValue(const std::string& key, T value, std::shared_ptr<ConfigManager> config)
{
if (config)
{
config->setValue(key, value);
return true;
}
return false;
}
template<typename T>
bool SourceGroupSettings::setValues(const std::string& key, std::vector<T> values, std::shared_ptr<ConfigManager> config)
{
if (config)
{
config->setValues(key, values);
return true;
}
return false;
}
#endif // SOURCE_GROUP_SETTINGS_H
+10 -33
View File
@@ -1,7 +1,8 @@
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
@@ -11,19 +12,15 @@ SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGrou
{
}
SourceGroupSettingsCxx::~SourceGroupSettingsCxx()
{
}
void SourceGroupSettingsCxx::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettings::load(config);
const std::string key = s_keyPrefix + getId();
setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path", config));
setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path", config));
setCompilerFlags(getValues<std::wstring>(key + "/compiler_flags/compiler_flag", std::vector<std::wstring>(), config));
setHeaderSearchPaths(config->getValuesOrDefaults(key + "/header_search_paths/header_search_path", std::vector<FilePath>()));
setFrameworkSearchPaths(config->getValuesOrDefaults(key + "/framework_search_paths/framework_search_path", std::vector<FilePath>()));
setCompilerFlags(config->getValuesOrDefaults(key + "/compiler_flags/compiler_flag", std::vector<std::wstring>()));
}
void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> config)
@@ -32,9 +29,9 @@ void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setPathValues(key + "/header_search_paths/header_search_path", getHeaderSearchPaths(), config);
setPathValues(key + "/framework_search_paths/framework_search_path", getFrameworkSearchPaths(), config);
setValues(key + "/compiler_flags/compiler_flag", getCompilerFlags(), config);
config->setValues(key + "/header_search_paths/header_search_path", getHeaderSearchPaths());
config->setValues(key + "/framework_search_paths/framework_search_path", getFrameworkSearchPaths());
config->setValues(key + "/compiler_flags/compiler_flag", getCompilerFlags());
}
bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -58,6 +55,7 @@ std::vector<std::string> SourceGroupSettingsCxx::getAvailableLanguageStandards()
{
case SOURCE_GROUP_CPP_EMPTY:
case SOURCE_GROUP_CXX_CDB:
case SOURCE_GROUP_CXX_SONARGRAPH:
standards.push_back("c++2a");
standards.push_back("gnu++2a");
@@ -143,33 +141,12 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::wstring>& c
m_compilerFlags = compilerFlags;
}
std::vector<std::wstring> SourceGroupSettingsCxx::getDefaultSourceExtensions() const
{
std::vector<std::wstring> defaultValues;
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
defaultValues.push_back(L".cpp");
defaultValues.push_back(L".cxx");
defaultValues.push_back(L".cc");
break;
case SOURCE_GROUP_C_EMPTY:
defaultValues.push_back(L".c");
break;
case SOURCE_GROUP_CXX_CDB:
default:
break;
}
return defaultValues;
}
std::string SourceGroupSettingsCxx::getDefaultStandard() const
{
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
case SOURCE_GROUP_CXX_SONARGRAPH:
return "c++17";
case SOURCE_GROUP_C_EMPTY:
return "c11";
+5 -7
View File
@@ -8,14 +8,13 @@ class SourceGroupSettingsCxx
{
public:
SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxx();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
virtual std::vector<std::string> getAvailableLanguageStandards() const override;
std::vector<std::string> getAvailableLanguageStandards() const override;
std::vector<FilePath> getHeaderSearchPaths() const;
std::vector<FilePath> getHeaderSearchPathsExpandedAndAbsolute() const;
@@ -29,8 +28,7 @@ public:
void setCompilerFlags(const std::vector<std::wstring>& compilerFlags);
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
virtual std::string getDefaultStandard() const override;
std::string getDefaultStandard() const override;
std::vector<FilePath> m_headerSearchPaths;
std::vector<FilePath> m_frameworkSearchPaths;
+15 -25
View File
@@ -1,7 +1,7 @@
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CDB, projectSettings)
@@ -9,18 +9,16 @@ SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, cons
{
}
SourceGroupSettingsCxxCdb::~SourceGroupSettingsCxxCdb()
{
}
void SourceGroupSettingsCxxCdb::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsCxx::load(config);
const std::string key = s_keyPrefix + getId();
setCompilationDatabasePath(FilePath(getValue<std::wstring>(key + "/build_file_path/compilation_db_path", L"", config)));
setIndexedHeaderPaths(getPathValues(key + "/indexed_header_paths/indexed_header_path", config));
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::load(config, key);
setCompilationDatabasePath(config->getValueOrDefault(key + "/build_file_path/compilation_db_path", FilePath(L"")));
}
void SourceGroupSettingsCxxCdb::save(std::shared_ptr<ConfigManager> config)
@@ -29,8 +27,10 @@ void SourceGroupSettingsCxxCdb::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().wstr(), config);
setPathValues(key + "/indexed_header_paths/indexed_header_path", getIndexedHeaderPaths(), config);
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::save(config, key);
config->setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().wstr());
}
bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -40,8 +40,9 @@ bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr<SourceGroupSettings> othe
return (
otherCxxCdb &&
SourceGroupSettingsCxx::equals(other) &&
m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath &&
utility::isPermutation(m_indexedHeaderPaths, otherCxxCdb->m_indexedHeaderPaths)
SourceGroupSettingsWithExcludeFilters::equals(otherCxxCdb) &&
SourceGroupSettingsWithIndexedHeaderPaths::equals(otherCxxCdb) &&
m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath
);
}
@@ -60,18 +61,7 @@ void SourceGroupSettingsCxxCdb::setCompilationDatabasePath(const FilePath& compi
m_compilationDatabasePath = compilationDatabasePath;
}
std::vector<FilePath> SourceGroupSettingsCxxCdb::getIndexedHeaderPaths() const
const ProjectSettings* SourceGroupSettingsCxxCdb::getProjectSettings() const
{
return m_indexedHeaderPaths;
return m_projectSettings;
}
std::vector<FilePath> SourceGroupSettingsCxxCdb::getIndexedHeaderPathsExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getIndexedHeaderPaths());
}
void SourceGroupSettingsCxxCdb::setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths)
{
m_indexedHeaderPaths = indexedHeaderPaths;
}
+10 -9
View File
@@ -2,30 +2,31 @@
#define SOURCE_GROUP_SETTINGS_CXX_CDB_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "utility/file/FilePath.h"
class SourceGroupSettingsCxxCdb
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithIndexedHeaderPaths
{
public:
SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxxCdb();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getCompilationDatabasePath() const;
FilePath getCompilationDatabasePathExpandedAndAbsolute() const;
void setCompilationDatabasePath(const FilePath& compilationDatabasePath);
std::vector<FilePath> getIndexedHeaderPaths() const;
std::vector<FilePath> getIndexedHeaderPathsExpandedAndAbsolute() const;
void setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths);
private:
const ProjectSettings* getProjectSettings() const override;
FilePath m_compilationDatabasePath;
std::vector<FilePath> m_indexedHeaderPaths;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_CDB_H
@@ -1,5 +1,6 @@
#include "settings/SourceGroupSettingsCxxEmpty.h"
#include "utility/ConfigManager.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
@@ -150,21 +151,20 @@ SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id,
{
}
SourceGroupSettingsCxxEmpty::~SourceGroupSettingsCxxEmpty()
{
}
void SourceGroupSettingsCxxEmpty::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsCxx::load(config);
const std::string key = s_keyPrefix + getId();
setTargetOptionsEnabled(getValue<bool>(key + "/cross_compilation/target_options_enabled", false, config));
setTargetArch(getValue<std::wstring>(key + "/cross_compilation/target/arch", L"", config));
setTargetVendor(getValue<std::wstring>(key + "/cross_compilation/target/vendor", L"", config));
setTargetSys(getValue<std::wstring>(key + "/cross_compilation/target/sys", L"", config));
setTargetAbi(getValue<std::wstring>(key + "/cross_compilation/target/abi", L"", config));
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
setTargetOptionsEnabled(config->getValueOrDefault<bool>(key + "/cross_compilation/target_options_enabled", false));
setTargetArch(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/arch", L""));
setTargetVendor(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/vendor", L""));
setTargetSys(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/sys", L""));
setTargetAbi(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/abi", L""));
}
void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> config)
@@ -173,11 +173,14 @@ void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled(), config);
setValue(key + "/cross_compilation/target/arch", getTargetArch(), config);
setValue(key + "/cross_compilation/target/vendor", getTargetVendor(), config);
setValue(key + "/cross_compilation/target/sys", getTargetSys(), config);
setValue(key + "/cross_compilation/target/abi", getTargetAbi(), config);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
config->setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled());
config->setValue(key + "/cross_compilation/target/arch", getTargetArch());
config->setValue(key + "/cross_compilation/target/vendor", getTargetVendor());
config->setValue(key + "/cross_compilation/target/sys", getTargetSys());
config->setValue(key + "/cross_compilation/target/abi", getTargetAbi());
}
bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -187,6 +190,8 @@ bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr<SourceGroupSettings> ot
return (
otherCxxEmpty &&
SourceGroupSettingsCxx::equals(other) &&
SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) &&
SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty) &&
getTargetFlag() == otherCxxEmpty->getTargetFlag()
);
}
@@ -254,3 +259,29 @@ std::wstring SourceGroupSettingsCxxEmpty::getTargetFlag() const
}
return targetFlag;
}
const ProjectSettings* SourceGroupSettingsCxxEmpty::getProjectSettings() const
{
return m_projectSettings;
}
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getDefaultSourceExtensions() const
{
std::vector<std::wstring> defaultValues;
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
defaultValues.push_back(L".cpp");
defaultValues.push_back(L".cxx");
defaultValues.push_back(L".cc");
break;
case SOURCE_GROUP_C_EMPTY:
defaultValues.push_back(L".c");
break;
default:
break;
}
return defaultValues;
}
+10 -4
View File
@@ -2,9 +2,13 @@
#define SOURCE_GROUP_SETTINGS_CXX_EMPTY_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithSourcePaths.h"
class SourceGroupSettingsCxxEmpty
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithSourcePaths
{
public:
static std::vector<std::wstring> getAvailableArchTypes();
@@ -13,12 +17,11 @@ public:
static std::vector<std::wstring> getAvailableEnvironmentTypes();
SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxxEmpty();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool getTargetOptionsEnabled() const;
void setTargetOptionsEnabled(bool targetOptionsEnabled);
@@ -38,6 +41,9 @@ public:
std::wstring getTargetFlag() const;
private:
const ProjectSettings* getProjectSettings() const override;
std::vector<std::wstring> getDefaultSourceExtensions() const override;
bool m_targetOptionsEnabled;
std::wstring m_targetArch;
std::wstring m_targetVendor;
@@ -0,0 +1,43 @@
#include "settings/SourceGroupSettingsCxxSonargraph.h"
SourceGroupSettingsCxxSonargraph::SourceGroupSettingsCxxSonargraph(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_SONARGRAPH, projectSettings)
{
}
void SourceGroupSettingsCxxSonargraph::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsCxx::load(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithIndexedHeaderPaths::load(config, key);
SourceGroupSettingsWithSonargraphProjectPath::load(config, key);
}
void SourceGroupSettingsCxxSonargraph::save(std::shared_ptr<ConfigManager> config)
{
SourceGroupSettingsCxx::save(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithIndexedHeaderPaths::save(config, key);
SourceGroupSettingsWithSonargraphProjectPath::save(config, key);
}
bool SourceGroupSettingsCxxSonargraph::equals(std::shared_ptr<SourceGroupSettings> other) const
{
std::shared_ptr<SourceGroupSettingsCxxSonargraph> otherCxxSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(other);
return (
otherCxxSonargraph &&
SourceGroupSettingsCxx::equals(other) &&
SourceGroupSettingsWithIndexedHeaderPaths::equals(otherCxxSonargraph) &&
SourceGroupSettingsWithSonargraphProjectPath::equals(otherCxxSonargraph)
);
}
const ProjectSettings* SourceGroupSettingsCxxSonargraph::getProjectSettings() const
{
return m_projectSettings;
}
@@ -0,0 +1,25 @@
#ifndef SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
#define SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
class SourceGroupSettingsCxxSonargraph
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithIndexedHeaderPaths
, public SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsCxxSonargraph(const std::string& id, const ProjectSettings* projectSettings);
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
private:
const ProjectSettings* getProjectSettings() const override;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
+11 -35
View File
@@ -1,15 +1,7 @@
#include "settings/SourceGroupSettingsJava.h"
#include "utility/utility.h"
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
, m_useJreSystemLibrary(true)
, m_classpath(std::vector<FilePath>())
{
}
SourceGroupSettingsJava::~SourceGroupSettingsJava()
{
}
@@ -19,8 +11,9 @@ void SourceGroupSettingsJava::load(std::shared_ptr<const ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setClasspath(getPathValues(key + "/class_paths/class_path", config));
setUseJreSystemLibrary(getValue<bool>(key + "/use_jre_system_library", true, config));
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithClasspath::load(config, key);
}
void SourceGroupSettingsJava::save(std::shared_ptr<ConfigManager> config)
@@ -29,8 +22,9 @@ void SourceGroupSettingsJava::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setPathValues(key + "/class_paths/class_path", getClasspath(), config);
setValue(key + "/use_jre_system_library", getUseJreSystemLibrary(), config);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithClasspath::save(config, key);
}
bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -40,8 +34,9 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
return (
otherJava &&
SourceGroupSettings::equals(other) &&
m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary &&
utility::isPermutation(m_classpath, otherJava->m_classpath)
SourceGroupSettingsWithSourcePaths::equals(otherJava) &&
SourceGroupSettingsWithExcludeFilters::equals(otherJava) &&
SourceGroupSettingsWithClasspath::equals(otherJava)
);
}
@@ -50,30 +45,11 @@ std::vector<std::string> SourceGroupSettingsJava::getAvailableLanguageStandards(
return std::vector<std::string>{"1", "2", "3", "4", "5", "6", "7", "8"};
}
bool SourceGroupSettingsJava::getUseJreSystemLibrary() const
const ProjectSettings* SourceGroupSettingsJava::getProjectSettings() const
{
return m_useJreSystemLibrary;
return m_projectSettings;
}
void SourceGroupSettingsJava::setUseJreSystemLibrary(bool useJreSystemLibrary)
{
m_useJreSystemLibrary = useJreSystemLibrary;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspath() const
{
return m_classpath;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspathExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspath());
}
void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpath)
{
m_classpath = classpath;
}
std::vector<std::wstring> SourceGroupSettingsJava::getDefaultSourceExtensions() const
{
return { L".java" };
+13 -17
View File
@@ -5,34 +5,30 @@
#include <vector>
#include "settings/SourceGroupSettings.h"
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithSourcePaths.h"
class SourceGroupSettingsJava
: public SourceGroupSettings
, public SourceGroupSettingsWithSourcePaths
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithClasspath
{
public:
SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJava();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
virtual std::vector<std::string> getAvailableLanguageStandards() const override;
bool getUseJreSystemLibrary() const;
void setUseJreSystemLibrary(bool useJreSystemLibrary);
std::vector<FilePath> getClasspath() const;
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
void setClasspath(const std::vector<FilePath>& classpath);
std::vector<std::string> getAvailableLanguageStandards() const override;
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
virtual std::string getDefaultStandard() const override;
bool m_useJreSystemLibrary;
std::vector<FilePath> m_classpath;
const ProjectSettings* getProjectSettings() const override;
std::vector<std::wstring> getDefaultSourceExtensions() const override;
std::string getDefaultStandard() const override;
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_H
@@ -4,7 +4,3 @@ SourceGroupSettingsJavaEmpty::SourceGroupSettingsJavaEmpty(const std::string& id
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_EMPTY, projectSettings)
{
}
SourceGroupSettingsJavaEmpty::~SourceGroupSettingsJavaEmpty()
{
}
@@ -8,7 +8,6 @@ class SourceGroupSettingsJavaEmpty
{
public:
SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaEmpty();
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H
@@ -1,5 +1,8 @@
#include "settings/SourceGroupSettingsJavaGradle.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_GRADLE, projectSettings)
, m_gradleProjectFilePath(FilePath())
@@ -8,19 +11,15 @@ SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string&
{
}
SourceGroupSettingsJavaGradle::~SourceGroupSettingsJavaGradle()
{
}
void SourceGroupSettingsJavaGradle::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsJava::load(config);
const std::string key = s_keyPrefix + getId();
setGradleProjectFilePath(FilePath(getValue<std::wstring>(key + "/gradle/project_file_path", L"", config)));
setGradleDependenciesDirectory(FilePath(getValue<std::wstring>(key + "/gradle/dependencies_directory", L"", config)));
setShouldIndexGradleTests(getValue<bool>(key + "/gradle/should_index_tests", false, config));
setGradleProjectFilePath(config->getValueOrDefault(key + "/gradle/project_file_path", FilePath(L"")));
setGradleDependenciesDirectory(config->getValueOrDefault(key + "/gradle/dependencies_directory", FilePath(L"")));
setShouldIndexGradleTests(config->getValueOrDefault(key + "/gradle/should_index_tests", false));
}
void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
@@ -29,9 +28,9 @@ void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().wstr(), config);
setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().wstr(), config);
setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests(), config);
config->setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().wstr());
config->setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().wstr());
config->setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests());
}
bool SourceGroupSettingsJavaGradle::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -8,12 +8,11 @@ class SourceGroupSettingsJavaGradle
{
public:
SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaGradle();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getGradleProjectFilePath() const;
FilePath getGradleProjectFilePathExpandedAndAbsolute() const;
@@ -1,5 +1,8 @@
#include "settings/SourceGroupSettingsJavaMaven.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_MAVEN, projectSettings)
, m_mavenProjectFilePath(FilePath())
@@ -8,19 +11,15 @@ SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id
{
}
SourceGroupSettingsJavaMaven::~SourceGroupSettingsJavaMaven()
{
}
void SourceGroupSettingsJavaMaven::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsJava::load(config);
const std::string key = s_keyPrefix + getId();
setMavenProjectFilePath(FilePath(getValue<std::wstring>(key + "/maven/project_file_path", L"", config)));
setMavenDependenciesDirectory(FilePath(getValue<std::wstring>(key + "/maven/dependencies_directory", L"", config)));
setShouldIndexMavenTests(getValue<bool>(key + "/maven/should_index_tests", false, config));
setMavenProjectFilePath(config->getValueOrDefault(key + "/maven/project_file_path", FilePath(L"")));
setMavenDependenciesDirectory(config->getValueOrDefault(key + "/maven/dependencies_directory", FilePath(L"")));
setShouldIndexMavenTests(config->getValueOrDefault(key + "/maven/should_index_tests", false));
}
void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
@@ -29,9 +28,9 @@ void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr(), config);
setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().wstr(), config);
setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests(), config);
config->setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr());
config->setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().wstr());
config->setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests());
}
bool SourceGroupSettingsJavaMaven::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -8,12 +8,11 @@ class SourceGroupSettingsJavaMaven
{
public:
SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaMaven();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getMavenProjectFilePath() const;
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
@@ -0,0 +1,53 @@
#include "settings/SourceGroupSettingsJavaSonargraph.h"
SourceGroupSettingsJavaSonargraph::SourceGroupSettingsJavaSonargraph(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, SOURCE_GROUP_JAVA_SONARGRAPH, projectSettings)
{
}
void SourceGroupSettingsJavaSonargraph::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettings::load(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithClasspath::load(config, key);
SourceGroupSettingsWithSonargraphProjectPath::load(config, key);
}
void SourceGroupSettingsJavaSonargraph::save(std::shared_ptr<ConfigManager> config)
{
SourceGroupSettings::save(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithClasspath::save(config, key);
SourceGroupSettingsWithSonargraphProjectPath::save(config, key);
}
bool SourceGroupSettingsJavaSonargraph::equals(std::shared_ptr<SourceGroupSettings> other) const
{
std::shared_ptr<SourceGroupSettingsJavaSonargraph> otherJavaSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsJavaSonargraph>(other);
return (
otherJavaSonargraph &&
SourceGroupSettings::equals(other) &&
SourceGroupSettingsWithClasspath::equals(otherJavaSonargraph) &&
SourceGroupSettingsWithSonargraphProjectPath::equals(otherJavaSonargraph)
);
}
std::vector<std::string> SourceGroupSettingsJavaSonargraph::getAvailableLanguageStandards() const
{
return std::vector<std::string>{"1", "2", "3", "4", "5", "6", "7", "8"};
}
std::string SourceGroupSettingsJavaSonargraph::getDefaultStandard() const
{
return "8";
}
const ProjectSettings* SourceGroupSettingsJavaSonargraph::getProjectSettings() const
{
return m_projectSettings;
}
@@ -0,0 +1,28 @@
#ifndef SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
#define SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
#include "settings/SourceGroupSettings.h"
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
class SourceGroupSettingsJavaSonargraph
: public SourceGroupSettings
, public SourceGroupSettingsWithClasspath
, public SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsJavaSonargraph(const std::string& id, const ProjectSettings* projectSettings);
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
std::vector<std::string> getAvailableLanguageStandards() const override;
private:
std::string getDefaultStandard() const override;
const ProjectSettings* getProjectSettings() const override;
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
@@ -0,0 +1,55 @@
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithClasspath::SourceGroupSettingsWithClasspath()
: m_classpath(std::vector<FilePath>())
, m_useJreSystemLibrary(true)
{
}
bool SourceGroupSettingsWithClasspath::equals(std::shared_ptr<SourceGroupSettingsWithClasspath> other) const
{
return (
(m_useJreSystemLibrary == other->m_useJreSystemLibrary) &&
utility::isPermutation(m_classpath, other->m_classpath)
);
}
void SourceGroupSettingsWithClasspath::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setClasspath(config->getValuesOrDefaults(key + "/class_paths/class_path", std::vector<FilePath>()));
setUseJreSystemLibrary(config->getValueOrDefault(key + "/use_jre_system_library", true));
}
void SourceGroupSettingsWithClasspath::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/class_paths/class_path", getClasspath());
config->setValue(key + "/use_jre_system_library", getUseJreSystemLibrary());
}
std::vector<FilePath> SourceGroupSettingsWithClasspath::getClasspath() const
{
return m_classpath;
}
std::vector<FilePath> SourceGroupSettingsWithClasspath::getClasspathExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getClasspath());
}
void SourceGroupSettingsWithClasspath::setClasspath(const std::vector<FilePath>& classpath)
{
m_classpath = classpath;
}
bool SourceGroupSettingsWithClasspath::getUseJreSystemLibrary() const
{
return m_useJreSystemLibrary;
}
void SourceGroupSettingsWithClasspath::setUseJreSystemLibrary(bool useJreSystemLibrary)
{
m_useJreSystemLibrary = useJreSystemLibrary;
}
@@ -0,0 +1,39 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#define SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#include <memory>
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class ConfigManager;
class ProjectSettings;
class SourceGroupSettingsWithClasspath
{
public:
SourceGroupSettingsWithClasspath();
virtual ~SourceGroupSettingsWithClasspath() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithClasspath> other) const;
std::vector<FilePath> getClasspath() const;
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
void setClasspath(const std::vector<FilePath>& classpath);
bool getUseJreSystemLibrary() const;
void setUseJreSystemLibrary(bool useJreSystemLibrary);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePath> m_classpath;
bool m_useJreSystemLibrary;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
@@ -0,0 +1,103 @@
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/ProjectSettings.h"
#include "utility/file/FilePathFilter.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
SourceGroupSettingsWithExcludeFilters::SourceGroupSettingsWithExcludeFilters()
: m_excludeFilters(std::vector<std::wstring>())
{
}
bool SourceGroupSettingsWithExcludeFilters::equals(std::shared_ptr<SourceGroupSettingsWithExcludeFilters> other) const
{
return (
utility::isPermutation(m_excludeFilters, other->m_excludeFilters)
);
}
void SourceGroupSettingsWithExcludeFilters::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setExcludeFilterStrings(config->getValuesOrDefaults(key + "/exclude_filters/exclude_filter", std::vector<std::wstring>()));
}
void SourceGroupSettingsWithExcludeFilters::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/exclude_filters/exclude_filter", getExcludeFilterStrings());
}
std::vector<std::wstring> SourceGroupSettingsWithExcludeFilters::getExcludeFilterStrings() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getExcludeFiltersExpandedAndAbsolute() const
{
return getFiltersExpandedAndAbsolute(getExcludeFilterStrings());
}
void SourceGroupSettingsWithExcludeFilters::setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters)
{
m_excludeFilters = excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getFiltersExpandedAndAbsolute(const std::vector<std::wstring>& filterStrings) const
{
std::vector<FilePathFilter> result;
for (const std::wstring& filterString : filterStrings)
{
if (!filterString.empty())
{
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
{
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
{
const FilePath p = getProjectSettings()->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
}
)
);
}
else
{
result.push_back(FilePathFilter(filterString));
}
}
else
{
const FilePath p = getProjectSettings()->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>
(
utility::toVector(symLinkPaths),
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
}
}
return result;
}
@@ -0,0 +1,35 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
#define SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePathFilter;
class ProjectSettings;
class SourceGroupSettingsWithExcludeFilters
{
public:
SourceGroupSettingsWithExcludeFilters();
virtual ~SourceGroupSettingsWithExcludeFilters() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithExcludeFilters> other) const;
std::vector<std::wstring> getExcludeFilterStrings() const;
std::vector<FilePathFilter> getExcludeFiltersExpandedAndAbsolute() const;
void setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePathFilter> getFiltersExpandedAndAbsolute(const std::vector<std::wstring>& filterStrings) const;
std::vector<std::wstring> m_excludeFilters;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
@@ -0,0 +1,41 @@
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithIndexedHeaderPaths::SourceGroupSettingsWithIndexedHeaderPaths()
: m_indexedHeaderPaths(std::vector<FilePath>())
{
}
bool SourceGroupSettingsWithIndexedHeaderPaths::equals(std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> other) const
{
return (
utility::isPermutation(m_indexedHeaderPaths, other->m_indexedHeaderPaths)
);
}
void SourceGroupSettingsWithIndexedHeaderPaths::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setIndexedHeaderPaths(config->getValuesOrDefaults(key + "/indexed_header_paths/indexed_header_path", std::vector<FilePath>()));
}
void SourceGroupSettingsWithIndexedHeaderPaths::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/indexed_header_paths/indexed_header_path", getIndexedHeaderPaths());
}
std::vector<FilePath> SourceGroupSettingsWithIndexedHeaderPaths::getIndexedHeaderPaths() const
{
return m_indexedHeaderPaths;
}
std::vector<FilePath> SourceGroupSettingsWithIndexedHeaderPaths::getIndexedHeaderPathsExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getIndexedHeaderPaths());
}
void SourceGroupSettingsWithIndexedHeaderPaths::setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths)
{
m_indexedHeaderPaths = indexedHeaderPaths;
}
@@ -0,0 +1,34 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
#define SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettingsWithIndexedHeaderPaths
{
public:
SourceGroupSettingsWithIndexedHeaderPaths();
virtual ~SourceGroupSettingsWithIndexedHeaderPaths() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> other) const;
std::vector<FilePath> getIndexedHeaderPaths() const;
std::vector<FilePath> getIndexedHeaderPathsExpandedAndAbsolute() const;
void setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePath> m_indexedHeaderPaths;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
@@ -0,0 +1,40 @@
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
#include "settings/ProjectSettings.h"
SourceGroupSettingsWithSonargraphProjectPath::SourceGroupSettingsWithSonargraphProjectPath()
{
}
bool SourceGroupSettingsWithSonargraphProjectPath::equals(std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> other) const
{
return (
other &&
m_sonargraphProjectPath == other->m_sonargraphProjectPath
);
}
void SourceGroupSettingsWithSonargraphProjectPath::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setSonargraphProjectPath(config->getValueOrDefault(key + "/sonargraph_project_path", FilePath(L"")));
}
void SourceGroupSettingsWithSonargraphProjectPath::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValue(key + "/sonargraph_project_path", getSonargraphProjectPath().wstr());
}
FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPath() const
{
return m_sonargraphProjectPath;
}
FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPathExpandedAndAbsolute() const
{
return getProjectSettings()->makePathExpandedAndAbsolute(getSonargraphProjectPath());
}
void SourceGroupSettingsWithSonargraphProjectPath::setSonargraphProjectPath(const FilePath& sonargraphProjectPath)
{
m_sonargraphProjectPath = sonargraphProjectPath;
}
@@ -0,0 +1,34 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
#define SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
#include <memory>
#include <string>
#include "utility/file/FilePath.h"
class ConfigManager;
class ProjectSettings;
class SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsWithSonargraphProjectPath();
virtual ~SourceGroupSettingsWithSonargraphProjectPath() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> other) const;
FilePath getSonargraphProjectPath() const;
FilePath getSonargraphProjectPathExpandedAndAbsolute() const;
void setSonargraphProjectPath(const FilePath& sonargraphProjectPath);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
FilePath m_sonargraphProjectPath;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
@@ -0,0 +1,59 @@
#include "settings/SourceGroupSettingsWithSourcePaths.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithSourcePaths::SourceGroupSettingsWithSourcePaths()
: m_sourcePaths(std::vector<FilePath>())
, m_sourceExtensions(std::vector<std::wstring>())
{
}
bool SourceGroupSettingsWithSourcePaths::equals(std::shared_ptr<SourceGroupSettingsWithSourcePaths> other) const
{
return (
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
);
}
void SourceGroupSettingsWithSourcePaths::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setSourcePaths(config->getValuesOrDefaults(key + "/source_paths/source_path", std::vector<FilePath>()));
setSourceExtensions(config->getValuesOrDefaults(key + "/source_extensions/source_extension", std::vector<std::wstring>()));
}
void SourceGroupSettingsWithSourcePaths::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/source_paths/source_path", getSourcePaths());
config->setValues(key + "/source_extensions/source_extension", getSourceExtensions());
}
std::vector<FilePath> SourceGroupSettingsWithSourcePaths::getSourcePaths() const
{
return m_sourcePaths;
}
std::vector<FilePath> SourceGroupSettingsWithSourcePaths::getSourcePathsExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getSourcePaths());
}
void SourceGroupSettingsWithSourcePaths::setSourcePaths(const std::vector<FilePath>& sourcePaths)
{
m_sourcePaths = sourcePaths;
}
std::vector<std::wstring> SourceGroupSettingsWithSourcePaths::getSourceExtensions() const
{
if (m_sourceExtensions.empty())
{
return getDefaultSourceExtensions();
}
return m_sourceExtensions;
}
void SourceGroupSettingsWithSourcePaths::setSourceExtensions(const std::vector<std::wstring>& sourceExtensions)
{
m_sourceExtensions = sourceExtensions;
}
@@ -0,0 +1,39 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
#define SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettingsWithSourcePaths
{
public:
SourceGroupSettingsWithSourcePaths();
virtual ~SourceGroupSettingsWithSourcePaths() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithSourcePaths> other) const;
std::vector<FilePath> getSourcePaths() const;
std::vector<FilePath> getSourcePathsExpandedAndAbsolute() const;
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
std::vector<std::wstring> getSourceExtensions() const;
void setSourceExtensions(const std::vector<std::wstring>& sourceExtensions);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
virtual std::vector<std::wstring> getDefaultSourceExtensions() const = 0;
std::vector<FilePath> m_sourcePaths;
std::vector<std::wstring> m_sourceExtensions;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
+17 -1
View File
@@ -10,6 +10,8 @@ std::string sourceGroupTypeToString(SourceGroupType v)
return "C++ Source Group";
case SOURCE_GROUP_CXX_CDB:
return "C/C++ from Compilation Database";
case SOURCE_GROUP_CXX_SONARGRAPH:
return "C/C++ from Sonargraph";
case SOURCE_GROUP_CXX_VS:
return "C/C++ from Visual Studio";
case SOURCE_GROUP_JAVA_EMPTY:
@@ -18,6 +20,8 @@ std::string sourceGroupTypeToString(SourceGroupType v)
return "Java Source Group from Maven";
case SOURCE_GROUP_JAVA_GRADLE:
return "Java Source Group from Gradle";
case SOURCE_GROUP_JAVA_SONARGRAPH:
return "Java from Sonargraph";
case SOURCE_GROUP_UNKNOWN:
break;
}
@@ -34,6 +38,8 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v)
return "Empty C++ Source Group";
case SOURCE_GROUP_CXX_CDB:
return "C/C++ from Compilation Database";
case SOURCE_GROUP_CXX_SONARGRAPH:
return "C/C++ from Sonargraph";
case SOURCE_GROUP_CXX_VS:
return "C/C++ from Visual Studio";
case SOURCE_GROUP_JAVA_EMPTY:
@@ -42,13 +48,15 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v)
return "Java Source Group from Maven";
case SOURCE_GROUP_JAVA_GRADLE:
return "Java Source Group from Gradle";
case SOURCE_GROUP_JAVA_SONARGRAPH:
return "Java from Sonargraph";
case SOURCE_GROUP_UNKNOWN:
break;
}
return "unknown";
}
SourceGroupType stringToSourceGroupType(std::string v)
SourceGroupType stringToSourceGroupType(const std::string& v)
{
if (v == sourceGroupTypeToString(SOURCE_GROUP_C_EMPTY))
{
@@ -62,6 +70,10 @@ SourceGroupType stringToSourceGroupType(std::string v)
{
return SOURCE_GROUP_CXX_CDB;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_SONARGRAPH))
{
return SOURCE_GROUP_CXX_SONARGRAPH;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_VS))
{
return SOURCE_GROUP_CXX_VS;
@@ -78,6 +90,10 @@ SourceGroupType stringToSourceGroupType(std::string v)
{
return SOURCE_GROUP_JAVA_GRADLE;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_SONARGRAPH))
{
return SOURCE_GROUP_JAVA_SONARGRAPH;
}
return SOURCE_GROUP_UNKNOWN;
}
+3 -1
View File
@@ -8,15 +8,17 @@ enum SourceGroupType
SOURCE_GROUP_C_EMPTY,
SOURCE_GROUP_CPP_EMPTY,
SOURCE_GROUP_CXX_CDB,
SOURCE_GROUP_CXX_SONARGRAPH,
SOURCE_GROUP_CXX_VS,
SOURCE_GROUP_JAVA_EMPTY,
SOURCE_GROUP_JAVA_MAVEN,
SOURCE_GROUP_JAVA_GRADLE,
SOURCE_GROUP_JAVA_SONARGRAPH,
SOURCE_GROUP_UNKNOWN
};
std::string sourceGroupTypeToString(SourceGroupType v);
std::string sourceGroupTypeToProjectSetupString(SourceGroupType v);
SourceGroupType stringToSourceGroupType(std::string v);
SourceGroupType stringToSourceGroupType(const std::string& v);
#endif // SOURCE_GROUP_TYPE_H
+44 -5
View File
@@ -4,6 +4,7 @@
#include "tinyxml/tinyxml.h"
#include "utility/file/FilePath.h"
#include "utility/logging/logging.h"
#include "utility/text/TextAccess.h"
#include "utility/utility.h"
@@ -96,6 +97,17 @@ bool ConfigManager::getValue(const std::string& key, bool& value) const
return false;
}
bool ConfigManager::getValue(const std::string& key, FilePath& value) const
{
std::wstring valueString;
if (getValue(key, valueString))
{
value = FilePath(valueString);
return true;
}
return false;
}
bool ConfigManager::getValues(const std::string& key, std::vector<std::string>& values) const
{
std::pair <std::multimap<std::string, std::string>::const_iterator,
@@ -178,6 +190,20 @@ bool ConfigManager::getValues(const std::string& key, std::vector<bool>& values)
return false;
}
bool ConfigManager::getValues(const std::string& key, std::vector<FilePath>& values) const
{
std::vector<std::wstring> valuesStringVector;
if (getValues(key, valuesStringVector))
{
for (const std::wstring& valueString : valuesStringVector)
{
values.push_back(FilePath(valueString));
}
return true;
}
return false;
}
void ConfigManager::setValue(const std::string& key, const std::string& value)
{
std::multimap<std::string, std::string>::iterator it = m_values.find(key);
@@ -214,6 +240,11 @@ void ConfigManager::setValue(const std::string& key, const bool value)
setValue(key, std::string(value ? "1" : "0"));
}
void ConfigManager::setValue(const std::string& key, const FilePath& value)
{
setValue(key, value.wstr());
}
void ConfigManager::setValues(const std::string& key, const std::vector<std::string>& values)
{
std::multimap<std::string, std::string>::iterator it = m_values.find(key);
@@ -268,6 +299,16 @@ void ConfigManager::setValues(const std::string& key, const std::vector<bool>& v
setValues(key, stringValues);
}
void ConfigManager::setValues(const std::string& key, const std::vector<FilePath>& values)
{
std::vector<std::wstring> stringValues;
for (const FilePath& p : values)
{
stringValues.push_back(p.wstr());
}
setValues(key, stringValues);
}
void ConfigManager::removeValues(const std::string& key)
{
for (const std::string& sublevelKey: getSublevelKeys(key))
@@ -304,20 +345,18 @@ std::vector<std::string> ConfigManager::getSublevelKeys(const std::string& key)
bool ConfigManager::load(const std::shared_ptr<TextAccess> textAccess)
{
std::string text = textAccess->getText();
TiXmlDocument doc;
const char* pTest = doc.Parse(text.c_str(), 0, TIXML_ENCODING_UTF8);
const char* pTest = doc.Parse(textAccess->getText().c_str(), 0, TIXML_ENCODING_UTF8);
if (pTest != nullptr)
{
TiXmlHandle docHandle(&doc);
TiXmlNode *rootNode = docHandle.FirstChild("config").ToNode();
TiXmlNode* rootNode = docHandle.FirstChild("config").ToNode();
if (rootNode == nullptr)
{
LOG_ERROR("No rootelement 'config' in the configfile");
return false;
}
for (TiXmlNode *childNode = rootNode->FirstChild(); childNode; childNode = childNode->NextSibling())
for (TiXmlNode* childNode = rootNode->FirstChild(); childNode; childNode = childNode->NextSibling())
{
parseSubtree(childNode, "");
}
+33
View File
@@ -8,6 +8,7 @@
class TextAccess;
class TiXmlNode;
class FilePath;
class ConfigManager
{
@@ -23,24 +24,34 @@ public:
bool getValue(const std::string& key, int& value) const;
bool getValue(const std::string& key, float& value) const;
bool getValue(const std::string& key, bool& value) const;
bool getValue(const std::string& key, FilePath& value) const;
template<typename T>
T getValueOrDefault(const std::string& key, T defaultValue) const;
bool getValues(const std::string& key, std::vector<std::string>& values) const;
bool getValues(const std::string& key, std::vector<std::wstring>& values) const;
bool getValues(const std::string& key, std::vector<int>& values) const;
bool getValues(const std::string& key, std::vector<float>& values) const;
bool getValues(const std::string& key, std::vector<bool>& values) const;
bool getValues(const std::string& key, std::vector<FilePath>& values) const;
template<typename T>
std::vector<T> getValuesOrDefaults(const std::string& key, std::vector<T> defaultValues) const;
void setValue(const std::string& key, const std::string& value);
void setValue(const std::string& key, const std::wstring& value);
void setValue(const std::string& key, const int value);
void setValue(const std::string& key, const float value);
void setValue(const std::string& key, const bool value);
void setValue(const std::string& key, const FilePath& value);
void setValues(const std::string& key, const std::vector<std::string>& values);
void setValues(const std::string& key, const std::vector<std::wstring>& values);
void setValues(const std::string& key, const std::vector<int>& values);
void setValues(const std::string& key, const std::vector<float>& values);
void setValues(const std::string& key, const std::vector<bool>& values);
void setValues(const std::string& key, const std::vector<FilePath>& values);
void removeValues(const std::string& key);
@@ -65,4 +76,26 @@ private:
mutable bool m_warnOnEmptyKey;
};
template<typename T>
T ConfigManager::getValueOrDefault(const std::string& key, T defaultValue) const
{
T value;
if (getValue(key, value))
{
return value;
}
return defaultValue;
}
template<typename T>
std::vector<T> ConfigManager::getValuesOrDefaults(const std::string& key, std::vector<T> defaultValues) const
{
std::vector<T> values;
if (getValues(key, values))
{
return values;
}
return defaultValues;
}
#endif // CONFIG_MANAGER_H
+53
View File
@@ -0,0 +1,53 @@
#ifndef OPTIONAL_H
#define OPTIONAL_H
template <typename T>
class Optional
{
public:
Optional();
Optional(const T& value);
T& get();
const T& get() const;
bool isPresent() const;
private:
bool m_isPresent;
T m_value;
};
template <typename T>
Optional<T>::Optional()
: m_isPresent(false)
{
}
template <typename T>
Optional<T>::Optional(const T& value)
: m_isPresent(false)
, m_value(value)
{
}
template <typename T>
T& Optional<T>::get()
{
return m_value;
}
template <typename T>
const T& Optional<T>::get() const
{
return m_value;
}
template <typename T>
bool Optional<T>::isPresent() const
{
return m_isPresent;
}
#endif // OPTIONAL_H
@@ -0,0 +1,89 @@
#include "utility/sonargraph/SonargraphProject.h"
#include "tinyxml/tinyxml.h"
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
#include "utility/logging/logging.h"
#include "utility/text/TextAccess.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::shared_ptr<Project> Project::load(const FilePath& projectFilePath, LanguageType targetLanguage)
{
return load(TextAccess::createFromFile(projectFilePath), targetLanguage);
}
std::shared_ptr<Project> Project::load(std::shared_ptr<TextAccess> xmlAccess, LanguageType targetLanguage)
{
if (!xmlAccess)
{
return std::shared_ptr<Project>();
}
std::shared_ptr<Project> project = std::shared_ptr<Project>(new Project());
TiXmlDocument doc;
doc.Parse(xmlAccess->getText().c_str(), 0, TIXML_ENCODING_UTF8);
if (doc.Error())
{
LOG_ERROR(
"Unable to parse Sonargraph project because of an error in row " + std::to_string(doc.ErrorRow()) + ", col " +
std::to_string(doc.ErrorCol()) + ": " + std::string(doc.ErrorDesc())
);
return std::shared_ptr<Project>();
}
TiXmlHandle docHandle(&doc);
TiXmlElement* softwareSystemElement = docHandle.FirstChildElement("ns2:softwareSystem").ToElement();
if (softwareSystemElement == nullptr)
{
LOG_ERROR("Unable to find \"ns2:softwareSystem\" in Sonargraph project.");
return std::shared_ptr<Project>();
}
std::shared_ptr<SoftwareSystem> softwareSystem = SoftwareSystem::create(
softwareSystemElement, xmlAccess->getFilePath().getParentDirectory().getParentDirectory(), targetLanguage
);
if (!softwareSystem)
{
return std::shared_ptr<Project>();
}
project->m_softwareSystem = softwareSystem;
return project;
}
int Project::getLoadedModuleCount() const
{
return m_softwareSystem->getModules().size();
}
std::set<FilePath> Project::getAllSourcePaths() const
{
return m_softwareSystem->getAllSourcePaths();
}
std::set<FilePath> Project::getAllSourceFilePathsCanonical() const
{
return m_softwareSystem->getAllSourceFilePathsCanonical();
}
std::set<FilePath> Project::getAllCxxHeaderSearchPathsCanonical() const
{
return m_softwareSystem->getAllCxxHeaderSearchPathsCanonical();
}
std::set<FilePath> Project::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
return m_softwareSystem->filterToContainedFilePaths(filePaths);
}
std::vector<std::shared_ptr<IndexerCommand>> Project::getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
return m_softwareSystem->getIndexerCommands(sourceGroupSettings, appSettings);
}
}
@@ -0,0 +1,50 @@
#ifndef SONARGRAPH_PROJECT_H
#define SONARGRAPH_PROJECT_H
#include <set>
#include <memory>
#include <vector>
// xsdCppModule
// xsdCppManualModule -> basePathForIncludes(0, n), sourceFileExtensions(0, n), moduleCompilerOptions(0, n)
// xsdCmakeJsonModule -> rootPathWithFiles(0, n)
// xsdCppMakefileModule -> makefile(1), additionalCompilerOptions(0, 1)
// xsdCppVsProjectFileModule -> projectFile(1,1)
// xsdCppCaptureModule -> captureFile(1,1)
class ApplicationSettings;
class FilePath;
class IndexerCommand;
class SourceGroupSettings;
class TextAccess;
enum LanguageType;
namespace Sonargraph
{
class SoftwareSystem;
class Project
{
public:
static std::shared_ptr<Project> load(const FilePath& projectFilePath, LanguageType targetLanguage);
static std::shared_ptr<Project> load(std::shared_ptr<TextAccess> xmlAccess, LanguageType targetLanguage);
int getLoadedModuleCount() const;
std::set<FilePath> getAllSourcePaths() const;
std::set<FilePath> getAllSourceFilePathsCanonical() const;
std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const;
private:
Project() = default;
std::shared_ptr<SoftwareSystem> m_softwareSystem;
};
}
#endif // SONARGRAPH_PROJECT_H
@@ -0,0 +1,210 @@
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
#include "tinyxml/tinyxml.h"
#include "data/indexer/IndexerCommand.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
#include "utility/utility.h"
namespace Sonargraph
{
std::shared_ptr<SoftwareSystem> SoftwareSystem::create(const TiXmlElement* element, const FilePath& baseDirectory, LanguageType targetLanguage)
{
std::shared_ptr<SoftwareSystem> softwareSystem = std::shared_ptr<SoftwareSystem>(new SoftwareSystem());
if (softwareSystem->init(element, baseDirectory, targetLanguage))
{
return softwareSystem;
}
return std::shared_ptr<SoftwareSystem>();
}
std::wstring SoftwareSystem::getName() const
{
return m_name;
}
std::string SoftwareSystem::getVersion() const
{
return m_version;
}
std::wstring SoftwareSystem::getDescription() const
{
return m_description;
}
std::vector<FilePathFilter> SoftwareSystem::getExcludeFilters() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> SoftwareSystem::getIncludeFilters() const
{
return m_includeFilters;
}
const std::vector<std::shared_ptr<XsdAbstractModule>> SoftwareSystem::getModules() const
{
return m_modules;
}
const std::vector<std::shared_ptr<XsdAbstractSystemExtension>> SoftwareSystem::getSystemExtensions() const
{
return m_systemExtensions;
}
FilePath SoftwareSystem::getBaseDirectory() const
{
return m_baseDirectory;
}
std::set<FilePath> SoftwareSystem::getAllSourcePaths() const
{
std::set<FilePath> sourcePaths;
for (std::shared_ptr<XsdAbstractModule> module : m_modules)
{
utility::append(sourcePaths, module->getAllSourcePaths());
}
return sourcePaths;
}
std::set<FilePath> SoftwareSystem::getAllSourceFilePathsCanonical() const
{
std::set<FilePath> sourceFilePaths;
for (std::shared_ptr<XsdAbstractModule> module : m_modules)
{
utility::append(sourceFilePaths, module->getAllSourceFilePathsCanonical());
}
return sourceFilePaths;
}
std::set<FilePath> SoftwareSystem::getAllCxxHeaderSearchPathsCanonical() const
{
std::set<FilePath> sourceFilePaths;
for (std::shared_ptr<XsdAbstractModule> module : m_modules)
{
utility::append(sourceFilePaths, module->getAllCxxHeaderSearchPathsCanonical());
}
return sourceFilePaths;
}
std::set<FilePath> SoftwareSystem::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
std::set<FilePath> containedFilePaths;
for (std::shared_ptr<XsdAbstractModule> module : m_modules)
{
utility::append(containedFilePaths, module->filterToContainedFilePaths(filePaths));
}
return containedFilePaths;
}
std::vector<std::shared_ptr<IndexerCommand>> SoftwareSystem::getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (std::shared_ptr<XsdAbstractModule> module : m_modules)
{
utility::append(indexerCommands, module->getIndexerCommands(sourceGroupSettings, appSettings));
}
return indexerCommands;
}
bool SoftwareSystem::init(const TiXmlElement* element, const FilePath& baseDirectory, LanguageType targetLanguage)
{
m_baseDirectory = baseDirectory;
if (element != nullptr)
{
{
const char* value = element->Attribute("name");
if (value != nullptr)
{
m_name = utility::decodeFromUtf8(value);
}
else
{
LOG_INFO("Unable to parse \"name\" attribute of Sonargraph softwareSystem.");
}
}
{
const char* value = element->Attribute("version");
if (value != nullptr)
{
m_version = value;
}
else
{
LOG_WARNING("Unable to parse \"version\" attribute of Sonargraph softwareSystem.");
}
}
{
const TiXmlElement* descriptionElement = element->FirstChildElement("description");
if (descriptionElement != nullptr)
{
const char* text = descriptionElement->GetText();
if (text != nullptr)
{
m_description = utility::decodeFromUtf8(text);
}
}
}
for (const TiXmlElement* excludeElement : utility::getXmlChildElementsWithName(element, "exclude"))
{
const char* text = excludeElement->GetText();
if (text != nullptr)
{
m_excludeFilters.push_back(FilePathFilter(utility::decodeFromUtf8(text)));
}
}
for (const TiXmlElement* includeElement : utility::getXmlChildElementsWithName(element, "include"))
{
const char* text = includeElement->GetText();
if (text != nullptr)
{
m_includeFilters.push_back(FilePathFilter(utility::decodeFromUtf8(text)));
}
}
for (const TiXmlElement* moduleElement : utility::getXmlChildElementsWithName(element, "module"))
{
if (std::shared_ptr<XsdAbstractModule> module = XsdAbstractModule::create(moduleElement, shared_from_this()))
{
if (module->getSupportedLanguage() == targetLanguage)
{
m_modules.push_back(module);
}
else
{
LOG_INFO(L"Discarding Sonargraph module \"" + module->getName() + L"\" because it does not match the Sourcetrail project's language type.");
}
}
else
{
LOG_ERROR("Unable to parse \"module\" element of Sonargraph softwareSystem.");
return false;
}
}
for (const TiXmlElement* systemExtensionElement : utility::getXmlChildElementsWithName(element, "systemExtension"))
{
if (std::shared_ptr<XsdAbstractSystemExtension> systemExtension = XsdAbstractSystemExtension::create(systemExtensionElement))
{
m_systemExtensions.push_back(systemExtension);
}
else
{
LOG_ERROR("Unable to parse \"systemExtension\" element of Sonargraph softwareSystem.");
return false;
}
}
return true;
}
return false;
}
}
@@ -0,0 +1,76 @@
#ifndef SONARGRAPH_SOFTWARE_SYSTEM_H
#define SONARGRAPH_SOFTWARE_SYSTEM_H
#include <string>
#include <vector>
#include "utility/file/FilePathFilter.h"
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
#include "utility/sonargraph/SonargraphXsdAbstractSystemExtension.h"
class ApplicationSettings;
class IndexerCommand;
class SourceGroupSettings;
class TiXmlElement;
enum LanguageType;
namespace Sonargraph
{
class SoftwareSystem : public std::enable_shared_from_this<SoftwareSystem>
{
public:
static std::shared_ptr<SoftwareSystem> create(const TiXmlElement* element, const FilePath& baseDirectory, LanguageType targetLanguage);
std::wstring getName() const;
std::string getVersion() const;
std::wstring getDescription() const;
std::vector<FilePathFilter> getExcludeFilters() const;
std::vector<FilePathFilter> getIncludeFilters() const;
const std::vector<std::shared_ptr<XsdAbstractModule>> getModules() const;
const std::vector<std::shared_ptr<XsdAbstractSystemExtension>> getSystemExtensions() const;
FilePath getBaseDirectory() const;
std::set<FilePath> getAllSourcePaths() const;
std::set<FilePath> getAllSourceFilePathsCanonical() const;
std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const;
template <typename ExtensionType>
std::vector<std::shared_ptr<ExtensionType>> getSpecificSystemExtensions() const;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const;
protected:
SoftwareSystem() = default;
bool init(const TiXmlElement* element, const FilePath& baseDirectory, LanguageType targetLanguage);
FilePath m_baseDirectory;
std::wstring m_name;
std::string m_version;
std::wstring m_description;
std::vector<FilePathFilter> m_excludeFilters;
std::vector<FilePathFilter> m_includeFilters;
std::vector<std::shared_ptr<XsdAbstractModule>> m_modules;
std::vector<std::shared_ptr<XsdAbstractSystemExtension>> m_systemExtensions;
};
template <typename ExtensionType>
std::vector<std::shared_ptr<ExtensionType>> SoftwareSystem::getSpecificSystemExtensions() const
{
std::vector<std::shared_ptr<ExtensionType>> systemExtensions;
for (std::shared_ptr<XsdAbstractSystemExtension> systemExtension : getSystemExtensions())
{
if (std::shared_ptr<ExtensionType> castSystemExtension = std::dynamic_pointer_cast<ExtensionType>(systemExtension))
{
systemExtensions.push_back(castSystemExtension);
}
}
return systemExtensions;
}
}
#endif // SONARGRAPH_SOFTWARE_SYSTEM_H
@@ -0,0 +1,67 @@
#include "utility/sonargraph/SonargraphSourceRootPath.h"
#include "tinyxml/tinyxml.h"
#include "data/indexer/IndexerCommandJava.h"
#include "utility/logging/logging.h"
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
#include "utility/sonargraph/SonargraphXsdRootPathWithFiles.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::string SourceRootPath::getXsdTypeName()
{
return "sourceRootPath";
}
std::shared_ptr<SourceRootPath> SourceRootPath::create(const TiXmlElement* element)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<SourceRootPath> rootPath = std::shared_ptr<SourceRootPath>(new SourceRootPath());
if (rootPath->init(element))
{
return rootPath;
}
}
return std::shared_ptr<SourceRootPath>();
}
std::wstring SourceRootPath::getName() const
{
return m_name;
}
FilePath SourceRootPath::getFilePath(const FilePath& baseDirectory) const
{
FilePath filePath(getName());
if (filePath.isAbsolute())
{
return filePath;
}
return baseDirectory.getConcatenated(filePath);
}
bool SourceRootPath::init(const TiXmlElement* element)
{
if (element != nullptr)
{
const char* value = element->Attribute("name");
if (value != nullptr)
{
m_name = utility::decodeFromUtf8(value);
}
else
{
LOG_ERROR("Unable to parse \"name\" of Sonargraph " + getXsdTypeName() + ".");
return false;
}
return true;
}
return false;
}
}
@@ -0,0 +1,34 @@
#ifndef SONARGRAPH_SOURCE_ROOT_PATH_H
#define SONARGRAPH_SOURCE_ROOT_PATH_H
#include <memory>
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class TiXmlElement;
namespace Sonargraph
{
class SourceRootPath
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<SourceRootPath> create(const TiXmlElement* element);
virtual ~SourceRootPath() = default;
std::wstring getName() const;
FilePath getFilePath(const FilePath& baseDirectory) const;
protected:
SourceRootPath() = default;
bool init(const TiXmlElement* element);
std::wstring m_name;
};
}
#endif // SONARGRAPH_SOURCE_ROOT_PATH_H
@@ -0,0 +1,148 @@
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
#include "tinyxml/tinyxml.h"
#include "utility/logging/logging.h"
#include "utility/sonargraph/SonargraphXsdCmakeJsonModule.h"
#include "utility/sonargraph/SonargraphXsdJavaModule.h"
#include "utility/sonargraph/SonargraphXsdRootPath.h"
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
#include "utility/utility.h"
namespace Sonargraph
{
std::string XsdAbstractModule::getXsdTypeName()
{
return "xsdAbstractModule";
}
std::shared_ptr<XsdAbstractModule> XsdAbstractModule::create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
if (std::shared_ptr<XsdAbstractModule> module = XsdCmakeJsonModule::create(element, parent))
{
return module;
}
if (std::shared_ptr<XsdJavaModule> module = XsdJavaModule::create(element, parent))
{
return module;
}
return std::shared_ptr<XsdAbstractModule>();
}
std::wstring XsdAbstractModule::getName() const
{
return m_name;
}
std::wstring XsdAbstractModule::getDescription() const
{
return m_description;
}
std::vector<FilePathFilter> XsdAbstractModule::getExcludeFilters() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> XsdAbstractModule::getIncludeFilters() const
{
return m_includeFilters;
}
std::vector<std::shared_ptr<XsdRootPath>> XsdAbstractModule::getRootPaths() const
{
return m_rootPaths;
}
std::shared_ptr<const SoftwareSystem> XsdAbstractModule::getSoftwareSystem() const
{
return m_parent.lock();
}
std::vector<FilePathFilter> XsdAbstractModule::getDerivedExcludeFilters() const
{
std::vector<FilePathFilter> excludeFilters = getExcludeFilters();
if (std::shared_ptr<const SoftwareSystem> parent = getSoftwareSystem())
{
utility::append(excludeFilters, parent->getExcludeFilters());
}
return excludeFilters;
}
std::vector<FilePathFilter> XsdAbstractModule::getDerivedIncludeFilters() const
{
std::vector<FilePathFilter> includeFilters = getIncludeFilters();
if (std::shared_ptr<const SoftwareSystem> parent = getSoftwareSystem())
{
utility::append(includeFilters, parent->getIncludeFilters());
}
return includeFilters;
}
bool XsdAbstractModule::init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
m_parent = parent;
if (element != nullptr)
{
{
const char* value = element->Attribute("name");
if (value != nullptr)
{
m_name = utility::decodeFromUtf8(value);
}
else
{
LOG_WARNING("Unable to parse \"name\" attribute of Sonargraph " + getXsdTypeName() + ".");
}
}
{
const TiXmlElement* descriptionElement = element->FirstChildElement("description");
if (descriptionElement != nullptr)
{
const char* text = descriptionElement->GetText();
if (text != nullptr)
{
m_description = utility::decodeFromUtf8(text);
}
}
}
for (const TiXmlElement* excludeElement : utility::getXmlChildElementsWithName(element, "exclude"))
{
const char* text = excludeElement->GetText();
if (text != nullptr)
{
m_excludeFilters.push_back(FilePathFilter(utility::decodeFromUtf8(text)));
}
}
for (const TiXmlElement* includeElement : utility::getXmlChildElementsWithName(element, "include"))
{
const char* text = includeElement->GetText();
if (text != nullptr)
{
m_includeFilters.push_back(FilePathFilter(utility::decodeFromUtf8(text)));
}
}
for (const TiXmlElement* rootPathElement : utility::getXmlChildElementsWithName(element, "rootPath"))
{
if (std::shared_ptr<XsdRootPath> rootPath = XsdRootPath::create(rootPathElement))
{
m_rootPaths.push_back(rootPath);
}
else
{
LOG_ERROR("Unable to parse \"rootPath\" element of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
return true;
}
return false;
}
}
@@ -0,0 +1,63 @@
#ifndef SONARGRAPH_XSD_ABSTRACT_MODULE_H
#define SONARGRAPH_XSD_ABSTRACT_MODULE_H
#include <set>
#include <string>
#include <vector>
#include "utility/file/FilePathFilter.h"
class ApplicationSettings;
class IndexerCommand;
class SourceGroupSettings;
class TiXmlElement;
enum LanguageType;
namespace Sonargraph
{
class XsdRootPath;
class SoftwareSystem;
class XsdAbstractModule
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdAbstractModule> create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
virtual ~XsdAbstractModule() = default;
virtual LanguageType getSupportedLanguage() const = 0;
std::wstring getName() const;
std::wstring getDescription() const;
std::vector<FilePathFilter> getExcludeFilters() const;
std::vector<FilePathFilter> getIncludeFilters() const;
std::vector<std::shared_ptr<XsdRootPath>> getRootPaths() const;
virtual std::set<FilePath> getAllSourcePaths() const = 0;
virtual std::set<FilePath> getAllSourceFilePathsCanonical() const = 0;
virtual std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const = 0;
virtual std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const = 0;
std::shared_ptr<const SoftwareSystem> getSoftwareSystem() const;
std::vector<FilePathFilter> getDerivedExcludeFilters() const;
std::vector<FilePathFilter> getDerivedIncludeFilters() const;
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const = 0;
protected:
XsdAbstractModule() = default;
bool init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
std::weak_ptr<SoftwareSystem> m_parent;
std::wstring m_name;
std::wstring m_description;
std::vector<FilePathFilter> m_excludeFilters;
std::vector<FilePathFilter> m_includeFilters;
std::vector<std::shared_ptr<XsdRootPath>> m_rootPaths;
};
}
#endif // SONARGRAPH_XSD_ABSTRACT_MODULE_H
@@ -0,0 +1,42 @@
#include "utility/sonargraph/SonargraphXsdAbstractSystemExtension.h"
#include "tinyxml/tinyxml.h"
#include "utility/logging/logging.h"
#include "utility/sonargraph/SonargraphXsdCppSystemSettings.h"
namespace Sonargraph
{
std::string XsdAbstractSystemExtension::getXsdTypeName()
{
return "xsdAbstractSystemExtension";
}
std::shared_ptr<XsdAbstractSystemExtension> XsdAbstractSystemExtension::create(const TiXmlElement* element)
{
if (std::shared_ptr<XsdCppSystemSettings> systemExtension = XsdCppSystemSettings::create(element))
{
return systemExtension;
}
return std::shared_ptr<XsdAbstractSystemExtension>();
}
bool XsdAbstractSystemExtension::init(const TiXmlElement* element)
{
if (element != nullptr)
{
const char* value = element->Attribute("language");
if (value != nullptr)
{
m_language = value;
}
else
{
LOG_WARNING("Unable to parse \"language\" attribute of Sonargraph " + getXsdTypeName() + ".");
}
return true;
}
return false;
}
}
@@ -0,0 +1,27 @@
#ifndef SONARGRAPH_XSD_ABSTRACT_SYSTEM_EXTENSION_H
#define SONARGRAPH_XSD_ABSTRACT_SYSTEM_EXTENSION_H
#include <memory>
#include <string>
class TiXmlElement;
namespace Sonargraph
{
class XsdAbstractSystemExtension
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdAbstractSystemExtension> create(const TiXmlElement* element);
virtual ~XsdAbstractSystemExtension() = default;
protected:
XsdAbstractSystemExtension() = default;
bool init(const TiXmlElement* element);
std::string m_language;
};
}
#endif // SONARGRAPH_XSD_ABSTRACT_SYSTEM_EXTENSION_H
@@ -0,0 +1,380 @@
#include "utility/sonargraph/SonargraphXsdCmakeJsonModule.h"
#include "tinyxml/tinyxml.h"
#include "data/indexer/IndexerCommandCxxEmpty.h"
#include "settings/ApplicationSettings.h"
#include "settings/LanguageType.h"
#include "settings/SourceGroupSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
#include "utility/sonargraph/SonargraphXsdCppSystemSettings.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/utility.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
#include "utility/OrderedCache.h"
namespace Sonargraph
{
std::string XsdCmakeJsonModule::getXsdTypeName()
{
return "xsdCmakeJsonModule";
}
std::shared_ptr<XsdCmakeJsonModule> XsdCmakeJsonModule::create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdCmakeJsonModule> module = std::shared_ptr<XsdCmakeJsonModule>(new XsdCmakeJsonModule());
if (module->init(element, parent))
{
return module;
}
}
return std::shared_ptr<XsdCmakeJsonModule>();
}
LanguageType XsdCmakeJsonModule::getSupportedLanguage() const
{
return LANGUAGE_CPP;
}
std::set<FilePath> XsdCmakeJsonModule::getAllSourcePaths() const
{
FilePath baseDirectory;
if (std::shared_ptr<const SoftwareSystem> softwareSystem = getSoftwareSystem())
{
baseDirectory = softwareSystem->getBaseDirectory();
}
std::set<FilePath> sourcePaths;
for (std::shared_ptr<XsdRootPath> rootPath : getRootPaths())
{
sourcePaths.insert(rootPath->getFilePath(baseDirectory));
}
for (std::shared_ptr<XsdRootPathWithFiles> rootPath : m_rootPathWithFiles)
{
sourcePaths.insert(rootPath->getFilePath(baseDirectory));
}
return sourcePaths;
}
std::set<FilePath> XsdCmakeJsonModule::getAllSourceFilePathsCanonical() const
{
FilePath baseDir;
if (std::shared_ptr<const SoftwareSystem> softwareSystem = getSoftwareSystem())
{
baseDir = softwareSystem->getBaseDirectory();
}
const std::set<FilePathFilter> excludeFilters = utility::toSet(getDerivedExcludeFilters());
const std::set<FilePathFilter> includeFilters = utility::toSet(getDerivedIncludeFilters());
std::set<FilePath> sourceFilePaths;
for (std::shared_ptr<XsdRootPath> rootPath : getRootPaths())
{
for (const XsdRootPathWithFiles::SourceFile& sourceFile : getIncludedSourceFilesForRootPath(rootPath, baseDir, excludeFilters, includeFilters))
{
sourceFilePaths.insert(sourceFile.getFilePath(baseDir.getConcatenated(rootPath->getName())));
}
}
for (std::shared_ptr<XsdRootPath> rootPath : m_rootPathWithFiles)
{
for (const XsdRootPathWithFiles::SourceFile& sourceFile : getIncludedSourceFilesForRootPath(rootPath, baseDir, excludeFilters, includeFilters))
{
sourceFilePaths.insert(sourceFile.getFilePath(baseDir.getConcatenated(rootPath->getName())));
}
}
return sourceFilePaths;
}
std::set<FilePath> XsdCmakeJsonModule::getAllCxxHeaderSearchPathsCanonical() const
{
std::set<Id> usedCompilerOptionSetIds;
for (std::shared_ptr<XsdRootPath> rootPath : getRootPaths())
{
if (std::shared_ptr<XsdRootPathWithFiles> rootPathWithFiles = std::dynamic_pointer_cast<XsdRootPathWithFiles>(rootPath))
{
for (const XsdRootPathWithFiles::SourceFile& sourceFile : rootPathWithFiles->getSourceFiles())
{
usedCompilerOptionSetIds.insert(sourceFile.compilerOptionSetId);
}
}
}
for (std::shared_ptr<XsdRootPathWithFiles> rootPath : m_rootPathWithFiles)
{
for (const XsdRootPathWithFiles::SourceFile& sourceFile : rootPath->getSourceFiles())
{
usedCompilerOptionSetIds.insert(sourceFile.compilerOptionSetId);
}
}
std::shared_ptr<const SoftwareSystem> softwareSystem = getSoftwareSystem();
if (!softwareSystem)
{
return std::set<FilePath>();
}
std::set<std::wstring> usedCompilerOptions;
for (Id compilerOptionSetId : usedCompilerOptionSetIds)
{
for (std::shared_ptr<const XsdCppSystemSettings> systemExtension :
softwareSystem->getSpecificSystemExtensions<XsdCppSystemSettings>()
)
{
if (systemExtension->hasCompilerOptionsForId(compilerOptionSetId))
{
utility::append(
usedCompilerOptions,
utility::toSet(systemExtension->getCompilerOptionsForId(compilerOptionSetId))
);
break;
}
}
}
// make sure that none of these prefixes is the prefix of a prefix that appears further down in the list
const std::vector<std::wstring> optionPrefixes = {
L"--include-directory=",
L"--include-directory",
L"-cxx-isystem",
L"-iquote",
L"-isystem-after",
L"-isystem",
L"-I"
};
std::set<FilePath> headerSearchPaths;
for (const std::wstring& compilerOption : usedCompilerOptions)
{
for (const std::wstring& optionPrefix : optionPrefixes)
{
if (utility::isPrefix(optionPrefix, compilerOption))
{
FilePath headerSearchPath(utility::trim(compilerOption.substr(optionPrefix.size())));
if (headerSearchPath.isAbsolute())
{
headerSearchPaths.insert(headerSearchPath);
}
else
{
headerSearchPaths.insert(softwareSystem->getBaseDirectory().getConcatenated(headerSearchPath));
}
break;
}
}
}
return headerSearchPaths;
}
std::set<FilePath> XsdCmakeJsonModule::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
const std::set<FilePath> indexedPaths = getAllSourcePaths();
const std::vector<FilePathFilter> excludeFilters = getDerivedExcludeFilters();
const std::vector<FilePathFilter> includeFilters = getDerivedIncludeFilters();
std::set<FilePath> containedFilePaths;
for (const FilePath& filePath : filePaths)
{
bool isInIndexedPaths = false;
for (const FilePath& indexedPath : indexedPaths)
{
if (indexedPath == filePath || indexedPath.contains(filePath))
{
isInIndexedPaths = true;
break;
}
}
if (isInIndexedPaths)
{
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(filePath))
{
isInIndexedPaths = false;
break;
}
}
if (!isInIndexedPaths)
{
for (const FilePathFilter& includeFilter : includeFilters)
{
if (includeFilter.isMatching(filePath))
{
isInIndexedPaths = true;
break;
}
}
}
}
if (isInIndexedPaths)
{
containedFilePaths.insert(filePath);
}
}
return containedFilePaths;
}
std::vector<std::shared_ptr<IndexerCommand>> XsdCmakeJsonModule::getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (std::shared_ptr<XsdRootPath> rootPath : getRootPaths())
{
if (std::shared_ptr<XsdRootPathWithFiles> rootPathWithFiles = std::dynamic_pointer_cast<XsdRootPathWithFiles>(rootPath))
{
utility::append(indexerCommands, getIndexerCommandsForRootPath(rootPathWithFiles, sourceGroupSettings, appSettings));
}
}
for (std::shared_ptr<XsdRootPathWithFiles> rootPath : m_rootPathWithFiles)
{
utility::append(indexerCommands, getIndexerCommandsForRootPath(rootPath, sourceGroupSettings, appSettings));
}
return indexerCommands;
}
bool XsdCmakeJsonModule::init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
if (!XsdAbstractModule::init(element, parent))
{
return false;
}
if (element != nullptr)
{
for (const TiXmlElement* rootPathWithFilesElement : utility::getXmlChildElementsWithName(element, "rootPathWithFiles"))
{
if (std::shared_ptr<XsdRootPathWithFiles> rootPath = XsdRootPathWithFiles::create(rootPathWithFilesElement))
{
m_rootPathWithFiles.push_back(rootPath);
}
else
{
LOG_ERROR("Unable to parse \"rootPathWithFiles\" element of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
return true;
}
return false;
}
std::vector<XsdRootPathWithFiles::SourceFile> XsdCmakeJsonModule::getIncludedSourceFilesForRootPath(
std::shared_ptr<XsdRootPath> rootPath,
const FilePath& baseDir,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters) const
{
std::vector<XsdRootPathWithFiles::SourceFile> sourceFiles;
if (std::shared_ptr<XsdRootPathWithFiles> rootPathWithFiles = std::dynamic_pointer_cast<XsdRootPathWithFiles>(rootPath))
{
for (const XsdRootPathWithFiles::SourceFile& sourceFile : rootPathWithFiles->getSourceFiles())
{
const FilePath sourceFilePath = sourceFile.getFilePath(baseDir).makeCanonical();
bool excludeMatches = false;
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(sourceFilePath))
{
excludeMatches = true;
break;
}
}
if (excludeMatches)
{
for (const FilePathFilter& includeFilter : includeFilters)
{
if (includeFilter.isMatching(sourceFilePath))
{
excludeMatches = false;
break;
}
}
}
if (!excludeMatches)
{
sourceFiles.push_back(sourceFile);
}
}
}
return sourceFiles;
}
std::vector<std::shared_ptr<IndexerCommand>> XsdCmakeJsonModule::getIndexerCommandsForRootPath(
std::shared_ptr<XsdRootPathWithFiles> rootPath,
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
if (rootPath)
{
std::shared_ptr<const SoftwareSystem> softwareSystem = getSoftwareSystem();
if (!softwareSystem)
{
return std::vector<std::shared_ptr<IndexerCommand>>();
}
const FilePath baseDir = rootPath->getFilePath(softwareSystem->getBaseDirectory());
const std::set<FilePath> indexedPaths = softwareSystem->getAllSourcePaths();
const std::set<FilePathFilter> excludeFilters = utility::toSet(getDerivedExcludeFilters());
const std::set<FilePathFilter> includeFilters = utility::toSet(getDerivedIncludeFilters());
const std::string languageStandard = sourceGroupSettings->getStandard();
const std::vector<FilePath> systemHeaderSearchPaths = utility::concat(
(appSettings ? appSettings->getHeaderSearchPathsExpanded() : std::vector<FilePath>()),
utility::toVector(indexedPaths)
);
const std::vector<FilePath> frameworkSearchPaths = (appSettings ? appSettings->getFrameworkSearchPathsExpanded() : std::vector<FilePath>());
OrderedCache<Id, std::vector<std::wstring>> compilerOptionCache([&](const Id& id) {
if (std::shared_ptr<const SoftwareSystem> softwareSystem = getSoftwareSystem())
{
for (std::shared_ptr<const XsdCppSystemSettings> systemExtension : softwareSystem->getSpecificSystemExtensions<XsdCppSystemSettings>())
{
if (systemExtension->hasCompilerOptionsForId(id))
{
return systemExtension->getCompilerOptionsForId(id);
}
}
}
return std::vector<std::wstring>();
});
for (const XsdRootPathWithFiles::SourceFile& sourceFile : getIncludedSourceFilesForRootPath(
rootPath, baseDir, excludeFilters, includeFilters)
)
{
indexerCommands.push_back(std::make_shared<IndexerCommandCxxEmpty>(
sourceFile.getFilePath(baseDir).makeCanonical(),
indexedPaths,
excludeFilters,
includeFilters,
softwareSystem->getBaseDirectory(),
systemHeaderSearchPaths,
frameworkSearchPaths,
compilerOptionCache.getValue(sourceFile.compilerOptionSetId),
languageStandard
));
}
}
return indexerCommands;
}
}
@@ -0,0 +1,44 @@
#ifndef SONARGRAPH_XSD_CMAKE_JSON_MODULE_H
#define SONARGRAPH_XSD_CMAKE_JSON_MODULE_H
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
#include "utility/sonargraph/SonargraphXsdRootPathWithFiles.h"
namespace Sonargraph
{
class XsdCmakeJsonModule : public XsdAbstractModule
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdCmakeJsonModule> create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
LanguageType getSupportedLanguage() const override;
std::set<FilePath> getAllSourcePaths() const override;
std::set<FilePath> getAllSourceFilePathsCanonical() const override;
std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const override;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const override;
protected:
XsdCmakeJsonModule() = default;
bool init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
std::vector<XsdRootPathWithFiles::SourceFile> getIncludedSourceFilesForRootPath(
std::shared_ptr<XsdRootPath> rootPath,
const FilePath& baseDir,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters) const;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommandsForRootPath(
std::shared_ptr<XsdRootPathWithFiles> rootPath,
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const;
std::vector<std::shared_ptr<XsdRootPathWithFiles>> m_rootPathWithFiles;
};
}
#endif // SONARGRAPH_XSD_CMAKE_JSON_MODULE_H
@@ -0,0 +1,85 @@
#include "utility/sonargraph/SonargraphXsdCppSystemSettings.h"
#include "tinyxml/tinyxml.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::string XsdCppSystemSettings::getXsdTypeName()
{
return "xsdCppSystemSettings";
}
std::shared_ptr<XsdCppSystemSettings> XsdCppSystemSettings::create(const TiXmlElement* element)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdCppSystemSettings> systemExtension = std::shared_ptr<XsdCppSystemSettings>(new XsdCppSystemSettings());
if (systemExtension->init(element))
{
return systemExtension;
}
}
return std::shared_ptr<XsdCppSystemSettings>();
}
bool XsdCppSystemSettings::hasCompilerOptionsForId(Id id) const
{
return m_compilerOptionSets.find(id) != m_compilerOptionSets.end();
}
std::vector<std::wstring> XsdCppSystemSettings::getCompilerOptionsForId(Id id) const
{
std::map<Id, std::vector<std::wstring>>::const_iterator it = m_compilerOptionSets.find(id);
if (it != m_compilerOptionSets.end())
{
return it->second;
}
return std::vector<std::wstring>();
}
bool XsdCppSystemSettings::init(const TiXmlElement* element)
{
XsdAbstractSystemExtension::init(element);
if (element != nullptr)
{
for (const TiXmlElement* compilerOptionSetElement : utility::getXmlChildElementsWithName(element, "compilerOptionSets"))
{
Id optionSetId = 0;
{
const char* value = compilerOptionSetElement->Attribute("id");
if (value != nullptr && atoi(value) >= 0)
{
optionSetId = atoi(value);
}
else
{
LOG_ERROR("Unable to parse \"id\" attribute of compilerOptionSets of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
for (const TiXmlElement* optionElement : utility::getXmlChildElementsWithName(compilerOptionSetElement, "option"))
{
const char* value = optionElement->GetText();
if (value != nullptr)
{
m_compilerOptionSets[optionSetId].push_back(utility::decodeFromUtf8(value));
}
else
{
LOG_ERROR("Unable to parse \"option\" attribute of compilerOptionSets of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
}
return true;
}
return false;
}
}
@@ -0,0 +1,30 @@
#ifndef SONARGRAPH_XSD_CPP_SYSTEM_SETTINGS_H
#define SONARGRAPH_XSD_CPP_SYSTEM_SETTINGS_H
#include <map>
#include <vector>
#include "utility/sonargraph/SonargraphXsdAbstractSystemExtension.h"
#include "utility/types.h"
namespace Sonargraph
{
class XsdCppSystemSettings : public XsdAbstractSystemExtension
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdCppSystemSettings> create(const TiXmlElement* element);
bool hasCompilerOptionsForId(Id id) const;
std::vector<std::wstring> getCompilerOptionsForId(Id id) const;
protected:
XsdCppSystemSettings() = default;
bool init(const TiXmlElement* element);
private:
std::map<Id, std::vector<std::wstring>> m_compilerOptionSets;
};
}
#endif // SONARGRAPH_XSD_CPP_SYSTEM_SETTINGS_H
@@ -0,0 +1,203 @@
#include "utility/sonargraph/SonargraphXsdJavaModule.h"
#include "tinyxml/tinyxml.h"
#include "data/indexer/IndexerCommandJava.h"
#include "settings/LanguageType.h"
#include "settings/SourceGroupSettingsJavaSonargraph.h"
#include "utility/file/FileSystem.h"
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
#include "utility/sonargraph/SonargraphSourceRootPath.h"
#include "utility/sonargraph/SonargraphXsdRootPath.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/utility.h"
#include "utility/utilityFile.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::string XsdJavaModule::getXsdTypeName()
{
return "xsdJavaModule";
}
std::shared_ptr<XsdJavaModule> XsdJavaModule::create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdJavaModule> module = std::shared_ptr<XsdJavaModule>(new XsdJavaModule());
if (module->init(element, parent))
{
return module;
}
}
return std::shared_ptr<XsdJavaModule>();
}
LanguageType XsdJavaModule::getSupportedLanguage() const
{
return LANGUAGE_JAVA;
}
std::set<FilePath> XsdJavaModule::getAllSourcePaths() const
{
const FilePath baseDirectory = getSoftwareSystem() ? getSoftwareSystem()->getBaseDirectory() : FilePath();
std::set<FilePath> sourcePaths;
for (std::shared_ptr<XsdRootPath> rootPath : getRootPaths())
{
sourcePaths.insert(rootPath->getFilePath(baseDirectory));
}
for (std::shared_ptr<SourceRootPath> rootPath : m_sourceRootPaths)
{
sourcePaths.insert(rootPath->getFilePath(baseDirectory));
}
return sourcePaths;
}
std::set<FilePath> XsdJavaModule::getAllSourceFilePathsCanonical() const
{
const std::vector<FilePathFilter> excludeFilters = getDerivedExcludeFilters();
const std::vector<FilePathFilter> includeFilters = getDerivedIncludeFilters();
std::set<FilePath> sourceFilePaths;
for (const FileInfo& fileInfo : FileSystem::getFileInfosFromPaths(utility::getTopLevelPaths(getAllSourcePaths()), { L".java" }))
{
const FilePath sourceFilePath = fileInfo.path.getCanonical();
bool excludeMatches = false;
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(sourceFilePath))
{
excludeMatches = true;
break;
}
}
if (excludeMatches)
{
for (const FilePathFilter& includeFilter : includeFilters)
{
if (includeFilter.isMatching(sourceFilePath))
{
excludeMatches = false;
break;
}
}
}
if (!excludeMatches)
{
sourceFilePaths.insert(sourceFilePath);
}
}
return sourceFilePaths;
}
std::set<FilePath> XsdJavaModule::getAllCxxHeaderSearchPathsCanonical() const
{
return std::set<FilePath>();
}
std::set<FilePath> XsdJavaModule::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
const std::set<FilePath> indexedPaths = getAllSourcePaths();
const std::vector<FilePathFilter> excludeFilters = getDerivedExcludeFilters();
const std::vector<FilePathFilter> includeFilters = getDerivedIncludeFilters();
std::set<FilePath> containedFilePaths;
for (const FilePath& filePath : filePaths)
{
bool isInIndexedPaths = false;
for (const FilePath& indexedPath : indexedPaths)
{
if (indexedPath == filePath || indexedPath.contains(filePath))
{
isInIndexedPaths = true;
break;
}
}
if (isInIndexedPaths)
{
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(filePath))
{
isInIndexedPaths = false;
break;
}
}
if (!isInIndexedPaths)
{
for (const FilePathFilter& includeFilter : includeFilters)
{
if (includeFilter.isMatching(filePath))
{
isInIndexedPaths = true;
break;
}
}
}
}
if (isInIndexedPaths)
{
containedFilePaths.insert(filePath);
}
}
return containedFilePaths;
}
std::vector<std::shared_ptr<IndexerCommand>> XsdJavaModule::getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
{
const std::string languageStandard = sourceGroupSettings->getStandard();
for (const FilePath& sourceFilePath : getAllSourceFilePathsCanonical())
{
indexerCommands.push_back(std::make_shared<IndexerCommandJava>(
sourceFilePath,
languageStandard,
std::vector<FilePath>() // the classpath is set later... TODO: fix this hack
));
}
}
return indexerCommands;
}
bool XsdJavaModule::init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent)
{
if (!XsdAbstractModule::init(element, parent))
{
return false;
}
if (element != nullptr)
{
for (const TiXmlElement* sourceRootPathElement : utility::getXmlChildElementsWithName(element, "sourceRootPath"))
{
if (std::shared_ptr<SourceRootPath> rootPath = SourceRootPath::create(sourceRootPathElement))
{
m_sourceRootPaths.push_back(rootPath);
}
else
{
LOG_ERROR("Unable to parse \"sourceRootPath\" element of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
return true;
}
return false;
}
}
@@ -0,0 +1,34 @@
#ifndef SONARGRAPH_XSD_JAVA_MODULE_H
#define SONARGRAPH_XSD_JAVA_MODULE_H
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
namespace Sonargraph
{
class SourceRootPath;
class XsdJavaModule : public XsdAbstractModule
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdJavaModule> create(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
LanguageType getSupportedLanguage() const override;
std::set<FilePath> getAllSourcePaths() const override;
std::set<FilePath> getAllSourceFilePathsCanonical() const override;
std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const override;
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
std::shared_ptr<const SourceGroupSettings> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const override;
protected:
XsdJavaModule() = default;
bool init(const TiXmlElement* element, std::weak_ptr<SoftwareSystem> parent);
std::vector<std::shared_ptr<SourceRootPath>> m_sourceRootPaths;
};
}
#endif // SONARGRAPH_XSD_JAVA_MODULE_H
@@ -0,0 +1,77 @@
#include "utility/sonargraph/SonargraphXsdRootPath.h"
#include "tinyxml/tinyxml.h"
#include "data/indexer/IndexerCommandJava.h"
#include "utility/logging/logging.h"
#include "utility/sonargraph/SonargraphXsdAbstractModule.h"
#include "utility/sonargraph/SonargraphXsdRootPathWithFiles.h"
#include "utility/sonargraph/SonargraphXsdSourceRootPath.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::string XsdRootPath::getXsdTypeName()
{
return "xsdRootPath";
}
std::shared_ptr<XsdRootPath> XsdRootPath::create(const TiXmlElement* element)
{
if (std::shared_ptr<XsdRootPathWithFiles> rootPath = XsdRootPathWithFiles::create(element))
{
return rootPath;
}
if (std::shared_ptr<XsdSourceRootPath> rootPath = XsdSourceRootPath::create(element))
{
return rootPath;
}
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdRootPath> rootPath = std::shared_ptr<XsdRootPath>(new XsdRootPath());
if (rootPath->init(element))
{
return rootPath;
}
}
return std::shared_ptr<XsdRootPath>();
}
std::wstring XsdRootPath::getName() const
{
return m_name;
}
FilePath XsdRootPath::getFilePath(const FilePath& baseDirectory) const
{
FilePath filePath(getName());
if (filePath.isAbsolute())
{
return filePath;
}
return baseDirectory.getConcatenated(filePath);
}
bool XsdRootPath::init(const TiXmlElement* element)
{
if (element != nullptr)
{
const char* value = element->Attribute("name");
if (value != nullptr)
{
m_name = utility::decodeFromUtf8(value);
}
else
{
LOG_ERROR("Unable to parse \"name\" of Sonargraph " + getXsdTypeName() + ".");
return false;
}
return true;
}
return false;
}
}
@@ -0,0 +1,36 @@
#ifndef SONARGRAPH_XSD_ROOT_PATH_H
#define SONARGRAPH_XSD_ROOT_PATH_H
#include <memory>
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class IndexerCommand;
class SonargraphAbstractModule;
class TiXmlElement;
namespace Sonargraph
{
class XsdRootPath
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdRootPath> create(const TiXmlElement* element);
virtual ~XsdRootPath() = default;
std::wstring getName() const;
FilePath getFilePath(const FilePath& baseDirectory) const;
protected:
XsdRootPath() = default;
bool init(const TiXmlElement* element);
std::wstring m_name;
};
}
#endif // SONARGRAPH_XSD_ROOT_PATH_H
@@ -0,0 +1,112 @@
#include "utility/sonargraph/SonargraphXsdRootPathWithFiles.h"
#include "tinyxml/tinyxml.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
XsdRootPathWithFiles::SourceFile::SourceFile(std::wstring fileName, Id compilerOptionSetId)
: fileName(fileName)
, compilerOptionSetId(compilerOptionSetId)
{
}
FilePath XsdRootPathWithFiles::SourceFile::getFilePath(const FilePath& baseDirectory) const
{
FilePath filePath(fileName);
if (filePath.isAbsolute())
{
return filePath;
}
return baseDirectory.getConcatenated(filePath).makeCanonical();
}
std::string XsdRootPathWithFiles::getXsdTypeName()
{
return "xsdRootPathWithFiles";
}
std::shared_ptr<XsdRootPathWithFiles> XsdRootPathWithFiles::create(const TiXmlElement* element)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdRootPathWithFiles> rootPath = std::shared_ptr<XsdRootPathWithFiles>(new XsdRootPathWithFiles());
if (rootPath->init(element))
{
return rootPath;
}
}
return std::shared_ptr<XsdRootPathWithFiles>();
}
std::vector<XsdRootPathWithFiles::SourceFile> XsdRootPathWithFiles::getSourceFiles() const
{
return m_sourceFiles;
}
std::vector<std::wstring> XsdRootPathWithFiles::getExcludedDirectories() const
{
return m_excludedDirectories;
}
bool XsdRootPathWithFiles::init(const TiXmlElement* element)
{
XsdRootPath::init(element);
if (element != nullptr)
{
for (const TiXmlElement* sourceFileElement : utility::getXmlChildElementsWithName(element, "sourceFile"))
{
std::wstring fileName;
{
const char* value = sourceFileElement->Attribute("fileName");
if (value != nullptr)
{
fileName = utility::decodeFromUtf8(value);
}
else
{
LOG_ERROR("Unable to parse \"fileName\" attribute of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
Id compilerOptionSetId;
{
int value;
if (sourceFileElement->QueryIntAttribute("compilerOptionSetId", &value) == TIXML_SUCCESS && value >= 0)
{
compilerOptionSetId = Id(value);
}
else
{
LOG_ERROR("Unable to parse \"compilerOptionSetId\" attribute of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
m_sourceFiles.push_back(SourceFile(fileName, compilerOptionSetId));
}
for (const TiXmlElement* excludedDirectoryElement : utility::getXmlChildElementsWithName(element, "excludedDirectory"))
{
const char* value = excludedDirectoryElement->Attribute("dir");
if (value != nullptr)
{
m_excludedDirectories.push_back(utility::decodeFromUtf8(value));
}
else
{
LOG_ERROR("Unable to parse \"dir\" attribute of Sonargraph " + getXsdTypeName() + ".");
return false;
}
}
return true;
}
return false;
}
}
@@ -0,0 +1,39 @@
#ifndef SONARGRAPH_XSD_ROOT_PATH_WITH_FILES_H
#define SONARGRAPH_XSD_ROOT_PATH_WITH_FILES_H
#include <memory>
#include "utility/sonargraph/SonargraphXsdRootPath.h"
#include "utility/types.h"
namespace Sonargraph
{
class XsdRootPathWithFiles : public XsdRootPath
{
public:
struct SourceFile
{
SourceFile(std::wstring fileName, Id compilerOptionSetId);
FilePath getFilePath(const FilePath& baseDirectory) const;
std::wstring fileName;
Id compilerOptionSetId;
};
static std::string getXsdTypeName();
static std::shared_ptr<XsdRootPathWithFiles> create(const TiXmlElement* element);
std::vector<SourceFile> getSourceFiles() const;
std::vector<std::wstring> getExcludedDirectories() const;
protected:
XsdRootPathWithFiles() = default;
bool init(const TiXmlElement* element);
std::vector<SourceFile> m_sourceFiles;
std::vector<std::wstring> m_excludedDirectories;
};
}
#endif // SONARGRAPH_XSD_ROOT_PATH_WITH_FILES_H
@@ -0,0 +1,34 @@
#include "utility/sonargraph/SonargraphXsdSourceRootPath.h"
#include "tinyxml/tinyxml.h"
#include "utility/sonargraph/utilitySonargraph.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
namespace Sonargraph
{
std::string XsdSourceRootPath::getXsdTypeName()
{
return "xsdSourceRootPath";
}
std::shared_ptr<XsdSourceRootPath> XsdSourceRootPath::create(const TiXmlElement* element)
{
if (!utility::xmlElementHasAttribute(element, "xsi:type") || utility::sonargraphXmlElementIsType(element, getXsdTypeName()))
{
std::shared_ptr<XsdSourceRootPath> rootPath = std::shared_ptr<XsdSourceRootPath>(new XsdSourceRootPath());
if (rootPath->init(element))
{
return rootPath;
}
}
return std::shared_ptr<XsdSourceRootPath>();
}
bool XsdSourceRootPath::init(const TiXmlElement* element)
{
return XsdRootPath::init(element);
}
}
@@ -0,0 +1,23 @@
#ifndef SONARGRAPH_XSD_SOURCE_ROOT_PATH_H
#define SONARGRAPH_XSD_SOURCE_ROOT_PATH_H
#include <memory>
#include "utility/sonargraph/SonargraphXsdRootPath.h"
#include "utility/types.h"
namespace Sonargraph
{
class XsdSourceRootPath : public XsdRootPath
{
public:
static std::string getXsdTypeName();
static std::shared_ptr<XsdSourceRootPath> create(const TiXmlElement* element);
protected:
XsdSourceRootPath() = default;
bool init(const TiXmlElement* element);
};
}
#endif // SONARGRAPH_XSD_SOURCE_ROOT_PATH_H
@@ -0,0 +1,12 @@
#include "utility/sonargraph/utilitySonargraph.h"
#include "tinyxml/tinyxml.h"
namespace utility
{
bool sonargraphXmlElementIsType(const TiXmlElement *element, const std::string& typeName)
{
const char* value = element->Attribute("xsi:type");
return (value != nullptr && value == "ns4:" + typeName);
}
}
@@ -0,0 +1,13 @@
#ifndef UTILITY_SONARGRAPH_H
#define UTILITY_SONARGRAPH_H
#include <string>
class TiXmlElement;
namespace utility
{
bool sonargraphXmlElementIsType(const TiXmlElement *element, const std::string& typeName);
}
#endif // UTILITY_SONARGRAPH_H
+15 -15
View File
@@ -1,28 +1,28 @@
#include "utility/utilityFile.h"
#include "utility/file/FilePath.h"
#include "utility/utility.h"
std::vector<FilePath> utility::getTopLevelPaths(const std::vector<FilePath>& paths)
{
return utility::getTopLevelPaths(utility::toSet(paths));
}
std::vector<FilePath> utility::getTopLevelPaths(const std::set<FilePath>& paths)
{
// this works because the set contains the paths already in alphabetical order
std::vector<FilePath> topLevelPaths;
FilePath lastPath;
for (const FilePath& path : paths)
{
bool addPath = true;
for (size_t i = 0; i < topLevelPaths.size(); i++)
{
if (topLevelPaths[i].contains(path))
{
addPath = false;
break;
}
else if (path.contains(topLevelPaths[i]))
{
topLevelPaths.erase(topLevelPaths.begin() + i);
break;
}
}
if (addPath)
if (lastPath.empty() || !lastPath.contains(path)) // don't add subdirectories of already added paths
{
lastPath = path;
topLevelPaths.push_back(path);
}
}
return topLevelPaths;
}
+3 -1
View File
@@ -2,12 +2,14 @@
#define UTILITY_FILE_H
#include <vector>
#include <set>
#include "utility/file/FilePath.h"
class FilePath;
namespace utility
{
std::vector<FilePath> getTopLevelPaths(const std::vector<FilePath>& paths);
std::vector<FilePath> getTopLevelPaths(const std::set<FilePath>& paths);
}
#endif // UTILITY_FILE_H
+36
View File
@@ -6,6 +6,42 @@
namespace utility
{
bool xmlElementHasAttribute(const TiXmlElement* element, const std::string& attributeName)
{
return (element->Attribute(attributeName.c_str()) != nullptr);
}
std::vector<const TiXmlElement*> getXmlChildElementsWithName(const TiXmlElement* parentElement, const std::string& elementName)
{
std::vector<const TiXmlElement*> elements;
const TiXmlElement* child = parentElement->FirstChildElement(elementName.c_str());
for (child; child; child = child->NextSiblingElement(elementName.c_str()))
{
elements.push_back(child);
}
return elements;
}
std::vector<const TiXmlElement*> getXmlChildElementsWithAttribute(const TiXmlElement* parentElement, const std::string& attributeName, const std::string& attributeValue)
{
std::vector<const TiXmlElement*> elements;
const TiXmlElement* child = parentElement->FirstChildElement();
for (child; child; child = child->NextSiblingElement())
{
const char* value = child->Attribute(attributeName.c_str());
if (value != nullptr && value == attributeValue)
{
elements.push_back(child);
}
}
return elements;
}
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags)
{
+5
View File
@@ -11,6 +11,11 @@ class TiXmlElement;
namespace utility
{
bool xmlElementHasAttribute(const TiXmlElement* element, const std::string& attributeName);
std::vector<const TiXmlElement*> getXmlChildElementsWithName(const TiXmlElement* parentElement, const std::string& elementName);
std::vector<const TiXmlElement*> getXmlChildElementsWithAttribute(const TiXmlElement* parentElement, const std::string& attributeName, const std::string& attributeValue);
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags);
std::vector<std::string> getValuesOfAllXmlTagsByName(std::shared_ptr<TextAccess> textAccess, const std::string& tag);
std::vector<TiXmlElement*> getAllXmlTagsByName(TiXmlElement* root, const std::string& tag);
+3 -3
View File
@@ -75,13 +75,13 @@ add_files(
data/parser/cxx/PreprocessorCallbacks.h
data/parser/cxx/utilityClang.cpp
data/parser/cxx/utilityClang.h
project/SourceGroupCxx.cpp
project/SourceGroupCxx.h
project/SourceGroupCxxCdb.cpp
project/SourceGroupCxxCdb.h
project/SourceGroupCxxEmpty.cpp
project/SourceGroupCxxEmpty.h
project/SourceGroupCxxSonargraph.cpp
project/SourceGroupCxxSonargraph.h
project/SourceGroupFactoryModuleCxx.cpp
project/SourceGroupFactoryModuleCxx.h
+41 -7
View File
@@ -6,12 +6,16 @@ IndexerCommandCxx::IndexerCommandCxx(
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths,
const std::vector<std::wstring>& compilerFlags
)
: IndexerCommand(sourceFilePath, indexedPaths, excludeFilters)
: IndexerCommand(sourceFilePath)
, m_indexedPaths(indexedPaths)
, m_excludeFilters(excludeFilters)
, m_includeFilters(includeFilters)
, m_workingDirectory(workingDirectory)
, m_systemHeaderSearchPaths(systemHeaderSearchPaths)
, m_frameworkSearchPaths(frameworkSearchPaths)
@@ -23,24 +27,54 @@ size_t IndexerCommandCxx::getByteSize(size_t stringSize) const
{
size_t size = IndexerCommand::getByteSize(stringSize);
for (auto& i : m_systemHeaderSearchPaths)
for (const FilePath& path : m_indexedPaths)
{
size += stringSize + utility::encodeToUtf8(i.wstr()).size();
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
}
for (auto& i : m_frameworkSearchPaths)
for (const FilePathFilter& filter : m_excludeFilters)
{
size += stringSize + utility::encodeToUtf8(i.wstr()).size();
size += stringSize + utility::encodeToUtf8(filter.wstr()).size();
}
for (auto& i : m_compilerFlags)
for (const FilePathFilter& filter : m_includeFilters)
{
size += stringSize + i.size();
size += stringSize + utility::encodeToUtf8(filter.wstr()).size();
}
for (const FilePath& path : m_systemHeaderSearchPaths)
{
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
}
for (const FilePath& path : m_frameworkSearchPaths)
{
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
}
for (const std::wstring& flag : m_compilerFlags)
{
size += stringSize + flag.size();
}
return size;
}
const std::set<FilePath>& IndexerCommandCxx::getIndexedPaths() const
{
return m_indexedPaths;
}
const std::set<FilePathFilter>& IndexerCommandCxx::getExcludeFilters() const
{
return m_excludeFilters;
}
const std::set<FilePathFilter>& IndexerCommandCxx::getIncludeFilters() const
{
return m_includeFilters;
}
const std::vector<FilePath>& IndexerCommandCxx::getSystemHeaderSearchPaths() const
{
return m_systemHeaderSearchPaths;
@@ -16,6 +16,7 @@ public:
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths,
@@ -23,12 +24,18 @@ public:
virtual size_t getByteSize(size_t stringSize) const override;
const std::set<FilePath>& getIndexedPaths() const;
const std::set<FilePathFilter>& getExcludeFilters() const;
const std::set<FilePathFilter>& getIncludeFilters() const;
const std::vector<FilePath>& getSystemHeaderSearchPaths() const;
const std::vector<FilePath>& getFrameworkSearchPaths() const;
const std::vector<std::wstring>& getCompilerFlags() const;
const FilePath& getWorkingDirectory() const;
private:
std::set<FilePath> m_indexedPaths;
std::set<FilePathFilter> m_excludeFilters;
std::set<FilePathFilter> m_includeFilters;
FilePath m_workingDirectory;
std::vector<FilePath> m_systemHeaderSearchPaths;
std::vector<FilePath> m_frameworkSearchPaths;
@@ -43,12 +43,21 @@ IndexerCommandCxxCdb::IndexerCommandCxxCdb(
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::vector<std::wstring>& compilerFlags,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths
)
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludeFilters, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
: IndexerCommandCxx(
sourceFilePath,
indexedPaths,
excludeFilters,
includeFilters,
workingDirectory,
systemHeaderSearchPaths,
frameworkSearchPaths,
compilerFlags)
{
}
@@ -25,6 +25,7 @@ public:
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::vector<std::wstring>& compilerFlags,
const std::vector<FilePath>& systemHeaderSearchPaths,
@@ -9,13 +9,14 @@ IndexerCommandCxxEmpty::IndexerCommandCxxEmpty(
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::string& languageStandard,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths,
const std::vector<std::wstring>& compilerFlags
)
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludeFilters, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
const std::vector<std::wstring>& compilerFlags,
const std::string& languageStandard
)
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludeFilters, includeFilters, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
, m_languageStandard(languageStandard)
{
}
@@ -15,11 +15,12 @@ public:
const FilePath& sourceFilePath,
const std::set<FilePath>& indexedPaths,
const std::set<FilePathFilter>& excludeFilters,
const std::set<FilePathFilter>& includeFilters,
const FilePath& workingDirectory,
const std::string& languageStandard,
const std::vector<FilePath>& systemHeaderSearchPaths,
const std::vector<FilePath>& frameworkSearchPaths,
const std::vector<std::wstring>& compilerFlags);
const std::vector<std::wstring>& compilerFlags,
const std::string& languageStandard);
virtual IndexerCommandType getIndexerCommandType() const override;
virtual size_t getByteSize(size_t stringSize) const override;
+8 -7
View File
@@ -13,19 +13,20 @@ class IndexerCxx: public Indexer<IndexerCommandType>
public:
virtual ~IndexerCxx() = default;
virtual std::shared_ptr<IntermediateStorage> doIndex(
std::shared_ptr<IndexerCommandType> indexerCommand,
std::shared_ptr<FileRegister> fileRegister);
virtual std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<IndexerCommandType> indexerCommand);
};
template <typename IndexerCommandType, typename ParserType>
std::shared_ptr<IntermediateStorage> IndexerCxx<IndexerCommandType, ParserType>::doIndex(
std::shared_ptr<IndexerCommandType> indexerCommand,
std::shared_ptr<FileRegister> fileRegister)
std::shared_ptr<IntermediateStorage> IndexerCxx<IndexerCommandType, ParserType>::doIndex(std::shared_ptr<IndexerCommandType> indexerCommand)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(
parserClient,
std::make_shared<FileRegister>(
indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludeFilters()
)
);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
parserClient->setStorage(storage);
-33
View File
@@ -1,33 +0,0 @@
#include "project/SourceGroupCxx.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "data/indexer/IndexerCommandCxxEmpty.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileManager.h"
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utility.h"
#include "Application.h"
SourceGroupCxx::SourceGroupCxx()
{
}
SourceGroupCxx::~SourceGroupCxx()
{
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxx::getSourceGroupSettings()
{
return getSourceGroupSettingsCxx();
}
std::shared_ptr<const SourceGroupSettings> SourceGroupCxx::getSourceGroupSettings() const
{
return getSourceGroupSettingsCxx();
}
-24
View File
@@ -1,24 +0,0 @@
#ifndef SOURCE_GROUP_CXX_H
#define SOURCE_GROUP_CXX_H
#include <memory>
#include <set>
#include "project/SourceGroup.h"
#include "settings/SourceGroupSettingsCxx.h"
class SourceGroupCxx
: public SourceGroup
{
public:
SourceGroupCxx();
virtual ~SourceGroupCxx();
private:
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx() = 0;
virtual std::shared_ptr<const SourceGroupSettingsCxx> getSourceGroupSettingsCxx() const = 0;
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
virtual std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
};
#endif // SOURCE_GROUP_CXX_H
+56 -34
View File
@@ -1,9 +1,9 @@
#include "project/SourceGroupCxxCdb.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "settings/ApplicationSettings.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utility.h"
@@ -14,15 +14,6 @@ SourceGroupCxxCdb::SourceGroupCxxCdb(std::shared_ptr<SourceGroupSettingsCxxCdb>
{
}
SourceGroupCxxCdb::~SourceGroupCxxCdb()
{
}
SourceGroupType SourceGroupCxxCdb::getType() const
{
return SOURCE_GROUP_CXX_CDB;
}
bool SourceGroupCxxCdb::prepareIndexing()
{
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
@@ -45,11 +36,55 @@ bool SourceGroupCxxCdb::prepareIndexing()
return true;
}
std::set<FilePath> SourceGroupCxxCdb::getIndexedPaths() const
std::set<FilePath> SourceGroupCxxCdb::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
{
return findAndAddSymlinkedDirectories(m_settings->getIndexedHeaderPathsExpandedAndAbsolute());
std::set<FilePath> containedFilePaths;
const std::set<FilePath> indexedPaths = getIndexedPaths();
const std::vector<FilePathFilter> excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute();
for (const FilePath& filePath : filePaths)
{
bool isInIndexedPaths = false;
for (const FilePath& indexedPath : indexedPaths)
{
if (indexedPath == filePath || indexedPath.contains(filePath))
{
isInIndexedPaths = true;
break;
}
}
if (isInIndexedPaths)
{
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(filePath))
{
isInIndexedPaths = false;
break;
}
}
}
if (isInIndexedPaths)
{
containedFilePaths.insert(filePath);
}
}
return containedFilePaths;
}
std::set<FilePath> SourceGroupCxxCdb::getAllSourceFilePaths() const
{
const FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
if (cdbPath.exists())
{
return utility::toSet(IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath));
}
return std::set<FilePath>();
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
@@ -59,15 +94,6 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute());
utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
for (const FilePath& sourcePath: m_settings->getSourcePathsExpandedAndAbsolute())
{
if (sourcePath.isDirectory())
{
systemHeaderSearchPaths.push_back(sourcePath);
}
}
std::vector<FilePath> frameworkSearchPaths;
utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute());
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
@@ -75,7 +101,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
const std::vector<std::wstring> compilerFlags = m_settings->getCompilerFlags();
const std::set<FilePath> indexedPaths = getIndexedPaths();
const std::set<FilePathFilter> excludeFilters = getExcludeFilters();
const std::set<FilePathFilter> excludeFilters = utility::toSet(m_settings->getExcludeFiltersExpandedAndAbsolute());
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
@@ -115,6 +141,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
sourcePath,
indexedPaths,
excludeFilters,
std::set<FilePathFilter>(),
FilePath(utility::decodeFromUtf8(command.Directory)),
utility::concat(
utility::convert<std::string, std::wstring>(command.CommandLine, [](const std::string& arg) { return utility::decodeFromUtf8(arg); }),
@@ -130,25 +157,20 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
return indexerCommands;
}
std::shared_ptr<SourceGroupSettingsCxx> SourceGroupCxxCdb::getSourceGroupSettingsCxx()
std::shared_ptr<SourceGroupSettings> SourceGroupCxxCdb::getSourceGroupSettings()
{
return m_settings;
}
std::shared_ptr<const SourceGroupSettingsCxx> SourceGroupCxxCdb::getSourceGroupSettingsCxx() const
std::shared_ptr<const SourceGroupSettings> SourceGroupCxxCdb::getSourceGroupSettings() const
{
return m_settings;
}
std::vector<FilePath> SourceGroupCxxCdb::getAllSourcePaths() const
std::set<FilePath> SourceGroupCxxCdb::getIndexedPaths() const
{
std::vector<FilePath> sourcePaths;
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
if (cdbPath.exists())
{
sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
}
return sourcePaths;
std::set<FilePath> indexedPaths;
utility::append(indexedPaths, getAllSourceFilePaths());
utility::append(indexedPaths, utility::toSet(m_settings->getIndexedHeaderPathsExpandedAndAbsolute()));
return indexedPaths;
}

Some files were not shown because too many files have changed in this diff Show More