logic: added C/C++ project setup from Code::Blocks
* also changed xml elements in sourcegroup settings that specify the used language standard, so that one sourcegroup can maintain multiple language standards * added migration and migrated sample projects
This commit is contained in:
@@ -344,7 +344,7 @@ FilePath FilePath::getLowerCase() const
|
||||
|
||||
bool FilePath::contains(const FilePath& other) const
|
||||
{
|
||||
if (!isDirectory())
|
||||
if (exists() && !isDirectory())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,11 +60,6 @@ namespace Sonargraph
|
||||
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();
|
||||
@@ -75,11 +70,6 @@ namespace Sonargraph
|
||||
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
|
||||
|
||||
@@ -32,10 +32,8 @@ namespace Sonargraph
|
||||
|
||||
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,
|
||||
|
||||
@@ -90,16 +90,6 @@ namespace Sonargraph
|
||||
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
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace Sonargraph
|
||||
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;
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace Sonargraph
|
||||
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;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "settings/LanguageType.h"
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxxSonargraph.h"
|
||||
#include "settings/SourceGroupSettingsWithCppStandard.h"
|
||||
#include "settings/SourceGroupSettingsWithCStandard.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/sonargraph/SonargraphSoftwareSystem.h"
|
||||
@@ -177,75 +179,45 @@ namespace Sonargraph
|
||||
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;
|
||||
|
||||
std::set<FilePath> indexedHeaderPaths;
|
||||
std::string languageStandard = SourceGroupSettingsWithCppStandard::getDefaultCppStandardStatic();
|
||||
|
||||
if (std::shared_ptr<const SourceGroupSettingsCxxSonargraph> sonargraphSettings =
|
||||
std::dynamic_pointer_cast<const SourceGroupSettingsCxxSonargraph>(sourceGroupSettings))
|
||||
{
|
||||
indexedHeaderPaths = utility::toSet(sonargraphSettings->getIndexedHeaderPathsExpandedAndAbsolute());
|
||||
languageStandard = sonargraphSettings->getCppStandard();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Source group doesn't specify language standard. Falling back to \"" + languageStandard + "\".");
|
||||
LOG_ERROR("Source group doesn't specify any indexed header paths");
|
||||
}
|
||||
|
||||
const std::vector<FilePath> systemHeaderSearchPaths = (appSettings ? appSettings->getHeaderSearchPathsExpanded() : std::vector<FilePath>());
|
||||
const std::vector<FilePath> frameworkSearchPaths = (appSettings ? appSettings->getFrameworkSearchPathsExpanded() : std::vector<FilePath>());
|
||||
|
||||
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));
|
||||
utility::append(indexerCommands, getIndexerCommandsForRootPath(
|
||||
rootPathWithFiles, indexedHeaderPaths, languageStandard, systemHeaderSearchPaths, frameworkSearchPaths
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
for (std::shared_ptr<XsdRootPathWithFiles> rootPath : m_rootPathWithFiles)
|
||||
{
|
||||
utility::append(indexerCommands, getIndexerCommandsForRootPath(rootPath, sourceGroupSettings, appSettings));
|
||||
utility::append(indexerCommands, getIndexerCommandsForRootPath(
|
||||
rootPath, indexedHeaderPaths ,languageStandard, systemHeaderSearchPaths, frameworkSearchPaths
|
||||
));
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
@@ -321,8 +293,10 @@ namespace Sonargraph
|
||||
|
||||
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
|
||||
const std::set<FilePath> indexedHeaderPaths,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath> systemHeaderSearchPaths,
|
||||
const std::vector<FilePath> frameworkSearchPaths) const
|
||||
{
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
if (rootPath)
|
||||
@@ -335,17 +309,8 @@ namespace Sonargraph
|
||||
|
||||
const FilePath baseDir = rootPath->getFilePath(softwareSystem->getBaseDirectory());
|
||||
|
||||
std::set<FilePath> indexedHeaderPaths;
|
||||
if (std::shared_ptr<const SourceGroupSettingsCxxSonargraph> sonargraphSettings = std::dynamic_pointer_cast<const SourceGroupSettingsCxxSonargraph>(sourceGroupSettings))
|
||||
{
|
||||
indexedHeaderPaths = utility::toSet(sonargraphSettings->getIndexedHeaderPathsExpandedAndAbsolute());
|
||||
}
|
||||
|
||||
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 = (appSettings ? appSettings->getHeaderSearchPathsExpanded() : std::vector<FilePath>());
|
||||
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())
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace Sonargraph
|
||||
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;
|
||||
@@ -33,9 +32,11 @@ namespace Sonargraph
|
||||
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::shared_ptr<XsdRootPathWithFiles> rootPath,
|
||||
const std::set<FilePath> indexedHeaderPaths,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath> systemHeaderSearchPaths,
|
||||
const std::vector<FilePath> frameworkSearchPaths) const;
|
||||
|
||||
std::vector<std::shared_ptr<XsdRootPathWithFiles>> m_rootPathWithFiles;
|
||||
};
|
||||
|
||||
@@ -102,58 +102,6 @@ namespace Sonargraph
|
||||
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
|
||||
@@ -161,7 +109,16 @@ namespace Sonargraph
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
{
|
||||
const std::string languageStandard = sourceGroupSettings->getStandard();
|
||||
std::string languageStandard = SourceGroupSettingsWithJavaStandard::getDefaultJavaStandardStatic();
|
||||
if (std::shared_ptr<const SourceGroupSettingsJavaSonargraph> settings =
|
||||
std::dynamic_pointer_cast<const SourceGroupSettingsJavaSonargraph>(sourceGroupSettings))
|
||||
{
|
||||
languageStandard = settings->getJavaStandard();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Source group doesn't specify language standard. Falling back to \"" + languageStandard + "\".");
|
||||
}
|
||||
|
||||
for (const FilePath& sourceFilePath : getAllSourceFilePathsCanonical())
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Sonargraph
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user