forked from qt-creator/qt-creator
CPlusPlus: Return FilePaths from Document::includedFile
... and fix fallout. Change-Id: Ieaad57700fa48d0c4a0dd9bf2c284315579b9473 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include <cplusplus/TypeVisitor.h>
|
||||
#include <cplusplus/CoreTypes.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
@@ -297,13 +299,13 @@ void Document::setLastModified(const QDateTime &lastModified)
|
||||
_lastModified = lastModified;
|
||||
}
|
||||
|
||||
QStringList Document::includedFiles() const
|
||||
FilePaths Document::includedFiles() const
|
||||
{
|
||||
QStringList files;
|
||||
for (const Include &i : std::as_const(_resolvedIncludes))
|
||||
files.append(i.resolvedFileName());
|
||||
files.removeDuplicates();
|
||||
return files;
|
||||
return transform(files, &FilePath::fromString);
|
||||
}
|
||||
|
||||
// This assumes to be called with a QDir::cleanPath cleaned fileName.
|
||||
@@ -762,18 +764,18 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
|
||||
return newDoc;
|
||||
}
|
||||
|
||||
QSet<QString> Snapshot::allIncludesForDocument(const QString &fileName) const
|
||||
QSet<FilePath> Snapshot::allIncludesForDocument(const FilePath &filePath) const
|
||||
{
|
||||
QSet<QString> result;
|
||||
QSet<FilePath> result;
|
||||
|
||||
QStack<QString> files;
|
||||
files.push(fileName);
|
||||
QStack<FilePath> files;
|
||||
files.push(filePath);
|
||||
|
||||
while (!files.isEmpty()) {
|
||||
QString file = files.pop();
|
||||
FilePath file = files.pop();
|
||||
if (Document::Ptr doc = document(file)) {
|
||||
const QStringList includedFiles = doc->includedFiles();
|
||||
for (const QString &inc : includedFiles) {
|
||||
const FilePaths includedFiles = doc->includedFiles();
|
||||
for (const FilePath &inc : includedFiles) {
|
||||
if (!result.contains(inc)) {
|
||||
result.insert(inc);
|
||||
files.push(inc);
|
||||
@@ -815,10 +817,10 @@ QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::FilePaths Snapshot::filesDependingOn(const Utils::FilePath &fileName) const
|
||||
FilePaths Snapshot::filesDependingOn(const FilePath &filePath) const
|
||||
{
|
||||
updateDependencyTable();
|
||||
return m_deps.filesDependingOn(fileName);
|
||||
return m_deps.filesDependingOn(filePath);
|
||||
}
|
||||
|
||||
void Snapshot::updateDependencyTable() const
|
||||
@@ -838,9 +840,9 @@ bool Snapshot::operator==(const Snapshot &other) const
|
||||
return _documents == other._documents;
|
||||
}
|
||||
|
||||
Document::Ptr Snapshot::document(const Utils::FilePath &fileName) const
|
||||
Document::Ptr Snapshot::document(const FilePath &filePath) const
|
||||
{
|
||||
return _documents.value(fileName);
|
||||
return _documents.value(filePath);
|
||||
}
|
||||
|
||||
Snapshot Snapshot::simplified(Document::Ptr doc) const
|
||||
@@ -849,9 +851,9 @@ Snapshot Snapshot::simplified(Document::Ptr doc) const
|
||||
|
||||
if (doc) {
|
||||
snapshot.insert(doc);
|
||||
const QSet<QString> fileNames = allIncludesForDocument(doc->filePath().toString());
|
||||
for (const QString &fileName : fileNames)
|
||||
if (Document::Ptr inc = document(fileName))
|
||||
const QSet<FilePath> filePaths = allIncludesForDocument(doc->filePath());
|
||||
for (const FilePath &filePath : filePaths)
|
||||
if (Document::Ptr inc = document(filePath))
|
||||
snapshot.insert(inc);
|
||||
}
|
||||
|
||||
|
@@ -300,7 +300,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
QStringList includedFiles() const;
|
||||
Utils::FilePaths includedFiles() const;
|
||||
void addIncludeFile(const Include &include);
|
||||
|
||||
const QList<Include> &resolvedIncludes() const
|
||||
@@ -404,7 +404,7 @@ public:
|
||||
Document::Ptr documentFromSource(const QByteArray &preprocessedDocument,
|
||||
const Utils::FilePath &filePath) const;
|
||||
|
||||
QSet<QString> allIncludesForDocument(const QString &fileName) const;
|
||||
QSet<Utils::FilePath> allIncludesForDocument(const Utils::FilePath &filePath) const;
|
||||
|
||||
QList<IncludeLocation> includeLocationsOfDocument(const QString &fileNameOrPath) const;
|
||||
|
||||
|
@@ -6,7 +6,9 @@
|
||||
#include <QDebug>
|
||||
#include <QFutureInterface>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
Utils::FilePaths DependencyTable::filesDependingOn(const Utils::FilePath &fileName) const
|
||||
{
|
||||
@@ -55,10 +57,10 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
if (Document::Ptr doc = snapshot.document(fileName)) {
|
||||
QBitArray bitmap(files.size());
|
||||
QList<int> directIncludes;
|
||||
const QStringList documentIncludes = doc->includedFiles();
|
||||
const FilePaths documentIncludes = doc->includedFiles();
|
||||
|
||||
for (const QString &includedFile : documentIncludes) {
|
||||
int index = fileIndex.value(Utils::FilePath::fromString(includedFile));
|
||||
for (const FilePath &includedFile : documentIncludes) {
|
||||
int index = fileIndex.value(includedFile);
|
||||
|
||||
if (index == -1)
|
||||
continue;
|
||||
@@ -104,3 +106,5 @@ void DependencyTable::build(QFutureInterfaceBase &futureInterface, const Snapsho
|
||||
return;
|
||||
} while (changed);
|
||||
}
|
||||
|
||||
} // CPlusPlus
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
@@ -57,8 +59,8 @@ static bool includesBoostTest(const CPlusPlus::Document::Ptr &doc,
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) {
|
||||
if (boostTestHpp.match(include).hasMatch())
|
||||
for (const FilePath &include : snapshot.allIncludesForDocument(doc->filePath())) {
|
||||
if (boostTestHpp.match(include.path()).hasMatch())
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,7 @@ static bool includesCatchHeader(const CPlusPlus::Document::Ptr &doc,
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) {
|
||||
for (const FilePath &include : snapshot.allIncludesForDocument(doc->filePath())) {
|
||||
for (const QString &catchHeader : catchHeaders) {
|
||||
if (include.endsWith(catchHeader))
|
||||
return true;
|
||||
|
@@ -47,8 +47,8 @@ static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) {
|
||||
if (include.endsWith(gtestH))
|
||||
for (const FilePath &include : snapshot.allIncludesForDocument(doc->filePath())) {
|
||||
if (include.path().endsWith(gtestH))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
using LookupInfo = QPair<QString, QString>;
|
||||
@@ -58,7 +60,7 @@ QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const
|
||||
bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||
const Utils::FilePath &filePath,
|
||||
const QString &cacheString,
|
||||
const std::function<bool(const QString &)> &checker)
|
||||
const std::function<bool(const FilePath &)> &checker)
|
||||
{
|
||||
const CppEditor::CppModelManager *modelManager = CppEditor::CppModelManager::instance();
|
||||
const QList<CppEditor::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||
@@ -70,8 +72,8 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||
auto it = s_pchLookupCache.find(info);
|
||||
if (it == s_pchLookupCache.end()) {
|
||||
it = s_pchLookupCache.insert(info,
|
||||
Utils::anyOf(snapshot.allIncludesForDocument(header),
|
||||
checker));
|
||||
Utils::anyOf(snapshot.allIncludesForDocument(FilePath::fromString(header)),
|
||||
checker));
|
||||
}
|
||||
return it.value();
|
||||
};
|
||||
@@ -86,8 +88,8 @@ bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||
return Autotest::precompiledHeaderContains(snapshot,
|
||||
filePath,
|
||||
headerFilePath,
|
||||
[&](const QString &include) {
|
||||
return include.endsWith(headerFilePath);
|
||||
[&](const FilePath &include) {
|
||||
return include.path().endsWith(headerFilePath);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,8 +100,8 @@ bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||
return Autotest::precompiledHeaderContains(snapshot,
|
||||
filePath,
|
||||
headerFileRegex.pattern(),
|
||||
[&](const QString &include) {
|
||||
return headerFileRegex.match(include).hasMatch();
|
||||
[&](const FilePath &include) {
|
||||
return headerFileRegex.match(include.path()).hasMatch();
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -53,10 +53,10 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
||||
}
|
||||
}
|
||||
|
||||
const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->filePath().toString());
|
||||
for (const QString &include : allIncludes) {
|
||||
const QSet<FilePath> allIncludes = snapshot.allIncludesForDocument(doc->filePath());
|
||||
for (const FilePath &include : allIncludes) {
|
||||
for (const QString &prefix : expectedHeaderPrefixes) {
|
||||
if (include.endsWith(QString("%1/qtest.h").arg(prefix)))
|
||||
if (include.pathView().endsWith(QString("%1/qtest.h").arg(prefix)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -60,9 +60,9 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) {
|
||||
for (const FilePath &include : snapshot.allIncludesForDocument(doc->filePath())) {
|
||||
for (const QString &prefix : expectedHeaderPrefixes) {
|
||||
if (include.endsWith(QString("%1/quicktest.h").arg(prefix)))
|
||||
if (include.pathView().endsWith(QString("%1/quicktest.h").arg(prefix)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,12 @@ namespace CppEditor::Internal {
|
||||
class CppIncludesIterator final : public BaseFileFilter::Iterator
|
||||
{
|
||||
public:
|
||||
CppIncludesIterator(CPlusPlus::Snapshot snapshot, const QSet<QString> &seedPaths);
|
||||
CppIncludesIterator(CPlusPlus::Snapshot snapshot, const QSet<FilePath> &seedPaths)
|
||||
: m_snapshot(snapshot),
|
||||
m_paths(seedPaths)
|
||||
{
|
||||
toFront();
|
||||
}
|
||||
|
||||
void toFront() override;
|
||||
bool hasNext() const override;
|
||||
@@ -32,20 +37,14 @@ private:
|
||||
void fetchMore();
|
||||
|
||||
CPlusPlus::Snapshot m_snapshot;
|
||||
QSet<QString> m_paths;
|
||||
QSet<QString> m_queuedPaths;
|
||||
QSet<QString> m_allResultPaths;
|
||||
QStringList m_resultQueue;
|
||||
QSet<FilePath> m_paths;
|
||||
QSet<FilePath> m_queuedPaths;
|
||||
QSet<FilePath> m_allResultPaths;
|
||||
FilePaths m_resultQueue;
|
||||
FilePath m_currentPath;
|
||||
};
|
||||
|
||||
CppIncludesIterator::CppIncludesIterator(CPlusPlus::Snapshot snapshot,
|
||||
const QSet<QString> &seedPaths)
|
||||
: m_snapshot(snapshot),
|
||||
m_paths(seedPaths)
|
||||
{
|
||||
toFront();
|
||||
}
|
||||
|
||||
|
||||
void CppIncludesIterator::toFront()
|
||||
{
|
||||
@@ -64,7 +63,7 @@ FilePath CppIncludesIterator::next()
|
||||
{
|
||||
if (m_resultQueue.isEmpty())
|
||||
return {};
|
||||
m_currentPath = FilePath::fromString(m_resultQueue.takeFirst());
|
||||
m_currentPath = m_resultQueue.takeFirst();
|
||||
if (m_resultQueue.isEmpty())
|
||||
fetchMore();
|
||||
return m_currentPath;
|
||||
@@ -78,13 +77,13 @@ FilePath CppIncludesIterator::filePath() const
|
||||
void CppIncludesIterator::fetchMore()
|
||||
{
|
||||
while (!m_queuedPaths.isEmpty() && m_resultQueue.isEmpty()) {
|
||||
const QString filePath = *m_queuedPaths.begin();
|
||||
const FilePath filePath = *m_queuedPaths.begin();
|
||||
m_queuedPaths.remove(filePath);
|
||||
CPlusPlus::Document::Ptr doc = m_snapshot.document(filePath);
|
||||
if (!doc)
|
||||
continue;
|
||||
const QStringList includedFiles = doc->includedFiles();
|
||||
for (const QString &includedPath : includedFiles ) {
|
||||
const FilePaths includedFiles = doc->includedFiles();
|
||||
for (const FilePath &includedPath : includedFiles ) {
|
||||
if (!m_allResultPaths.contains(includedPath)) {
|
||||
m_allResultPaths.insert(includedPath);
|
||||
m_queuedPaths.insert(includedPath);
|
||||
@@ -127,16 +126,16 @@ void CppIncludesFilter::prepareSearch(const QString &entry)
|
||||
Q_UNUSED(entry)
|
||||
if (m_needsUpdate) {
|
||||
m_needsUpdate = false;
|
||||
QSet<QString> seedPaths;
|
||||
QSet<FilePath> seedPaths;
|
||||
for (Project *project : SessionManager::projects()) {
|
||||
const Utils::FilePaths allFiles = project->files(Project::SourceFiles);
|
||||
for (const Utils::FilePath &filePath : allFiles )
|
||||
seedPaths.insert(filePath.toString());
|
||||
const FilePaths allFiles = project->files(Project::SourceFiles);
|
||||
for (const FilePath &filePath : allFiles )
|
||||
seedPaths.insert(filePath);
|
||||
}
|
||||
const QList<DocumentModel::Entry *> entries = DocumentModel::entries();
|
||||
for (DocumentModel::Entry *entry : entries) {
|
||||
if (entry)
|
||||
seedPaths.insert(entry->fileName().toString());
|
||||
seedPaths.insert(entry->fileName());
|
||||
}
|
||||
CPlusPlus::Snapshot snapshot = CppModelManager::instance()->snapshot();
|
||||
setFileIterator(new CppIncludesIterator(snapshot, seedPaths));
|
||||
|
@@ -1309,9 +1309,10 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
|
||||
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectInfo.projectParts()) {
|
||||
for (const ProjectFile &cxxFile : std::as_const(projectPart->files)) {
|
||||
const QSet<QString> fileNames = d->m_snapshot.allIncludesForDocument(cxxFile.path);
|
||||
for (const QString &fileName : fileNames)
|
||||
d->m_snapshot.remove(fileName);
|
||||
const QSet<FilePath> filePaths = d->m_snapshot.allIncludesForDocument(
|
||||
FilePath::fromString(cxxFile.path));
|
||||
for (const FilePath &filePath : filePaths)
|
||||
d->m_snapshot.remove(filePath);
|
||||
d->m_snapshot.remove(cxxFile.path);
|
||||
}
|
||||
}
|
||||
@@ -1939,19 +1940,18 @@ void CppModelManager::GC()
|
||||
// The configuration file is part of the project files, which is just fine.
|
||||
// If single files are open, without any project, then there is no need to
|
||||
// keep the configuration file around.
|
||||
QStringList todo = filesInEditorSupports + projectFiles();
|
||||
FilePaths todo = transform(filesInEditorSupports + projectFiles(), &FilePath::fromString);
|
||||
|
||||
// Collect all files that are reachable from the project files
|
||||
while (!todo.isEmpty()) {
|
||||
const QString file = todo.last();
|
||||
const FilePath filePath = todo.last();
|
||||
todo.removeLast();
|
||||
|
||||
const Utils::FilePath fileName = Utils::FilePath::fromString(file);
|
||||
if (reachableFiles.contains(fileName))
|
||||
if (reachableFiles.contains(filePath))
|
||||
continue;
|
||||
reachableFiles.insert(fileName);
|
||||
reachableFiles.insert(filePath);
|
||||
|
||||
if (Document::Ptr doc = currentSnapshot.document(file))
|
||||
if (Document::Ptr doc = currentSnapshot.document(filePath))
|
||||
todo += doc->includedFiles();
|
||||
}
|
||||
|
||||
|
@@ -626,10 +626,10 @@ void ModelManagerTest::testExtraeditorsupportUiFiles()
|
||||
const CPlusPlus::Snapshot snapshot = mm->snapshot();
|
||||
const Document::Ptr document = snapshot.document(fileIncludingTheUiFile);
|
||||
QVERIFY(document);
|
||||
const QStringList includedFiles = document->includedFiles();
|
||||
const FilePaths includedFiles = document->includedFiles();
|
||||
QCOMPARE(includedFiles.size(), 2);
|
||||
QCOMPARE(Utils::FilePath::fromString(includedFiles.at(0)).fileName(), _("mainwindow.h"));
|
||||
QCOMPARE(Utils::FilePath::fromString(includedFiles.at(1)).fileName(), _("ui_mainwindow.h"));
|
||||
QCOMPARE(includedFiles.at(0).fileName(), _("mainwindow.h"));
|
||||
QCOMPARE(includedFiles.at(1).fileName(), _("ui_mainwindow.h"));
|
||||
}
|
||||
|
||||
/// QTCREATORBUG-9828: Locator shows symbols of closed files
|
||||
@@ -999,8 +999,8 @@ void ModelManagerTest::testRenameIncludes()
|
||||
|
||||
const QDir workingDir(tmpDir.path());
|
||||
const QStringList fileNames = {"foo.h", "foo.cpp", "main.cpp"};
|
||||
const QString oldHeader(workingDir.filePath(_("foo.h")));
|
||||
const QString newHeader(workingDir.filePath(_("bar.h")));
|
||||
const FilePath oldHeader = FilePath::fromString(workingDir.filePath("foo.h"));
|
||||
const FilePath newHeader = FilePath::fromString(workingDir.filePath("bar.h"));
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
const MyTestDataDir testDir(_("testdata_project1"));
|
||||
|
||||
@@ -1019,20 +1019,24 @@ void ModelManagerTest::testRenameIncludes()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
CPlusPlus::Snapshot snapshot = modelManager->snapshot();
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>{oldHeader});
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles)) {
|
||||
QCOMPARE(snapshot.allIncludesForDocument(FilePath::fromString(sourceFile)),
|
||||
QSet<FilePath>{oldHeader});
|
||||
}
|
||||
|
||||
// Renaming the header
|
||||
QVERIFY(Core::FileUtils::renameFile(Utils::FilePath::fromString(oldHeader),
|
||||
Utils::FilePath::fromString(newHeader),
|
||||
QVERIFY(Core::FileUtils::renameFile(oldHeader,
|
||||
newHeader,
|
||||
Core::HandleIncludeGuards::Yes));
|
||||
|
||||
// Update the c++ model manager again and check for the new includes
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
snapshot = modelManager->snapshot();
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>{newHeader});
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles)) {
|
||||
QCOMPARE(snapshot.allIncludesForDocument(FilePath::fromString(sourceFile)),
|
||||
QSet<FilePath>{newHeader});
|
||||
}
|
||||
}
|
||||
|
||||
void ModelManagerTest::testRenameIncludesInEditor()
|
||||
@@ -1047,8 +1051,8 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
|
||||
const QDir workingDir(tmpDir.path());
|
||||
const QStringList fileNames = {"baz.h", "baz2.h", "baz3.h", "foo.h", "foo.cpp", "main.cpp"};
|
||||
const QString headerWithPragmaOnce(workingDir.filePath(_("foo.h")));
|
||||
const QString renamedHeaderWithPragmaOnce(workingDir.filePath(_("bar.h")));
|
||||
const FilePath headerWithPragmaOnce = FilePath::fromString(workingDir.filePath("foo.h"));
|
||||
const FilePath renamedHeaderWithPragmaOnce = FilePath::fromString(workingDir.filePath("bar.h"));
|
||||
const QString headerWithNormalGuard(workingDir.filePath(_("baz.h")));
|
||||
const QString renamedHeaderWithNormalGuard(workingDir.filePath(_("foobar2000.h")));
|
||||
const QString headerWithUnderscoredGuard(workingDir.filePath(_("baz2.h")));
|
||||
@@ -1077,8 +1081,10 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
CPlusPlus::Snapshot snapshot = modelManager->snapshot();
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>{headerWithPragmaOnce});
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles)) {
|
||||
QCOMPARE(snapshot.allIncludesForDocument(FilePath::fromString(sourceFile)),
|
||||
QSet<FilePath>{headerWithPragmaOnce});
|
||||
}
|
||||
|
||||
// Open a file in the editor
|
||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
||||
@@ -1093,8 +1099,8 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
QVERIFY(modelManager->workingCopy().contains(mainFile));
|
||||
|
||||
// Test the renaming of a header file where a pragma once guard is present
|
||||
QVERIFY(Core::FileUtils::renameFile(Utils::FilePath::fromString(headerWithPragmaOnce),
|
||||
Utils::FilePath::fromString(renamedHeaderWithPragmaOnce),
|
||||
QVERIFY(Core::FileUtils::renameFile(headerWithPragmaOnce,
|
||||
renamedHeaderWithPragmaOnce,
|
||||
Core::HandleIncludeGuards::Yes));
|
||||
|
||||
// Test the renaming the header with include guard:
|
||||
@@ -1155,8 +1161,10 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
snapshot = modelManager->snapshot();
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>{renamedHeaderWithPragmaOnce});
|
||||
for (const QString &sourceFile : std::as_const(sourceFiles)) {
|
||||
QCOMPARE(snapshot.allIncludesForDocument(FilePath::fromString(sourceFile)),
|
||||
QSet<FilePath>{renamedHeaderWithPragmaOnce});
|
||||
}
|
||||
}
|
||||
|
||||
void ModelManagerTest::testDocumentsAndRevisions()
|
||||
|
@@ -346,9 +346,9 @@ static ClassDocumentPtrPair
|
||||
if (maxIncludeDepth) {
|
||||
// Check the includes
|
||||
const unsigned recursionMaxIncludeDepth = maxIncludeDepth - 1u;
|
||||
const auto includedFiles = doc->includedFiles();
|
||||
for (const QString &include : includedFiles) {
|
||||
const Snapshot::const_iterator it = docTable.find(FilePath::fromString(include));
|
||||
const FilePaths includedFiles = doc->includedFiles();
|
||||
for (const FilePath &include : includedFiles) {
|
||||
const Snapshot::const_iterator it = docTable.find(include);
|
||||
if (it != docTable.end()) {
|
||||
const Document::Ptr &includeDoc = it.value();
|
||||
LookupContext context(includeDoc, docTable);
|
||||
|
Reference in New Issue
Block a user