CppEditor: Remove Snapshot::remove(QString) overload

... and fix fallout.

Change-Id: Ibbf865c3e4158fc98bb9b5372ce0633807b85576
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
hjk
2022-11-23 18:29:50 +01:00
parent 3694d00dce
commit 03a91f9f98
16 changed files with 53 additions and 58 deletions

View File

@@ -381,8 +381,6 @@ public:
void insert(Document::Ptr doc); // ### remove void insert(Document::Ptr doc); // ### remove
void remove(const Utils::FilePath &fileName); // ### remove void remove(const Utils::FilePath &fileName); // ### remove
void remove(const QString &fileName)
{ remove(Utils::FilePath::fromString(fileName)); }
const_iterator begin() const { return _documents.begin(); } const_iterator begin() const { return _documents.begin(); }
const_iterator end() const { return _documents.end(); } const_iterator end() const { return _documents.end(); }

View File

@@ -8,6 +8,8 @@
#include "cppprojectpartchooser.h" #include "cppprojectpartchooser.h"
#include "editordocumenthandle.h" #include "editordocumenthandle.h"
using namespace Utils;
namespace CppEditor { namespace CppEditor {
/*! /*!
@@ -29,7 +31,7 @@ namespace CppEditor {
\endlist \endlist
*/ */
BaseEditorDocumentParser::BaseEditorDocumentParser(const QString &filePath) BaseEditorDocumentParser::BaseEditorDocumentParser(const FilePath &filePath)
: m_filePath(filePath) : m_filePath(filePath)
{ {
static int meta = qRegisterMetaType<ProjectPartInfo>("ProjectPartInfo"); static int meta = qRegisterMetaType<ProjectPartInfo>("ProjectPartInfo");
@@ -38,7 +40,7 @@ BaseEditorDocumentParser::BaseEditorDocumentParser(const QString &filePath)
BaseEditorDocumentParser::~BaseEditorDocumentParser() = default; BaseEditorDocumentParser::~BaseEditorDocumentParser() = default;
QString BaseEditorDocumentParser::filePath() const const FilePath &BaseEditorDocumentParser::filePath() const
{ {
return m_filePath; return m_filePath;
} }

View File

@@ -58,10 +58,10 @@ public:
}; };
public: public:
BaseEditorDocumentParser(const QString &filePath); BaseEditorDocumentParser(const Utils::FilePath &filePath);
~BaseEditorDocumentParser() override; ~BaseEditorDocumentParser() override;
QString filePath() const; const Utils::FilePath &filePath() const;
Configuration configuration() const; Configuration configuration() const;
void setConfiguration(const Configuration &configuration); void setConfiguration(const Configuration &configuration);
@@ -94,10 +94,10 @@ private:
virtual void updateImpl(const QFutureInterface<void> &future, virtual void updateImpl(const QFutureInterface<void> &future,
const UpdateParams &updateParams) = 0; const UpdateParams &updateParams) = 0;
const QString m_filePath; const Utils::FilePath m_filePath;
Configuration m_configuration; Configuration m_configuration;
State m_state; State m_state;
mutable QMutex m_updateIsRunning; mutable QMutex m_updateIsRunning;
}; };
} // namespace CppEditor } // CppEditor

View File

@@ -69,7 +69,7 @@ void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
} }
parser->update(future, updateParams); parser->update(future, updateParams);
CppModelManager::instance()->finishedRefreshingSourceFiles({parser->filePath()}); CppModelManager::instance()->finishedRefreshingSourceFiles({parser->filePath().toString()});
future.setProgressValue(1); future.setProgressValue(1);
} }

View File

@@ -31,7 +31,7 @@ static QByteArray overwrittenToolchainDefines(const ProjectPart &projectPart)
return defines; return defines;
} }
BuiltinEditorDocumentParser::BuiltinEditorDocumentParser(const QString &filePath, BuiltinEditorDocumentParser::BuiltinEditorDocumentParser(const FilePath &filePath,
int fileSizeLimitInMb) int fileSizeLimitInMb)
: BaseEditorDocumentParser(filePath) : BaseEditorDocumentParser(filePath)
, m_fileSizeLimitInMb(fileSizeLimitInMb) , m_fileSizeLimitInMb(fileSizeLimitInMb)
@@ -62,7 +62,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
QString projectConfigFile; QString projectConfigFile;
LanguageFeatures features = LanguageFeatures::defaultFeatures(); LanguageFeatures features = LanguageFeatures::defaultFeatures();
baseState.projectPartInfo = determineProjectPart(filePath(), baseState.projectPartInfo = determineProjectPart(filePath().toString(),
baseConfig.preferredProjectPartId, baseConfig.preferredProjectPartId,
baseState.projectPartInfo, baseState.projectPartInfo,
updateParams.activeProject, updateParams.activeProject,
@@ -166,7 +166,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
state.snapshot.remove(filePath()); state.snapshot.remove(filePath());
Internal::CppSourceProcessor sourceProcessor(state.snapshot, [&](const Document::Ptr &doc) { Internal::CppSourceProcessor sourceProcessor(state.snapshot, [&](const Document::Ptr &doc) {
const bool isInEditor = doc->filePath().toString() == filePath(); const bool isInEditor = doc->filePath() == filePath();
Document::Ptr otherDoc = modelManager->document(doc->filePath()); Document::Ptr otherDoc = modelManager->document(doc->filePath());
unsigned newRev = otherDoc.isNull() ? 1U : otherDoc->revision() + 1; unsigned newRev = otherDoc.isNull() ? 1U : otherDoc->revision() + 1;
if (isInEditor) if (isInEditor)
@@ -193,12 +193,12 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
sourceProcessor.run(precompiledHeader); sourceProcessor.run(precompiledHeader);
} }
if (!baseState.editorDefines.isEmpty()) if (!baseState.editorDefines.isEmpty())
sourceProcessor.run(CppModelManager::editorConfigurationFileName()); sourceProcessor.run(CppModelManager::editorConfigurationFileName().path());
QStringList includedFiles = state.includedFiles; QStringList includedFiles = state.includedFiles;
if (baseConfig.usePrecompiledHeaders) if (baseConfig.usePrecompiledHeaders)
includedFiles << state.precompiledHeaders; includedFiles << state.precompiledHeaders;
includedFiles.removeDuplicates(); includedFiles.removeDuplicates();
sourceProcessor.run(filePath(), includedFiles); sourceProcessor.run(filePath().toString(), includedFiles);
state.snapshot = sourceProcessor.snapshot(); state.snapshot = sourceProcessor.snapshot();
Snapshot newSnapshot = state.snapshot.simplified(state.snapshot.document(filePath())); Snapshot newSnapshot = state.snapshot.simplified(state.snapshot.document(filePath()));
for (Snapshot::const_iterator i = state.snapshot.begin(), ei = state.snapshot.end(); i != ei; ++i) { for (Snapshot::const_iterator i = state.snapshot.begin(), ei = state.snapshot.end(); i != ei; ++i) {
@@ -253,7 +253,7 @@ void BuiltinEditorDocumentParser::addFileAndDependencies(Snapshot *snapshot,
QTC_ASSERT(snapshot, return); QTC_ASSERT(snapshot, return);
toRemove->insert(fileName); toRemove->insert(fileName);
if (fileName != Utils::FilePath::fromString(filePath())) { if (fileName != filePath()) {
Utils::FilePaths deps = snapshot->filesDependingOn(fileName); Utils::FilePaths deps = snapshot->filesDependingOn(fileName);
toRemove->unite(Utils::toSet(deps)); toRemove->unite(Utils::toSet(deps));
} }

View File

@@ -17,7 +17,7 @@ class CPPEDITOR_EXPORT BuiltinEditorDocumentParser : public BaseEditorDocumentPa
Q_OBJECT Q_OBJECT
public: public:
BuiltinEditorDocumentParser(const QString &filePath, int fileSizeLimitInMb = -1); BuiltinEditorDocumentParser(const Utils::FilePath &filePath, int fileSizeLimitInMb = -1);
bool releaseSourceAndAST() const; bool releaseSourceAndAST() const;
void setReleaseSourceAndAST(bool release); void setReleaseSourceAndAST(bool release);

View File

@@ -137,8 +137,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(TextEditor::TextDocument *document) BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(TextEditor::TextDocument *document)
: BaseEditorDocumentProcessor(document->document(), document->filePath()) : BaseEditorDocumentProcessor(document->document(), document->filePath())
, m_parser(new BuiltinEditorDocumentParser(document->filePath().toString(), , m_parser(new BuiltinEditorDocumentParser(document->filePath(), indexerFileSizeLimitInMb()))
indexerFileSizeLimitInMb()))
, m_codeWarningsUpdated(false) , m_codeWarningsUpdated(false)
, m_semanticHighlighter(new SemanticHighlighter(document)) , m_semanticHighlighter(new SemanticHighlighter(document))
{ {

View File

@@ -135,7 +135,7 @@ void indexFindErrors(QFutureInterface<void> &indexingFuture,
qDebug("FindErrorsIndexing: \"%s\"", qPrintable(file)); qDebug("FindErrorsIndexing: \"%s\"", qPrintable(file));
// Parse the file as precisely as possible // Parse the file as precisely as possible
BuiltinEditorDocumentParser parser(file); BuiltinEditorDocumentParser parser(FilePath::fromString(file));
parser.setReleaseSourceAndAST(false); parser.setReleaseSourceAndAST(false);
parser.update({CppModelManager::instance()->workingCopy(), nullptr, parser.update({CppModelManager::instance()->workingCopy(), nullptr,
Utils::Language::Cxx, false}); Utils::Language::Cxx, false});
@@ -171,7 +171,7 @@ void index(QFutureInterface<void> &indexingFuture,
classifyFiles(params.sourceFiles, &headers, &sources); classifyFiles(params.sourceFiles, &headers, &sources);
for (const QString &file : std::as_const(params.sourceFiles)) for (const QString &file : std::as_const(params.sourceFiles))
sourceProcessor->removeFromCache(file); sourceProcessor->removeFromCache(FilePath::fromString(file));
const int sourceCount = sources.size(); const int sourceCount = sources.size();
QStringList files = sources + headers; QStringList files = sources + headers;

View File

@@ -648,7 +648,7 @@ void FollowSymbolUnderCursor::findLink(
return processLinkCallback(link); //already on definition! return processLinkCallback(link); //already on definition!
} else if (const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1)) { } else if (const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1)) {
const FilePath filePath = use->macro().filePath(); const FilePath filePath = use->macro().filePath();
if (filePath.path() == CppModelManager::editorConfigurationFileName()) { if (filePath.path() == CppModelManager::editorConfigurationFileName().path()) {
editorWidget->showPreProcessorWidget(); editorWidget->showPreProcessorWidget();
} else if (filePath.path() != CppModelManager::configurationFileName().path()) { } else if (filePath.path() != CppModelManager::configurationFileName().path()) {
const Macro &macro = use->macro(); const Macro &macro = use->macro();

View File

@@ -304,9 +304,10 @@ CppSourceProcessor *CppModelManager::createSourceProcessor()
}); });
} }
QString CppModelManager::editorConfigurationFileName() const FilePath &CppModelManager::editorConfigurationFileName()
{ {
return QLatin1String("<per-editor-defines>"); static const FilePath config = FilePath::fromPathPart(u"<per-editor-defines>");
return config;
} }
ModelManagerSupport *CppModelManager::modelManagerSupport(Backend backend) const ModelManagerSupport *CppModelManager::modelManagerSupport(Backend backend) const
@@ -1309,7 +1310,7 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
FilePath::fromString(cxxFile.path)); FilePath::fromString(cxxFile.path));
for (const FilePath &filePath : filePaths) for (const FilePath &filePath : filePaths)
d->m_snapshot.remove(filePath); d->m_snapshot.remove(filePath);
d->m_snapshot.remove(cxxFile.path); d->m_snapshot.remove(FilePath::fromString(cxxFile.path));
} }
} }
} }
@@ -1325,7 +1326,7 @@ void CppModelManager::removeFilesFromSnapshot(const QSet<QString> &filesToRemove
{ {
QMutexLocker snapshotLocker(&d->m_snapshotMutex); QMutexLocker snapshotLocker(&d->m_snapshotMutex);
for (const QString &file : filesToRemove) for (const QString &file : filesToRemove)
d->m_snapshot.remove(file); d->m_snapshot.remove(FilePath::fromString(file));
} }
class ProjectInfoComparer class ProjectInfoComparer

View File

@@ -211,7 +211,7 @@ public:
static Internal::CppSourceProcessor *createSourceProcessor(); static Internal::CppSourceProcessor *createSourceProcessor();
static const Utils::FilePath &configurationFileName(); static const Utils::FilePath &configurationFileName();
static QString editorConfigurationFileName(); static const Utils::FilePath &editorConfigurationFileName();
void setLocatorFilter(std::unique_ptr<Core::ILocatorFilter> &&filter); void setLocatorFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);
void setClassesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter); void setClassesFilter(std::unique_ptr<Core::ILocatorFilter> &&filter);

View File

@@ -1059,7 +1059,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
const QString renamedHeaderWithUnderscoredGuard(workingDir.filePath(_("foobar4000.h"))); const QString renamedHeaderWithUnderscoredGuard(workingDir.filePath(_("foobar4000.h")));
const QString headerWithMalformedGuard(workingDir.filePath(_("baz3.h"))); const QString headerWithMalformedGuard(workingDir.filePath(_("baz3.h")));
const QString renamedHeaderWithMalformedGuard(workingDir.filePath(_("foobar5000.h"))); const QString renamedHeaderWithMalformedGuard(workingDir.filePath(_("foobar5000.h")));
const QString mainFile(workingDir.filePath(_("main.cpp"))); const FilePath mainFile = FilePath::fromString(workingDir.filePath("main.cpp"));
CppModelManager *modelManager = CppModelManager::instance(); CppModelManager *modelManager = CppModelManager::instance();
const MyTestDataDir testDir(_("testdata_project1")); const MyTestDataDir testDir(_("testdata_project1"));
@@ -1088,7 +1088,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
// Open a file in the editor // Open a file in the editor
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0); QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(Utils::FilePath::fromString(mainFile)); Core::IEditor *editor = Core::EditorManager::openEditor(mainFile);
QVERIFY(editor); QVERIFY(editor);
EditorCloser editorCloser(editor); EditorCloser editorCloser(editor);
Utils::ExecuteOnDestruction saveAllFiles([](){ Utils::ExecuteOnDestruction saveAllFiles([](){
@@ -1157,7 +1157,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
QCOMPARE(renamedHeaderContents, originalMalformedGuardContents); QCOMPARE(renamedHeaderContents, originalMalformedGuardContents);
// Update the c++ model manager again and check for the new includes // Update the c++ model manager again and check for the new includes
TestCase::waitForProcessedEditorDocument(mainFile); TestCase::waitForProcessedEditorDocument(mainFile.toString());
modelManager->updateSourceFiles(sourceFiles).waitForFinished(); modelManager->updateSourceFiles(sourceFiles).waitForFinished();
QCoreApplication::processEvents(); QCoreApplication::processEvents();
snapshot = modelManager->snapshot(); snapshot = modelManager->snapshot();

View File

@@ -170,9 +170,9 @@ void CppSourceProcessor::run(const QString &fileName,
sourceNeeded(0, fileName, IncludeGlobal, initialIncludes); sourceNeeded(0, fileName, IncludeGlobal, initialIncludes);
} }
void CppSourceProcessor::removeFromCache(const QString &fileName) void CppSourceProcessor::removeFromCache(const FilePath &filePath)
{ {
m_snapshot.remove(fileName); m_snapshot.remove(filePath);
} }
void CppSourceProcessor::resetEnvironment() void CppSourceProcessor::resetEnvironment()
@@ -213,7 +213,7 @@ bool CppSourceProcessor::getFileContents(const FilePath &absoluteFilePath,
return true; return true;
} }
bool CppSourceProcessor::checkFile(const QString &absoluteFilePath) const bool CppSourceProcessor::checkFile(const FilePath &absoluteFilePath) const
{ {
if (absoluteFilePath.isEmpty() if (absoluteFilePath.isEmpty()
|| m_included.contains(absoluteFilePath) || m_included.contains(absoluteFilePath)
@@ -221,8 +221,7 @@ bool CppSourceProcessor::checkFile(const QString &absoluteFilePath) const
return true; return true;
} }
const QFileInfo fileInfo(absoluteFilePath); return absoluteFilePath.isReadableFile();
return fileInfo.isFile() && fileInfo.isReadable();
} }
QString CppSourceProcessor::cleanPath(const QString &path) QString CppSourceProcessor::cleanPath(const QString &path)
@@ -240,14 +239,15 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ
if (isInjectedFile(fileName)) if (isInjectedFile(fileName))
return fileName; return fileName;
if (QFileInfo(fileName).isAbsolute()) const FilePath filePath = FilePath::fromString(fileName);
return checkFile(fileName) ? fileName : QString(); if (filePath.isAbsolutePath())
return checkFile(filePath) ? fileName : QString();
if (m_currentDoc) { if (m_currentDoc) {
if (type == IncludeLocal) { if (type == IncludeLocal) {
const QFileInfo currentFileInfo = m_currentDoc->filePath().toFileInfo(); const QFileInfo currentFileInfo = m_currentDoc->filePath().toFileInfo();
const QString path = cleanPath(currentFileInfo.absolutePath()) + fileName; const QString path = cleanPath(currentFileInfo.absolutePath()) + fileName;
if (checkFile(path)) if (checkFile(FilePath::fromString(path)))
return path; return path;
// Fall through! "16.2 Source file inclusion" from the standard states to continue // Fall through! "16.2 Source file inclusion" from the standard states to continue
// searching as if this would be a global include. // searching as if this would be a global include.
@@ -291,7 +291,8 @@ QString CppSourceProcessor::resolveFile_helper(const QString &fileName,
} else { } else {
path = headerPathsIt->path + fileName; path = headerPathsIt->path + fileName;
} }
if (m_workingCopy.contains(path) || checkFile(path)) const FilePath filePath = FilePath::fromString(path);
if (m_workingCopy.contains(filePath) || checkFile(filePath))
return path; return path;
} }
} }
@@ -386,7 +387,7 @@ void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
if (Document::Ptr includedDoc = m_snapshot.document(includedFile)) if (Document::Ptr includedDoc = m_snapshot.document(includedFile))
mergeEnvironment(includedDoc); mergeEnvironment(includedDoc);
else if (!m_included.contains(includedFile)) else if (!m_included.contains(FilePath::fromString(includedFile)))
run(includedFile); run(includedFile);
} }
@@ -421,10 +422,10 @@ void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, Include
return; return;
} }
} }
if (m_included.contains(absoluteFileName)) if (m_included.contains(absoluteFilePath))
return; // We've already seen this file. return; // We've already seen this file.
if (!isInjectedFile(absoluteFileName)) if (!isInjectedFile(absoluteFileName))
m_included.insert(absoluteFileName); m_included.insert(absoluteFilePath);
// Already in snapshot? Use it! // Already in snapshot? Use it!
if (Document::Ptr document = m_snapshot.document(absoluteFileName)) { if (Document::Ptr document = m_snapshot.document(absoluteFileName)) {
@@ -451,7 +452,7 @@ void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, Include
document->setEditorRevision(editorRevision); document->setEditorRevision(editorRevision);
document->setLanguageFeatures(m_languageFeatures); document->setLanguageFeatures(m_languageFeatures);
for (const QString &include : initialIncludes) { for (const QString &include : initialIncludes) {
m_included.insert(include); m_included.insert(FilePath::fromString(include));
Document::Include inc(include, include, 0, IncludeLocal); Document::Include inc(include, include, 0, IncludeLocal);
document->addIncludeFile(inc); document->addIncludeFile(inc);
} }

View File

@@ -46,7 +46,7 @@ public:
void setTodo(const QSet<QString> &files); void setTodo(const QSet<QString> &files);
void run(const QString &fileName, const QStringList &initialIncludes = QStringList()); void run(const QString &fileName, const QStringList &initialIncludes = QStringList());
void removeFromCache(const QString &fileName); void removeFromCache(const Utils::FilePath &filePath);
void resetEnvironment(); void resetEnvironment();
CPlusPlus::Snapshot snapshot() const { return m_snapshot; } CPlusPlus::Snapshot snapshot() const { return m_snapshot; }
@@ -61,7 +61,7 @@ private:
bool getFileContents(const Utils::FilePath &absoluteFilePath, QByteArray *contents, bool getFileContents(const Utils::FilePath &absoluteFilePath, QByteArray *contents,
unsigned *revision) const; unsigned *revision) const;
bool checkFile(const QString &absoluteFilePath) const; bool checkFile(const Utils::FilePath &absoluteFilePath) const;
QString resolveFile(const QString &fileName, IncludeType type); QString resolveFile(const QString &fileName, IncludeType type);
QString resolveFile_helper(const QString &fileName, QString resolveFile_helper(const QString &fileName,
ProjectExplorer::HeaderPaths::Iterator headerPathsIt); ProjectExplorer::HeaderPaths::Iterator headerPathsIt);
@@ -95,7 +95,7 @@ private:
ProjectExplorer::HeaderPaths m_headerPaths; ProjectExplorer::HeaderPaths m_headerPaths;
CPlusPlus::LanguageFeatures m_languageFeatures; CPlusPlus::LanguageFeatures m_languageFeatures;
WorkingCopy m_workingCopy; WorkingCopy m_workingCopy;
QSet<QString> m_included; QSet<Utils::FilePath> m_included;
CPlusPlus::Document::Ptr m_currentDoc; CPlusPlus::Document::Ptr m_currentDoc;
QSet<QString> m_todo; QSet<QString> m_todo;
QSet<QString> m_processed; QSet<QString> m_processed;
@@ -104,4 +104,4 @@ private:
QTextCodec *m_defaultCodec; QTextCodec *m_defaultCodec;
}; };
} // namespace CppEditor::Internal } // CppEditor::Internal

View File

@@ -18,15 +18,9 @@ class CPPEDITOR_EXPORT WorkingCopy
public: public:
WorkingCopy(); WorkingCopy();
void insert(const QString &fileName, const QByteArray &source, unsigned revision = 0)
{ insert(Utils::FilePath::fromString(fileName), source, revision); }
void insert(const Utils::FilePath &fileName, const QByteArray &source, unsigned revision = 0) void insert(const Utils::FilePath &fileName, const QByteArray &source, unsigned revision = 0)
{ _elements.insert(fileName, {source, revision}); } { _elements.insert(fileName, {source, revision}); }
bool contains(const QString &fileName) const
{ return contains(Utils::FilePath::fromString(fileName)); }
bool contains(const Utils::FilePath &fileName) const bool contains(const Utils::FilePath &fileName) const
{ return _elements.contains(fileName); } { return _elements.contains(fileName); }

View File

@@ -130,7 +130,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
QVERIFY(waitUntilAProjectIsLoaded()); QVERIFY(waitUntilAProjectIsLoaded());
// Collect files to process // Collect files to process
QStringList filesToOpen; FilePaths filesToOpen;
QList<QPointer<ProjectExplorer::Project> > projects; QList<QPointer<ProjectExplorer::Project> > projects;
const QList<ProjectInfo::ConstPtr> projectInfos = m_modelManager->projectInfos(); const QList<ProjectInfo::ConstPtr> projectInfos = m_modelManager->projectInfos();
@@ -139,15 +139,15 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
<< info->sourceFiles().size(); << info->sourceFiles().size();
const QSet<QString> sourceFiles = info->sourceFiles(); const QSet<QString> sourceFiles = info->sourceFiles();
for (const QString &sourceFile : sourceFiles) for (const QString &sourceFile : sourceFiles)
filesToOpen << sourceFile; filesToOpen << FilePath::fromString(sourceFile);
} }
Utils::sort(filesToOpen); Utils::sort(filesToOpen);
// Process all files from the projects // Process all files from the projects
for (const QString &filePath : std::as_const(filesToOpen)) { for (const FilePath &filePath : std::as_const(filesToOpen)) {
// Skip e.g. "<configuration>" // Skip e.g. "<configuration>"
if (!QFileInfo::exists(filePath)) if (!filePath.exists())
continue; continue;
qDebug() << " --" << filePath; qDebug() << " --" << filePath;
@@ -159,7 +159,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
QCOMPARE(DocumentModel::openedDocuments().size(), 0); QCOMPARE(DocumentModel::openedDocuments().size(), 0);
BaseTextEditor *editor; BaseTextEditor *editor;
CppEditorWidget *editorWidget; CppEditorWidget *editorWidget;
QVERIFY(openCppEditor(FilePath::fromString(filePath), &editor, &editorWidget)); QVERIFY(openCppEditor(filePath, &editor, &editorWidget));
QCOMPARE(DocumentModel::openedDocuments().size(), 1); QCOMPARE(DocumentModel::openedDocuments().size(), 1);
QVERIFY(m_modelManager->isCppEditor(editor)); QVERIFY(m_modelManager->isCppEditor(editor));
@@ -176,7 +176,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
const Snapshot snapshot = globalSnapshot(); const Snapshot snapshot = globalSnapshot();
Document::Ptr document = snapshot.preprocessedDocument( Document::Ptr document = snapshot.preprocessedDocument(
editorWidget->document()->toPlainText().toUtf8(), Utils::FilePath::fromString(filePath)); editorWidget->document()->toPlainText().toUtf8(), filePath);
QVERIFY(document); QVERIFY(document);
document->parse(); document->parse();
TranslationUnit *translationUnit = document->translationUnit(); TranslationUnit *translationUnit = document->translationUnit();