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
+18 -1
View File
@@ -365,7 +365,24 @@ target_include_directories(${LIB_CXX_PROJECT_NAME} SYSTEM
)
link_directories(${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
llvm_map_components_to_libnames(REQ_LLVM_LIBS support core libdriver passes x86asmparser x86codegen)
llvm_map_components_to_libnames(REQ_LLVM_LIBS
support core libdriver passes
x86asmparser x86codegen
aarch64asmparser aarch64codegen
amdgpuasmparser amdgpucodegen
armasmparser armcodegen
bpfasmparser bpfcodegen
hexagonasmparser hexagoncodegen
lanaiasmparser lanaicodegen
mipsasmparser mipscodegen
msp430asmparser msp430codegen
nvptxcodegen
powerpcasmparser powerpccodegen
sparcasmparser sparccodegen
systemzasmparser systemzcodegen
webassemblyasmparser webassemblycodegen
xcorecodegen
)
target_link_libraries(${LIB_CXX_PROJECT_NAME} ${LIB_UTILITY_PROJECT_NAME} ${CLANG_LIBRARIES} ${REQ_LLVM_LIBS})
+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);
}
+5 -2
View File
@@ -37,9 +37,8 @@ add_files(
data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp
data/parser/cxx/name_resolver/CxxTypeNameResolver.h
data/parser/cxx/ASTAction.cpp
data/parser/cxx/ASTAction.h
data/parser/cxx/ASTActionFactory.cpp
data/parser/cxx/ASTActionFactory.h
data/parser/cxx/ASTConsumer.cpp
data/parser/cxx/ASTConsumer.h
data/parser/cxx/CanonicalFilePathCache.cpp
@@ -72,8 +71,12 @@ add_files(
data/parser/cxx/CxxParser.h
data/parser/cxx/CxxVerboseAstVisitor.cpp
data/parser/cxx/CxxVerboseAstVisitor.h
data/parser/cxx/GeneratePCHAction.cpp
data/parser/cxx/GeneratePCHAction.h
data/parser/cxx/PreprocessorCallbacks.cpp
data/parser/cxx/PreprocessorCallbacks.h
data/parser/cxx/SingleFrontendActionFactory.cpp
data/parser/cxx/SingleFrontendActionFactory.h
data/parser/cxx/utilityClang.cpp
data/parser/cxx/utilityClang.h
+34
View File
@@ -0,0 +1,34 @@
#include "ASTAction.h"
#include <clang/Frontend/CompilerInstance.h>
#include "ASTConsumer.h"
#include "PreprocessorCallbacks.h"
ASTAction::ASTAction(
std::shared_ptr<ParserClient> client,
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache,
std::shared_ptr<IndexerStateInfo> indexerStateInfo
)
: m_client(client)
, m_canonicalFilePathCache(canonicalFilePathCache)
, m_indexerStateInfo(indexerStateInfo)
, m_commentHandler(client, canonicalFilePathCache)
{}
std::unique_ptr<clang::ASTConsumer> ASTAction::CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile)
{
return std::unique_ptr<clang::ASTConsumer>(new ASTConsumer(
&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_canonicalFilePathCache, m_indexerStateInfo
));
}
bool ASTAction::BeginSourceFileAction(clang::CompilerInstance& compiler)
{
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
preprocessor.addPPCallbacks(llvm::make_unique<PreprocessorCallbacks>(
compiler.getSourceManager(), m_client, m_canonicalFilePathCache
));
preprocessor.addCommentHandler(&m_commentHandler);
return true;
}
+8 -29
View File
@@ -3,47 +3,26 @@
#include <memory>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendAction.h>
#include <clang/Lex/Preprocessor.h>
#include "ASTConsumer.h"
#include "CommentHandler.h"
#include "PreprocessorCallbacks.h"
template <typename ASTActionBase>
class ASTAction
: public ASTActionBase
class ParserClient;
class CanonicalFilePathCache;
struct IndexerStateInfo;
class ASTAction : public clang::ASTFrontendAction
{
public:
explicit ASTAction(
std::shared_ptr<ParserClient> client,
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache,
std::shared_ptr<IndexerStateInfo> indexerStateInfo
)
: m_client(client)
, m_canonicalFilePathCache(canonicalFilePathCache)
, m_indexerStateInfo(indexerStateInfo)
, m_commentHandler(client, canonicalFilePathCache)
{}
virtual ~ASTAction() {}
);
protected:
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile) override
{
return std::unique_ptr<clang::ASTConsumer>(
new ASTConsumer(&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_canonicalFilePathCache, m_indexerStateInfo));
}
virtual bool BeginSourceFileAction(clang::CompilerInstance& compiler) override
{
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
preprocessor.addPPCallbacks(
llvm::make_unique<PreprocessorCallbacks>(compiler.getSourceManager(), m_client, m_canonicalFilePathCache));
preprocessor.addCommentHandler(&m_commentHandler);
return true;
}
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile) override;
bool BeginSourceFileAction(clang::CompilerInstance& compiler) override;
private:
std::shared_ptr<ParserClient> m_client;
@@ -1,25 +0,0 @@
#include "ASTActionFactory.h"
#include <clang/Frontend/FrontendActions.h>
#include "ASTAction.h"
ASTActionFactory::ASTActionFactory(
std::shared_ptr<ParserClient> client,
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache,
std::shared_ptr<IndexerStateInfo> indexerStateInfo
)
: m_client(client)
, m_canonicalFilePathCache(canonicalFilePathCache)
, m_indexerStateInfo(indexerStateInfo)
{
}
ASTActionFactory::~ASTActionFactory()
{
}
clang::FrontendAction* ASTActionFactory::create()
{
return new ASTAction<clang::ASTFrontendAction>(m_client, m_canonicalFilePathCache, m_indexerStateInfo);
}
@@ -1,33 +0,0 @@
#ifndef AST_ACTION_FACTORY
#define AST_ACTION_FACTORY
#include <memory>
#include <clang/Tooling/Tooling.h>
#include "IndexerStateInfo.h"
class CanonicalFilePathCache;
class ParserClient;
class ASTActionFactory
: public clang::tooling::FrontendActionFactory
{
public:
explicit ASTActionFactory(
std::shared_ptr<ParserClient> client,
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache,
std::shared_ptr<IndexerStateInfo> indexerStateInfo
);
virtual ~ASTActionFactory();
virtual clang::FrontendAction* create() override;
private:
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<CanonicalFilePathCache> m_canonicalFilePathCache;
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
};
#endif // AST_ACTION_FACTORY
+51 -33
View File
@@ -10,7 +10,7 @@
#include <llvm/Support/TargetSelect.h>
#include "ApplicationSettings.h"
#include "ASTActionFactory.h"
#include "ASTAction.h"
#include "CanonicalFilePathCache.h"
#include "CxxCompilationDatabaseSingle.h"
#include "CxxDiagnosticConsumer.h"
@@ -20,6 +20,7 @@
#include "logging.h"
#include "ParserClient.h"
#include "ResourcePaths.h"
#include "SingleFrontendActionFactory.h"
#include "TextAccess.h"
#include "utilityString.h"
#include "utility.h"
@@ -114,6 +115,8 @@ namespace
const clang::tooling::FileContentMappings &VirtualMappedFiles = clang::tooling::FileContentMappings()
)
{
CxxParser::initializeLLVM();
llvm::SmallString<16> FileNameStorage;
llvm::StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
@@ -136,6 +139,47 @@ namespace
}
}
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(const std::vector<std::wstring>& compilerFlags)
{
std::vector<std::string> args;
// The option -fno-delayed-template-parsing signals that templates that there should
// be AST elements for unused template functions as well.
args.push_back("-fno-delayed-template-parsing");
// The option -fexceptions signals that clang should watch out for exception-related code during indexing.
args.push_back("-fexceptions");
// The option -c signals that no executable is built.
args.push_back("-c");
// The option -w disables all warnings.
args.push_back("-w");
// This option tells clang just to continue parsing no matter how manny errors have been thrown.
args.push_back("-ferror-limit=0");
for (const std::wstring& compilerFlag : compilerFlags)
{
args.push_back(utility::encodeToUtf8(compilerFlag));
}
return args;
}
void CxxParser::initializeLLVM()
{
static bool intialized = false;
if (!intialized)
{
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllAsmParsers();
intialized = true;
}
}
CxxParser::CxxParser(
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
@@ -172,13 +216,13 @@ void CxxParser::buildIndex(const std::wstring& fileName, std::shared_ptr<TextAcc
std::make_shared<CanonicalFilePathCache>(m_fileRegister);
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(FilePath(), canonicalFilePathCache, false);
ASTActionFactory actionFactory(m_client, canonicalFilePathCache, m_indexerStateInfo);
clang::ASTFrontendAction* action = new ASTAction(m_client, canonicalFilePathCache, m_indexerStateInfo);
std::vector<std::string> args = getCommandlineArgumentsEssential(compilerFlags);
runToolOnCodeWithArgs(
diagnostics.get(),
actionFactory.create(),
action,
fileContent->getText(),
args,
utility::encodeToUtf8(fileName)
@@ -187,6 +231,8 @@ void CxxParser::buildIndex(const std::wstring& fileName, std::shared_ptr<TextAcc
void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase, const FilePath& sourceFilePath)
{
initializeLLVM();
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, utility::encodeToUtf8(sourceFilePath.wstr())));
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache = std::make_shared<CanonicalFilePathCache>(m_fileRegister);
@@ -207,8 +253,8 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase
}
}
ASTActionFactory actionFactory(m_client, canonicalFilePathCache, m_indexerStateInfo);
tool.run(&actionFactory);
clang::ASTFrontendAction* action = new ASTAction(m_client, canonicalFilePathCache, m_indexerStateInfo);
tool.run(new SingleFrontendActionFactory(action));
if (!m_client->hasContent())
{
@@ -231,34 +277,6 @@ void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase
}
}
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(const std::vector<std::wstring>& compilerFlags) const
{
std::vector<std::string> args;
// The option -fno-delayed-template-parsing signals that templates that there should
// be AST elements for unused template functions as well.
args.push_back("-fno-delayed-template-parsing");
// The option -fexceptions signals that clang should watch out for exception-related code during indexing.
args.push_back("-fexceptions");
// The option -c signals that no executable is built.
args.push_back("-c");
// The option -w disables all warnings.
args.push_back("-w");
// This option tells clang just to continue parsing no matter how manny errors have been thrown.
args.push_back("-ferror-limit=0");
for (const std::wstring& compilerFlag: compilerFlags)
{
args.push_back(utility::encodeToUtf8(compilerFlag));
}
return args;
}
std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(const FilePath& sourceFilePath, std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache, bool logErrors) const
{
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
+3 -2
View File
@@ -26,6 +26,9 @@ struct IndexerStateInfo;
class CxxParser: public Parser
{
public:
static std::vector<std::string> getCommandlineArgumentsEssential(const std::vector<std::wstring>& compilerFlags);
static void CxxParser::initializeLLVM();
CxxParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister, std::shared_ptr<IndexerStateInfo> indexerStateInfo);
void buildIndex(std::shared_ptr<IndexerCommandCxx> indexerCommand);
@@ -34,8 +37,6 @@ public:
private:
void runTool(clang::tooling::CompilationDatabase* compilationDatabase, const FilePath& sourceFilePath);
std::vector<std::string> getCommandlineArgumentsEssential(const std::vector<std::wstring>& compilerFlags) const;
std::shared_ptr<CxxDiagnosticConsumer> getDiagnostics(
const FilePath& sourceFilePath, std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache, bool logErrors) const;
@@ -0,0 +1,39 @@
#include "GeneratePCHAction.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Serialization/ASTWriter.h"
#include "clang/Frontend/MultiplexConsumer.h"
bool GeneratePCHAction::shouldEraseOutputFiles()
{
return false;
}
std::unique_ptr<clang::ASTConsumer> GeneratePCHAction::CreateASTConsumer(clang::CompilerInstance &CI, llvm::StringRef InFile)
{
std::string Sysroot;
if (!ComputeASTConsumerArguments(CI, /*ref*/ Sysroot))
return nullptr;
std::string OutputFile;
std::unique_ptr<llvm::raw_pwrite_stream> OS =
CreateOutputFile(CI, InFile, /*ref*/ OutputFile);
if (!OS)
return nullptr;
if (!CI.getFrontendOpts().RelocatablePCH)
Sysroot.clear();
const auto &FrontendOpts = CI.getFrontendOpts();
auto Buffer = std::make_shared<clang::PCHBuffer>();
std::vector<std::unique_ptr<clang::ASTConsumer>> Consumers;
Consumers.push_back(llvm::make_unique<clang::PCHGenerator>(
CI.getPreprocessor(), OutputFile, Sysroot,
Buffer, FrontendOpts.ModuleFileExtensions,
true,
FrontendOpts.IncludeTimestamps));
Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
CI, InFile, OutputFile, std::move(OS), Buffer));
return llvm::make_unique<clang::MultiplexConsumer>(std::move(Consumers));
}
@@ -0,0 +1,16 @@
#ifndef GENERATE_PCH_ACTION_H
#define GENERATE_PCH_ACTION_H
#include "clang/Frontend/FrontendActions.h"
class GeneratePCHAction : public clang::GeneratePCHAction
{
protected:
// this method has been overridden to prevent erasing output file independently of provided flags
bool shouldEraseOutputFiles() override;
// this method has been overridden to always set "AllowASTWithErrors" of the PCHGenerator to "true"
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &CI, llvm::StringRef InFile) override;
};
#endif // GENERATE_PCH_ACTION_H
@@ -0,0 +1,10 @@
#include "SingleFrontendActionFactory.h"
SingleFrontendActionFactory::SingleFrontendActionFactory(clang::FrontendAction* action)
: m_action(action)
{}
clang::FrontendAction* SingleFrontendActionFactory::create()
{
return m_action;
}
@@ -0,0 +1,16 @@
#ifndef SINGLE_FRONTEND_ACTION_FACTORY
#define SINGLE_FRONTEND_ACTION_FACTORY
#include "clang/Tooling/Tooling.h"
class SingleFrontendActionFactory : public clang::tooling::FrontendActionFactory
{
public:
SingleFrontendActionFactory(clang::FrontendAction* action);
clang::FrontendAction* create() override;
private:
clang::FrontendAction* m_action;
};
#endif // SINGLE_FRONTEND_ACTION_FACTORY
+153 -58
View File
@@ -1,13 +1,20 @@
#include "SourceGroupCxxEmpty.h"
#include "ApplicationSettings.h"
#include "CxxCompilationDatabaseSingle.h"
#include "CxxIndexerCommandProvider.h"
#include "CxxParser.h"
#include "DialogView.h"
#include "FileManager.h"
#include "FileSystem.h"
#include "GeneratePCHAction.h"
#include "IndexerCommandCxx.h"
#include "SingleFrontendActionFactory.h"
#include "SourceGroupSettingsCEmpty.h"
#include "SourceGroupSettingsCppEmpty.h"
#include "SourceGroupSettingsWithCppStandard.h"
#include "SourceGroupSettingsWithCStandard.h"
#include "TaskLambda.h"
#include "utility.h"
SourceGroupCxxEmpty::SourceGroupCxxEmpty(std::shared_ptr<SourceGroupSettingsCxx> settings)
@@ -67,55 +74,173 @@ std::set<FilePath> SourceGroupCxxEmpty::getAllSourceFilePaths() const
std::shared_ptr<IndexerCommandProvider> SourceGroupCxxEmpty::getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const
{
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
std::set<FilePath> indexedPaths;
std::set<FilePathFilter> excludeFilters;
std::wstring targetFlag;
FilePath pchInputFilePath;
FilePath pchDependenciesDirectoryPath;
if (std::shared_ptr<SourceGroupSettingsCEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCEmpty>(m_settings))
{
indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute());
excludeFilters = utility::toSet(settings->getExcludeFiltersExpandedAndAbsolute());
targetFlag = settings->getTargetFlag();
pchInputFilePath = settings->getPchInputFilePathExpandedAndAbsolute();
pchDependenciesDirectoryPath = settings->getPchDependenciesDirectoryPath();
}
else if (std::shared_ptr<SourceGroupSettingsCppEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(m_settings))
{
indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute());
excludeFilters = utility::toSet(settings->getExcludeFiltersExpandedAndAbsolute());
targetFlag = settings->getTargetFlag();
pchInputFilePath = settings->getPchInputFilePathExpandedAndAbsolute();
pchDependenciesDirectoryPath = settings->getPchDependenciesDirectoryPath();
}
std::vector<std::wstring> compilerFlags = getCompilerFlags();
if (!pchInputFilePath.empty() && !pchDependenciesDirectoryPath.empty())
{
const FilePath pchOutputFilePath = pchDependenciesDirectoryPath.getConcatenated(pchInputFilePath.fileName()).replaceExtension(L"pch");
compilerFlags.push_back(L"-fallow-pch-with-compiler-errors");
compilerFlags.push_back(L"-include-pch");
compilerFlags.push_back(pchOutputFilePath.wstr());
}
std::shared_ptr<CxxIndexerCommandProvider> provider = std::make_shared<CxxIndexerCommandProvider>();
for (const FilePath& sourcePath: getAllSourceFilePaths())
{
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
provider->addCommand(std::make_shared<IndexerCommandCxx>(
sourcePath,
indexedPaths,
excludeFilters,
std::set<FilePathFilter>(),
m_settings->getProjectDirectoryPath(),
utility::concat(compilerFlags, sourcePath.wstr())
));
}
}
return provider;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
return getIndexerCommandProvider(filesToIndex)->consumeAllCommands();
}
std::shared_ptr<Task> SourceGroupCxxEmpty::getPreIndexTask(std::shared_ptr<DialogView> dialogView) const
{
FilePath pchInputFilePath;
FilePath pchDependenciesDirectoryPath;
if (std::shared_ptr<SourceGroupSettingsCEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCEmpty>(m_settings))
{
pchInputFilePath = settings->getPchInputFilePathExpandedAndAbsolute();
pchDependenciesDirectoryPath = settings->getPchDependenciesDirectoryPath();
}
else if (std::shared_ptr<SourceGroupSettingsCppEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(m_settings))
{
pchInputFilePath = settings->getPchInputFilePathExpandedAndAbsolute();
pchDependenciesDirectoryPath = settings->getPchDependenciesDirectoryPath();
}
if (pchInputFilePath.empty() || pchDependenciesDirectoryPath.empty())
{
return std::make_shared<TaskLambda>([]() {});
}
if (!pchInputFilePath.exists())
{
LOG_ERROR(L"Precompiled header input file \"" + pchInputFilePath.wstr() + L"\" does not exist.");
return std::make_shared<TaskLambda>([]() {});
}
const FilePath pchOutputFilePath = pchDependenciesDirectoryPath.getConcatenated(pchInputFilePath.fileName()).replaceExtension(L"pch");
std::vector<std::wstring> compilerFlags = getCompilerFlags();
compilerFlags.push_back(pchInputFilePath.wstr());
compilerFlags.push_back(L"-emit-pch");
compilerFlags.push_back(L"-o");
compilerFlags.push_back(pchOutputFilePath.wstr());
return std::make_shared<TaskLambda>(
[dialogView, pchInputFilePath, pchOutputFilePath, compilerFlags]()
{
dialogView->showUnknownProgressDialog(L"Preparing Indexing", L"Processing Precompiled Headers");
LOG_INFO(
L"Generating precompiled header output for input file \"" + pchInputFilePath.wstr() +
L"\" at location \"" + pchOutputFilePath.wstr() + L"\""
);
CxxParser::initializeLLVM();
if (!pchOutputFilePath.getParentDirectory().exists())
{
FileSystem::createDirectory(pchOutputFilePath.getParentDirectory());
}
clang::tooling::CompileCommand pchCommand;
pchCommand.Filename = utility::encodeToUtf8(pchInputFilePath.fileName());
pchCommand.Directory = pchOutputFilePath.getParentDirectory().str();
// DON'T use "-fsyntax-only" here because it will cause the output file to be erased
pchCommand.CommandLine = utility::concat({ "clang-tool" }, CxxParser::getCommandlineArgumentsEssential(compilerFlags));
CxxCompilationDatabaseSingle compilationDatabase(pchCommand);
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, utility::encodeToUtf8(pchInputFilePath.wstr())));
GeneratePCHAction* action = new GeneratePCHAction();
tool.clearArgumentsAdjusters();
tool.run(new SingleFrontendActionFactory(action));
}
);
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxxEmpty::getSourceGroupSettings()
{
return m_settings;
}
std::shared_ptr<const SourceGroupSettings> SourceGroupCxxEmpty::getSourceGroupSettings() const
{
return m_settings;
}
std::vector<std::wstring> SourceGroupCxxEmpty::getCompilerFlags() const
{
std::vector<std::wstring> compilerFlags;
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
std::set<FilePath> indexedPaths;
std::wstring targetFlag;
std::wstring languageStandard = SourceGroupSettingsWithCppStandard::getDefaultCppStandardStatic();
if (std::shared_ptr<SourceGroupSettingsCEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCEmpty>(m_settings))
{
if (!targetFlag.empty())
{
compilerFlags.push_back(targetFlag);
}
indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute());
targetFlag = settings->getTargetFlag();
languageStandard = settings->getCStandard();
}
else if (std::shared_ptr<SourceGroupSettingsCppEmpty> settings =
std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(m_settings))
{
indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute());
targetFlag = settings->getTargetFlag();
languageStandard = settings->getCppStandard();
}
else
{
LOG_ERROR(L"Source group doesn't specify language standard. Falling back to \"" + languageStandard + L"\".");
}
if (!targetFlag.empty())
{
std::wstring languageStandard = SourceGroupSettingsWithCppStandard::getDefaultCppStandardStatic();
if (std::shared_ptr<SourceGroupSettingsWithCStandard> cSettings =
std::dynamic_pointer_cast<SourceGroupSettingsWithCStandard>(m_settings))
{
languageStandard = cSettings->getCStandard();
}
else if (std::shared_ptr<SourceGroupSettingsWithCppStandard> cppSettings =
std::dynamic_pointer_cast<SourceGroupSettingsWithCppStandard>(m_settings))
{
languageStandard = cppSettings->getCppStandard();
}
else
{
LOG_ERROR(L"Source group doesn't specify language standard. Falling back to \"" + languageStandard + L"\".");
}
compilerFlags.push_back(IndexerCommandCxx::getCompilerFlagLanguageStandard(languageStandard));
compilerFlags.push_back(targetFlag);
}
compilerFlags.push_back(IndexerCommandCxx::getCompilerFlagLanguageStandard(languageStandard));
if (std::dynamic_pointer_cast<SourceGroupSettingsCppEmpty>(m_settings))
{
compilerFlags.push_back(L"-x");
@@ -143,36 +268,6 @@ std::shared_ptr<IndexerCommandProvider> SourceGroupCxxEmpty::getIndexerCommandPr
utility::append(compilerFlags, m_settings->getCompilerFlags());
std::shared_ptr<CxxIndexerCommandProvider> provider = std::make_shared<CxxIndexerCommandProvider>();
for (const FilePath& sourcePath: getAllSourceFilePaths())
{
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
provider->addCommand(std::make_shared<IndexerCommandCxx>(
sourcePath,
indexedPaths,
excludeFilters,
std::set<FilePathFilter>(),
m_settings->getProjectDirectoryPath(),
utility::concat(compilerFlags, sourcePath.wstr())
));
}
}
return provider;
return compilerFlags;
}
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(const std::set<FilePath>& filesToIndex) const
{
return getIndexerCommandProvider(filesToIndex)->consumeAllCommands();
}
std::shared_ptr<SourceGroupSettings> SourceGroupCxxEmpty::getSourceGroupSettings()
{
return m_settings;
}
std::shared_ptr<const SourceGroupSettings> SourceGroupCxxEmpty::getSourceGroupSettings() const
{
return m_settings;
}
@@ -17,10 +17,12 @@ public:
std::set<FilePath> getAllSourceFilePaths() const override;
std::shared_ptr<IndexerCommandProvider> getIndexerCommandProvider(const std::set<FilePath>& filesToIndex) const override;
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const std::set<FilePath>& filesToIndex) const override;
std::shared_ptr<Task> getPreIndexTask(std::shared_ptr<DialogView> dialogView) const override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
std::vector<std::wstring> getCompilerFlags() const;
std::shared_ptr<SourceGroupSettingsCxx> m_settings;
};
+2 -4
View File
@@ -150,10 +150,8 @@ add_files(
qt/project_wizard/content/path/QtProjectWizardContentPathCDB.h
qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathCodeblocksProject.h
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesGradle.h
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathDependenciesMaven.h
qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathCxxPch.h
qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathPythonEnvironment.h
qt/project_wizard/content/path/QtProjectWizardContentPathSonargraphProject.cpp
@@ -19,8 +19,7 @@
#include "QtProjectWizardContentPath.h"
#include "QtProjectWizardContentPathCDB.h"
#include "QtProjectWizardContentPathCodeblocksProject.h"
#include "QtProjectWizardContentPathDependenciesGradle.h"
#include "QtProjectWizardContentPathDependenciesMaven.h"
#include "QtProjectWizardContentPathCxxPch.h"
#include "QtProjectWizardContentPathPythonEnvironment.h"
#include "QtProjectWizardContentPathSonargraphProject.h"
#include "QtProjectWizardContentPathSourceGradle.h"
@@ -141,6 +140,13 @@ namespace
{
QtSourceGroupWizardPage<SourceGroupSettingsCEmpty> page("Advanced (optional)");
page.addContentCreatorWithSettings<QtProjectWizardContentFlags>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreator(
WIZARD_CONTENT_CONTEXT_ALL,
[](std::shared_ptr<SourceGroupSettingsCEmpty> settings, QtProjectWizardWindow* window)
{
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
}
);
pages.push_back(page);
}
@@ -180,6 +186,13 @@ namespace
{
QtSourceGroupWizardPage<SourceGroupSettingsCppEmpty> page("Advanced (optional)");
page.addContentCreatorWithSettings<QtProjectWizardContentFlags>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreator(
WIZARD_CONTENT_CONTEXT_ALL,
[](std::shared_ptr<SourceGroupSettingsCppEmpty> settings, QtProjectWizardWindow* window)
{
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
}
);
pages.push_back(page);
}
@@ -362,7 +375,6 @@ namespace
QtSourceGroupWizardPage<SourceGroupSettingsJavaMaven> page("Indexed Paths");
page.addContentCreatorWithSettings<QtProjectWizardContentJavaStandard>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSourceMaven>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathDependenciesMaven>(WIZARD_CONTENT_CONTEXT_ALL);
pages.push_back(page);
}
{
@@ -383,7 +395,6 @@ namespace
QtSourceGroupWizardPage<SourceGroupSettingsJavaGradle> page("Indexed Paths");
page.addContentCreatorWithSettings<QtProjectWizardContentJavaStandard>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSourceGradle>(WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathDependenciesGradle>(WIZARD_CONTENT_CONTEXT_ALL);
pages.push_back(page);
}
{
@@ -1107,28 +1118,12 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType)
case SOURCE_GROUP_JAVA_MAVEN:
{
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::make_shared<SourceGroupSettingsJavaMaven>(sourceGroupId, m_projectSettings.get());
settings->setMavenDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(settings->getId()) +
L"/maven"
)
);
executeSourceGroupSetup<SourceGroupSettingsJavaMaven>(settings);
}
break;
case SOURCE_GROUP_JAVA_GRADLE:
{
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::make_shared<SourceGroupSettingsJavaGradle>(sourceGroupId, m_projectSettings.get());
settings->setGradleDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(settings->getId()) +
L"/gradle"
)
);
executeSourceGroupSetup<SourceGroupSettingsJavaGradle>(settings);
}
break;
@@ -3,10 +3,10 @@
#include <QMessageBox>
#include "SourceGroupSettings.h"
#include "utilityFile.h"
QtProjectWizardContentPath::QtProjectWizardContentPath(QtProjectWizardWindow* window)
: QtProjectWizardContent(window)
, m_makePathRelativeToProjectFileLocation(true)
, m_allowEmpty(false)
{
}
@@ -25,10 +25,7 @@ void QtProjectWizardContentPath::populate(QGridLayout* layout, int& row)
m_picker->setPickDirectory(true);
m_picker->setPlaceholderText(m_placeholderString);
if (m_makePathRelativeToProjectFileLocation)
{
m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath());
}
m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath());
layout->addWidget(m_picker, row, QtProjectWizardWindow::BACK_COL);
row++;
@@ -53,7 +50,7 @@ bool QtProjectWizardContentPath::check()
}
}
FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString()));
FilePath path = utility::getExpandedAndAbsolutePath(FilePath(m_picker->getText().toStdWString()), getSourceGroupSettings()->getProjectDirectoryPath());
if (m_picker->pickDirectory())
{
@@ -66,7 +63,7 @@ bool QtProjectWizardContentPath::check()
break;
}
if (m_fileEndings.find(path.extension()) == m_fileEndings.end())
if (!m_fileEndings.empty() && m_fileEndings.find(path.extension()) == m_fileEndings.end())
{
error = "The entered path does have a correct file ending at \"" + m_titleString + "\".";
break;
@@ -31,8 +31,6 @@ protected:
QtLocationPicker* m_picker;
bool m_makePathRelativeToProjectFileLocation;
private:
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() = 0;
@@ -0,0 +1,46 @@
#include "QtProjectWizardContentPathCxxPch.h"
#include "SourceGroupSettingsWithCxxPchOptions.h"
#include "utility.h"
#include "utilityFile.h"
QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch(
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settingsCxxPch,
QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
, m_settingsCxxPch(settingsCxxPch)
{
setTitleString("Precompiled Header File");
setHelpString(
"Specify the path to the input header file that should be used to generate a precompiled header during indexing.<br />"
"If the indexed source code is usually built using precompiled headers, using this option will speed up your indexing performance.<br />"
"Leave blank to disable the use of precompiled headers. You can make use of environment variables with ${ENV_VAR}."
);
setAllowEmpty(true);
setPlaceholderString("Not Using Precompiled Headers");
}
void QtProjectWizardContentPathCxxPch::populate(QGridLayout* layout, int& row)
{
QtProjectWizardContentPath::populate(layout, row);
m_picker->setPickDirectory(false);
}
void QtProjectWizardContentPathCxxPch::load()
{
m_picker->setText(QString::fromStdWString(m_settingsCxxPch->getPchInputFilePath().wstr()));
}
void QtProjectWizardContentPathCxxPch::save()
{
m_settingsCxxPch->setPchInputFilePathFilePath(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathCxxPch::getSourceGroupSettings()
{
return m_settings;
}
@@ -0,0 +1,33 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
#include "QtProjectWizardContentPath.h"
#include "SingleValueCache.h"
class SourceGroupSettingsWithCxxPchOptions;
class QtProjectWizardContentPathCxxPch
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathCxxPch(
std::shared_ptr<SourceGroupSettings> settings,
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settingsCxxPch,
QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void populate(QGridLayout* layout, int& row) override;
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettings> m_settings;
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> m_settingsCxxPch;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_CXX_PCH_H
@@ -1,33 +0,0 @@
#include "QtProjectWizardContentPathDependenciesGradle.h"
#include "SourceGroupSettingsJavaGradle.h"
QtProjectWizardContentPathDependenciesGradle::QtProjectWizardContentPathDependenciesGradle(
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle "
"project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizardContentPathDependenciesGradle::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr()));
}
void QtProjectWizardContentPathDependenciesGradle::save()
{
m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathDependenciesGradle::getSourceGroupSettings()
{
return m_settings;
}
@@ -1,27 +0,0 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
#include "QtProjectWizardContentPath.h"
class SourceGroupSettingsJavaGradle;
class QtProjectWizardContentPathDependenciesGradle
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathDependenciesGradle(
std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_GRADLE_H
@@ -1,32 +0,0 @@
#include "QtProjectWizardContentPathDependenciesMaven.h"
#include "SourceGroupSettingsJavaMaven.h"
QtProjectWizardContentPathDependenciesMaven::QtProjectWizardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window
)
: QtProjectWizardContentPath(window)
, m_settings(settings)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizardContentPathDependenciesMaven::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr()));
}
void QtProjectWizardContentPathDependenciesMaven::save()
{
m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathDependenciesMaven::getSourceGroupSettings()
{
return m_settings;
}
@@ -1,26 +0,0 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
#include "QtProjectWizardContentPath.h"
class SourceGroupSettingsJavaMaven;
class QtProjectWizardContentPathDependenciesMaven
: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathDependenciesMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_DEPENDENCIES_MAVEN_H
@@ -3,6 +3,7 @@
#include "ResourcePaths.h"
#include "SourceGroupSettingsPythonEmpty.h"
#include "utilityApp.h"
#include "utilityFile.h"
QtProjectWizardContentPathPythonEnvironment::QtProjectWizardContentPathPythonEnvironment(
std::shared_ptr<SourceGroupSettingsPythonEmpty> settings, QtProjectWizardWindow* window
@@ -63,7 +64,7 @@ void QtProjectWizardContentPathPythonEnvironment::onTextChanged(const QString& t
std::thread([=]() {
std::pair<int, std::string> out = utility::executeProcess(
"\"" + ResourcePaths::getPythonPath().str() + "SourcetrailPythonIndexer\" check-environment " +
"--environment-path \"" + m_settings->makePathExpandedAndAbsolute(FilePath(text.toStdWString())).str() + "\"",
"--environment-path \"" + utility::getExpandedAndAbsolutePath(FilePath(text.toStdWString()), m_settings->getProjectDirectoryPath()).str() + "\"",
FilePath(),
5000
);
@@ -53,10 +53,10 @@ std::vector<FilePath> SourceGroupJavaGradle::doGetClassPath() const
{
std::vector<FilePath> classPath = utility::getClassPath({}, true, getAllSourceFilePaths());
if (m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute().exists())
if (m_settings->getGradleDependenciesDirectoryPath().exists())
{
std::vector<FilePath> gradleJarPaths = FileSystem::getFilePathsFromDirectory(
m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(),
m_settings->getGradleDependenciesDirectoryPath(),
{ L".jar" }
);
@@ -97,7 +97,7 @@ bool SourceGroupJavaGradle::prepareGradleData()
bool success = utility::gradleCopyDependencies(
projectRootPath,
m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(),
m_settings->getGradleDependenciesDirectoryPath(),
m_settings->getShouldIndexGradleTests()
);
@@ -52,10 +52,10 @@ std::vector<FilePath> SourceGroupJavaMaven::doGetClassPath() const
{
std::vector<FilePath> classPath = utility::getClassPath({}, true, getAllSourceFilePaths());
if (m_settings && m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists())
if (m_settings && m_settings->getMavenDependenciesDirectoryPath().exists())
{
std::vector<FilePath> mavenJarPaths = FileSystem::getFilePathsFromDirectory(
m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute(),
m_settings->getMavenDependenciesDirectoryPath(),
{ L".jar" }
);
@@ -105,7 +105,7 @@ bool SourceGroupJavaMaven::prepareMavenData()
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nExporting Dependencies");
bool success = utility::mavenCopyDependencies(
mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute()
mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryPath()
);
return success;
-2
View File
@@ -313,7 +313,6 @@ public:
sourceGroupSettings->setJavaStandard({ L"10" });
sourceGroupSettings->setGradleProjectFilePath({ getInputDirectoryPath(projectName).concatenate(L"build.gradle") });
sourceGroupSettings->setShouldIndexGradleTests(true);
sourceGroupSettings->setGradleDependenciesDirectory(getInputDirectoryPath(projectName).concatenate(L"gradle_dependencies"));
std::shared_ptr<ApplicationSettings> applicationSettings = ApplicationSettings::getInstance();
@@ -353,7 +352,6 @@ public:
sourceGroupSettings->setJavaStandard({ L"10" });
sourceGroupSettings->setMavenProjectFilePath({ getInputDirectoryPath(projectName).concatenate(L"my-app/pom.xml") });
sourceGroupSettings->setShouldIndexMavenTests(true);
sourceGroupSettings->setMavenDependenciesDirectory(getInputDirectoryPath(projectName).concatenate(L"maven_dependencies"));
std::shared_ptr<ApplicationSettings> applicationSettings = ApplicationSettings::getInstance();