CppTools: Remove some duplicate code

Change-Id: I83c0bbcf221fd163cd2514a9d23983b82e1f04fd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-03-20 17:03:27 -03:00
parent 11845cd3dc
commit 5f7f6f877a
2 changed files with 13 additions and 30 deletions

View File

@@ -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;