forked from qt-creator/qt-creator
ClangRefactoring: Integrate generated files
This is an intermediate step to handle the indexing of the project parts completely. The generated files are now independently handled from the project parts. We still not handle the case the a file is indexed but the generated file is not provided. This will be done in a different patch. All provided data is now sorted too to improve merging. Change-Id: I09712b99217a881ec0a233d09aea8659fb787324 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -77,8 +77,8 @@ public:
|
|||||||
|
|
||||||
friend bool operator<(const FileContainer &first, const FileContainer &second)
|
friend bool operator<(const FileContainer &first, const FileContainer &second)
|
||||||
{
|
{
|
||||||
return std::tie(first.documentRevision, first.filePath, first.unsavedFileContent, first.commandLineArguments)
|
return std::tie(first.filePath, first.documentRevision, first.unsavedFileContent, first.commandLineArguments)
|
||||||
< std::tie(second.documentRevision, second.filePath, second.unsavedFileContent, second.commandLineArguments);
|
< std::tie(second.filePath, second.documentRevision, second.unsavedFileContent, second.commandLineArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileContainer clone() const
|
FileContainer clone() const
|
||||||
|
|||||||
@@ -133,7 +133,9 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const FilePath &first, const FilePath &second)
|
friend bool operator==(const FilePath &first, const FilePath &second)
|
||||||
{
|
{
|
||||||
return first.toStringView() == second.toStringView();
|
return first.slashIndex() == second.slashIndex()
|
||||||
|
&& first.name() == second.name()
|
||||||
|
&& first.directory() == second.directory();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const FilePath &first, const FilePathView &second)
|
friend bool operator==(const FilePath &first, const FilePathView &second)
|
||||||
@@ -148,7 +150,8 @@ public:
|
|||||||
|
|
||||||
friend bool operator<(const FilePath &first, const FilePath &second)
|
friend bool operator<(const FilePath &first, const FilePath &second)
|
||||||
{
|
{
|
||||||
return first.toStringView() < second.toStringView();
|
return std::make_tuple(first.slashIndex(), first.name(), first.directory())
|
||||||
|
< std::make_tuple(second.slashIndex(), second.name(), second.directory());
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath clone() const
|
FilePath clone() const
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
#include "generatedfiles.h"
|
#include "generatedfiles.h"
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
template<class Type>
|
||||||
void GeneratedFiles::update(V2::FileContainers &&fileContainers)
|
void GeneratedFiles::updateInternal(Type &&fileContainers)
|
||||||
{
|
{
|
||||||
V2::FileContainers unionFileContainers;
|
V2::FileContainers unionFileContainers;
|
||||||
unionFileContainers.reserve(m_fileContainers.size() + fileContainers.size());
|
unionFileContainers.reserve(m_fileContainers.size() + fileContainers.size());
|
||||||
@@ -46,6 +46,16 @@ void GeneratedFiles::update(V2::FileContainers &&fileContainers)
|
|||||||
m_fileContainers = std::move(unionFileContainers);
|
m_fileContainers = std::move(unionFileContainers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneratedFiles::update(V2::FileContainers &&fileContainers)
|
||||||
|
{
|
||||||
|
updateInternal(std::move(fileContainers));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneratedFiles::update(const V2::FileContainers &fileContainers)
|
||||||
|
{
|
||||||
|
updateInternal(fileContainers);
|
||||||
|
}
|
||||||
|
|
||||||
class Compare {
|
class Compare {
|
||||||
public:
|
public:
|
||||||
bool operator()(const FilePath &first, const FilePath &second)
|
bool operator()(const FilePath &first, const FilePath &second)
|
||||||
|
|||||||
@@ -29,13 +29,18 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
class GeneratedFiles
|
class CLANGSUPPORT_EXPORT GeneratedFiles
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void update(V2::FileContainers &&fileContainers);
|
void update(V2::FileContainers &&fileContainers);
|
||||||
|
void update(const V2::FileContainers &fileContainers);
|
||||||
void remove(const FilePaths &filePaths);
|
void remove(const FilePaths &filePaths);
|
||||||
|
|
||||||
const V2::FileContainers &fileContainers() const;
|
const V2::FileContainers &fileContainers() const;
|
||||||
|
private:
|
||||||
|
template<class Type>
|
||||||
|
void updateInternal(Type &&fileContainers);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
V2::FileContainers m_fileContainers;
|
V2::FileContainers m_fileContainers;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <filepathid.h>
|
#include <filepathid.h>
|
||||||
#include <pchmanagerserverinterface.h>
|
#include <pchmanagerserverinterface.h>
|
||||||
|
#include <removegeneratedfilesmessage.h>
|
||||||
#include <removeprojectpartsmessage.h>
|
#include <removeprojectpartsmessage.h>
|
||||||
#include <updategeneratedfilesmessage.h>
|
#include <updategeneratedfilesmessage.h>
|
||||||
#include <updateprojectpartsmessage.h>
|
#include <updateprojectpartsmessage.h>
|
||||||
@@ -63,14 +64,8 @@ ProjectUpdater::ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &s
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts,
|
void ProjectUpdater::updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts)
|
||||||
ClangBackEnd::V2::FileContainers &&generatedFiles)
|
|
||||||
{
|
{
|
||||||
m_excludedPaths = createExcludedPaths(generatedFiles);
|
|
||||||
|
|
||||||
m_server.updateGeneratedFiles( // TODO move to an other code path
|
|
||||||
ClangBackEnd::UpdateGeneratedFilesMessage{std::move(generatedFiles)});
|
|
||||||
|
|
||||||
m_server.updateProjectParts(
|
m_server.updateProjectParts(
|
||||||
ClangBackEnd::UpdateProjectPartsMessage{toProjectPartContainers(projectParts)});
|
ClangBackEnd::UpdateProjectPartsMessage{toProjectPartContainers(projectParts)});
|
||||||
}
|
}
|
||||||
@@ -82,9 +77,41 @@ void ProjectUpdater::removeProjectParts(const QStringList &projectPartIds)
|
|||||||
m_server.removeProjectParts(std::move(message));
|
m_server.removeProjectParts(std::move(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::setExcludedPaths(Utils::PathStringVector &&excludedPaths)
|
void ProjectUpdater::updateGeneratedFiles(ClangBackEnd::V2::FileContainers &&generatedFiles)
|
||||||
{
|
{
|
||||||
m_excludedPaths = excludedPaths;
|
std::sort(generatedFiles.begin(), generatedFiles.end());
|
||||||
|
|
||||||
|
m_generatedFiles.update(generatedFiles);
|
||||||
|
|
||||||
|
m_excludedPaths = createExcludedPaths(m_generatedFiles.fileContainers());
|
||||||
|
|
||||||
|
m_server.updateGeneratedFiles(
|
||||||
|
ClangBackEnd::UpdateGeneratedFilesMessage{std::move(generatedFiles)});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectUpdater::removeGeneratedFiles(ClangBackEnd::FilePaths &&filePaths)
|
||||||
|
{
|
||||||
|
m_generatedFiles.remove(filePaths);
|
||||||
|
|
||||||
|
m_excludedPaths = createExcludedPaths(m_generatedFiles.fileContainers());
|
||||||
|
|
||||||
|
m_server.removeGeneratedFiles(
|
||||||
|
ClangBackEnd::RemoveGeneratedFilesMessage{std::move(filePaths)});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectUpdater::setExcludedPaths(ClangBackEnd::FilePaths &&excludedPaths)
|
||||||
|
{
|
||||||
|
m_excludedPaths = std::move(excludedPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ClangBackEnd::FilePaths &ProjectUpdater::excludedPaths() const
|
||||||
|
{
|
||||||
|
return m_excludedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ClangBackEnd::GeneratedFiles &ProjectUpdater::generatedFiles() const
|
||||||
|
{
|
||||||
|
return m_generatedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectUpdater::addToHeaderAndSources(HeaderAndSources &headerAndSources,
|
void ProjectUpdater::addToHeaderAndSources(HeaderAndSources &headerAndSources,
|
||||||
@@ -113,6 +140,9 @@ HeaderAndSources ProjectUpdater::headerAndSourcesFromProjectPart(
|
|||||||
for (const CppTools::ProjectFile &projectFile : projectPart->files)
|
for (const CppTools::ProjectFile &projectFile : projectPart->files)
|
||||||
addToHeaderAndSources(headerAndSources, projectFile);
|
addToHeaderAndSources(headerAndSources, projectFile);
|
||||||
|
|
||||||
|
std::sort(headerAndSources.sources.begin(), headerAndSources.sources.end());
|
||||||
|
std::sort(headerAndSources.headers.begin(), headerAndSources.headers.end());
|
||||||
|
|
||||||
return headerAndSources;
|
return headerAndSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +175,8 @@ Utils::SmallStringVector ProjectUpdater::createIncludeSearchPaths(
|
|||||||
includePaths.emplace_back(projectPartHeaderPath.path);
|
includePaths.emplace_back(projectPartHeaderPath.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::sort(includePaths.begin(), includePaths.end());
|
||||||
|
|
||||||
return includePaths;
|
return includePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,17 +209,19 @@ std::vector<ClangBackEnd::V2::ProjectPartContainer> ProjectUpdater::toProjectPar
|
|||||||
std::back_inserter(projectPartContainers),
|
std::back_inserter(projectPartContainers),
|
||||||
std::bind(&ProjectUpdater::toProjectPartContainer, this, _1));
|
std::bind(&ProjectUpdater::toProjectPartContainer, this, _1));
|
||||||
|
|
||||||
|
std::sort(projectPartContainers.begin(), projectPartContainers.end());
|
||||||
|
|
||||||
return projectPartContainers;
|
return projectPartContainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::PathStringVector ProjectUpdater::createExcludedPaths(
|
ClangBackEnd::FilePaths ProjectUpdater::createExcludedPaths(
|
||||||
const ClangBackEnd::V2::FileContainers &generatedFiles)
|
const ClangBackEnd::V2::FileContainers &generatedFiles)
|
||||||
{
|
{
|
||||||
Utils::PathStringVector excludedPaths;
|
ClangBackEnd::FilePaths excludedPaths;
|
||||||
excludedPaths.reserve(generatedFiles.size());
|
excludedPaths.reserve(generatedFiles.size());
|
||||||
|
|
||||||
auto convertToPath = [] (const ClangBackEnd::V2::FileContainer &fileContainer) {
|
auto convertToPath = [] (const ClangBackEnd::V2::FileContainer &fileContainer) {
|
||||||
return fileContainer.filePath.path();
|
return fileContainer.filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::transform(generatedFiles.begin(),
|
std::transform(generatedFiles.begin(),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <compilermacro.h>
|
#include <compilermacro.h>
|
||||||
#include <filecontainerv2.h>
|
#include <filecontainerv2.h>
|
||||||
#include <filepathcachinginterface.h>
|
#include <filepathcachinginterface.h>
|
||||||
|
#include <generatedfiles.h>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Macro;
|
class Macro;
|
||||||
@@ -66,12 +67,17 @@ public:
|
|||||||
ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||||
ClangBackEnd::FilePathCachingInterface &filePathCache);
|
ClangBackEnd::FilePathCachingInterface &filePathCache);
|
||||||
|
|
||||||
void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts,
|
void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts);
|
||||||
ClangBackEnd::V2::FileContainers &&generatedFiles);
|
|
||||||
void removeProjectParts(const QStringList &projectPartIds);
|
void removeProjectParts(const QStringList &projectPartIds);
|
||||||
|
|
||||||
|
void updateGeneratedFiles(ClangBackEnd::V2::FileContainers &&generatedFiles);
|
||||||
|
void removeGeneratedFiles(ClangBackEnd::FilePaths &&filePaths);
|
||||||
|
|
||||||
unittest_public:
|
unittest_public:
|
||||||
void setExcludedPaths(Utils::PathStringVector &&excludedPaths);
|
void setExcludedPaths(ClangBackEnd::FilePaths &&excludedPaths);
|
||||||
|
const ClangBackEnd::FilePaths &excludedPaths() const;
|
||||||
|
|
||||||
|
const ClangBackEnd::GeneratedFiles &generatedFiles() const;
|
||||||
|
|
||||||
HeaderAndSources headerAndSourcesFromProjectPart(CppTools::ProjectPart *projectPart) const;
|
HeaderAndSources headerAndSourcesFromProjectPart(CppTools::ProjectPart *projectPart) const;
|
||||||
ClangBackEnd::V2::ProjectPartContainer toProjectPartContainer(
|
ClangBackEnd::V2::ProjectPartContainer toProjectPartContainer(
|
||||||
@@ -85,11 +91,12 @@ unittest_public:
|
|||||||
const ProjectExplorer::Macros &projectMacros);
|
const ProjectExplorer::Macros &projectMacros);
|
||||||
static Utils::SmallStringVector createIncludeSearchPaths(
|
static Utils::SmallStringVector createIncludeSearchPaths(
|
||||||
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths);
|
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths);
|
||||||
static Utils::PathStringVector createExcludedPaths(
|
static ClangBackEnd::FilePaths createExcludedPaths(
|
||||||
const ClangBackEnd::V2::FileContainers &generatedFiles);
|
const ClangBackEnd::V2::FileContainers &generatedFiles);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::PathStringVector m_excludedPaths;
|
ClangBackEnd::GeneratedFiles m_generatedFiles;
|
||||||
|
ClangBackEnd::FilePaths m_excludedPaths;
|
||||||
ClangBackEnd::ProjectManagementServerInterface &m_server;
|
ClangBackEnd::ProjectManagementServerInterface &m_server;
|
||||||
ClangBackEnd::FilePathCachingInterface &m_filePathCache;
|
ClangBackEnd::FilePathCachingInterface &m_filePathCache;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ std::vector<ClangBackEnd::V2::FileContainer> createGeneratedFiles()
|
|||||||
std::back_inserter(generatedFiles),
|
std::back_inserter(generatedFiles),
|
||||||
toFileContainer);
|
toFileContainer);
|
||||||
|
|
||||||
|
std::sort(generatedFiles.begin(), generatedFiles.end());
|
||||||
|
|
||||||
return generatedFiles;
|
return generatedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ public:
|
|||||||
|
|
||||||
void projectPartsUpdated(ProjectExplorer::Project *project)
|
void projectPartsUpdated(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
ProjectUpdaterType::updateProjectParts(Internal::createProjectParts(project),
|
ProjectUpdaterType::updateProjectParts(Internal::createProjectParts(project));
|
||||||
Internal::createGeneratedFiles());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void projectPartsRemoved(const QStringList &projectPartIds)
|
void projectPartsRemoved(const QStringList &projectPartIds)
|
||||||
@@ -80,15 +79,35 @@ public:
|
|||||||
ProjectUpdaterType::removeProjectParts(projectPartIds);
|
ProjectUpdaterType::removeProjectParts(projectPartIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void abstractEditorUpdated(const QString &filePath, const QByteArray &contents)
|
||||||
|
{
|
||||||
|
ProjectUpdaterType::updateGeneratedFiles({{ClangBackEnd::FilePath{filePath}, contents}});
|
||||||
|
}
|
||||||
|
|
||||||
|
void abstractEditorRemoved(const QString &filePath)
|
||||||
|
{
|
||||||
|
ProjectUpdaterType::removeGeneratedFiles({ClangBackEnd::FilePath{filePath}});
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connectToCppModelManager()
|
void connectToCppModelManager()
|
||||||
{
|
{
|
||||||
|
ProjectUpdaterType::updateGeneratedFiles(Internal::createGeneratedFiles());
|
||||||
|
|
||||||
QObject::connect(Internal::cppModelManager(),
|
QObject::connect(Internal::cppModelManager(),
|
||||||
&CppTools::CppModelManager::projectPartsUpdated,
|
&CppTools::CppModelManager::projectPartsUpdated,
|
||||||
[&] (ProjectExplorer::Project *project) { projectPartsUpdated(project); });
|
[&] (ProjectExplorer::Project *project) { projectPartsUpdated(project); });
|
||||||
QObject::connect(Internal::cppModelManager(),
|
QObject::connect(Internal::cppModelManager(),
|
||||||
&CppTools::CppModelManager::projectPartsRemoved,
|
&CppTools::CppModelManager::projectPartsRemoved,
|
||||||
[&] (const QStringList &projectPartIds) { projectPartsRemoved(projectPartIds); });
|
[&] (const QStringList &projectPartIds) { projectPartsRemoved(projectPartIds); });
|
||||||
|
QObject::connect(Internal::cppModelManager(),
|
||||||
|
&CppTools::CppModelManager::abstractEditorSupportContentsUpdated,
|
||||||
|
[&] (const QString &filePath, const QByteArray &contents) {
|
||||||
|
abstractEditorUpdated(filePath, contents);
|
||||||
|
});
|
||||||
|
QObject::connect(Internal::cppModelManager(),
|
||||||
|
&CppTools::CppModelManager::abstractEditorSupportRemoved,
|
||||||
|
[&] (const QString &filePath) { abstractEditorRemoved(filePath); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -97,12 +97,13 @@ void RefactoringServer::requestSourceRangesForQueryMessage(RequestSourceRangesFo
|
|||||||
|
|
||||||
void RefactoringServer::updateProjectParts(UpdateProjectPartsMessage &&message)
|
void RefactoringServer::updateProjectParts(UpdateProjectPartsMessage &&message)
|
||||||
{
|
{
|
||||||
m_symbolIndexing.updateProjectParts(message.takeProjectsParts(), m_generatedFiles);
|
m_symbolIndexing.updateProjectParts(message.takeProjectsParts(),
|
||||||
|
m_generatedFiles.fileContainers());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefactoringServer::updateGeneratedFiles(UpdateGeneratedFilesMessage &&message)
|
void RefactoringServer::updateGeneratedFiles(UpdateGeneratedFilesMessage &&message)
|
||||||
{
|
{
|
||||||
m_generatedFiles = message.takeGeneratedFiles();
|
m_generatedFiles.update(message.takeGeneratedFiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefactoringServer::removeProjectParts(RemoveProjectPartsMessage &&)
|
void RefactoringServer::removeProjectParts(RemoveProjectPartsMessage &&)
|
||||||
@@ -112,7 +113,7 @@ void RefactoringServer::removeProjectParts(RemoveProjectPartsMessage &&)
|
|||||||
|
|
||||||
void RefactoringServer::removeGeneratedFiles(RemoveGeneratedFilesMessage &&message)
|
void RefactoringServer::removeGeneratedFiles(RemoveGeneratedFilesMessage &&message)
|
||||||
{
|
{
|
||||||
// TODO
|
m_generatedFiles.remove(message.generatedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefactoringServer::cancel()
|
void RefactoringServer::cancel()
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <ipcclientprovider.h>
|
#include <ipcclientprovider.h>
|
||||||
#include <filepathcachinginterface.h>
|
#include <filepathcachinginterface.h>
|
||||||
|
#include <generatedfiles.h>
|
||||||
|
|
||||||
#include <utils/smallstring.h>
|
#include <utils/smallstring.h>
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ClangQueryGatherer m_gatherer;
|
ClangQueryGatherer m_gatherer;
|
||||||
V2::FileContainers m_generatedFiles;
|
GeneratedFiles m_generatedFiles;
|
||||||
QTimer m_pollTimer;
|
QTimer m_pollTimer;
|
||||||
SymbolIndexingInterface &m_symbolIndexing;
|
SymbolIndexingInterface &m_symbolIndexing;
|
||||||
FilePathCachingInterface &m_filePathCache;
|
FilePathCachingInterface &m_filePathCache;
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
|
|||||||
return out << "(" << lineColumn.line << ", " << lineColumn.column << ")";
|
return out << "(" << lineColumn.line << ", " << lineColumn.column << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintTo(Utils::SmallStringView text, ::std::ostream *os)
|
||||||
|
{
|
||||||
|
*os << text;
|
||||||
|
}
|
||||||
|
|
||||||
void PrintTo(const Utils::SmallString &text, ::std::ostream *os)
|
void PrintTo(const Utils::SmallString &text, ::std::ostream *os)
|
||||||
{
|
{
|
||||||
*os << text;
|
*os << text;
|
||||||
@@ -981,6 +986,16 @@ std::ostream &operator<<(std::ostream &out, SymbolTags symbolTags)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, const UpdateGeneratedFilesMessage &message)
|
||||||
|
{
|
||||||
|
return out << "(" << message.generatedFiles << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &message)
|
||||||
|
{
|
||||||
|
return out << "(" << message.generatedFiles << ")";
|
||||||
|
}
|
||||||
|
|
||||||
void PrintTo(const FilePath &filePath, ::std::ostream *os)
|
void PrintTo(const FilePath &filePath, ::std::ostream *os)
|
||||||
{
|
{
|
||||||
*os << filePath;
|
*os << filePath;
|
||||||
@@ -1020,6 +1035,7 @@ std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &containe
|
|||||||
<< container.projectPartId << ", "
|
<< container.projectPartId << ", "
|
||||||
<< container.arguments << ", "
|
<< container.arguments << ", "
|
||||||
<< container.headerPathIds << ", "
|
<< container.headerPathIds << ", "
|
||||||
|
<< container.sourcePathIds << ", "
|
||||||
<< container.compilerMacros << ", "
|
<< container.compilerMacros << ", "
|
||||||
<< container.includeSearchPaths << ")";
|
<< container.includeSearchPaths << ")";
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ std::ostream &operator<<(std::ostream &out, const Macro ¯o);
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class LineColumn;
|
class LineColumn;
|
||||||
|
class SmallStringView;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn);
|
std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn);
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ void PrintTo(const Utils::optional<Type> &optional, ::std::ostream *os)
|
|||||||
*os << optional;
|
*os << optional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintTo(Utils::SmallStringView text, ::std::ostream *os);
|
||||||
void PrintTo(const Utils::SmallString &text, ::std::ostream *os);
|
void PrintTo(const Utils::SmallString &text, ::std::ostream *os);
|
||||||
void PrintTo(const Utils::PathString &text, ::std::ostream *os);
|
void PrintTo(const Utils::PathString &text, ::std::ostream *os);
|
||||||
|
|
||||||
@@ -165,6 +167,8 @@ class SymbolEntry;
|
|||||||
enum class SymbolKind : uchar;
|
enum class SymbolKind : uchar;
|
||||||
enum class SymbolTag : uchar;
|
enum class SymbolTag : uchar;
|
||||||
using SymbolTags = Utils::SizedArray<SymbolTag, 7>;
|
using SymbolTags = Utils::SizedArray<SymbolTag, 7>;
|
||||||
|
class UpdateGeneratedFilesMessage;
|
||||||
|
class RemoveGeneratedFilesMessage;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry);
|
std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry);
|
||||||
std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths);
|
std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths);
|
||||||
@@ -242,6 +246,8 @@ std::ostream &operator<<(std::ostream &out, const SymbolEntry &symbolEntry);
|
|||||||
std::ostream &operator<<(std::ostream &out, SymbolKind symbolKind);
|
std::ostream &operator<<(std::ostream &out, SymbolKind symbolKind);
|
||||||
std::ostream &operator<<(std::ostream &out, SymbolTag symbolTag);
|
std::ostream &operator<<(std::ostream &out, SymbolTag symbolTag);
|
||||||
std::ostream &operator<<(std::ostream &out, SymbolTags symbolTags);
|
std::ostream &operator<<(std::ostream &out, SymbolTags symbolTags);
|
||||||
|
std::ostream &operator<<(std::ostream &out, const UpdateGeneratedFilesMessage &message);
|
||||||
|
std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &message);
|
||||||
|
|
||||||
void PrintTo(const FilePath &filePath, ::std::ostream *os);
|
void PrintTo(const FilePath &filePath, ::std::ostream *os);
|
||||||
void PrintTo(const FilePathView &filePathView, ::std::ostream *os);
|
void PrintTo(const FilePathView &filePathView, ::std::ostream *os);
|
||||||
|
|||||||
@@ -83,11 +83,19 @@ protected:
|
|||||||
projectPart.files.push_back(source1ProjectFile);
|
projectPart.files.push_back(source1ProjectFile);
|
||||||
projectPart.files.push_back(source2ProjectFile);
|
projectPart.files.push_back(source2ProjectFile);
|
||||||
projectPart.displayName = QString(projectPartId);
|
projectPart.displayName = QString(projectPartId);
|
||||||
projectPart.projectMacros.push_back({"DEFINE", "1"});
|
projectPart.projectMacros = {{"FOO", "2"}, {"BAR", "1"}};
|
||||||
|
|
||||||
|
projectPart2.files.push_back(header2ProjectFile);
|
||||||
|
projectPart2.files.push_back(header1ProjectFile);
|
||||||
|
projectPart2.files.push_back(source2ProjectFile);
|
||||||
|
projectPart2.files.push_back(source1ProjectFile);
|
||||||
|
projectPart2.displayName = QString(projectPartId2);
|
||||||
|
projectPart2.projectMacros = {{"BAR", "1"}, {"FOO", "2"}};
|
||||||
|
|
||||||
Utils::SmallStringVector arguments{ClangPchManager::ProjectUpdater::compilerArguments(
|
Utils::SmallStringVector arguments{ClangPchManager::ProjectUpdater::compilerArguments(
|
||||||
&projectPart)};
|
&projectPart)};
|
||||||
|
Utils::SmallStringVector arguments2{ClangPchManager::ProjectUpdater::compilerArguments(
|
||||||
|
&projectPart2)};
|
||||||
|
|
||||||
expectedContainer = {projectPartId.clone(),
|
expectedContainer = {projectPartId.clone(),
|
||||||
arguments.clone(),
|
arguments.clone(),
|
||||||
@@ -95,6 +103,12 @@ protected:
|
|||||||
{},
|
{},
|
||||||
{filePathId(headerPaths[1])},
|
{filePathId(headerPaths[1])},
|
||||||
{filePathIds(sourcePaths)}};
|
{filePathIds(sourcePaths)}};
|
||||||
|
expectedContainer2 = {projectPartId2.clone(),
|
||||||
|
arguments2.clone(),
|
||||||
|
Utils::clone(compilerMacros),
|
||||||
|
{},
|
||||||
|
{filePathId(headerPaths[1])},
|
||||||
|
{filePathIds(sourcePaths)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -110,34 +124,73 @@ protected:
|
|||||||
Utils::SmallString projectPartId2{"project2"};
|
Utils::SmallString projectPartId2{"project2"};
|
||||||
Utils::PathStringVector headerPaths = {"/path/to/header1.h", "/path/to/header2.h"};
|
Utils::PathStringVector headerPaths = {"/path/to/header1.h", "/path/to/header2.h"};
|
||||||
Utils::PathStringVector sourcePaths = {"/path/to/source1.cpp", "/path/to/source2.cpp"};
|
Utils::PathStringVector sourcePaths = {"/path/to/source1.cpp", "/path/to/source2.cpp"};
|
||||||
ClangBackEnd::CompilerMacros compilerMacros = {{"DEFINE", "1"}};
|
ClangBackEnd::CompilerMacros compilerMacros = {{"BAR", "1"}, {"FOO", "2"}};
|
||||||
CppTools::ProjectFile header1ProjectFile{QString(headerPaths[0]), CppTools::ProjectFile::CXXHeader};
|
CppTools::ProjectFile header1ProjectFile{QString(headerPaths[0]), CppTools::ProjectFile::CXXHeader};
|
||||||
CppTools::ProjectFile header2ProjectFile{QString(headerPaths[1]), CppTools::ProjectFile::CXXHeader};
|
CppTools::ProjectFile header2ProjectFile{QString(headerPaths[1]), CppTools::ProjectFile::CXXHeader};
|
||||||
CppTools::ProjectFile source1ProjectFile{QString(sourcePaths[0]), CppTools::ProjectFile::CXXSource};
|
CppTools::ProjectFile source1ProjectFile{QString(sourcePaths[0]), CppTools::ProjectFile::CXXSource};
|
||||||
CppTools::ProjectFile source2ProjectFile{QString(sourcePaths[1]), CppTools::ProjectFile::CXXSource};
|
CppTools::ProjectFile source2ProjectFile{QString(sourcePaths[1]), CppTools::ProjectFile::CXXSource};
|
||||||
CppTools::ProjectPart projectPart;
|
CppTools::ProjectPart projectPart;
|
||||||
|
CppTools::ProjectPart projectPart2;
|
||||||
ProjectPartContainer expectedContainer;
|
ProjectPartContainer expectedContainer;
|
||||||
|
ProjectPartContainer expectedContainer2;
|
||||||
FileContainer generatedFile{{"/path/to", "header1.h"}, "content", {}};
|
FileContainer generatedFile{{"/path/to", "header1.h"}, "content", {}};
|
||||||
|
FileContainer generatedFile2{{"/path/to2", "header1.h"}, "content", {}};
|
||||||
|
FileContainer generatedFile3{{"/path/to", "header2.h"}, "content", {}};
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CallUpdateProjectParts)
|
TEST_F(ProjectUpdater, CallUpdateProjectParts)
|
||||||
{
|
{
|
||||||
std::vector<CppTools::ProjectPart*> projectParts = {&projectPart, &projectPart};
|
std::vector<CppTools::ProjectPart*> projectParts = {&projectPart2, &projectPart};
|
||||||
ClangBackEnd::UpdateProjectPartsMessage message{{expectedContainer.clone(), expectedContainer.clone()}};
|
ClangBackEnd::UpdateProjectPartsMessage message{{expectedContainer.clone(), expectedContainer2.clone()}};
|
||||||
|
updater.updateGeneratedFiles({generatedFile});
|
||||||
|
|
||||||
EXPECT_CALL(mockPchManagerServer, updateProjectParts(message));
|
EXPECT_CALL(mockPchManagerServer, updateProjectParts(message));
|
||||||
|
|
||||||
updater.updateProjectParts(projectParts, {generatedFile});
|
updater.updateProjectParts(projectParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CallUpdateGeneratedFiles)
|
TEST_F(ProjectUpdater, CallUpdateGeneratedFilesWithSortedEntries)
|
||||||
{
|
{
|
||||||
std::vector<CppTools::ProjectPart*> projectParts = {&projectPart, &projectPart};
|
ClangBackEnd::UpdateGeneratedFilesMessage message{{generatedFile, generatedFile3, generatedFile2}};
|
||||||
ClangBackEnd::UpdateGeneratedFilesMessage message{{generatedFile}};
|
|
||||||
|
|
||||||
EXPECT_CALL(mockPchManagerServer, updateGeneratedFiles(message));
|
EXPECT_CALL(mockPchManagerServer, updateGeneratedFiles(message));
|
||||||
|
|
||||||
updater.updateProjectParts(projectParts, {generatedFile});
|
updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectUpdater, GeneratedFilesAddedAreSorted)
|
||||||
|
{
|
||||||
|
updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile});
|
||||||
|
|
||||||
|
ASSERT_THAT(updater.generatedFiles().fileContainers(),
|
||||||
|
ElementsAre(generatedFile, generatedFile3, generatedFile2));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectUpdater, GeneratedFilesAddedToExcludePaths)
|
||||||
|
{
|
||||||
|
updater.updateGeneratedFiles({generatedFile2, generatedFile3, generatedFile});
|
||||||
|
|
||||||
|
ASSERT_THAT(updater.excludedPaths(), ElementsAre(generatedFile.filePath,
|
||||||
|
generatedFile3.filePath,
|
||||||
|
generatedFile2.filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectUpdater, CallRemoveGeneratedFiles)
|
||||||
|
{
|
||||||
|
ClangBackEnd::RemoveGeneratedFilesMessage message{{{"/path/to/header1.h"}}};
|
||||||
|
|
||||||
|
EXPECT_CALL(mockPchManagerServer, removeGeneratedFiles(message));
|
||||||
|
|
||||||
|
updater.removeGeneratedFiles({{"/path/to/header1.h"}});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectUpdater, GeneratedFilesRemovedFromExcludePaths)
|
||||||
|
{
|
||||||
|
updater.updateGeneratedFiles({generatedFile});
|
||||||
|
|
||||||
|
updater.removeGeneratedFiles({generatedFile.filePath});
|
||||||
|
|
||||||
|
ASSERT_THAT(updater.excludedPaths(), IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CallRemoveProjectParts)
|
TEST_F(ProjectUpdater, CallRemoveProjectParts)
|
||||||
@@ -153,6 +206,7 @@ TEST_F(ProjectUpdater, CallPrecompiledHeaderRemovedInPchManagerProjectUpdater)
|
|||||||
{
|
{
|
||||||
ClangPchManager::PchManagerProjectUpdater pchUpdater{mockPchManagerServer, pchManagerClient, filePathCache};
|
ClangPchManager::PchManagerProjectUpdater pchUpdater{mockPchManagerServer, pchManagerClient, filePathCache};
|
||||||
ClangBackEnd::RemoveProjectPartsMessage message{{projectPartId, projectPartId2}};
|
ClangBackEnd::RemoveProjectPartsMessage message{{projectPartId, projectPartId2}};
|
||||||
|
EXPECT_CALL(mockPrecompiledHeaderStorage, deletePrecompiledHeader(_)).Times(AnyNumber());
|
||||||
|
|
||||||
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId.toQString()));
|
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId.toQString()));
|
||||||
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId2.toQString()));
|
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId2.toQString()));
|
||||||
@@ -176,29 +230,34 @@ TEST_F(ProjectUpdater, ConvertProjectPartToProjectPartContainersHaveSameSizeLike
|
|||||||
ASSERT_THAT(containers, SizeIs(2));
|
ASSERT_THAT(containers, SizeIs(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CreateExcludedPaths)
|
TEST_F(ProjectUpdater, CreateSortedExcludedPaths)
|
||||||
{
|
{
|
||||||
auto excludedPaths = updater.createExcludedPaths({generatedFile});
|
auto excludedPaths = updater.createExcludedPaths({generatedFile2, generatedFile3, generatedFile});
|
||||||
|
|
||||||
ASSERT_THAT(excludedPaths, ElementsAre("/path/to/header1.h"));
|
ASSERT_THAT(excludedPaths, ElementsAre(ClangBackEnd::FilePath{"/path/to/header1.h"},
|
||||||
|
ClangBackEnd::FilePath{"/path/to/header2.h"},
|
||||||
|
ClangBackEnd::FilePath{"/path/to2/header1.h"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CreateCompilerMacros)
|
TEST_F(ProjectUpdater, CreateSortedCompilerMacros)
|
||||||
{
|
{
|
||||||
auto paths = updater.createCompilerMacros({{"DEFINE", "1"}});
|
auto paths = updater.createCompilerMacros({{"DEFINE", "1"}, {"FOO", "2"}, {"BAR", "1"}});
|
||||||
|
|
||||||
ASSERT_THAT(paths, ElementsAre(CompilerMacro{"DEFINE", "1"}));
|
ASSERT_THAT(paths, ElementsAre(CompilerMacro{"BAR", "1"},
|
||||||
|
CompilerMacro{"FOO", "2"},
|
||||||
|
CompilerMacro{"DEFINE", "1"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectUpdater, CreateIncludeSearchPaths)
|
TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths)
|
||||||
{
|
{
|
||||||
ProjectPartHeaderPath includePath{"/to/path", ProjectPartHeaderPath::IncludePath};
|
ProjectPartHeaderPath includePath{"/to/path1", ProjectPartHeaderPath::IncludePath};
|
||||||
|
ProjectPartHeaderPath includePath2{"/to/path2", ProjectPartHeaderPath::IncludePath};
|
||||||
ProjectPartHeaderPath invalidPath;
|
ProjectPartHeaderPath invalidPath;
|
||||||
ProjectPartHeaderPath frameworkPath{"/framework/path", ProjectPartHeaderPath::FrameworkPath};
|
ProjectPartHeaderPath frameworkPath{"/framework/path", ProjectPartHeaderPath::FrameworkPath};
|
||||||
|
|
||||||
auto paths = updater.createIncludeSearchPaths({includePath, invalidPath, frameworkPath});
|
auto paths = updater.createIncludeSearchPaths({frameworkPath, includePath2, includePath, invalidPath});
|
||||||
|
|
||||||
ASSERT_THAT(paths, ElementsAre(includePath.path, frameworkPath.path));
|
ASSERT_THAT(paths, ElementsAre(includePath.path, includePath2.path, frameworkPath.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user