logic: Implemented usage of PCH for indexing EmptyCxx Source Groups

* further change: initialize all llvm targets before indexing
* further change: remove configurable dependencies directory from gradle and maven sourcegroups
This commit is contained in:
mlangkabel
2019-07-02 15:52:17 +02:00
parent 3aebe91e36
commit bb78c04b34
57 changed files with 677 additions and 457 deletions
+2
View File
@@ -380,6 +380,8 @@ add_files(
settings/SourceGroupSettingsWithIndexedHeaderPaths.h
settings/SourceGroupSettingsWithJavaStandard.cpp
settings/SourceGroupSettingsWithJavaStandard.h
settings/SourceGroupSettingsWithCxxPchOptions.cpp
settings/SourceGroupSettingsWithCxxPchOptions.h
settings/SourceGroupSettingsWithSonargraphProjectPath.cpp
settings/SourceGroupSettingsWithSonargraphProjectPath.h
settings/SourceGroupSettingsWithSourceExtensions.cpp
+10
View File
@@ -542,6 +542,16 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("indexer_command_queue_started", false));
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("indexer_command_queue_stopped", false));
std::shared_ptr<TaskGroupSequence> preIndexTasks = std::make_shared<TaskGroupSequence>();
taskSequential->addTask(preIndexTasks);
for (const std::shared_ptr<SourceGroup>& sourceGroup : m_sourceGroups)
{
if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED)
{
preIndexTasks->addTask(sourceGroup->getPreIndexTask(dialogView));
}
}
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(tempStorage, dialogView);
taskSequential->addTask(taskParserWrapper);
+9 -2
View File
@@ -1,15 +1,22 @@
#include "SourceGroup.h"
#include "MemoryIndexerCommandProvider.h"
#include "SourceGroupSettings.h"
#include "FilePath.h"
#include "FilePathFilter.h"
#include "MemoryIndexerCommandProvider.h"
#include "ProjectSettings.h"
#include "SourceGroupSettings.h"
#include "TaskLambda.h"
std::shared_ptr<IndexerCommandProvider> SourceGroup::getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const
{
return std::make_shared<MemoryIndexerCommandProvider>(getIndexerCommands(filesToIndex));
}
std::shared_ptr<Task> SourceGroup::getPreIndexTask(std::shared_ptr<DialogView> dialogView) const
{
return std::make_shared<TaskLambda>([]() {});
}
SourceGroupType SourceGroup::getType() const
{
return getSourceGroupSettings()->getType();
+5 -2
View File
@@ -9,11 +9,13 @@
#include "SourceGroupStatusType.h"
#include "SourceGroupType.h"
class IndexerCommand;
class IndexerCommandProvider;
class DialogView;
class FilePath;
class FilePathFilter;
class IndexerCommand;
class IndexerCommandProvider;
class SourceGroupSettings;
class Task;
class SourceGroup
{
@@ -27,6 +29,7 @@ public:
virtual std::set<FilePath> getAllSourceFilePaths() const = 0;
virtual std::shared_ptr<IndexerCommandProvider> getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const;
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const = 0;
virtual std::shared_ptr<Task> getPreIndexTask(std::shared_ptr<DialogView> dialogView) const;
SourceGroupType getType() const;
LanguageType getLanguage() const;
+5 -4
View File
@@ -8,8 +8,9 @@
#include "ResourcePaths.h"
#include "Status.h"
#include "TimeStamp.h"
#include "utility.h"
#include "UserPaths.h"
#include "utility.h"
#include "utilityFile.h"
#include "Version.h"
const size_t ApplicationSettings::VERSION = 8;
@@ -390,7 +391,7 @@ std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPaths() const
std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPathsExpanded() const
{
return expandPaths(getJreSystemLibraryPaths());
return utility::getExpandedPaths(getJreSystemLibraryPaths());
}
bool ApplicationSettings::setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths)
@@ -445,7 +446,7 @@ std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
std::vector<FilePath> ApplicationSettings::getHeaderSearchPathsExpanded() const
{
return expandPaths(getHeaderSearchPaths());
return utility::getExpandedPaths(getHeaderSearchPaths());
}
bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
@@ -470,7 +471,7 @@ std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPathsExpanded() const
{
return expandPaths(getFrameworkSearchPaths());
return utility::getExpandedPaths(getFrameworkSearchPaths());
}
bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
+8 -9
View File
@@ -15,6 +15,7 @@
#include "SourceGroupSettingsJavaSonargraph.h"
#include "SourceGroupSettingsPythonEmpty.h"
#include "logging.h"
#include "utilityFile.h"
#include "utilityString.h"
#include "utilityUuid.h"
@@ -128,6 +129,11 @@ void ProjectSettings::setProjectFilePath(std::wstring projectName, const FilePat
setFilePath(projectFileLocation.getConcatenated(L"/" + projectName + PROJECT_FILE_EXTENSION));
}
FilePath ProjectSettings::getDependenciesDirectoryPath() const
{
return getProjectDirectoryPath().concatenate(L"sourcetrail_dependencies");
}
FilePath ProjectSettings::getDBFilePath() const
{
return getFilePath().replaceExtension(INDEX_DB_FILE_EXTENSION);
@@ -240,7 +246,7 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector<std::shared_pt
std::vector<FilePath> ProjectSettings::makePathsExpandedAndAbsolute(const std::vector<FilePath>& paths) const
{
std::vector<FilePath> p = expandPaths(paths);
std::vector<FilePath> p = utility::getExpandedPaths(paths);
std::vector<FilePath> absPaths;
const FilePath basePath = getProjectDirectoryPath();
@@ -261,14 +267,7 @@ std::vector<FilePath> ProjectSettings::makePathsExpandedAndAbsolute(const std::v
FilePath ProjectSettings::makePathExpandedAndAbsolute(const FilePath& path) const
{
FilePath p = expandPath(path);
if (p.empty() || p.isAbsolute())
{
return p;
}
return getProjectDirectoryPath().concatenate(p).makeCanonical();
return utility::getExpandedAndAbsolutePath(path, getProjectDirectoryPath());
}
SettingsMigrator ProjectSettings::getMigrations() const
+1
View File
@@ -35,6 +35,7 @@ public:
FilePath getProjectFilePath() const;
void setProjectFilePath(std::wstring projectName, const FilePath& projectFileLocation);
FilePath getDependenciesDirectoryPath() const;
FilePath getDBFilePath() const;
FilePath getTempDBFilePath() const;
-27
View File
@@ -98,33 +98,6 @@ void Settings::setVersion(size_t version)
setValue<int>("version", version);
}
FilePath Settings::expandPath(const FilePath& path)
{
std::vector<FilePath> paths = path.expandEnvironmentVariables();
if (!paths.empty())
{
if (paths.size() > 1)
{
LOG_WARNING(
L"Environment variable in path \"" + path.wstr() + L"\" has been expanded to " + std::to_wstring(paths.size()) +
L"paths, but only \"" + paths.front().wstr() + L"\" will be used."
);
}
return paths.front();
}
return FilePath();
}
std::vector<FilePath> Settings::expandPaths(const std::vector<FilePath>& paths)
{
std::vector<FilePath> expanedPaths;
for (const FilePath& path : paths)
{
utility::append(expanedPaths, path.expandEnvironmentVariables());
}
return expanedPaths;
}
Settings::Settings()
{
clear();
-3
View File
@@ -29,9 +29,6 @@ public:
size_t getVersion() const;
void setVersion(size_t version);
static FilePath expandPath(const FilePath& path);
static std::vector<FilePath> expandPaths(const std::vector<FilePath>& paths);
protected:
Settings();
+7 -6
View File
@@ -1,7 +1,8 @@
#include "SourceGroupSettings.h"
#include "ProjectSettings.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityString.h"
const size_t SourceGroupSettings::s_version = 1;
const std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
@@ -93,16 +94,16 @@ const ProjectSettings* SourceGroupSettings::getProjectSettings() const
return m_projectSettings;
}
FilePath SourceGroupSettings::getSourceGroupDependenciesDirectoryPath() const
{
return getProjectSettings()->getDependenciesDirectoryPath().concatenate(utility::decodeFromUtf8(getId()));
}
FilePath SourceGroupSettings::getProjectDirectoryPath() const
{
return m_projectSettings->getProjectDirectoryPath();
}
FilePath SourceGroupSettings::makePathExpandedAndAbsolute(const FilePath& path) const
{
return m_projectSettings->makePathExpandedAndAbsolute(path);
}
std::vector<FilePath> SourceGroupSettings::makePathsExpandedAndAbsolute(const std::vector<FilePath>& paths) const
{
return m_projectSettings->makePathsExpandedAndAbsolute(paths);
+1 -1
View File
@@ -42,9 +42,9 @@ public:
void setStatus(SourceGroupStatusType status);
const ProjectSettings* getProjectSettings() const override;
FilePath getSourceGroupDependenciesDirectoryPath() const override;
FilePath getProjectDirectoryPath() const;
FilePath makePathExpandedAndAbsolute(const FilePath& path) const;
std::vector<FilePath> makePathsExpandedAndAbsolute(const std::vector<FilePath>& paths) const;
protected:
@@ -1,6 +1,7 @@
#ifndef SOURCE_GROUP_SETTINGS_BASE_H
#define SOURCE_GROUP_SETTINGS_BASE_H
class FilePath;
class ProjectSettings;
class SourceGroupSettingsBase
@@ -9,6 +10,7 @@ public:
virtual ~SourceGroupSettingsBase() = default;
virtual const ProjectSettings* getProjectSettings() const = 0;
virtual FilePath getSourceGroupDependenciesDirectoryPath() const = 0;
};
#endif // SOURCE_GROUP_SETTINGS_BASE_H
@@ -19,6 +19,7 @@ void SourceGroupSettingsCEmpty::load(std::shared_ptr<const ConfigManager> config
SourceGroupSettingsWithCStandard::load(config, key);
SourceGroupSettingsWithCxxCrossCompilationOptions::load(config, key);
SourceGroupSettingsWithSourceExtensions::load(config, key);
SourceGroupSettingsWithCxxPchOptions::load(config, key);
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
}
@@ -32,6 +33,7 @@ void SourceGroupSettingsCEmpty::save(std::shared_ptr<ConfigManager> config)
SourceGroupSettingsWithCStandard::save(config, key);
SourceGroupSettingsWithCxxCrossCompilationOptions::save(config, key);
SourceGroupSettingsWithSourceExtensions::save(config, key);
SourceGroupSettingsWithCxxPchOptions::save(config, key);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
}
@@ -46,6 +48,7 @@ bool SourceGroupSettingsCEmpty::equals(std::shared_ptr<SourceGroupSettings> othe
SourceGroupSettingsWithCStandard::equals(otherCxxEmpty) &&
SourceGroupSettingsWithCxxCrossCompilationOptions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithSourceExtensions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithCxxPchOptions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) &&
SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty)
);
@@ -5,6 +5,7 @@
#include "SourceGroupSettingsWithCStandard.h"
#include "SourceGroupSettingsWithCxxCrossCompilationOptions.h"
#include "SourceGroupSettingsWithExcludeFilters.h"
#include "SourceGroupSettingsWithCxxPchOptions.h"
#include "SourceGroupSettingsWithSourceExtensions.h"
#include "SourceGroupSettingsWithSourcePaths.h"
@@ -13,6 +14,7 @@ class SourceGroupSettingsCEmpty
, public SourceGroupSettingsWithCStandard
, public SourceGroupSettingsWithCxxCrossCompilationOptions
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithCxxPchOptions
, public SourceGroupSettingsWithSourceExtensions
, public SourceGroupSettingsWithSourcePaths
{
@@ -19,6 +19,7 @@ void SourceGroupSettingsCppEmpty::load(std::shared_ptr<const ConfigManager> conf
SourceGroupSettingsWithCppStandard::load(config, key);
SourceGroupSettingsWithCxxCrossCompilationOptions::load(config, key);
SourceGroupSettingsWithSourceExtensions::load(config, key);
SourceGroupSettingsWithCxxPchOptions::load(config, key);
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
}
@@ -32,6 +33,7 @@ void SourceGroupSettingsCppEmpty::save(std::shared_ptr<ConfigManager> config)
SourceGroupSettingsWithCppStandard::save(config, key);
SourceGroupSettingsWithCxxCrossCompilationOptions::save(config, key);
SourceGroupSettingsWithSourceExtensions::save(config, key);
SourceGroupSettingsWithCxxPchOptions::save(config, key);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
}
@@ -46,6 +48,7 @@ bool SourceGroupSettingsCppEmpty::equals(std::shared_ptr<SourceGroupSettings> ot
SourceGroupSettingsWithCppStandard::equals(otherCxxEmpty) &&
SourceGroupSettingsWithCxxCrossCompilationOptions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithSourceExtensions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithCxxPchOptions::equals(otherCxxEmpty) &&
SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) &&
SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty)
);
@@ -5,6 +5,7 @@
#include "SourceGroupSettingsWithCppStandard.h"
#include "SourceGroupSettingsWithCxxCrossCompilationOptions.h"
#include "SourceGroupSettingsWithExcludeFilters.h"
#include "SourceGroupSettingsWithCxxPchOptions.h"
#include "SourceGroupSettingsWithSourceExtensions.h"
#include "SourceGroupSettingsWithSourcePaths.h"
@@ -13,6 +14,7 @@ class SourceGroupSettingsCppEmpty
, public SourceGroupSettingsWithCppStandard
, public SourceGroupSettingsWithCxxCrossCompilationOptions
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithCxxPchOptions
, public SourceGroupSettingsWithSourceExtensions
, public SourceGroupSettingsWithSourcePaths
{
@@ -1,7 +1,8 @@
#include "SourceGroupSettingsCxxCdb.h"
#include "ProjectSettings.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CDB, projectSettings)
@@ -58,7 +59,7 @@ FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePath() const
FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getCompilationDatabasePath());
return utility::getExpandedAndAbsolutePath(getCompilationDatabasePath(), m_projectSettings->getProjectDirectoryPath());
}
void SourceGroupSettingsCxxCdb::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
@@ -2,6 +2,7 @@
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsCxxCodeblocks::SourceGroupSettingsCxxCodeblocks(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CODEBLOCKS, projectSettings)
@@ -66,7 +67,7 @@ FilePath SourceGroupSettingsCxxCodeblocks::getCodeblocksProjectPath() const
FilePath SourceGroupSettingsCxxCodeblocks::getCodeblocksProjectPathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getCodeblocksProjectPath());
return utility::getExpandedAndAbsolutePath(getCodeblocksProjectPath(), m_projectSettings->getProjectDirectoryPath());
}
void SourceGroupSettingsCxxCodeblocks::setCodeblocksProjectPath(const FilePath& compilationDatabasePath)
@@ -1,12 +1,12 @@
#include "SourceGroupSettingsJavaGradle.h"
#include "ProjectSettings.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_GRADLE, projectSettings)
, m_gradleProjectFilePath(FilePath())
, m_gradleDependenciesDirectory(FilePath())
, m_shouldIndexGradleTests(false)
{
}
@@ -23,7 +23,6 @@ void SourceGroupSettingsJavaGradle::load(std::shared_ptr<const ConfigManager> co
const std::string key = s_keyPrefix + getId();
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));
}
@@ -34,7 +33,6 @@ void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
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());
}
@@ -46,11 +44,15 @@ bool SourceGroupSettingsJavaGradle::equals(std::shared_ptr<SourceGroupSettings>
otherJavaGradle &&
SourceGroupSettingsJava::equals(other) &&
m_gradleProjectFilePath == otherJavaGradle->m_gradleProjectFilePath &&
m_gradleDependenciesDirectory == otherJavaGradle->m_gradleDependenciesDirectory &&
m_shouldIndexGradleTests == otherJavaGradle->m_shouldIndexGradleTests
);
}
FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectoryPath() const
{
return getSourceGroupDependenciesDirectoryPath().concatenate(L"gradle");
}
FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePath() const
{
return m_gradleProjectFilePath;
@@ -58,7 +60,7 @@ FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePath() const
FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getGradleProjectFilePath());
return utility::getExpandedAndAbsolutePath(getGradleProjectFilePath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsJavaGradle::setGradleProjectFilePath(const FilePath& path)
@@ -66,21 +68,6 @@ void SourceGroupSettingsJavaGradle::setGradleProjectFilePath(const FilePath& pat
m_gradleProjectFilePath = path;
}
FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectory() const
{
return m_gradleDependenciesDirectory;
}
FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectoryExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getGradleDependenciesDirectory());
}
void SourceGroupSettingsJavaGradle::setGradleDependenciesDirectory(const FilePath& path)
{
m_gradleDependenciesDirectory = path;
}
bool SourceGroupSettingsJavaGradle::getShouldIndexGradleTests() const
{
return m_shouldIndexGradleTests;
@@ -16,21 +16,18 @@ public:
void save(std::shared_ptr<ConfigManager> config) override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getGradleDependenciesDirectoryPath() const;
FilePath getGradleProjectFilePath() const;
FilePath getGradleProjectFilePathExpandedAndAbsolute() const;
void setGradleProjectFilePath(const FilePath& path);
FilePath getGradleDependenciesDirectory() const;
FilePath getGradleDependenciesDirectoryExpandedAndAbsolute() const;
void setGradleDependenciesDirectory(const FilePath& path);
bool getShouldIndexGradleTests() const;
void setShouldIndexGradleTests(bool value);
private:
FilePath m_gradleProjectFilePath;
FilePath m_gradleDependenciesDirectory;
bool m_shouldIndexGradleTests;
};
@@ -1,12 +1,12 @@
#include "SourceGroupSettingsJavaMaven.h"
#include "ProjectSettings.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_MAVEN, projectSettings)
, m_mavenProjectFilePath(FilePath())
, m_mavenDependenciesDirectory(FilePath())
, m_shouldIndexMavenTests(false)
{
}
@@ -23,7 +23,6 @@ void SourceGroupSettingsJavaMaven::load(std::shared_ptr<const ConfigManager> con
const std::string key = s_keyPrefix + getId();
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));
}
@@ -34,7 +33,6 @@ void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
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());
}
@@ -46,11 +44,15 @@ bool SourceGroupSettingsJavaMaven::equals(std::shared_ptr<SourceGroupSettings> o
otherJavaMaven &&
SourceGroupSettingsJava::equals(other) &&
m_mavenProjectFilePath == otherJavaMaven->m_mavenProjectFilePath &&
m_mavenDependenciesDirectory == otherJavaMaven->m_mavenDependenciesDirectory &&
m_shouldIndexMavenTests == otherJavaMaven->m_shouldIndexMavenTests
);
}
FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectoryPath() const
{
return getSourceGroupDependenciesDirectoryPath().concatenate(L"maven");
}
FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePath() const
{
return m_mavenProjectFilePath;
@@ -58,7 +60,7 @@ FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePath() const
FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getMavenProjectFilePath());
return utility::getExpandedAndAbsolutePath(getMavenProjectFilePath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsJavaMaven::setMavenProjectFilePath(const FilePath& path)
@@ -66,21 +68,6 @@ void SourceGroupSettingsJavaMaven::setMavenProjectFilePath(const FilePath& path)
m_mavenProjectFilePath = path;
}
FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectory() const
{
return m_mavenDependenciesDirectory;
}
FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectoryExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getMavenDependenciesDirectory());
}
void SourceGroupSettingsJavaMaven::setMavenDependenciesDirectory(const FilePath& path)
{
m_mavenDependenciesDirectory = path;
}
bool SourceGroupSettingsJavaMaven::getShouldIndexMavenTests() const
{
return m_shouldIndexMavenTests;
@@ -17,20 +17,17 @@ public:
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getMavenDependenciesDirectoryPath() const;
FilePath getMavenProjectFilePath() const;
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
void setMavenProjectFilePath(const FilePath& path);
FilePath getMavenDependenciesDirectory() const;
FilePath getMavenDependenciesDirectoryExpandedAndAbsolute() const;
void setMavenDependenciesDirectory(const FilePath& path);
bool getShouldIndexMavenTests() const;
void setShouldIndexMavenTests(bool value);
private:
FilePath m_mavenProjectFilePath;
FilePath m_mavenDependenciesDirectory;
bool m_shouldIndexMavenTests;
};
@@ -2,6 +2,7 @@
#include "FilePath.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsPythonEmpty::SourceGroupSettingsPythonEmpty(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, SOURCE_GROUP_PYTHON_EMPTY, projectSettings)
@@ -60,7 +61,7 @@ FilePath SourceGroupSettingsPythonEmpty::getEnvironmentPath() const
FilePath SourceGroupSettingsPythonEmpty::getEnvironmentPathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getEnvironmentPath());
return utility::getExpandedAndAbsolutePath(getEnvironmentPath(), m_projectSettings->getProjectDirectoryPath());
}
void SourceGroupSettingsPythonEmpty::setEnvironmentPath(const FilePath& environmentPath)
@@ -0,0 +1,42 @@
#include "SourceGroupSettingsWithCxxPchOptions.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
bool SourceGroupSettingsWithCxxPchOptions::equals(std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> other) const
{
return (
other &&
m_pchInputFilePath == other->m_pchInputFilePath
);
}
void SourceGroupSettingsWithCxxPchOptions::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setPchInputFilePathFilePath(config->getValueOrDefault(key + "/pch_input_file_path", FilePath(L"")));
}
void SourceGroupSettingsWithCxxPchOptions::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValue(key + "/pch_input_file_path", getPchInputFilePath().wstr());
}
FilePath SourceGroupSettingsWithCxxPchOptions::getPchDependenciesDirectoryPath() const
{
return getSourceGroupDependenciesDirectoryPath().concatenate(L"pch");
}
FilePath SourceGroupSettingsWithCxxPchOptions::getPchInputFilePath() const
{
return m_pchInputFilePath;
}
FilePath SourceGroupSettingsWithCxxPchOptions::getPchInputFilePathExpandedAndAbsolute() const
{
return utility::getExpandedAndAbsolutePath(getPchInputFilePath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsWithCxxPchOptions::setPchInputFilePathFilePath(const FilePath& path)
{
m_pchInputFilePath = path;
}
@@ -0,0 +1,35 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_CXX_PCH_OPTIONS_H
#define SOURCE_GROUP_SETTINGS_WITH_CXX_PCH_OPTIONS_H
#include <memory>
#include <string>
#include "FilePath.h"
#include "SourceGroupSettingsBase.h"
class ConfigManager;
class SourceGroupSettingsWithCxxPchOptions
: virtual public SourceGroupSettingsBase
{
public:
SourceGroupSettingsWithCxxPchOptions() = default;
virtual ~SourceGroupSettingsWithCxxPchOptions() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> other) const;
FilePath getPchDependenciesDirectoryPath() const;
FilePath getPchInputFilePath() const;
FilePath getPchInputFilePathExpandedAndAbsolute() const;
void setPchInputFilePathFilePath(const FilePath& path);
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:
FilePath m_pchInputFilePath;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_CXX_PCH_OPTIONS_H
@@ -4,6 +4,7 @@
#include "FilePathFilter.h"
#include "FileSystem.h"
#include "utility.h"
#include "utilityFile.h"
SourceGroupSettingsWithExcludeFilters::SourceGroupSettingsWithExcludeFilters()
: m_excludeFilters(std::vector<std::wstring>())
@@ -45,6 +46,8 @@ void SourceGroupSettingsWithExcludeFilters::setExcludeFilterStrings(const std::v
std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getFiltersExpandedAndAbsolute(const std::vector<std::wstring>& filterStrings) const
{
const FilePath projectDirectoryPath = getProjectSettings()->getProjectDirectoryPath();
std::vector<FilePathFilter> result;
for (const std::wstring& filterString : filterStrings)
@@ -58,7 +61,7 @@ std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getFiltersExp
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()));
const FilePath p = utility::getExpandedAndAbsolutePath(FilePath(match.prefix().str()), projectDirectoryPath);
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
@@ -79,7 +82,7 @@ std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getFiltersExp
}
else
{
const FilePath p = getProjectSettings()->makePathExpandedAndAbsolute(FilePath(filterString));
const FilePath p = utility::getExpandedAndAbsolutePath(FilePath(filterString), projectDirectoryPath);
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
@@ -1,6 +1,7 @@
#include "SourceGroupSettingsWithSonargraphProjectPath.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
SourceGroupSettingsWithSonargraphProjectPath::SourceGroupSettingsWithSonargraphProjectPath()
{
@@ -31,7 +32,7 @@ FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPath(
FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPathExpandedAndAbsolute() const
{
return getProjectSettings()->makePathExpandedAndAbsolute(getSonargraphProjectPath());
return utility::getExpandedAndAbsolutePath(getSonargraphProjectPath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsWithSonargraphProjectPath::setSonargraphProjectPath(const FilePath& sonargraphProjectPath)
+39
View File
@@ -66,6 +66,45 @@ std::vector<FilePath> utility::getTopLevelPaths(const std::set<FilePath>& paths)
return topLevelPaths;
}
FilePath utility::getExpandedPath(const FilePath& path)
{
std::vector<FilePath> paths = path.expandEnvironmentVariables();
if (!paths.empty())
{
if (paths.size() > 1)
{
LOG_WARNING(
L"Environment variable in path \"" + path.wstr() + L"\" has been expanded to " + std::to_wstring(paths.size()) +
L"paths, but only \"" + paths.front().wstr() + L"\" will be used."
);
}
return paths.front();
}
return FilePath();
}
std::vector<FilePath> utility::getExpandedPaths(const std::vector<FilePath>& paths)
{
std::vector<FilePath> expanedPaths;
for (const FilePath& path : paths)
{
utility::append(expanedPaths, path.expandEnvironmentVariables());
}
return expanedPaths;
}
FilePath utility::getExpandedAndAbsolutePath(const FilePath& path, const FilePath& baseDirectory)
{
FilePath p = getExpandedPath(path);
if (p.empty() || p.isAbsolute())
{
return p;
}
return baseDirectory.getConcatenated(p).makeCanonical();
}
FilePath utility::getAsRelativeIfShorter(const FilePath& absolutePath, const FilePath& baseDirectory)
{
if (!baseDirectory.empty())
+3
View File
@@ -13,6 +13,9 @@ namespace utility
std::vector<FilePath> getTopLevelPaths(const std::vector<FilePath>& paths);
std::vector<FilePath> getTopLevelPaths(const std::set<FilePath>& paths);
FilePath getExpandedPath(const FilePath& path);
std::vector<FilePath> getExpandedPaths(const std::vector<FilePath>& paths);
FilePath getExpandedAndAbsolutePath(const FilePath& path, const FilePath& baseDirectory);
FilePath getAsRelativeIfShorter(const FilePath& absolutePath, const FilePath& baseDirectory);
std::vector<FilePath> getAsRelativeIfShorter(const std::vector<FilePath>& absolutePaths, const FilePath& baseDirectory);
}