forked from qt-creator/qt-creator
CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of use that these data structures are immutable. Change-Id: Iea615c090bde462c445d15223caccc561b0c713d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -255,7 +255,7 @@ void AutoTestUnitTests::testCodeParserBoostTest()
|
||||
QFETCH(QString, projectFilePath);
|
||||
QFETCH(QString, extension);
|
||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||
const CppTools::ProjectInfo::Ptr projectInfo
|
||||
const CppTools::ProjectInfo::ConstPtr projectInfo
|
||||
= projectManager.open(projectFilePath, true, m_kit);
|
||||
QVERIFY(projectInfo);
|
||||
|
||||
|
@@ -126,10 +126,11 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
return false;
|
||||
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
||||
const QList<CppTools::ProjectPart::ConstPtr> projectParts
|
||||
= modelManager->projectPart(fileName);
|
||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
||||
const CppTools::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||
const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
|
||||
|
@@ -133,11 +133,11 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
}
|
||||
|
||||
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
||||
const QList<CppTools::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(fileName);
|
||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
Utils::FilePath proFile;
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
||||
const CppTools::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||
proFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||
|
||||
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
||||
|
@@ -116,7 +116,7 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInt
|
||||
|
||||
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||
Utils::FilePath proFile;
|
||||
const QList<CppTools::ProjectPart::Ptr> &ppList = modelManager->projectPart(filePath);
|
||||
const QList<CppTools::ProjectPart::ConstPtr> &ppList = modelManager->projectPart(filePath);
|
||||
if (!ppList.isEmpty())
|
||||
proFile = Utils::FilePath::fromString(ppList.first()->projectFile);
|
||||
else
|
||||
|
@@ -528,10 +528,10 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
||||
return {};
|
||||
const Utils::FilePath filePath = item.filePath();
|
||||
const QString file = filePath.toString();
|
||||
const QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo->projectParts();
|
||||
const QVector<CppTools::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||
if (projectParts.isEmpty())
|
||||
return cppMM->dependingInternalTargets(item.filePath());
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) {
|
||||
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
||||
&& Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) {
|
||||
return pf.path == file;
|
||||
|
@@ -54,7 +54,7 @@ void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
||||
|
||||
bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
||||
{
|
||||
QList<CppTools::ProjectPart::Ptr> projParts =
|
||||
QList<CppTools::ProjectPart::ConstPtr> projParts =
|
||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||
|
||||
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
||||
@@ -83,7 +83,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||
const std::function<bool(const QString &)> &checker)
|
||||
{
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
const QList<CppTools::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||
if (projectParts.isEmpty())
|
||||
return false;
|
||||
const QStringList precompiledHeaders = projectParts.first()->precompiledHeaders;
|
||||
|
@@ -92,7 +92,8 @@ bool LoadProjectScenario::loadProject()
|
||||
|
||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||
// This code must trigger a call to PluginManager::finishScenario() at some later point.
|
||||
const CppTools::ProjectInfo::Ptr projectInfo = projectManager.open(projectFilePath, true, m_kit);
|
||||
const CppTools::ProjectInfo::ConstPtr projectInfo = projectManager.open(projectFilePath,
|
||||
true, m_kit);
|
||||
return projectInfo.get();
|
||||
}
|
||||
|
||||
|
@@ -93,7 +93,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
||||
|
||||
static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
||||
{
|
||||
const QList<CppTools::ProjectPart::Ptr> parts =
|
||||
const QList<CppTools::ProjectPart::ConstPtr> parts =
|
||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
return Utils::anyOf(parts.at(0)->projectMacros, [] (const ProjectExplorer::Macro ¯o) {
|
||||
@@ -327,7 +327,8 @@ bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureIn
|
||||
if (earlyReturn.has_value() || !data.valid)
|
||||
continue;
|
||||
|
||||
QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
||||
QList<CppTools::ProjectPart::ConstPtr> projectParts
|
||||
= modelManager->projectPart(fileName);
|
||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
|
||||
|
@@ -101,7 +101,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
||||
static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName);
|
||||
const QList<CppTools::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
||||
auto found = std::find_if(
|
||||
@@ -267,7 +267,7 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> fut
|
||||
if (quickTestName(document).isEmpty())
|
||||
return false;
|
||||
|
||||
QList<CppTools::ProjectPart::Ptr> ppList = modelManager->projectPart(document->fileName());
|
||||
QList<CppTools::ProjectPart::ConstPtr> ppList = modelManager->projectPart(document->fileName());
|
||||
if (ppList.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName());
|
||||
|
@@ -391,7 +391,7 @@ QSet<QString> internalTargets(const Utils::FilePath &proFile)
|
||||
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
||||
if (!projectInfo)
|
||||
return {};
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
||||
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
continue;
|
||||
if (projectPart->projectFile == proFile.toString())
|
||||
|
@@ -90,11 +90,11 @@ static void extractAllFiles(const DebuggerRunTool *runTool, QStringList &include
|
||||
FilePaths &headers, FilePaths &sources, FilePaths &assemblers)
|
||||
{
|
||||
const auto project = runTool->runControl()->project();
|
||||
const CppTools::ProjectInfo::Ptr info = CppModelManager::instance()->projectInfo(project);
|
||||
const CppTools::ProjectInfo::ConstPtr info = CppModelManager::instance()->projectInfo(project);
|
||||
if (!info)
|
||||
return;
|
||||
const QVector<ProjectPart::Ptr> parts = info->projectParts();
|
||||
for (const ProjectPart::Ptr &part : parts) {
|
||||
const QVector<ProjectPart::ConstPtr> parts = info->projectParts();
|
||||
for (const ProjectPart::ConstPtr &part : parts) {
|
||||
for (const ProjectFile &file : qAsConst(part->files)) {
|
||||
if (!file.active)
|
||||
continue;
|
||||
|
@@ -94,7 +94,7 @@ static bool isDBGenerationEnabled(ProjectExplorer::Project *project)
|
||||
using namespace CppTools;
|
||||
if (!project)
|
||||
return false;
|
||||
const ProjectInfo::Ptr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||
const ProjectInfo::ConstPtr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||
return projectInfo && !projectInfo->projectParts().isEmpty();
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterfac
|
||||
int position,
|
||||
TextEditor::AssistReason reason) const
|
||||
{
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor(
|
||||
const CppTools::ProjectPart::ConstPtr projectPart = projectPartForFileBasedOnProcessor(
|
||||
filePath.toString());
|
||||
if (projectPart) {
|
||||
return new ClangCompletionAssistInterface(m_communicator,
|
||||
|
@@ -171,7 +171,7 @@ bool ClangEditorDocumentProcessor::hasProjectPart() const
|
||||
return !m_projectPart.isNull();
|
||||
}
|
||||
|
||||
CppTools::ProjectPart::Ptr ClangEditorDocumentProcessor::projectPart() const
|
||||
CppTools::ProjectPart::ConstPtr ClangEditorDocumentProcessor::projectPart() const
|
||||
{
|
||||
return m_projectPart;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &f
|
||||
return qobject_cast<ClangEditorDocumentProcessor*>(processor);
|
||||
}
|
||||
|
||||
static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPart)
|
||||
static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::ConstPtr projectPart)
|
||||
{
|
||||
return projectPart
|
||||
&& (projectPart->id().isEmpty() || isProjectPartLoaded(projectPart));
|
||||
@@ -429,7 +429,7 @@ static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPa
|
||||
|
||||
void ClangEditorDocumentProcessor::updateBackendProjectPartAndDocument()
|
||||
{
|
||||
const CppTools::ProjectPart::Ptr projectPart = m_parser->projectPartInfo().projectPart;
|
||||
const CppTools::ProjectPart::ConstPtr projectPart = m_parser->projectPartInfo().projectPart;
|
||||
|
||||
if (isProjectPartLoadedOrIsFallback(projectPart)) {
|
||||
updateBackendDocument(*projectPart.data());
|
||||
@@ -448,7 +448,7 @@ void ClangEditorDocumentProcessor::onParserFinished()
|
||||
updateBackendProjectPartAndDocument();
|
||||
}
|
||||
|
||||
void ClangEditorDocumentProcessor::updateBackendDocument(CppTools::ProjectPart &projectPart)
|
||||
void ClangEditorDocumentProcessor::updateBackendDocument(const CppTools::ProjectPart &projectPart)
|
||||
{
|
||||
// On registration we send the document content immediately as an unsaved
|
||||
// file, because
|
||||
|
@@ -67,7 +67,7 @@ public:
|
||||
bool isParserRunning() const override;
|
||||
|
||||
bool hasProjectPart() const;
|
||||
CppTools::ProjectPart::Ptr projectPart() const;
|
||||
CppTools::ProjectPart::ConstPtr projectPart() const;
|
||||
void clearProjectPart();
|
||||
|
||||
::Utils::Id diagnosticConfigId() const;
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
void onParserFinished();
|
||||
|
||||
void updateBackendProjectPartAndDocument();
|
||||
void updateBackendDocument(CppTools::ProjectPart &projectPart);
|
||||
void updateBackendDocument(const CppTools::ProjectPart &projectPart);
|
||||
void updateBackendDocumentIfProjectPartExists();
|
||||
void requestAnnotationsFromBackend();
|
||||
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
ClangDiagnosticManager m_diagnosticManager;
|
||||
BackendCommunicator &m_communicator;
|
||||
QSharedPointer<ClangEditorDocumentParser> m_parser;
|
||||
CppTools::ProjectPart::Ptr m_projectPart;
|
||||
CppTools::ProjectPart::ConstPtr m_projectPart;
|
||||
::Utils::Id m_diagnosticConfigId;
|
||||
bool m_isProjectFile = false;
|
||||
QFutureWatcher<void> m_parserWatcher;
|
||||
|
@@ -274,8 +274,8 @@ void ClangModelManagerSupport::connectToWidgetsMarkContextMenuRequested(QWidget
|
||||
}
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *project,
|
||||
const CppTools::ProjectInfo::Ptr &projectInfo)
|
||||
void ClangModelManagerSupport::updateLanguageClient(
|
||||
ProjectExplorer::Project *project, const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||
{
|
||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||
return;
|
||||
@@ -300,7 +300,8 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
||||
return;
|
||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||
return;
|
||||
const CppTools::ProjectInfo::Ptr newProjectInfo = cppModelManager()->projectInfo(project);
|
||||
const CppTools::ProjectInfo::ConstPtr newProjectInfo
|
||||
= cppModelManager()->projectInfo(project);
|
||||
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
||||
return;
|
||||
if (getJsonDbDir() != jsonDbDir)
|
||||
@@ -321,7 +322,7 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
||||
return;
|
||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||
return;
|
||||
const CppTools::ProjectInfo::Ptr newProjectInfo
|
||||
const CppTools::ProjectInfo::ConstPtr newProjectInfo
|
||||
= cppModelManager()->projectInfo(project);
|
||||
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
||||
return;
|
||||
@@ -615,13 +616,13 @@ void ClangModelManagerSupport::onAboutToRemoveProject(ProjectExplorer::Project *
|
||||
void ClangModelManagerSupport::onProjectPartsUpdated(ProjectExplorer::Project *project)
|
||||
{
|
||||
QTC_ASSERT(project, return);
|
||||
const CppTools::ProjectInfo::Ptr projectInfo = cppModelManager()->projectInfo(project);
|
||||
const CppTools::ProjectInfo::ConstPtr projectInfo = cppModelManager()->projectInfo(project);
|
||||
QTC_ASSERT(projectInfo, return);
|
||||
|
||||
updateLanguageClient(project, projectInfo);
|
||||
|
||||
QStringList projectPartIds;
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo->projectParts())
|
||||
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts())
|
||||
projectPartIds.append(projectPart->id());
|
||||
onProjectPartsRemoved(projectPartIds);
|
||||
}
|
||||
|
@@ -130,7 +130,7 @@ private:
|
||||
void connectToWidgetsMarkContextMenuRequested(QWidget *editorWidget);
|
||||
|
||||
void updateLanguageClient(ProjectExplorer::Project *project,
|
||||
const CppTools::ProjectInfo::Ptr &projectInfo);
|
||||
const CppTools::ProjectInfo::ConstPtr &projectInfo);
|
||||
ClangdClient *createClient(ProjectExplorer::Project *project, const Utils::FilePath &jsonDbDir);
|
||||
void claimNonProjectSources(ClangdClient *fallbackClient);
|
||||
|
||||
|
@@ -39,7 +39,7 @@ namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
CppTools::ProjectPart *,
|
||||
const CppTools::ProjectPart *,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
ClangdClient * const client
|
||||
|
@@ -42,7 +42,7 @@ class RefactoringEngine : public CppTools::RefactoringEngineInterface
|
||||
{
|
||||
public:
|
||||
void startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
CppTools::ProjectPart *projectPart,
|
||||
const CppTools::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback) override;
|
||||
void globalRename(const CppTools::CursorInEditor &cursor, CppTools::UsagesCallback &&callback,
|
||||
const QString &replacement) override;
|
||||
|
@@ -87,7 +87,7 @@ ProjectExplorer::Project *projectForCurrentEditor()
|
||||
return nullptr;
|
||||
|
||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||
if (ProjectPart::Ptr projectPart = processor->projectPart())
|
||||
if (ProjectPart::ConstPtr projectPart = processor->projectPart())
|
||||
return projectForProjectPart(*projectPart);
|
||||
}
|
||||
|
||||
|
@@ -109,21 +109,21 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
||||
ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
||||
{
|
||||
if (const auto parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
||||
return parser->projectPartInfo().projectPart;
|
||||
return ProjectPart::Ptr();
|
||||
return ProjectPart::ConstPtr();
|
||||
}
|
||||
|
||||
ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath)
|
||||
ProjectPart::ConstPtr projectPartForFileBasedOnProcessor(const QString &filePath)
|
||||
{
|
||||
if (const auto processor = ClangEditorDocumentProcessor::get(filePath))
|
||||
return processor->projectPart();
|
||||
return ProjectPart::Ptr();
|
||||
return ProjectPart::ConstPtr();
|
||||
}
|
||||
|
||||
bool isProjectPartLoaded(const ProjectPart::Ptr projectPart)
|
||||
bool isProjectPartLoaded(const ProjectPart::ConstPtr projectPart)
|
||||
{
|
||||
if (projectPart)
|
||||
return !CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
||||
@@ -132,7 +132,7 @@ bool isProjectPartLoaded(const ProjectPart::Ptr projectPart)
|
||||
|
||||
QString projectPartIdForFile(const QString &filePath)
|
||||
{
|
||||
const ProjectPart::Ptr projectPart = projectPartForFile(filePath);
|
||||
const ProjectPart::ConstPtr projectPart = projectPartForFile(filePath);
|
||||
|
||||
if (isProjectPartLoaded(projectPart))
|
||||
return projectPart->id(); // OK, Project Part is still loaded
|
||||
@@ -371,7 +371,7 @@ static QJsonObject createFileObject(const FilePath &buildDir,
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::Ptr projectInfo,
|
||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::ConstPtr projectInfo,
|
||||
CompilationDbPurpose purpose,
|
||||
const ClangDiagnosticConfig &warningsConfig,
|
||||
const QStringList &projectOptions)
|
||||
@@ -392,7 +392,7 @@ GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::P
|
||||
}
|
||||
compileCommandsFile.write("[");
|
||||
|
||||
for (ProjectPart::Ptr projectPart : projectInfo->projectParts()) {
|
||||
for (ProjectPart::ConstPtr projectPart : projectInfo->projectParts()) {
|
||||
QStringList args;
|
||||
if (purpose == CompilationDbPurpose::Project)
|
||||
args = projectPartArguments(*projectPart);
|
||||
|
@@ -61,9 +61,9 @@ QStringList createClangOptions(const CppTools::ProjectPart &projectPart, const Q
|
||||
const CppTools::ClangDiagnosticConfig &warningsConfig,
|
||||
const QStringList &projectOptions);
|
||||
|
||||
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath);
|
||||
CppTools::ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath);
|
||||
bool isProjectPartLoaded(const CppTools::ProjectPart::Ptr projectPart);
|
||||
CppTools::ProjectPart::ConstPtr projectPartForFile(const QString &filePath);
|
||||
CppTools::ProjectPart::ConstPtr projectPartForFileBasedOnProcessor(const QString &filePath);
|
||||
bool isProjectPartLoaded(const CppTools::ProjectPart::ConstPtr projectPart);
|
||||
QString projectPartIdForFile(const QString &filePath);
|
||||
int clangColumn(const QTextBlock &line, int cppEditorColumn);
|
||||
int cppEditorColumn(const QTextBlock &line, int clangColumn);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
};
|
||||
|
||||
enum class CompilationDbPurpose { Project, CodeModel };
|
||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::Ptr projectInfo,
|
||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::ConstPtr projectInfo,
|
||||
CompilationDbPurpose purpose, const CppTools::ClangDiagnosticConfig &warningsConfig,
|
||||
const QStringList &projectOptions);
|
||||
|
||||
|
@@ -246,7 +246,7 @@ bool OpenEditorAtCursorPosition::waitUntil(const std::function<bool ()> &conditi
|
||||
return false;
|
||||
}
|
||||
|
||||
CppTools::ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||
CppTools::ProjectPart::ConstPtr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||
const QStringList &files,
|
||||
const ProjectExplorer::Macros ¯os)
|
||||
{
|
||||
@@ -262,15 +262,15 @@ CppTools::ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFileP
|
||||
return ProjectPart::create(projectFilePath, rpp, {}, projectFiles);
|
||||
}
|
||||
|
||||
CppTools::ProjectInfo::Ptr createProjectInfo(ProjectExplorer::Project *project,
|
||||
CppTools::ProjectInfo::ConstPtr createProjectInfo(ProjectExplorer::Project *project,
|
||||
const QStringList &files,
|
||||
const ProjectExplorer::Macros ¯os)
|
||||
{
|
||||
using namespace CppTools;
|
||||
QTC_ASSERT(project, return {});
|
||||
|
||||
const CppTools::ProjectPart::Ptr projectPart = createProjectPart(project->projectFilePath(),
|
||||
files, macros);
|
||||
const CppTools::ProjectPart::ConstPtr projectPart
|
||||
= createProjectPart(project->projectFilePath(), files, macros);
|
||||
const auto projectInfo = ProjectInfo::create(
|
||||
{project, ProjectExplorer::KitInfo(nullptr), {}, {}}, {projectPart});
|
||||
return projectInfo;
|
||||
@@ -292,7 +292,7 @@ public:
|
||||
bool load()
|
||||
{
|
||||
m_project = m_helper.createProject(QLatin1String("testProject"));
|
||||
const CppTools::ProjectInfo::Ptr projectInfo = createProjectInfo(m_project,
|
||||
const CppTools::ProjectInfo::ConstPtr projectInfo = createProjectInfo(m_project,
|
||||
m_projectFiles,
|
||||
m_projectMacros);
|
||||
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
||||
@@ -302,14 +302,14 @@ public:
|
||||
bool updateProject(const ProjectExplorer::Macros &updatedProjectMacros)
|
||||
{
|
||||
QTC_ASSERT(m_project, return false);
|
||||
const CppTools::ProjectInfo::Ptr updatedProjectInfo
|
||||
const CppTools::ProjectInfo::ConstPtr updatedProjectInfo
|
||||
= createProjectInfo(m_project, m_projectFiles, updatedProjectMacros);
|
||||
return updateProjectInfo(updatedProjectInfo);
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
bool updateProjectInfo(const CppTools::ProjectInfo::Ptr &projectInfo)
|
||||
bool updateProjectInfo(const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||
{
|
||||
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
||||
return m_projectFiles.size() == filesIndexedAfterLoading.size();
|
||||
|
@@ -41,14 +41,14 @@ public:
|
||||
FileInfo() = default;
|
||||
FileInfo(Utils::FilePath file,
|
||||
CppTools::ProjectFile::Kind kind,
|
||||
CppTools::ProjectPart::Ptr projectPart)
|
||||
CppTools::ProjectPart::ConstPtr projectPart)
|
||||
: file(std::move(file))
|
||||
, kind(kind)
|
||||
, projectPart(projectPart)
|
||||
{}
|
||||
Utils::FilePath file;
|
||||
CppTools::ProjectFile::Kind kind;
|
||||
CppTools::ProjectPart::Ptr projectPart;
|
||||
CppTools::ProjectPart::ConstPtr projectPart;
|
||||
};
|
||||
using FileInfos = std::vector<FileInfo>;
|
||||
|
||||
|
@@ -325,11 +325,11 @@ private:
|
||||
QMap<Utils::FilePath, RefactoringFileInfo> m_refactoringFileInfos;
|
||||
};
|
||||
|
||||
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &projectParts)
|
||||
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
FileInfos fileInfos;
|
||||
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) {
|
||||
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||
QTC_ASSERT(projectPart, continue);
|
||||
if (!projectPart->selectedForBuilding)
|
||||
continue;
|
||||
|
@@ -114,8 +114,8 @@ private:
|
||||
Utils::Environment m_environment;
|
||||
Utils::TemporaryDirectory m_temporaryDir;
|
||||
|
||||
CppTools::ProjectInfo::Ptr m_projectInfoBeforeBuild;
|
||||
CppTools::ProjectInfo::Ptr m_projectInfo;
|
||||
CppTools::ProjectInfo::ConstPtr m_projectInfoBeforeBuild;
|
||||
CppTools::ProjectInfo::ConstPtr m_projectInfo;
|
||||
QString m_targetTriple;
|
||||
Utils::Id m_toolChainType;
|
||||
|
||||
|
@@ -141,12 +141,12 @@ static VirtualFileSystemOverlay &vfso()
|
||||
|
||||
static FileInfo getFileInfo(const FilePath &file, Project *project)
|
||||
{
|
||||
const ProjectInfo::Ptr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||
const ProjectInfo::ConstPtr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||
if (!projectInfo)
|
||||
return {};
|
||||
|
||||
FileInfo candidate;
|
||||
for (const ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||
QTC_ASSERT(projectPart, continue);
|
||||
|
||||
for (const ProjectFile &projectFile : qAsConst(projectPart->files)) {
|
||||
|
@@ -77,13 +77,13 @@ void CompilationDatabaseTests::testProject()
|
||||
QFETCH(QString, projectFilePath);
|
||||
|
||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||
const CppTools::ProjectInfo::Ptr projectInfo = projectManager.open(projectFilePath, true);
|
||||
const CppTools::ProjectInfo::ConstPtr projectInfo = projectManager.open(projectFilePath, true);
|
||||
QVERIFY(projectInfo);
|
||||
|
||||
QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo->projectParts();
|
||||
QVector<CppTools::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||
QVERIFY(!projectParts.isEmpty());
|
||||
|
||||
CppTools::ProjectPart &projectPart = *projectParts.first();
|
||||
const CppTools::ProjectPart &projectPart = *projectParts.first();
|
||||
QVERIFY(!projectPart.headerPaths.isEmpty());
|
||||
QVERIFY(!projectPart.projectMacros.isEmpty());
|
||||
QVERIFY(!projectPart.toolChainMacros.isEmpty());
|
||||
|
@@ -204,21 +204,21 @@ void CppcheckTool::check(const Utils::FilePaths &files)
|
||||
if (filtered.isEmpty())
|
||||
return;
|
||||
|
||||
const CppTools::ProjectInfo::Ptr info
|
||||
const CppTools::ProjectInfo::ConstPtr info
|
||||
= CppTools::CppModelManager::instance()->projectInfo(m_project);
|
||||
if (!info)
|
||||
return;
|
||||
const QVector<CppTools::ProjectPart::Ptr> parts = info->projectParts();
|
||||
const QVector<CppTools::ProjectPart::ConstPtr> parts = info->projectParts();
|
||||
if (parts.size() == 1) {
|
||||
QTC_ASSERT(parts.first(), return);
|
||||
addToQueue(filtered, *parts.first());
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<CppTools::ProjectPart::Ptr, Utils::FilePaths> groups;
|
||||
std::map<CppTools::ProjectPart::ConstPtr, Utils::FilePaths> groups;
|
||||
for (const Utils::FilePath &file : qAsConst(filtered)) {
|
||||
const QString stringed = file.toString();
|
||||
for (const CppTools::ProjectPart::Ptr &part : parts) {
|
||||
for (const CppTools::ProjectPart::ConstPtr &part : parts) {
|
||||
using CppTools::ProjectFile;
|
||||
QTC_ASSERT(part, continue);
|
||||
const auto match = [stringed](const ProjectFile &pFile){return pFile.path == stringed;};
|
||||
@@ -231,7 +231,7 @@ void CppcheckTool::check(const Utils::FilePaths &files)
|
||||
addToQueue(group.second, *group.first);
|
||||
}
|
||||
|
||||
void CppcheckTool::addToQueue(const Utils::FilePaths &files, CppTools::ProjectPart &part)
|
||||
void CppcheckTool::addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part)
|
||||
{
|
||||
const QString key = part.id();
|
||||
if (!m_cachedAdditionalArguments.contains(key))
|
||||
|
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
private:
|
||||
void updateArguments();
|
||||
void addToQueue(const Utils::FilePaths &files, CppTools::ProjectPart &part);
|
||||
void addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part);
|
||||
QStringList additionalArguments(const CppTools::ProjectPart &part) const;
|
||||
|
||||
CppcheckDiagnosticManager &m_manager;
|
||||
|
@@ -76,7 +76,7 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
|
||||
return;
|
||||
|
||||
using CppModelManager = CppTools::CppModelManager;
|
||||
const CppTools::ProjectInfo::Ptr info
|
||||
const CppTools::ProjectInfo::ConstPtr info
|
||||
= CppModelManager::instance()->projectInfo(m_currentProject);
|
||||
if (!info)
|
||||
return;
|
||||
|
@@ -1112,11 +1112,11 @@ class ProjectPartsModel : public QAbstractListModel
|
||||
public:
|
||||
ProjectPartsModel(QObject *parent);
|
||||
|
||||
void configure(const QList<ProjectInfo::Ptr> &projectInfos,
|
||||
const ProjectPart::Ptr ¤tEditorsProjectPart);
|
||||
void configure(const QList<ProjectInfo::ConstPtr> &projectInfos,
|
||||
const ProjectPart::ConstPtr ¤tEditorsProjectPart);
|
||||
|
||||
QModelIndex indexForCurrentEditorsProjectPart() const;
|
||||
ProjectPart::Ptr projectPartForProjectId(const QString &projectPartId) const;
|
||||
ProjectPart::ConstPtr projectPartForProjectId(const QString &projectPartId) const;
|
||||
|
||||
enum Columns { PartNameColumn, PartFilePathColumn, ColumnCount };
|
||||
|
||||
@@ -1126,7 +1126,7 @@ public:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
private:
|
||||
QList<ProjectPart::Ptr> m_projectPartsList;
|
||||
QList<ProjectPart::ConstPtr> m_projectPartsList;
|
||||
int m_currentEditorsProjectPartIndex;
|
||||
};
|
||||
|
||||
@@ -1135,13 +1135,13 @@ ProjectPartsModel::ProjectPartsModel(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ProjectPartsModel::configure(const QList<ProjectInfo::Ptr> &projectInfos,
|
||||
const ProjectPart::Ptr ¤tEditorsProjectPart)
|
||||
void ProjectPartsModel::configure(const QList<ProjectInfo::ConstPtr> &projectInfos,
|
||||
const ProjectPart::ConstPtr ¤tEditorsProjectPart)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
m_projectPartsList.clear();
|
||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
||||
foreach (const ProjectPart::Ptr &projectPart, info->projectParts()) {
|
||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, info->projectParts()) {
|
||||
if (!m_projectPartsList.contains(projectPart)) {
|
||||
m_projectPartsList << projectPart;
|
||||
if (projectPart == currentEditorsProjectPart)
|
||||
@@ -1159,13 +1159,13 @@ QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
|
||||
return createIndex(m_currentEditorsProjectPartIndex, PartFilePathColumn);
|
||||
}
|
||||
|
||||
ProjectPart::Ptr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
||||
ProjectPart::ConstPtr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
||||
{
|
||||
foreach (const ProjectPart::Ptr &part, m_projectPartsList) {
|
||||
foreach (const ProjectPart::ConstPtr &part, m_projectPartsList) {
|
||||
if (part->id() == projectPartId)
|
||||
return part;
|
||||
}
|
||||
return ProjectPart::Ptr();
|
||||
return ProjectPart::ConstPtr();
|
||||
}
|
||||
|
||||
int ProjectPartsModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
@@ -1589,11 +1589,11 @@ void CppCodeModelInspectorDialog::refresh()
|
||||
onSnapshotSelected(snapshotIndex);
|
||||
|
||||
// Project Parts
|
||||
const ProjectPart::Ptr editorsProjectPart = cppEditorDocument
|
||||
const ProjectPart::ConstPtr editorsProjectPart = cppEditorDocument
|
||||
? cppEditorDocument->processor()->parser()->projectPartInfo().projectPart
|
||||
: ProjectPart::Ptr();
|
||||
: ProjectPart::ConstPtr();
|
||||
|
||||
const QList<ProjectInfo::Ptr> projectInfos = cmmi->projectInfos();
|
||||
const QList<ProjectInfo::ConstPtr> projectInfos = cmmi->projectInfos();
|
||||
dumper.dumpProjectInfos(projectInfos);
|
||||
m_projectPartsModel->configure(projectInfos, editorsProjectPart);
|
||||
m_projectPartsView->resizeColumns(ProjectPartsModel::ColumnCount);
|
||||
@@ -1778,7 +1778,7 @@ static int defineCount(const ProjectExplorer::Macros ¯os)
|
||||
[](const Macro ¯o) { return macro.type == ProjectExplorer::MacroType::Define; }));
|
||||
}
|
||||
|
||||
void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &part)
|
||||
void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::ConstPtr &part)
|
||||
{
|
||||
QTC_ASSERT(part, return);
|
||||
|
||||
|
@@ -88,7 +88,7 @@ private:
|
||||
void updateDocumentData(const CPlusPlus::Document::Ptr &document);
|
||||
|
||||
void clearProjectPartData();
|
||||
void updateProjectPartData(const CppTools::ProjectPart::Ptr &part);
|
||||
void updateProjectPartData(const CppTools::ProjectPart::ConstPtr &part);
|
||||
|
||||
bool event(QEvent *e) override;
|
||||
|
||||
|
@@ -591,10 +591,10 @@ bool CppEditorWidget::isWidgetHighlighted(QWidget *widget)
|
||||
|
||||
namespace {
|
||||
|
||||
QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManager,
|
||||
QList<ProjectPart::ConstPtr> fetchProjectParts(CppTools::CppModelManager *modelManager,
|
||||
const Utils::FilePath &filePath)
|
||||
{
|
||||
QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
QList<ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||
|
||||
if (projectParts.isEmpty())
|
||||
projectParts = modelManager->projectPartFromDependencies(filePath);
|
||||
@@ -604,12 +604,13 @@ QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManage
|
||||
return projectParts;
|
||||
}
|
||||
|
||||
ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &projectParts,
|
||||
const ProjectPart *findProjectPartForCurrentProject(
|
||||
const QList<ProjectPart::ConstPtr> &projectParts,
|
||||
ProjectExplorer::Project *currentProject)
|
||||
{
|
||||
const auto found = std::find_if(projectParts.cbegin(),
|
||||
projectParts.cend(),
|
||||
[&](const CppTools::ProjectPart::Ptr &projectPart) {
|
||||
[&](const CppTools::ProjectPart::ConstPtr &projectPart) {
|
||||
return projectPart->belongsToProject(currentProject);
|
||||
});
|
||||
|
||||
@@ -621,7 +622,7 @@ ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &pro
|
||||
|
||||
} // namespace
|
||||
|
||||
ProjectPart *CppEditorWidget::projectPart() const
|
||||
const ProjectPart *CppEditorWidget::projectPart() const
|
||||
{
|
||||
if (!d->m_modelManager)
|
||||
return nullptr;
|
||||
@@ -680,7 +681,7 @@ void CppEditorWidget::renameSymbolUnderCursor()
|
||||
{
|
||||
using ClangBackEnd::SourceLocationsContainer;
|
||||
|
||||
ProjectPart *projPart = projectPart();
|
||||
const ProjectPart *projPart = projectPart();
|
||||
if (!projPart)
|
||||
return;
|
||||
|
||||
|
@@ -151,7 +151,7 @@ private:
|
||||
|
||||
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
||||
|
||||
CppTools::ProjectPart *projectPart() const;
|
||||
const CppTools::ProjectPart *projectPart() const;
|
||||
|
||||
private:
|
||||
QScopedPointer<CppEditorWidgetPrivate> d;
|
||||
|
@@ -87,7 +87,7 @@ void ParseContextModel::reset(const CppTools::ProjectPartInfo &projectPartInfo)
|
||||
|
||||
// Determine index for current
|
||||
const QString id = projectPartInfo.projectPart->id();
|
||||
m_currentIndex = Utils::indexOf(m_projectParts, [id](const CppTools::ProjectPart::Ptr &pp) {
|
||||
m_currentIndex = Utils::indexOf(m_projectParts, [id](const CppTools::ProjectPart::ConstPtr &pp) {
|
||||
return pp->id() == id;
|
||||
});
|
||||
QTC_CHECK(m_currentIndex >= 0);
|
||||
|
@@ -62,7 +62,7 @@ private:
|
||||
|
||||
private:
|
||||
CppTools::ProjectPartInfo::Hints m_hints;
|
||||
QList<CppTools::ProjectPart::Ptr> m_projectParts;
|
||||
QList<CppTools::ProjectPart::ConstPtr> m_projectParts;
|
||||
int m_currentIndex = -1;
|
||||
};
|
||||
|
||||
|
@@ -1913,11 +1913,11 @@ ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
const QList<ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||
if (projectParts.isEmpty()) { // Not part of any project, better use all include paths than none
|
||||
headerPaths += modelManager->headerPaths();
|
||||
} else {
|
||||
foreach (const ProjectPart::Ptr &part, projectParts)
|
||||
foreach (const ProjectPart::ConstPtr &part, projectParts)
|
||||
headerPaths += part->headerPaths;
|
||||
}
|
||||
|
||||
|
@@ -152,9 +152,9 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
|
||||
// Collect files to process
|
||||
QStringList filesToOpen;
|
||||
QList<QPointer<ProjectExplorer::Project> > projects;
|
||||
const QList<ProjectInfo::Ptr> projectInfos = m_modelManager->projectInfos();
|
||||
const QList<ProjectInfo::ConstPtr> projectInfos = m_modelManager->projectInfos();
|
||||
|
||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||
qDebug() << "Project" << info->projectFilePath().toUserOutput() << "- files to process:"
|
||||
<< info->sourceFiles().size();
|
||||
foreach (const QString &sourceFile, info->sourceFiles())
|
||||
|
@@ -95,7 +95,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
||||
state.forceSnapshotInvalidation = false;
|
||||
}
|
||||
|
||||
if (const ProjectPart::Ptr part = baseState.projectPartInfo.projectPart) {
|
||||
if (const ProjectPart::ConstPtr part = baseState.projectPartInfo.projectPart) {
|
||||
configFile += ProjectExplorer::Macro::toByteArray(part->toolChainMacros);
|
||||
configFile += overwrittenToolchainDefines(*part.data());
|
||||
configFile += ProjectExplorer::Macro::toByteArray(part->projectMacros);
|
||||
|
@@ -211,7 +211,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
||||
break;
|
||||
|
||||
const QString fileName = files.at(i);
|
||||
const QList<ProjectPart::Ptr> parts = cmm->projectPart(fileName);
|
||||
const QList<ProjectPart::ConstPtr> parts = cmm->projectPart(fileName);
|
||||
const CPlusPlus::LanguageFeatures languageFeatures = parts.isEmpty()
|
||||
? defaultFeatures
|
||||
: parts.first()->languageFeatures;
|
||||
|
@@ -110,7 +110,7 @@ public:
|
||||
Utils::optional<CompilerOptionsBuilder> compilerOptionsBuilder;
|
||||
|
||||
private:
|
||||
ProjectPart::Ptr projectPart;
|
||||
ProjectPart::ConstPtr projectPart;
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -410,10 +410,10 @@ QString Utils::toString(ProjectPart::ToolChainWordWidth width)
|
||||
|
||||
QString Utils::partsForFile(const QString &fileName)
|
||||
{
|
||||
const QList<ProjectPart::Ptr> parts
|
||||
const QList<ProjectPart::ConstPtr> parts
|
||||
= CppModelManager::instance()->projectPart(fileName);
|
||||
QString result;
|
||||
foreach (const ProjectPart::Ptr &part, parts)
|
||||
foreach (const ProjectPart::ConstPtr &part, parts)
|
||||
result += part->displayName + QLatin1Char(',');
|
||||
if (result.endsWith(QLatin1Char(',')))
|
||||
result.chop(1);
|
||||
@@ -503,7 +503,7 @@ static void printIncludeType(QTextStream &out, ProjectExplorer::HeaderPathType t
|
||||
}
|
||||
}
|
||||
|
||||
void Dumper::dumpProjectInfos(const QList<ProjectInfo::Ptr> &projectInfos)
|
||||
void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||
{
|
||||
const QByteArray i1 = indent(1);
|
||||
const QByteArray i2 = indent(2);
|
||||
@@ -511,12 +511,12 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::Ptr> &projectInfos)
|
||||
const QByteArray i4 = indent(4);
|
||||
|
||||
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||
m_out << i1 << "Project " << info->projectName()
|
||||
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
||||
|
||||
const QVector<ProjectPart::Ptr> projectParts = info->projectParts();
|
||||
foreach (const ProjectPart::Ptr &part, projectParts) {
|
||||
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||
foreach (const ProjectPart::ConstPtr &part, projectParts) {
|
||||
QString projectName = QLatin1String("<None>");
|
||||
QString projectFilePath = "<None>";
|
||||
if (part->hasProject()) {
|
||||
|
@@ -70,7 +70,7 @@ public:
|
||||
const QString &logFileId = QString());
|
||||
~Dumper();
|
||||
|
||||
void dumpProjectInfos(const QList<CppTools::ProjectInfo::Ptr> &projectInfos);
|
||||
void dumpProjectInfos(const QList<CppTools::ProjectInfo::ConstPtr> &projectInfos);
|
||||
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
||||
const QString &title,
|
||||
bool isGlobalSnapshot = false);
|
||||
|
@@ -150,7 +150,7 @@ static CppModelManager *m_instance;
|
||||
class ProjectData
|
||||
{
|
||||
public:
|
||||
ProjectInfo::Ptr projectInfo;
|
||||
ProjectInfo::ConstPtr projectInfo;
|
||||
QFutureWatcher<void> *indexer = nullptr;
|
||||
bool fullyIndexed = false;
|
||||
};
|
||||
@@ -168,8 +168,9 @@ public:
|
||||
// Project integration
|
||||
QReadWriteLock m_projectLock;
|
||||
QHash<ProjectExplorer::Project *, ProjectData> m_projectData;
|
||||
QMap<Utils::FilePath, QList<ProjectPart::Ptr> > m_fileToProjectParts;
|
||||
QMap<QString, ProjectPart::Ptr> m_projectPartIdToProjectProjectPart;
|
||||
QMap<Utils::FilePath, QList<ProjectPart::ConstPtr> > m_fileToProjectParts;
|
||||
QMap<QString, ProjectPart::ConstPtr> m_projectPartIdToProjectProjectPart;
|
||||
|
||||
// The members below are cached/(re)calculated from the projects and/or their project parts
|
||||
bool m_dirty;
|
||||
QStringList m_projectFiles;
|
||||
@@ -190,7 +191,7 @@ public:
|
||||
bool m_indexerEnabled;
|
||||
|
||||
QMutex m_fallbackProjectPartMutex;
|
||||
ProjectPart::Ptr m_fallbackProjectPart;
|
||||
ProjectPart::ConstPtr m_fallbackProjectPart;
|
||||
|
||||
CppFindReferences *m_findReferences;
|
||||
|
||||
@@ -325,7 +326,7 @@ static RefactoringEngineInterface *getRefactoringEngine(CppModelManagerPrivate::
|
||||
}
|
||||
|
||||
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
||||
CppTools::ProjectPart *projectPart,
|
||||
const CppTools::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
||||
@@ -761,7 +762,7 @@ QStringList CppModelManager::internalProjectFiles() const
|
||||
{
|
||||
QStringList files;
|
||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectFile &file : part->files)
|
||||
files += file.path;
|
||||
}
|
||||
@@ -774,7 +775,7 @@ ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const
|
||||
{
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
for (const ProjectData &projectData: qAsConst(d->m_projectData)) {
|
||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectExplorer::HeaderPath &path : part->headerPaths) {
|
||||
ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type);
|
||||
if (!headerPaths.contains(hp))
|
||||
@@ -802,7 +803,7 @@ ProjectExplorer::Macros CppModelManager::internalDefinedMacros() const
|
||||
ProjectExplorer::Macros macros;
|
||||
QSet<ProjectExplorer::Macro> alreadyIn;
|
||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||
addUnique(part->toolChainMacros, macros, alreadyIn);
|
||||
addUnique(part->projectMacros, macros, alreadyIn);
|
||||
}
|
||||
@@ -982,14 +983,14 @@ QFuture<void> CppModelManager::updateSourceFiles(const QSet<QString> &sourceFile
|
||||
return d->m_internalIndexingSupport->refreshSourceFiles(filteredFiles, mode);
|
||||
}
|
||||
|
||||
QList<ProjectInfo::Ptr> CppModelManager::projectInfos() const
|
||||
QList<ProjectInfo::ConstPtr> CppModelManager::projectInfos() const
|
||||
{
|
||||
QReadLocker locker(&d->m_projectLock);
|
||||
return Utils::transform<QList<ProjectInfo::Ptr>>(d->m_projectData,
|
||||
return Utils::transform<QList<ProjectInfo::ConstPtr>>(d->m_projectData,
|
||||
[](const ProjectData &d) { return d.projectInfo; });
|
||||
}
|
||||
|
||||
ProjectInfo::Ptr CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
||||
ProjectInfo::ConstPtr CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
||||
{
|
||||
QReadLocker locker(&d->m_projectLock);
|
||||
return d->m_projectData.value(project).projectInfo;
|
||||
@@ -999,7 +1000,7 @@ ProjectInfo::Ptr CppModelManager::projectInfo(ProjectExplorer::Project *project)
|
||||
void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo)
|
||||
{
|
||||
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
||||
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, projectInfo.projectParts()) {
|
||||
foreach (const ProjectFile &cxxFile, projectPart->files) {
|
||||
foreach (const QString &fileName, d->m_snapshot.allIncludesForDocument(cxxFile.path))
|
||||
d->m_snapshot.remove(fileName);
|
||||
@@ -1074,11 +1075,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static QSet<QString> projectPartIds(const QVector<ProjectPart::Ptr> &projectParts)
|
||||
static QSet<QString> projectPartIds(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
QSet<QString> ids;
|
||||
|
||||
foreach (const ProjectPart::Ptr &projectPart, projectParts)
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, projectParts)
|
||||
ids.insert(projectPart->id());
|
||||
|
||||
return ids;
|
||||
@@ -1098,7 +1099,7 @@ void CppModelManager::recalculateProjectPartMappings()
|
||||
d->m_projectPartIdToProjectProjectPart.clear();
|
||||
d->m_fileToProjectParts.clear();
|
||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||
for (const ProjectPart::Ptr &projectPart : projectData.projectInfo->projectParts()) {
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectData.projectInfo->projectParts()) {
|
||||
d->m_projectPartIdToProjectProjectPart[projectPart->id()] = projectPart;
|
||||
for (const ProjectFile &cxxFile : projectPart->files)
|
||||
d->m_fileToProjectParts[Utils::FilePath::fromString(cxxFile.path)].append(
|
||||
@@ -1157,7 +1158,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
||||
}
|
||||
}
|
||||
|
||||
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProjectInfo,
|
||||
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::ConstPtr &newProjectInfo,
|
||||
const QSet<QString> &additionalFiles)
|
||||
{
|
||||
if (!newProjectInfo)
|
||||
@@ -1181,7 +1182,6 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProj
|
||||
const auto it = d->m_projectData.find(project);
|
||||
if (it != d->m_projectData.end() && it->projectInfo && it->fullyIndexed) {
|
||||
ProjectInfoComparer comparer(*it->projectInfo, *newProjectInfo);
|
||||
|
||||
if (comparer.configurationOrFilesChanged()) {
|
||||
d->m_dirty = true;
|
||||
|
||||
@@ -1268,22 +1268,22 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProj
|
||||
return indexingFuture;
|
||||
}
|
||||
|
||||
ProjectPart::Ptr CppModelManager::projectPartForId(const QString &projectPartId) const
|
||||
ProjectPart::ConstPtr CppModelManager::projectPartForId(const QString &projectPartId) const
|
||||
{
|
||||
QReadLocker locker(&d->m_projectLock);
|
||||
return d->m_projectPartIdToProjectProjectPart.value(projectPartId);
|
||||
}
|
||||
|
||||
QList<ProjectPart::Ptr> CppModelManager::projectPart(const Utils::FilePath &fileName) const
|
||||
QList<ProjectPart::ConstPtr> CppModelManager::projectPart(const Utils::FilePath &fileName) const
|
||||
{
|
||||
QReadLocker locker(&d->m_projectLock);
|
||||
return d->m_fileToProjectParts.value(fileName);
|
||||
}
|
||||
|
||||
QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(
|
||||
QList<ProjectPart::ConstPtr> CppModelManager::projectPartFromDependencies(
|
||||
const Utils::FilePath &fileName) const
|
||||
{
|
||||
QSet<ProjectPart::Ptr> parts;
|
||||
QSet<ProjectPart::ConstPtr> parts;
|
||||
const Utils::FilePaths deps = snapshot().filesDependingOn(fileName);
|
||||
|
||||
QReadLocker locker(&d->m_projectLock);
|
||||
@@ -1293,7 +1293,7 @@ QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(
|
||||
return parts.values();
|
||||
}
|
||||
|
||||
ProjectPart::Ptr CppModelManager::fallbackProjectPart()
|
||||
ProjectPart::ConstPtr CppModelManager::fallbackProjectPart()
|
||||
{
|
||||
QMutexLocker locker(&d->m_fallbackProjectPartMutex);
|
||||
return d->m_fallbackProjectPart;
|
||||
@@ -1431,7 +1431,7 @@ QSet<QString> CppModelManager::dependingInternalTargets(const Utils::FilePath &f
|
||||
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
|
||||
wasHeader ? file : Utils::FilePath::fromString(correspondingFile));
|
||||
for (const Utils::FilePath &fn : qAsConst(dependingFiles)) {
|
||||
for (const ProjectPart::Ptr &part : projectPart(fn))
|
||||
for (const ProjectPart::ConstPtr &part : projectPart(fn))
|
||||
result.insert(part->buildSystemTarget);
|
||||
}
|
||||
return result;
|
||||
@@ -1439,12 +1439,12 @@ QSet<QString> CppModelManager::dependingInternalTargets(const Utils::FilePath &f
|
||||
|
||||
QSet<QString> CppModelManager::internalTargets(const Utils::FilePath &filePath) const
|
||||
{
|
||||
const QList<ProjectPart::Ptr> projectParts = projectPart(filePath);
|
||||
const QList<ProjectPart::ConstPtr> projectParts = projectPart(filePath);
|
||||
// if we have no project parts it's most likely a header with declarations only and CMake based
|
||||
if (projectParts.isEmpty())
|
||||
return dependingInternalTargets(filePath);
|
||||
QSet<QString> targets;
|
||||
for (const ProjectPart::Ptr &part : projectParts) {
|
||||
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||
targets.insert(part->buildSystemTarget);
|
||||
if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
targets.unite(dependingInternalTargets(filePath));
|
||||
|
@@ -114,23 +114,23 @@ public:
|
||||
QByteArray codeModelConfiguration() const;
|
||||
CppLocatorData *locatorData() const;
|
||||
|
||||
QList<ProjectInfo::Ptr> projectInfos() const;
|
||||
ProjectInfo::Ptr projectInfo(ProjectExplorer::Project *project) const;
|
||||
QFuture<void> updateProjectInfo(const ProjectInfo::Ptr &newProjectInfo,
|
||||
QList<ProjectInfo::ConstPtr> projectInfos() const;
|
||||
ProjectInfo::ConstPtr projectInfo(ProjectExplorer::Project *project) const;
|
||||
QFuture<void> updateProjectInfo(const ProjectInfo::ConstPtr &newProjectInfo,
|
||||
const QSet<QString> &additionalFiles = {});
|
||||
|
||||
/// \return The project part with the given project file
|
||||
ProjectPart::Ptr projectPartForId(const QString &projectPartId) const override;
|
||||
ProjectPart::ConstPtr projectPartForId(const QString &projectPartId) const override;
|
||||
/// \return All project parts that mention the given file name as one of the sources/headers.
|
||||
QList<ProjectPart::Ptr> projectPart(const Utils::FilePath &fileName) const;
|
||||
QList<ProjectPart::Ptr> projectPart(const QString &fileName) const
|
||||
QList<ProjectPart::ConstPtr> projectPart(const Utils::FilePath &fileName) const;
|
||||
QList<ProjectPart::ConstPtr> projectPart(const QString &fileName) const
|
||||
{ return projectPart(Utils::FilePath::fromString(fileName)); }
|
||||
/// This is a fall-back function: find all files that includes the file directly or indirectly,
|
||||
/// and return its \c ProjectPart list for use with this file.
|
||||
QList<ProjectPart::Ptr> projectPartFromDependencies(const Utils::FilePath &fileName) const;
|
||||
QList<ProjectPart::ConstPtr> projectPartFromDependencies(const Utils::FilePath &fileName) const;
|
||||
/// \return A synthetic \c ProjectPart which consists of all defines/includes/frameworks from
|
||||
/// all loaded projects.
|
||||
ProjectPart::Ptr fallbackProjectPart();
|
||||
ProjectPart::ConstPtr fallbackProjectPart();
|
||||
|
||||
CPlusPlus::Snapshot snapshot() const override;
|
||||
Document::Ptr document(const QString &fileName) const;
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
||||
|
||||
void startLocalRenaming(const CursorInEditor &data,
|
||||
CppTools::ProjectPart *projectPart,
|
||||
const ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback) final;
|
||||
void globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
||||
const QString &replacement) final;
|
||||
|
@@ -118,7 +118,7 @@ public:
|
||||
}
|
||||
|
||||
ModelManagerTestHelper *modelManagerTestHelper;
|
||||
ProjectInfo::Ptr projectInfo;
|
||||
ProjectInfo::ConstPtr projectInfo;
|
||||
QStringList projectFiles;
|
||||
};
|
||||
|
||||
@@ -164,10 +164,10 @@ private:
|
||||
const QString &m_filePath;
|
||||
};
|
||||
|
||||
ProjectPart::Ptr projectPartOfEditorDocument(const QString &filePath)
|
||||
ProjectPart::ConstPtr projectPartOfEditorDocument(const QString &filePath)
|
||||
{
|
||||
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
||||
QTC_ASSERT(editorDocument, return ProjectPart::Ptr());
|
||||
QTC_ASSERT(editorDocument, return ProjectPart::ConstPtr());
|
||||
return editorDocument->processor()->parser()->projectPartInfo().projectPart;
|
||||
}
|
||||
|
||||
@@ -948,7 +948,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
||||
EditorCloser closerA(editorA);
|
||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||
QVERIFY(TestCase::waitForProcessedEditorDocument(fileA));
|
||||
ProjectPart::Ptr documentAProjectPart = projectPartOfEditorDocument(fileA);
|
||||
ProjectPart::ConstPtr documentAProjectPart = projectPartOfEditorDocument(fileA);
|
||||
QVERIFY(!documentAProjectPart->hasProject());
|
||||
|
||||
// Open file B in editor
|
||||
@@ -957,7 +957,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
||||
EditorCloser closerB(editorB);
|
||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
||||
QVERIFY(TestCase::waitForProcessedEditorDocument(fileB));
|
||||
ProjectPart::Ptr documentBProjectPart = projectPartOfEditorDocument(fileB);
|
||||
ProjectPart::ConstPtr documentBProjectPart = projectPartOfEditorDocument(fileB);
|
||||
QVERIFY(!documentBProjectPart->hasProject());
|
||||
|
||||
// Switch back to document A
|
||||
|
@@ -32,7 +32,7 @@ namespace CppTools {
|
||||
class CppModelManagerInterface
|
||||
{
|
||||
public:
|
||||
virtual ProjectPart::Ptr projectPartForId(const QString &projectPartId) const = 0;
|
||||
virtual ProjectPart::ConstPtr projectPartForId(const QString &projectPartId) const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~CppModelManagerInterface() = default;
|
||||
|
@@ -42,22 +42,25 @@ using namespace ProjectExplorer;
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<ProjectInfo::Ptr> &futureInterface,
|
||||
ProjectInfoGenerator::ProjectInfoGenerator(
|
||||
const QFutureInterface<ProjectInfo::ConstPtr> &futureInterface,
|
||||
const ProjectUpdateInfo &projectUpdateInfo)
|
||||
: m_futureInterface(futureInterface)
|
||||
, m_projectUpdateInfo(projectUpdateInfo)
|
||||
{
|
||||
}
|
||||
|
||||
ProjectInfo::Ptr ProjectInfoGenerator::generate()
|
||||
ProjectInfo::ConstPtr ProjectInfoGenerator::generate()
|
||||
{
|
||||
QVector<ProjectPart::Ptr> projectParts;
|
||||
QVector<ProjectPart::ConstPtr> projectParts;
|
||||
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
||||
if (m_futureInterface.isCanceled())
|
||||
return {};
|
||||
for (const ProjectPart::Ptr &part : createProjectParts(rpp, m_projectUpdateInfo.projectFilePath))
|
||||
for (const ProjectPart::ConstPtr &part : createProjectParts(
|
||||
rpp, m_projectUpdateInfo.projectFilePath)) {
|
||||
projectParts << part;
|
||||
}
|
||||
}
|
||||
const auto projectInfo = ProjectInfo::create(m_projectUpdateInfo, projectParts);
|
||||
|
||||
static const auto showWarning = [](const QString &message) {
|
||||
@@ -78,12 +81,12 @@ ProjectInfo::Ptr ProjectInfoGenerator::generate()
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
const QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(
|
||||
const QVector<ProjectPart::ConstPtr> ProjectInfoGenerator::createProjectParts(
|
||||
const RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath)
|
||||
{
|
||||
using Utils::LanguageExtension;
|
||||
|
||||
QVector<ProjectPart::Ptr> result;
|
||||
QVector<ProjectPart::ConstPtr> result;
|
||||
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
||||
rawProjectPart.files,
|
||||
rawProjectPart.fileIsActive);
|
||||
@@ -137,7 +140,7 @@ const QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
||||
ProjectPart::ConstPtr ProjectInfoGenerator::createProjectPart(
|
||||
const Utils::FilePath &projectFilePath,
|
||||
const RawProjectPart &rawProjectPart,
|
||||
const ProjectFiles &projectFiles,
|
||||
|
@@ -36,14 +36,16 @@ namespace Internal {
|
||||
class ProjectInfoGenerator
|
||||
{
|
||||
public:
|
||||
ProjectInfoGenerator(const QFutureInterface<ProjectInfo::Ptr> &futureInterface,
|
||||
ProjectInfoGenerator(const QFutureInterface<ProjectInfo::ConstPtr> &futureInterface,
|
||||
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
|
||||
|
||||
ProjectInfo::Ptr generate();
|
||||
ProjectInfo::ConstPtr generate();
|
||||
|
||||
private:
|
||||
const QVector<ProjectPart::Ptr> createProjectParts(const ProjectExplorer::RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath);
|
||||
ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||
const QVector<ProjectPart::ConstPtr> createProjectParts(
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||
const Utils::FilePath &projectFilePath);
|
||||
ProjectPart::ConstPtr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||
const ProjectFiles &projectFiles,
|
||||
const QString &partName,
|
||||
@@ -51,7 +53,7 @@ private:
|
||||
Utils::LanguageExtensions languageExtensions);
|
||||
|
||||
private:
|
||||
const QFutureInterface<ProjectInfo::Ptr> m_futureInterface;
|
||||
const QFutureInterface<ProjectInfo::ConstPtr> m_futureInterface;
|
||||
const ProjectExplorer::ProjectUpdateInfo &m_projectUpdateInfo;
|
||||
bool m_cToolchainMissing = false;
|
||||
bool m_cxxToolchainMissing = false;
|
||||
|
@@ -36,14 +36,14 @@ class ProjectPartPrioritizer
|
||||
public:
|
||||
struct PrioritizedProjectPart
|
||||
{
|
||||
PrioritizedProjectPart(const ProjectPart::Ptr &projectPart, int priority)
|
||||
PrioritizedProjectPart(const ProjectPart::ConstPtr &projectPart, int priority)
|
||||
: projectPart(projectPart), priority(priority) {}
|
||||
|
||||
ProjectPart::Ptr projectPart;
|
||||
ProjectPart::ConstPtr projectPart;
|
||||
int priority = 0;
|
||||
};
|
||||
|
||||
ProjectPartPrioritizer(const QList<ProjectPart::Ptr> &projectParts,
|
||||
ProjectPartPrioritizer(const QList<ProjectPart::ConstPtr> &projectParts,
|
||||
const QString &preferredProjectPartId,
|
||||
const ProjectExplorer::Project *activeProject,
|
||||
Language languagePreference,
|
||||
@@ -77,11 +77,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts) const
|
||||
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::ConstPtr> &projectParts) const
|
||||
{
|
||||
// Prioritize
|
||||
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
|
||||
[&](const ProjectPart::Ptr &projectPart) {
|
||||
[&](const ProjectPart::ConstPtr &projectPart) {
|
||||
return PrioritizedProjectPart{projectPart, priority(*projectPart)};
|
||||
});
|
||||
|
||||
@@ -143,8 +143,8 @@ ProjectPartInfo ProjectPartChooser::choose(
|
||||
QTC_CHECK(m_projectPartsFromDependenciesForFile);
|
||||
QTC_CHECK(m_fallbackProjectPart);
|
||||
|
||||
ProjectPart::Ptr projectPart = currentProjectPartInfo.projectPart;
|
||||
QList<ProjectPart::Ptr> projectParts = m_projectPartsForFile(filePath);
|
||||
ProjectPart::ConstPtr projectPart = currentProjectPartInfo.projectPart;
|
||||
QList<ProjectPart::ConstPtr> projectParts = m_projectPartsForFile(filePath);
|
||||
bool areProjectPartsFromDependencies = false;
|
||||
|
||||
if (projectParts.isEmpty()) {
|
||||
|
@@ -38,10 +38,10 @@ namespace Internal {
|
||||
class ProjectPartChooser
|
||||
{
|
||||
public:
|
||||
using FallBackProjectPart = std::function<ProjectPart::Ptr()>;
|
||||
using ProjectPartsForFile = std::function<QList<ProjectPart::Ptr>(const QString &filePath)>;
|
||||
using FallBackProjectPart = std::function<ProjectPart::ConstPtr()>;
|
||||
using ProjectPartsForFile = std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;
|
||||
using ProjectPartsFromDependenciesForFile
|
||||
= std::function<QList<ProjectPart::Ptr>(const QString &filePath)>;
|
||||
= std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;
|
||||
|
||||
public:
|
||||
void setFallbackProjectPart(const FallBackProjectPart &getter);
|
||||
|
@@ -77,7 +77,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
// Run the project info generator in a worker thread and continue if that one is finished.
|
||||
auto generateFuture = Utils::runAsync([=](QFutureInterface<ProjectInfo::Ptr> &futureInterface) {
|
||||
auto generateFuture = Utils::runAsync([=](QFutureInterface<ProjectInfo::ConstPtr> &futureInterface) {
|
||||
ProjectUpdateInfo fullProjectUpdateInfo = projectUpdateInfo;
|
||||
if (fullProjectUpdateInfo.rppGenerator)
|
||||
fullProjectUpdateInfo.rawProjectParts = fullProjectUpdateInfo.rppGenerator();
|
||||
|
@@ -70,7 +70,7 @@ private:
|
||||
ProjectExplorer::ProjectUpdateInfo m_projectUpdateInfo;
|
||||
QList<QPointer<ProjectExplorer::ExtraCompiler>> m_extraCompilers;
|
||||
|
||||
QFutureWatcher<ProjectInfo::Ptr> m_generateFutureWatcher;
|
||||
QFutureWatcher<ProjectInfo::ConstPtr> m_generateFutureWatcher;
|
||||
bool m_isProjectInfoGenerated = false;
|
||||
QSet<QFutureWatcher<void> *> m_extraCompilersFutureWatchers;
|
||||
std::unique_ptr<QFutureInterface<void>> m_projectUpdateFutureInterface;
|
||||
|
@@ -38,7 +38,7 @@
|
||||
namespace CppTools {
|
||||
|
||||
void CppRefactoringEngine::startLocalRenaming(const CursorInEditor &data,
|
||||
ProjectPart *,
|
||||
const ProjectPart *,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||
|
@@ -33,7 +33,7 @@ class CPPTOOLS_EXPORT CppRefactoringEngine : public RefactoringEngineInterface
|
||||
{
|
||||
public:
|
||||
void startLocalRenaming(const CursorInEditor &data,
|
||||
ProjectPart *projectPart,
|
||||
const ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback) override;
|
||||
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
||||
const QString &replacement) override;
|
||||
|
@@ -44,8 +44,8 @@ public:
|
||||
Q_DECLARE_FLAGS(Hints, Hint)
|
||||
|
||||
ProjectPartInfo() = default;
|
||||
ProjectPartInfo(const ProjectPart::Ptr &projectPart,
|
||||
const QList<ProjectPart::Ptr> &projectParts,
|
||||
ProjectPartInfo(const ProjectPart::ConstPtr &projectPart,
|
||||
const QList<ProjectPart::ConstPtr> &projectParts,
|
||||
Hints hints)
|
||||
: projectPart(projectPart)
|
||||
, projectParts(projectParts)
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ProjectPart::Ptr projectPart;
|
||||
QList<ProjectPart::Ptr> projectParts; // The one above as first plus alternatives.
|
||||
ProjectPart::ConstPtr projectPart;
|
||||
QList<ProjectPart::ConstPtr> projectParts; // The one above as first plus alternatives.
|
||||
Hints hints = NoHint;
|
||||
};
|
||||
|
||||
|
@@ -44,15 +44,15 @@ CppToolsBridgeQtCreatorImplementation::cppEditorDocument(const QString &filePath
|
||||
|
||||
namespace {
|
||||
|
||||
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
||||
CppTools::ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
||||
{
|
||||
if (const auto parser = BaseEditorDocumentParser::get(filePath))
|
||||
return parser->projectPartInfo().projectPart;
|
||||
|
||||
return CppTools::ProjectPart::Ptr();
|
||||
return CppTools::ProjectPart::ConstPtr();
|
||||
}
|
||||
|
||||
bool isProjectPartValid(const CppTools::ProjectPart::Ptr projectPart)
|
||||
bool isProjectPartValid(const CppTools::ProjectPart::ConstPtr projectPart)
|
||||
{
|
||||
if (projectPart)
|
||||
return !CppTools::CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
||||
@@ -64,7 +64,7 @@ bool isProjectPartValid(const CppTools::ProjectPart::Ptr projectPart)
|
||||
|
||||
QString CppToolsBridgeQtCreatorImplementation::projectPartIdForFile(const QString &filePath) const
|
||||
{
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectPartForFile(filePath);
|
||||
const CppTools::ProjectPart::ConstPtr projectPart = projectPartForFile(filePath);
|
||||
|
||||
if (isProjectPartValid(projectPart))
|
||||
return projectPart->id(); // OK, Project Part is still loaded
|
||||
|
@@ -514,8 +514,8 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader, Ca
|
||||
// Find files in other projects
|
||||
} else {
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
const QList<ProjectInfo::Ptr> projectInfos = modelManager->projectInfos();
|
||||
for (const ProjectInfo::Ptr &projectInfo : projectInfos) {
|
||||
const QList<ProjectInfo::ConstPtr> projectInfos = modelManager->projectInfos();
|
||||
for (const ProjectInfo::ConstPtr &projectInfo : projectInfos) {
|
||||
const Project *project = projectForProjectInfo(*projectInfo);
|
||||
if (project == currentProject)
|
||||
continue; // We have already checked the current project.
|
||||
|
@@ -278,7 +278,7 @@ ProjectOpenerAndCloser::~ProjectOpenerAndCloser()
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
ProjectInfo::Ptr ProjectOpenerAndCloser::open(const QString &projectFile,
|
||||
ProjectInfo::ConstPtr ProjectOpenerAndCloser::open(const QString &projectFile,
|
||||
bool configureAsExampleProject, Kit *kit)
|
||||
{
|
||||
ProjectExplorerPlugin::OpenProjectResult result =
|
||||
|
@@ -141,7 +141,9 @@ public:
|
||||
ProjectOpenerAndCloser();
|
||||
~ProjectOpenerAndCloser(); // Closes opened projects
|
||||
|
||||
CppTools::ProjectInfo::Ptr open(const QString &projectFile, bool configureAsExampleProject = false,
|
||||
CppTools::ProjectInfo::ConstPtr open(
|
||||
const QString &projectFile,
|
||||
bool configureAsExampleProject = false,
|
||||
ProjectExplorer::Kit *kit = nullptr);
|
||||
|
||||
private:
|
||||
|
@@ -77,7 +77,7 @@ ModelManagerTestHelper::~ModelManagerTestHelper()
|
||||
void ModelManagerTestHelper::cleanup()
|
||||
{
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
QList<ProjectInfo::Ptr> pies = mm->projectInfos();
|
||||
QList<ProjectInfo::ConstPtr> pies = mm->projectInfos();
|
||||
for (Project * const p : qAsConst(m_projects)) {
|
||||
ProjectExplorer::SessionManager::removeProject(p);
|
||||
emit aboutToRemoveProject(p);
|
||||
@@ -98,7 +98,7 @@ ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(
|
||||
}
|
||||
|
||||
QSet<QString> ModelManagerTestHelper::updateProjectInfo(
|
||||
const CppTools::ProjectInfo::Ptr &projectInfo)
|
||||
const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||
{
|
||||
resetRefreshedSourceFiles();
|
||||
CppModelManager::instance()->updateProjectInfo(projectInfo).waitForFinished();
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
Project *createProject(const QString &name, const Utils::FilePath &filePath = {});
|
||||
|
||||
QSet<QString> updateProjectInfo(const ProjectInfo::Ptr &projectInfo);
|
||||
QSet<QString> updateProjectInfo(const ProjectInfo::ConstPtr &projectInfo);
|
||||
|
||||
void resetRefreshedSourceFiles();
|
||||
QSet<QString> waitForRefreshedSourceFiles();
|
||||
|
@@ -33,13 +33,13 @@
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
ProjectInfo::Ptr ProjectInfo::create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::Ptr> &projectParts)
|
||||
ProjectInfo::ConstPtr ProjectInfo::create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
return Ptr(new ProjectInfo(updateInfo, projectParts));
|
||||
return ConstPtr(new ProjectInfo(updateInfo, projectParts));
|
||||
}
|
||||
|
||||
const QVector<ProjectPart::Ptr> ProjectInfo::projectParts() const
|
||||
const QVector<ProjectPart::ConstPtr> ProjectInfo::projectParts() const
|
||||
{
|
||||
return m_projectParts;
|
||||
}
|
||||
@@ -80,30 +80,31 @@ bool ProjectInfo::configurationOrFilesChanged(const ProjectInfo &other) const
|
||||
return configurationChanged(other) || m_sourceFiles != other.m_sourceFiles;
|
||||
}
|
||||
|
||||
static QSet<QString> getSourceFiles(const QVector<ProjectPart::Ptr> &projectParts)
|
||||
static QSet<QString> getSourceFiles(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
QSet<QString> sourceFiles;
|
||||
for (const ProjectPart::Ptr &part : projectParts) {
|
||||
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||
for (const ProjectFile &file : qAsConst(part->files))
|
||||
sourceFiles.insert(file.path);
|
||||
}
|
||||
return sourceFiles;
|
||||
}
|
||||
|
||||
static ProjectExplorer::Macros getDefines(const QVector<ProjectPart::Ptr> &projectParts)
|
||||
static ProjectExplorer::Macros getDefines(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
ProjectExplorer::Macros defines;
|
||||
for (const ProjectPart::Ptr &part : projectParts) {
|
||||
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||
defines.append(part->toolChainMacros);
|
||||
defines.append(part->projectMacros);
|
||||
}
|
||||
return defines;
|
||||
}
|
||||
|
||||
static ProjectExplorer::HeaderPaths getHeaderPaths(const QVector<ProjectPart::Ptr> &projectParts)
|
||||
static ProjectExplorer::HeaderPaths getHeaderPaths(
|
||||
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
{
|
||||
QSet<ProjectExplorer::HeaderPath> uniqueHeaderPaths;
|
||||
for (const ProjectPart::Ptr &part : projectParts) {
|
||||
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(part->headerPaths))
|
||||
uniqueHeaderPaths.insert(headerPath);
|
||||
}
|
||||
@@ -111,7 +112,7 @@ static ProjectExplorer::HeaderPaths getHeaderPaths(const QVector<ProjectPart::Pt
|
||||
}
|
||||
|
||||
ProjectInfo::ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::Ptr> &projectParts)
|
||||
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||
: m_projectParts(projectParts),
|
||||
m_projectName(updateInfo.projectName),
|
||||
m_projectFilePath(updateInfo.projectFilePath),
|
||||
|
@@ -45,11 +45,11 @@ namespace CppTools {
|
||||
class CPPTOOLS_EXPORT ProjectInfo
|
||||
{
|
||||
public:
|
||||
using Ptr = std::shared_ptr<ProjectInfo>;
|
||||
static Ptr create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::Ptr> &projectParts);
|
||||
using ConstPtr = std::shared_ptr<const ProjectInfo>;
|
||||
static ConstPtr create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::ConstPtr> &projectParts);
|
||||
|
||||
const QVector<ProjectPart::Ptr> projectParts() const;
|
||||
const QVector<ProjectPart::ConstPtr> projectParts() const;
|
||||
const QSet<QString> sourceFiles() const;
|
||||
QString projectName() const { return m_projectName; }
|
||||
Utils::FilePath projectFilePath() const { return m_projectFilePath; }
|
||||
@@ -65,9 +65,9 @@ public:
|
||||
|
||||
private:
|
||||
ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||
const QVector<ProjectPart::Ptr> &projectParts);
|
||||
const QVector<ProjectPart::ConstPtr> &projectParts);
|
||||
|
||||
const QVector<ProjectPart::Ptr> m_projectParts;
|
||||
const QVector<ProjectPart::ConstPtr> m_projectParts;
|
||||
const QString m_projectName;
|
||||
const Utils::FilePath m_projectFilePath;
|
||||
const Utils::FilePath m_buildRoot;
|
||||
|
@@ -66,9 +66,9 @@ public:
|
||||
languagePreference, projectsChanged);
|
||||
}
|
||||
|
||||
static QList<ProjectPart::Ptr> createProjectPartsWithDifferentProjects()
|
||||
static QList<ProjectPart::ConstPtr> createProjectPartsWithDifferentProjects()
|
||||
{
|
||||
QList<ProjectPart::Ptr> projectParts;
|
||||
QList<ProjectPart::ConstPtr> projectParts;
|
||||
|
||||
const auto p1 = std::make_shared<Project>(
|
||||
QString(), Utils::FilePath::fromString("p1.pro"));
|
||||
@@ -82,16 +82,16 @@ public:
|
||||
return projectParts;
|
||||
}
|
||||
|
||||
static QList<ProjectPart::Ptr> createCAndCxxProjectParts()
|
||||
static QList<ProjectPart::ConstPtr> createCAndCxxProjectParts()
|
||||
{
|
||||
QList<ProjectPart::Ptr> projectParts;
|
||||
QList<ProjectPart::ConstPtr> projectParts;
|
||||
ToolChainInfo tcInfo;
|
||||
|
||||
// Create project part for C
|
||||
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
||||
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::C11};
|
||||
};
|
||||
const ProjectPart::Ptr cprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||
const ProjectPart::ConstPtr cprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||
tcInfo);
|
||||
projectParts.append(cprojectpart);
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
||||
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::CXX98};
|
||||
};
|
||||
const ProjectPart::Ptr cxxprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||
const ProjectPart::ConstPtr cxxprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||
tcInfo);
|
||||
projectParts.append(cxxprojectpart);
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
}
|
||||
|
||||
QString filePath;
|
||||
ProjectPart::Ptr currentProjectPart = ProjectPart::create({});
|
||||
ProjectPart::ConstPtr currentProjectPart = ProjectPart::create({});
|
||||
ProjectPartInfo currentProjectPartInfo{currentProjectPart,
|
||||
{currentProjectPart},
|
||||
ProjectPartInfo::NoHint};
|
||||
@@ -117,9 +117,9 @@ public:
|
||||
bool projectsChanged = false;
|
||||
ProjectPartChooser chooser;
|
||||
|
||||
QList<ProjectPart::Ptr> projectPartsForFile;
|
||||
QList<ProjectPart::Ptr> projectPartsFromDependenciesForFile;
|
||||
ProjectPart::Ptr fallbackProjectPart;
|
||||
QList<ProjectPart::ConstPtr> projectPartsForFile;
|
||||
QList<ProjectPart::ConstPtr> projectPartsFromDependenciesForFile;
|
||||
ProjectPart::ConstPtr fallbackProjectPart;
|
||||
|
||||
static QHash<Utils::FilePath, std::shared_ptr<Project>> projectMap;
|
||||
};
|
||||
@@ -130,10 +130,10 @@ ProjectPartChooserTestHelper::projectMap;
|
||||
|
||||
void ProjectPartChooserTest::testChooseManuallySet()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
@@ -143,10 +143,10 @@ void ProjectPartChooserTest::testChooseManuallySet()
|
||||
|
||||
void ProjectPartChooserTest::testIndicateManuallySet()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
@@ -156,10 +156,10 @@ void ProjectPartChooserTest::testIndicateManuallySet()
|
||||
|
||||
void ProjectPartChooserTest::testIndicateManuallySetForFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||
@@ -175,8 +175,8 @@ void ProjectPartChooserTest::testDoNotIndicateNotManuallySet()
|
||||
void ProjectPartChooserTest::testForMultipleChooseFromActiveProject()
|
||||
{
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||
t.projectPartsForFile += projectParts;
|
||||
t.activeProject = secondProjectPart->topLevelProject;
|
||||
|
||||
@@ -189,8 +189,8 @@ void ProjectPartChooserTest::testForMultiplePreferSelectedForBuilding()
|
||||
rpp1.setSelectedForBuilding(false);
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setSelectedForBuilding(true);
|
||||
const ProjectPart::Ptr firstProjectPart = ProjectPart::create({}, rpp1);
|
||||
const ProjectPart::Ptr secondProjectPart = ProjectPart::create({}, rpp2);
|
||||
const ProjectPart::ConstPtr firstProjectPart = ProjectPart::create({}, rpp1);
|
||||
const ProjectPart::ConstPtr secondProjectPart = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += firstProjectPart;
|
||||
t.projectPartsForFile += secondProjectPart;
|
||||
@@ -201,8 +201,8 @@ void ProjectPartChooserTest::testForMultiplePreferSelectedForBuilding()
|
||||
void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProject()
|
||||
{
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||
t.projectPartsFromDependenciesForFile += projectParts;
|
||||
t.activeProject = secondProjectPart->topLevelProject;
|
||||
|
||||
@@ -212,9 +212,9 @@ void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProj
|
||||
void ProjectPartChooserTest::testForMultipleCheckIfActiveProjectChanged()
|
||||
{
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr firstProjectPart = projectParts.at(0);
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::ConstPtr firstProjectPart = projectParts.at(0);
|
||||
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||
t.projectPartsForFile += projectParts;
|
||||
t.currentProjectPartInfo.projectPart = firstProjectPart;
|
||||
t.activeProject = secondProjectPart->topLevelProject;
|
||||
@@ -227,7 +227,7 @@ void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCProjectPart
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.languagePreference = Language::C;
|
||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||
const ProjectPart::Ptr cProjectPart = t.projectPartsForFile.at(0);
|
||||
const ProjectPart::ConstPtr cProjectPart = t.projectPartsForFile.at(0);
|
||||
|
||||
QCOMPARE(t.choose().projectPart, cProjectPart);
|
||||
}
|
||||
@@ -237,15 +237,15 @@ void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCxxProjectPa
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.languagePreference = Language::Cxx;
|
||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||
const ProjectPart::Ptr cxxProjectPart = t.projectPartsForFile.at(1);
|
||||
const ProjectPart::ConstPtr cxxProjectPart = t.projectPartsForFile.at(1);
|
||||
|
||||
QCOMPARE(t.choose().projectPart, cxxProjectPart);
|
||||
}
|
||||
|
||||
void ProjectPartChooserTest::testIndicateMultiple()
|
||||
{
|
||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr p2 = ProjectPart::create({});
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
|
||||
@@ -254,8 +254,8 @@ void ProjectPartChooserTest::testIndicateMultiple()
|
||||
|
||||
void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr p2 = ProjectPart::create({});
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||
|
||||
@@ -264,7 +264,7 @@ void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDep
|
||||
|
||||
void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
||||
{
|
||||
const ProjectPart::Ptr newProjectPart = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr newProjectPart = ProjectPart::create({});
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += newProjectPart;
|
||||
|
||||
@@ -273,7 +273,7 @@ void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
||||
|
||||
void ProjectPartChooserTest::testFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
const ProjectPart::Ptr fromDependencies = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr fromDependencies = ProjectPart::create({});
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsFromDependenciesForFile += fromDependencies;
|
||||
|
||||
@@ -306,7 +306,7 @@ void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChang
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||
const ProjectPart::Ptr addedProject = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr addedProject = ProjectPart::create({});
|
||||
t.projectPartsForFile += addedProject;
|
||||
|
||||
QCOMPARE(t.choose().projectPart, addedProject);
|
||||
@@ -318,7 +318,7 @@ void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChang
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||
const ProjectPart::Ptr addedProject = ProjectPart::create({});
|
||||
const ProjectPart::ConstPtr addedProject = ProjectPart::create({});
|
||||
t.projectPartsFromDependenciesForFile += addedProject;
|
||||
t.projectsChanged = true;
|
||||
|
||||
@@ -380,9 +380,9 @@ public:
|
||||
projectUpdateInfo.cToolChainInfo = {&aToolChain, {}, {}};
|
||||
}
|
||||
|
||||
ProjectInfo::Ptr generate()
|
||||
ProjectInfo::ConstPtr generate()
|
||||
{
|
||||
QFutureInterface<ProjectInfo::Ptr> fi;
|
||||
QFutureInterface<ProjectInfo::ConstPtr> fi;
|
||||
|
||||
projectUpdateInfo.rawProjectParts += rawProjectPart;
|
||||
ProjectInfoGenerator generator(fi, projectUpdateInfo);
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
void ProjectInfoGeneratorTest::testCreateNoProjectPartsForEmptyFileList()
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QVERIFY(projectInfo->projectParts().isEmpty());
|
||||
}
|
||||
@@ -407,7 +407,7 @@ void ProjectInfoGeneratorTest::testCreateSingleProjectPart()
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h"};
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ void ProjectInfoGeneratorTest::testCreateMultipleProjectParts()
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h", "bar.c", "bar.h" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 2);
|
||||
}
|
||||
@@ -425,7 +425,7 @@ void ProjectInfoGeneratorTest::testProjectPartIndicatesObjectiveCExtensionsByDef
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.mm" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
|
||||
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
||||
@@ -436,7 +436,7 @@ void ProjectInfoGeneratorTest::testProjectPartHasLatestLanguageVersionByDefault(
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
|
||||
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
||||
@@ -450,7 +450,7 @@ void ProjectInfoGeneratorTest::testUseMacroInspectionReportForLanguageVersion()
|
||||
return TestToolchain::MacroInspectionReport{Macros(), Utils::LanguageVersion::CXX17};
|
||||
};
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
|
||||
@@ -463,7 +463,7 @@ void ProjectInfoGeneratorTest::testUseCompilerFlagsForLanguageExtensions()
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||
t.rawProjectPart.flagsForCxx.languageExtensions = Utils::LanguageExtension::Microsoft;
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
|
||||
@@ -475,22 +475,22 @@ void ProjectInfoGeneratorTest::testProjectFileKindsMatchProjectPartVersion()
|
||||
{
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.h" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 4);
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||
return p->languageVersion == Utils::LanguageVersion::LatestC
|
||||
&& p->files.first().kind == ProjectFile::CHeader;
|
||||
}));
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||
return p->languageVersion == Utils::LanguageVersion::LatestC
|
||||
&& p->files.first().kind == ProjectFile::ObjCHeader;
|
||||
}));
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
||||
&& p->files.first().kind == ProjectFile::CXXHeader;
|
||||
}));
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
||||
&& p->files.first().kind == ProjectFile::ObjCXXHeader;
|
||||
}));
|
||||
@@ -548,7 +548,7 @@ public:
|
||||
Utils::optional<HeaderPathFilter> filter;
|
||||
|
||||
private:
|
||||
ProjectPart::Ptr projectPart;
|
||||
ProjectPart::ConstPtr projectPart;
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -55,10 +55,10 @@ public:
|
||||
WordWidth64Bit,
|
||||
};
|
||||
|
||||
using Ptr = QSharedPointer<ProjectPart>;
|
||||
using ConstPtr = QSharedPointer<const ProjectPart>;
|
||||
|
||||
public:
|
||||
static Ptr create(const Utils::FilePath &topLevelProject,
|
||||
static ConstPtr create(const Utils::FilePath &topLevelProject,
|
||||
const ProjectExplorer::RawProjectPart &rpp = {},
|
||||
const QString &displayName = {},
|
||||
const ProjectFiles &files = {},
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
const ProjectExplorer::RawProjectPartFlags &flags = {},
|
||||
const ProjectExplorer::ToolChainInfo &tcInfo = {})
|
||||
{
|
||||
return Ptr(new ProjectPart(topLevelProject, rpp, displayName, files, language,
|
||||
return ConstPtr(new ProjectPart(topLevelProject, rpp, displayName, files, language,
|
||||
languageExtensions, flags, tcInfo));
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,7 @@ public:
|
||||
virtual ~RefactoringEngineInterface() = default;
|
||||
|
||||
virtual void startLocalRenaming(const CursorInEditor &data,
|
||||
CppTools::ProjectPart *projectPart,
|
||||
const CppTools::ProjectPart *projectPart,
|
||||
RenameCallback &&renameSymbolsCallback) = 0;
|
||||
virtual void globalRename(const CursorInEditor &data,
|
||||
UsagesCallback &&renameCallback,
|
||||
|
@@ -492,7 +492,7 @@ void SymbolFinder::checkCacheConsistency(const QString &referenceFile, const Sna
|
||||
|
||||
const QString projectPartIdForFile(const QString &filePath)
|
||||
{
|
||||
const QList<ProjectPart::Ptr> parts = CppModelManager::instance()->projectPart(filePath);
|
||||
const QList<ProjectPart::ConstPtr> parts = CppModelManager::instance()->projectPart(filePath);
|
||||
if (!parts.isEmpty())
|
||||
return parts.first()->id();
|
||||
return QString();
|
||||
|
@@ -58,7 +58,7 @@ void CppTodoItemsScanner::scannerParamsChanged()
|
||||
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
|
||||
QSet<QString> filesToBeUpdated;
|
||||
foreach (const CppTools::ProjectInfo::Ptr &info, modelManager->projectInfos())
|
||||
foreach (const CppTools::ProjectInfo::ConstPtr &info, modelManager->projectInfos())
|
||||
filesToBeUpdated.unite(info->sourceFiles());
|
||||
|
||||
modelManager->updateSourceFiles(filesToBeUpdated);
|
||||
|
Reference in New Issue
Block a user