forked from qt-creator/qt-creator
C++: Change QStringList to QSet<QString> to prevent conversions.
This eliminates a bunch of list->set->list conversions. Especially the ProjectInfo::appendProjectPart takes lots of time converting for every part added. Change-Id: Ib3c8cd4b0ad6c012ccbeed12ebedd46b9b6cca95 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -49,7 +49,7 @@ AbstractEditorSupport::~AbstractEditorSupport()
|
||||
void AbstractEditorSupport::updateDocument()
|
||||
{
|
||||
++m_revision;
|
||||
m_modelmanager->updateSourceFiles(QStringList(fileName()));
|
||||
m_modelmanager->updateSourceFiles(QSet<QString>() << fileName());
|
||||
}
|
||||
|
||||
QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelManager,
|
||||
|
||||
@@ -127,7 +127,7 @@ void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
|
||||
|
||||
parser->update(workingCopy);
|
||||
CppModelManagerInterface::instance()
|
||||
->finishedRefreshingSourceFiles(QStringList(parser->filePath()));
|
||||
->finishedRefreshingSourceFiles(QSet<QString>() << parser->filePath());
|
||||
|
||||
future.setProgressValue(1);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
int revision;
|
||||
ProjectPart::HeaderPaths headerPaths;
|
||||
WorkingCopy workingCopy;
|
||||
QStringList sourceFiles;
|
||||
QSet<QString> sourceFiles;
|
||||
};
|
||||
|
||||
class WriteTaskFileForDiagnostics
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
int m_processedDiagnostics;
|
||||
};
|
||||
|
||||
void classifyFiles(const QStringList &files, QStringList *headers, QStringList *sources)
|
||||
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
||||
{
|
||||
foreach (const QString &file, files) {
|
||||
if (ProjectFile::isSource(ProjectFile::classify(file)))
|
||||
@@ -145,11 +145,11 @@ void classifyFiles(const QStringList &files, QStringList *headers, QStringList *
|
||||
|
||||
void indexFindErrors(QFutureInterface<void> &future, const ParseParams params)
|
||||
{
|
||||
QStringList files = params.sourceFiles;
|
||||
files.sort();
|
||||
QStringList sources, headers;
|
||||
classifyFiles(files, &headers, &sources);
|
||||
files = sources + headers;
|
||||
classifyFiles(params.sourceFiles, &headers, &sources);
|
||||
sources.sort();
|
||||
headers.sort();
|
||||
QStringList files = sources + headers;
|
||||
|
||||
WriteTaskFileForDiagnostics taskFileWriter;
|
||||
QElapsedTimer timer;
|
||||
@@ -196,20 +196,18 @@ void index(QFutureInterface<void> &future, const ParseParams params)
|
||||
sourceProcessor->setHeaderPaths(params.headerPaths);
|
||||
sourceProcessor->setWorkingCopy(params.workingCopy);
|
||||
|
||||
QStringList files = params.sourceFiles;
|
||||
|
||||
QStringList sources;
|
||||
QStringList headers;
|
||||
classifyFiles(files, &headers, &sources);
|
||||
classifyFiles(params.sourceFiles, &headers, &sources);
|
||||
|
||||
foreach (const QString &file, files)
|
||||
foreach (const QString &file, params.sourceFiles)
|
||||
sourceProcessor->removeFromCache(file);
|
||||
|
||||
const int sourceCount = sources.size();
|
||||
files = sources;
|
||||
files += headers;
|
||||
QStringList files = sources + headers;
|
||||
|
||||
sourceProcessor->setTodo(files);
|
||||
sourceProcessor->setTodo(files.toSet());
|
||||
|
||||
const QString conf = CppModelManagerInterface::configurationFileName();
|
||||
bool processingHeaders = false;
|
||||
@@ -250,7 +248,7 @@ void index(QFutureInterface<void> &future, const ParseParams params)
|
||||
|
||||
void parse(QFutureInterface<void> &future, const ParseParams params)
|
||||
{
|
||||
const QStringList files = params.sourceFiles;
|
||||
const QSet<QString> &files = params.sourceFiles;
|
||||
if (files.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -356,7 +354,7 @@ BuiltinIndexingSupport::BuiltinIndexingSupport()
|
||||
BuiltinIndexingSupport::~BuiltinIndexingSupport()
|
||||
{}
|
||||
|
||||
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sourceFiles,
|
||||
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QSet<QString> &sourceFiles,
|
||||
CppModelManagerInterface::ProgressNotificationMode mode)
|
||||
{
|
||||
CppModelManager *mgr = CppModelManager::instance();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
BuiltinIndexingSupport();
|
||||
~BuiltinIndexingSupport();
|
||||
|
||||
virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles,
|
||||
virtual QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles,
|
||||
CppModelManagerInterface::ProgressNotificationMode mode);
|
||||
virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
|
||||
QSet<QString> fileNames);
|
||||
|
||||
@@ -385,7 +385,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
||||
{
|
||||
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
|
||||
if (!fileNames.isEmpty()) {
|
||||
m_modelManager->updateSourceFiles(fileNames);
|
||||
m_modelManager->updateSourceFiles(fileNames.toSet());
|
||||
Core::SearchResultWindow::instance()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class CPPTOOLS_EXPORT CppIndexingSupport
|
||||
public:
|
||||
virtual ~CppIndexingSupport() = 0;
|
||||
|
||||
virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles,
|
||||
virtual QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles,
|
||||
CppModelManagerInterface::ProgressNotificationMode mode) = 0;
|
||||
virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
|
||||
QSet<QString> fileNames) = 0;
|
||||
|
||||
@@ -141,9 +141,9 @@ static const char pp_configuration[] =
|
||||
"#define __inline inline\n"
|
||||
"#define __forceinline inline\n";
|
||||
|
||||
QStringList CppModelManager::timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck)
|
||||
QSet<QString> CppModelManager::timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck)
|
||||
{
|
||||
QStringList sourceFiles;
|
||||
QSet<QString> sourceFiles;
|
||||
|
||||
foreach (const Document::Ptr doc, documentsToCheck) {
|
||||
const QDateTime lastModified = doc->lastModified();
|
||||
@@ -152,7 +152,7 @@ QStringList CppModelManager::timeStampModifiedFiles(const QList<Document::Ptr> &
|
||||
QFileInfo fileInfo(doc->fileName());
|
||||
|
||||
if (fileInfo.exists() && fileInfo.lastModified() != lastModified)
|
||||
sourceFiles.append(doc->fileName());
|
||||
sourceFiles.insert(doc->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +184,7 @@ void CppModelManager::updateModifiedSourceFiles()
|
||||
foreach (const Document::Ptr document, snapshot)
|
||||
documentsToCheck << document;
|
||||
|
||||
const QStringList filesToUpdate = timeStampModifiedFiles(documentsToCheck);
|
||||
updateSourceFiles(filesToUpdate);
|
||||
updateSourceFiles(timeStampModifiedFiles(documentsToCheck));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -224,7 +223,7 @@ CppModelManager::CppModelManager(QObject *parent)
|
||||
this, SIGNAL(globalSnapshotChanged()));
|
||||
connect(this, SIGNAL(aboutToRemoveFiles(QStringList)),
|
||||
this, SIGNAL(globalSnapshotChanged()));
|
||||
connect(this, SIGNAL(sourceFilesRefreshed(QStringList)),
|
||||
connect(this, SIGNAL(sourceFilesRefreshed(QSet<QString>)),
|
||||
this, SLOT(onSourceFilesRefreshed()));
|
||||
|
||||
m_findReferences = new CppFindReferences(this);
|
||||
@@ -505,7 +504,7 @@ QByteArray CppModelManager::codeModelConfiguration() const
|
||||
return QByteArray::fromRawData(pp_configuration, qstrlen(pp_configuration));
|
||||
}
|
||||
|
||||
QFuture<void> CppModelManager::updateSourceFiles(const QStringList &sourceFiles,
|
||||
QFuture<void> CppModelManager::updateSourceFiles(const QSet<QString> &sourceFiles,
|
||||
ProgressNotificationMode mode)
|
||||
{
|
||||
if (sourceFiles.isEmpty() || !m_indexerEnabled)
|
||||
@@ -565,9 +564,9 @@ public:
|
||||
ProjectInfoComparer(const ProjectInfo &oldProjectInfo,
|
||||
const ProjectInfo &newProjectInfo)
|
||||
: m_old(oldProjectInfo)
|
||||
, m_oldSourceFiles(oldProjectInfo.sourceFiles().toSet())
|
||||
, m_oldSourceFiles(oldProjectInfo.sourceFiles())
|
||||
, m_new(newProjectInfo)
|
||||
, m_newSourceFiles(newProjectInfo.sourceFiles().toSet())
|
||||
, m_newSourceFiles(newProjectInfo.sourceFiles())
|
||||
{}
|
||||
|
||||
bool definesChanged() const
|
||||
@@ -614,7 +613,7 @@ public:
|
||||
documentsToCheck << document;
|
||||
}
|
||||
|
||||
return CppModelManager::timeStampModifiedFiles(documentsToCheck).toSet();
|
||||
return CppModelManager::timeStampModifiedFiles(documentsToCheck);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -645,14 +644,14 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
|
||||
if (!newProjectInfo.isValid())
|
||||
return QFuture<void>();
|
||||
|
||||
QStringList filesToReindex;
|
||||
QSet<QString> filesToReindex;
|
||||
bool filesRemoved = false;
|
||||
|
||||
{ // Only hold the mutex for a limited scope, so the dumping afterwards does not deadlock.
|
||||
QMutexLocker projectLocker(&m_projectMutex);
|
||||
|
||||
ProjectExplorer::Project *project = newProjectInfo.project().data();
|
||||
const QStringList newSourceFiles = newProjectInfo.sourceFiles();
|
||||
const QSet<QString> newSourceFiles = newProjectInfo.sourceFiles();
|
||||
|
||||
// Check if we can avoid a full reindexing
|
||||
ProjectInfo oldProjectInfo = m_projectToProjectsInfo.value(project);
|
||||
@@ -664,7 +663,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
|
||||
// If the project configuration changed, do a full reindexing
|
||||
if (comparer.configurationChanged()) {
|
||||
removeProjectInfoFilesAndIncludesFromSnapshot(oldProjectInfo);
|
||||
filesToReindex << newSourceFiles;
|
||||
filesToReindex.unite(newSourceFiles);
|
||||
|
||||
// The "configuration file" includes all defines and therefore should be updated
|
||||
if (comparer.definesChanged()) {
|
||||
@@ -675,10 +674,10 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
|
||||
// Otherwise check for added and modified files
|
||||
} else {
|
||||
const QSet<QString> addedFiles = comparer.addedFiles();
|
||||
filesToReindex << addedFiles.toList();
|
||||
filesToReindex.unite(addedFiles);
|
||||
|
||||
const QSet<QString> modifiedFiles = comparer.timeStampModifiedFiles(snapshot());
|
||||
filesToReindex << modifiedFiles.toList();
|
||||
filesToReindex.unite(modifiedFiles);
|
||||
}
|
||||
|
||||
// Announce and purge the removed files from the snapshot
|
||||
@@ -691,7 +690,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
|
||||
|
||||
// A new project was opened/created, do a full indexing
|
||||
} else {
|
||||
filesToReindex << newSourceFiles;
|
||||
filesToReindex.unite(newSourceFiles);
|
||||
}
|
||||
|
||||
// Update Project/ProjectInfo and File/ProjectPart table
|
||||
@@ -872,7 +871,7 @@ void CppModelManager::GC()
|
||||
emit gcFinished();
|
||||
}
|
||||
|
||||
void CppModelManager::finishedRefreshingSourceFiles(const QStringList &files)
|
||||
void CppModelManager::finishedRefreshingSourceFiles(const QSet<QString> &files)
|
||||
{
|
||||
emit sourceFilesRefreshed(files);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
static CppModelManager *instance();
|
||||
|
||||
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles,
|
||||
virtual QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
|
||||
ProgressNotificationMode mode = ReservedProgressNotification);
|
||||
virtual WorkingCopy workingCopy() const;
|
||||
virtual QByteArray codeModelConfiguration() const;
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
virtual void findMacroUsages(const CPlusPlus::Macro ¯o);
|
||||
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement);
|
||||
|
||||
virtual void finishedRefreshingSourceFiles(const QStringList &files);
|
||||
virtual void finishedRefreshingSourceFiles(const QSet<QString> &files);
|
||||
|
||||
virtual void addModelManagerSupport(ModelManagerSupport *modelManagerSupport);
|
||||
virtual ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const;
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
|
||||
void enableGarbageCollector(bool enable);
|
||||
|
||||
static QStringList timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck);
|
||||
static QSet<QString> timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck);
|
||||
|
||||
static CppSourceProcessor *createSourceProcessor();
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ private:
|
||||
const QString &m_filePath;
|
||||
};
|
||||
|
||||
static QStringList updateProjectInfo(CppModelManager *modelManager, ModelManagerTestHelper *helper,
|
||||
static QSet<QString> updateProjectInfo(CppModelManager *modelManager, ModelManagerTestHelper *helper,
|
||||
const ProjectInfo &projectInfo)
|
||||
{
|
||||
helper->resetRefreshedSourceFiles();
|
||||
@@ -315,7 +315,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
|
||||
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
|
||||
pi.appendProjectPart(part);
|
||||
|
||||
QStringList refreshedFiles = updateProjectInfo(mm, &helper, pi);
|
||||
QSet<QString> refreshedFiles = updateProjectInfo(mm, &helper, pi);
|
||||
QCOMPARE(refreshedFiles.size(), 1);
|
||||
QVERIFY(refreshedFiles.contains(testCpp));
|
||||
CPlusPlus::Snapshot snapshot = mm->snapshot();
|
||||
@@ -375,7 +375,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
|
||||
mm->updateProjectInfo(pi);
|
||||
|
||||
CPlusPlus::Snapshot snapshot;
|
||||
QStringList refreshedFiles;
|
||||
QSet<QString> refreshedFiles;
|
||||
CPlusPlus::Document::Ptr document;
|
||||
|
||||
QByteArray defines = "#define FIRST_DEFINE";
|
||||
@@ -441,7 +441,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
|
||||
QFuture<void> firstFuture = mm->updateProjectInfo(pi);
|
||||
QVERIFY(firstFuture.isStarted() || firstFuture.isRunning());
|
||||
firstFuture.waitForFinished();
|
||||
const QStringList refreshedFiles = helper.waitForRefreshedSourceFiles();
|
||||
const QSet<QString> refreshedFiles = helper.waitForRefreshedSourceFiles();
|
||||
QCOMPARE(refreshedFiles.size(), 1);
|
||||
QVERIFY(refreshedFiles.contains(testCpp));
|
||||
|
||||
@@ -475,7 +475,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
|
||||
pi.appendProjectPart(part);
|
||||
|
||||
CPlusPlus::Snapshot snapshot;
|
||||
QStringList refreshedFiles;
|
||||
QSet<QString> refreshedFiles;
|
||||
|
||||
refreshedFiles = updateProjectInfo(mm, &helper, pi);
|
||||
|
||||
@@ -533,7 +533,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
|
||||
Document::Ptr document;
|
||||
CPlusPlus::Snapshot snapshot;
|
||||
QStringList refreshedFiles;
|
||||
QSet<QString> refreshedFiles;
|
||||
|
||||
refreshedFiles = updateProjectInfo(mm, &helper, pi);
|
||||
|
||||
@@ -608,7 +608,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
/// files of the first project.
|
||||
void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
|
||||
{
|
||||
QStringList refreshedFiles;
|
||||
QSet<QString> refreshedFiles;
|
||||
ModelManagerTestHelper helper;
|
||||
ProjectCreator project1(&helper);
|
||||
ProjectCreator project2(&helper);
|
||||
@@ -622,7 +622,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
|
||||
<< _("main.cpp"));
|
||||
|
||||
refreshedFiles = updateProjectInfo(mm, &helper, project1.projectInfo);
|
||||
QCOMPARE(refreshedFiles.toSet(), project1.projectFiles.toSet());
|
||||
QCOMPARE(refreshedFiles, project1.projectFiles.toSet());
|
||||
const int snapshotSizeAfterProject1 = mm->snapshot().size();
|
||||
|
||||
foreach (const QString &file, project1.projectFiles)
|
||||
@@ -636,7 +636,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
|
||||
<< _("main.cpp"));
|
||||
|
||||
refreshedFiles = updateProjectInfo(mm, &helper, project2.projectInfo);
|
||||
QCOMPARE(refreshedFiles.toSet(), project2.projectFiles.toSet());
|
||||
QCOMPARE(refreshedFiles, project2.projectFiles.toSet());
|
||||
|
||||
const int snapshotSizeAfterProject2 = mm->snapshot().size();
|
||||
QVERIFY(snapshotSizeAfterProject2 > snapshotSizeAfterProject1);
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement = QString()) = 0;
|
||||
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0;
|
||||
|
||||
virtual void finishedRefreshingSourceFiles(const QStringList &files) = 0;
|
||||
virtual void finishedRefreshingSourceFiles(const QSet<QString> &files) = 0;
|
||||
|
||||
virtual void addModelManagerSupport(ModelManagerSupport *modelManagerSupport) = 0;
|
||||
virtual ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const = 0;
|
||||
@@ -132,7 +132,7 @@ signals:
|
||||
void aboutToRemoveFiles(const QStringList &files);
|
||||
|
||||
void documentUpdated(CPlusPlus::Document::Ptr doc);
|
||||
void sourceFilesRefreshed(const QStringList &files);
|
||||
void sourceFilesRefreshed(const QSet<QString> &files);
|
||||
|
||||
/// \brief Emitted after updateProjectInfo function is called on the model-manager.
|
||||
///
|
||||
@@ -143,7 +143,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
// Documented in source file.
|
||||
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles,
|
||||
virtual QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
|
||||
ProgressNotificationMode mode = ReservedProgressNotification) = 0;
|
||||
|
||||
virtual void updateModifiedSourceFiles() = 0;
|
||||
|
||||
@@ -183,10 +183,8 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
|
||||
}
|
||||
|
||||
// Update source files
|
||||
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
|
||||
foreach (const ProjectFile &file, part->files)
|
||||
srcs.insert(file.path);
|
||||
m_sourceFiles = srcs.toList();
|
||||
m_sourceFiles.insert(file.path);
|
||||
|
||||
// Update defines
|
||||
if (!m_defines.isEmpty())
|
||||
@@ -213,7 +211,7 @@ const ProjectPart::HeaderPaths ProjectInfo::headerPaths() const
|
||||
return m_headerPaths;
|
||||
}
|
||||
|
||||
const QStringList ProjectInfo::sourceFiles() const
|
||||
const QSet<QString> ProjectInfo::sourceFiles() const
|
||||
{
|
||||
return m_sourceFiles;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
@@ -148,7 +149,7 @@ public:
|
||||
void clearProjectParts();
|
||||
|
||||
const ProjectPart::HeaderPaths headerPaths() const;
|
||||
const QStringList sourceFiles() const;
|
||||
const QSet<QString> sourceFiles() const;
|
||||
const QByteArray defines() const;
|
||||
|
||||
private:
|
||||
@@ -156,7 +157,7 @@ private:
|
||||
QList<ProjectPart::Ptr> m_projectParts;
|
||||
// The members below are (re)calculated from the project parts once a part is appended.
|
||||
ProjectPart::HeaderPaths m_headerPaths;
|
||||
QStringList m_sourceFiles;
|
||||
QSet<QString> m_sourceFiles;
|
||||
QByteArray m_defines;
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
virtual void fileChanged(const QString &fileName)
|
||||
{
|
||||
m_modelManager->updateSourceFiles(QStringList(fileName));
|
||||
m_modelManager->updateSourceFiles(QSet<QString>() << fileName);
|
||||
}
|
||||
|
||||
Snapshot m_snapshot;
|
||||
|
||||
@@ -174,8 +174,10 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPart::HeaderPath &framewo
|
||||
}
|
||||
}
|
||||
|
||||
void CppSourceProcessor::setTodo(const QStringList &files)
|
||||
{ m_todo = QSet<QString>::fromList(files); }
|
||||
void CppSourceProcessor::setTodo(const QSet<QString> &files)
|
||||
{
|
||||
m_todo = files;
|
||||
}
|
||||
|
||||
void CppSourceProcessor::run(const QString &fileName,
|
||||
const QStringList &initialIncludes)
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
void setRevision(unsigned revision);
|
||||
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
|
||||
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
|
||||
void setTodo(const QStringList &files);
|
||||
void setTodo(const QSet<QString> &files);
|
||||
|
||||
void run(const QString &fileName, const QStringList &initialIncludes = QStringList());
|
||||
void removeFromCache(const QString &fileName);
|
||||
|
||||
@@ -129,7 +129,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
|
||||
{
|
||||
const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h"));
|
||||
const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
|
||||
const QStringList sourceFiles = QStringList() << fileName1 << fileName2;
|
||||
const QSet<QString> sourceFiles = QSet<QString>() << fileName1 << fileName2;
|
||||
|
||||
// Create global snapshot (needed in BuiltinEditorDocumentParser)
|
||||
TestCase testCase;
|
||||
|
||||
@@ -139,8 +139,10 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
connect(VcsManager::instance(), SIGNAL(repositoryChanged(QString)),
|
||||
modelManager, SLOT(updateModifiedSourceFiles()));
|
||||
connect(DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)),
|
||||
modelManager, SLOT(updateSourceFiles(QStringList)));
|
||||
connect(DocumentManager::instance(), &DocumentManager::filesChangedInternally,
|
||||
[=](const QStringList &files) {
|
||||
modelManager->updateSourceFiles(files.toSet());
|
||||
});
|
||||
|
||||
CppLocatorData *locatorData = new CppLocatorData;
|
||||
connect(modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
|
||||
|
||||
@@ -45,7 +45,7 @@ static bool closeEditorsWithoutGarbageCollectorInvocation(const QList<Core::IEdi
|
||||
return closeEditorsSucceeded;
|
||||
}
|
||||
|
||||
static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QStringList &filePaths)
|
||||
static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QString> &filePaths)
|
||||
{
|
||||
foreach (const QString &filePath, filePaths) {
|
||||
if (!snapshot.contains(filePath)) {
|
||||
@@ -125,7 +125,7 @@ bool TestCase::garbageCollectGlobalSnapshot()
|
||||
return globalSnapshot().isEmpty();
|
||||
}
|
||||
|
||||
bool TestCase::parseFiles(const QStringList &filePaths)
|
||||
bool TestCase::parseFiles(const QSet<QString> &filePaths)
|
||||
{
|
||||
CppModelManagerInterface::instance()->updateSourceFiles(filePaths).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
@@ -143,7 +143,7 @@ bool TestCase::parseFiles(const QStringList &filePaths)
|
||||
|
||||
bool TestCase::parseFiles(const QString &filePath)
|
||||
{
|
||||
return parseFiles(QStringList(filePath));
|
||||
return parseFiles(QSet<QString>() << filePath);
|
||||
}
|
||||
|
||||
void TestCase::closeEditorAtEndOfTestCase(Core::IEditor *editor)
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
static bool closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor);
|
||||
|
||||
static bool parseFiles(const QString &filePath);
|
||||
static bool parseFiles(const QStringList &filePaths);
|
||||
static bool parseFiles(const QSet<QString> &filePaths);
|
||||
|
||||
static CPlusPlus::Snapshot globalSnapshot();
|
||||
static bool garbageCollectGlobalSnapshot();
|
||||
|
||||
@@ -55,9 +55,12 @@ ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) :
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
assert(mm);
|
||||
|
||||
connect(this, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), mm, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
|
||||
connect(this, SIGNAL(projectAdded(ProjectExplorer::Project*)), mm, SLOT(onProjectAdded(ProjectExplorer::Project*)));
|
||||
connect(mm, SIGNAL(sourceFilesRefreshed(QStringList)), this, SLOT(sourceFilesRefreshed(QStringList)));
|
||||
connect(this, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
|
||||
mm, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
|
||||
connect(this, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
||||
mm, SLOT(onProjectAdded(ProjectExplorer::Project*)));
|
||||
connect(mm, SIGNAL(sourceFilesRefreshed(QSet<QString>)),
|
||||
this, SLOT(sourceFilesRefreshed(QSet<QString>)));
|
||||
connect(mm, SIGNAL(gcFinished()), this, SLOT(gcFinished()));
|
||||
|
||||
cleanup();
|
||||
@@ -110,7 +113,7 @@ void ModelManagerTestHelper::resetRefreshedSourceFiles()
|
||||
m_refreshHappened = false;
|
||||
}
|
||||
|
||||
QStringList ModelManagerTestHelper::waitForRefreshedSourceFiles()
|
||||
QSet<QString> ModelManagerTestHelper::waitForRefreshedSourceFiles()
|
||||
{
|
||||
while (!m_refreshHappened)
|
||||
QCoreApplication::processEvents();
|
||||
@@ -126,7 +129,7 @@ void ModelManagerTestHelper::waitForFinishedGc()
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
void ModelManagerTestHelper::sourceFilesRefreshed(const QStringList &files)
|
||||
void ModelManagerTestHelper::sourceFilesRefreshed(const QSet<QString> &files)
|
||||
{
|
||||
m_lastRefreshedSourceFiles = files;
|
||||
m_refreshHappened = true;
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
Project *createProject(const QString &name);
|
||||
|
||||
void resetRefreshedSourceFiles();
|
||||
QStringList waitForRefreshedSourceFiles();
|
||||
QSet<QString> waitForRefreshedSourceFiles();
|
||||
void waitForFinishedGc();
|
||||
|
||||
signals:
|
||||
@@ -88,13 +88,13 @@ signals:
|
||||
void projectAdded(ProjectExplorer::Project*);
|
||||
|
||||
public slots:
|
||||
void sourceFilesRefreshed(const QStringList &files);
|
||||
void sourceFilesRefreshed(const QSet<QString> &files);
|
||||
void gcFinished();
|
||||
|
||||
private:
|
||||
bool m_gcFinished;
|
||||
bool m_refreshHappened;
|
||||
QStringList m_lastRefreshedSourceFiles;
|
||||
QSet<QString> m_lastRefreshedSourceFiles;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
QVERIFY(succeededSoFar());
|
||||
|
||||
// Write files
|
||||
QStringList filePaths;
|
||||
QSet<QString> filePaths;
|
||||
foreach (const Tests::TestDocument &document, documents) {
|
||||
QVERIFY(document.writeToDisk());
|
||||
filePaths << document.filePath();
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
const Snapshot snapshot = globalSnapshot();
|
||||
|
||||
// Get class for which to generate the hierarchy
|
||||
const Document::Ptr firstDocument = snapshot.document(filePaths.first());
|
||||
const Document::Ptr firstDocument = snapshot.document(documents.first().filePath());
|
||||
QVERIFY(firstDocument);
|
||||
QVERIFY(firstDocument->diagnosticMessages().isEmpty());
|
||||
Class *clazz = FindFirstClassInDocument()(firstDocument);
|
||||
|
||||
Reference in New Issue
Block a user