Skip to content
Snippets Groups Projects
Commit 5f7f6f87 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

CppTools: Remove some duplicate code


Change-Id: I83c0bbcf221fd163cd2514a9d23983b82e1f04fd
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 11845cd3
No related branches found
No related tags found
No related merge requests found
......@@ -472,15 +472,9 @@ void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot)
CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
{
QList<CppEditorSupport *> cppEditorSupports;
{
QMutexLocker locker(&m_cppEditorSupportsMutex);
cppEditorSupports = m_cppEditorSupports.values();
}
WorkingCopy workingCopy;
foreach (const CppEditorSupport *editorSupport, cppEditorSupports) {
foreach (const CppEditorSupport *editorSupport, cppEditorSupportList()) {
workingCopy.insert(editorSupport->fileName(), editorSupport->contents(),
editorSupport->editorRevision());
}
......@@ -548,6 +542,12 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
}
}
QList<CppEditorSupport *> CppModelManager::cppEditorSupportList() const
{
QMutexLocker locker(&m_cppEditorSupportsMutex);
return m_cppEditorSupports.values();
}
/// \brief Remove all given files from the snapshot.
void CppModelManager::removeFilesFromSnapshot(const QSet<QString> &filesToRemove)
{
......@@ -817,12 +817,7 @@ void CppModelManager::GC()
// Collect files of CppEditorSupport and AbstractEditorSupport.
QStringList filesInEditorSupports;
QList<CppEditorSupport *> cppEditorSupports;
{
QMutexLocker locker(&m_cppEditorSupportsMutex);
cppEditorSupports = m_cppEditorSupports.values();
}
foreach (const CppEditorSupport *cppEditorSupport, cppEditorSupports)
foreach (const CppEditorSupport *cppEditorSupport, cppEditorSupportList())
filesInEditorSupports << cppEditorSupport->fileName();
QSetIterator<AbstractEditorSupport *> jt(m_extraEditorSupports);
......@@ -928,14 +923,7 @@ bool CppModelManager::setExtraDiagnostics(const QString &fileName,
const QString &kind,
const QList<Document::DiagnosticMessage> &diagnostics)
{
QList<CppEditorSupport *> cppEditorSupports;
{
QMutexLocker locker(&m_cppEditorSupportsMutex);
cppEditorSupports = m_cppEditorSupports.values();
}
foreach (CppEditorSupport *editorSupport, cppEditorSupports) {
foreach (CppEditorSupport *editorSupport, cppEditorSupportList()) {
if (editorSupport->fileName() == fileName) {
editorSupport->setExtraDiagnostics(kind, diagnostics);
return true;
......@@ -947,14 +935,7 @@ bool CppModelManager::setExtraDiagnostics(const QString &fileName,
void CppModelManager::setIfdefedOutBlocks(const QString &fileName,
const QList<TextEditor::BlockRange> &ifdeffedOutBlocks)
{
QList<CppEditorSupport *> cppEditorSupports;
{
QMutexLocker locker(&m_cppEditorSupportsMutex);
cppEditorSupports = m_cppEditorSupports.values();
}
foreach (CppEditorSupport *editorSupport, cppEditorSupports) {
foreach (CppEditorSupport *editorSupport, cppEditorSupportList()) {
if (editorSupport->fileName() == fileName) {
editorSupport->setIfdefedOutBlocks(ifdeffedOutBlocks);
break;
......
......@@ -177,6 +177,8 @@ private:
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
void removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo);
QList<CppEditorSupport *> cppEditorSupportList() const;
WorkingCopy buildWorkingCopyList();
void ensureUpdated();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment