summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2014-11-24 11:19:41 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-01-14 12:33:15 +0100
commit4d3d0e02903e28388937cb602b6e2255feef0385 (patch)
tree43f8340413fdc057c20d17b3de38810e2791777c /src/plugins/cpptools/cppmodelmanager.cpp
parent845cb2e432c73712d27a96dc3765a539b13a195f (diff)
downloadqt-creator-4d3d0e02903e28388937cb602b6e2255feef0385.tar.gz
CppTools: Rename EditorDocumentHandle to CppEditorDocumentHandle
...and related functions. For clarity in client code. Change-Id: Icad6fc7b1eee2ce46a2eba8435359837a23409c8 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp65
1 files changed, 35 insertions, 30 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 7568a32e7c..680ff85cff 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -139,8 +139,8 @@ public:
QByteArray m_definedMacros;
// Editor integration
- mutable QMutex m_cppEditorsMutex;
- QMap<QString, EditorDocumentHandle *> m_cppEditors;
+ mutable QMutex m_cppEditorDocumentsMutex;
+ QMap<QString, CppEditorDocumentHandle *> m_cppEditorDocuments;
QSet<AbstractEditorSupport *> m_extraEditorSupports;
// Completion & highlighting
@@ -462,27 +462,27 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
d->m_extraEditorSupports.remove(editorSupport);
}
-EditorDocumentHandle *CppModelManager::editorDocument(const QString &filePath) const
+CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const QString &filePath) const
{
if (filePath.isEmpty())
return 0;
- QMutexLocker locker(&d->m_cppEditorsMutex);
- return d->m_cppEditors.value(filePath, 0);
+ QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
+ return d->m_cppEditorDocuments.value(filePath, 0);
}
-void CppModelManager::registerEditorDocument(EditorDocumentHandle *editorDocument)
+void CppModelManager::registerCppEditorDocument(CppEditorDocumentHandle *editorDocument)
{
QTC_ASSERT(editorDocument, return);
const QString filePath = editorDocument->filePath();
QTC_ASSERT(!filePath.isEmpty(), return);
- QMutexLocker locker(&d->m_cppEditorsMutex);
- QTC_ASSERT(d->m_cppEditors.value(filePath, 0) == 0, return);
- d->m_cppEditors.insert(filePath, editorDocument);
+ QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
+ QTC_ASSERT(d->m_cppEditorDocuments.value(filePath, 0) == 0, return);
+ d->m_cppEditorDocuments.insert(filePath, editorDocument);
}
-void CppModelManager::unregisterEditorDocument(const QString &filePath)
+void CppModelManager::unregisterCppEditorDocument(const QString &filePath)
{
QTC_ASSERT(!filePath.isEmpty(), return);
@@ -490,10 +490,10 @@ void CppModelManager::unregisterEditorDocument(const QString &filePath)
int openCppDocuments = 0;
{
- QMutexLocker locker(&d->m_cppEditorsMutex);
- QTC_ASSERT(d->m_cppEditors.value(filePath, 0), return);
- QTC_CHECK(d->m_cppEditors.remove(filePath) == 1);
- openCppDocuments = d->m_cppEditors.size();
+ QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
+ QTC_ASSERT(d->m_cppEditorDocuments.value(filePath, 0), return);
+ QTC_CHECK(d->m_cppEditorDocuments.remove(filePath) == 1);
+ openCppDocuments = d->m_cppEditorDocuments.size();
}
++closedCppDocuments;
@@ -542,8 +542,11 @@ WorkingCopy CppModelManager::buildWorkingCopyList()
{
WorkingCopy workingCopy;
- foreach (const EditorDocumentHandle *cppEditor, cppEditors())
- workingCopy.insert(cppEditor->filePath(), cppEditor->contents(), cppEditor->revision());
+ foreach (const CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments()) {
+ workingCopy.insert(cppEditorDocument->filePath(),
+ cppEditorDocument->contents(),
+ cppEditorDocument->revision());
+ }
QSetIterator<AbstractEditorSupport *> it(d->m_extraEditorSupports);
while (it.hasNext()) {
@@ -608,10 +611,10 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
}
}
-QList<EditorDocumentHandle *> CppModelManager::cppEditors() const
+QList<CppEditorDocumentHandle *> CppModelManager::cppEditorDocuments() const
{
- QMutexLocker locker(&d->m_cppEditorsMutex);
- return d->m_cppEditors.values();
+ QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
+ return d->m_cppEditorDocuments.values();
}
/// \brief Remove all given files from the snapshot.
@@ -699,9 +702,10 @@ void CppModelManager::updateCppEditorDocuments() const
QSet<Core::IDocument *> visibleCppEditorDocuments;
foreach (Core::IEditor *editor, Core::EditorManager::visibleEditors()) {
if (Core::IDocument *document = editor->document()) {
- if (EditorDocumentHandle *cppEditorDocument = editorDocument(document->filePath().toString())) {
+ const QString filePath = document->filePath().toString();
+ if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
visibleCppEditorDocuments.insert(document);
- cppEditorDocument->processor()->run();
+ theCppEditorDocument->processor()->run();
}
}
}
@@ -711,8 +715,9 @@ void CppModelManager::updateCppEditorDocuments() const
= Core::DocumentModel::openedDocuments().toSet();
invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments);
foreach (Core::IDocument *document, invisibleCppEditorDocuments) {
- if (EditorDocumentHandle *cppEditorDocument = editorDocument(document->filePath().toString()))
- cppEditorDocument->setNeedsRefresh(true);
+ const QString filePath = document->filePath().toString();
+ if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath))
+ theCppEditorDocument->setNeedsRefresh(true);
}
}
@@ -887,11 +892,11 @@ void CppModelManager::onCurrentEditorChanged(Core::IEditor *editor)
if (!editor || !editor->document())
return;
- if (EditorDocumentHandle *cppEditorDocument =
- editorDocument(editor->document()->filePath().toString())) {
- if (cppEditorDocument->needsRefresh()) {
- cppEditorDocument->setNeedsRefresh(false);
- cppEditorDocument->processor()->run();
+ const QString filePath = editor->document()->filePath().toString();
+ if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
+ if (theCppEditorDocument->needsRefresh()) {
+ theCppEditorDocument->setNeedsRefresh(false);
+ theCppEditorDocument->processor()->run();
}
}
}
@@ -955,8 +960,8 @@ void CppModelManager::GC()
// Collect files of opened editors and editor supports (e.g. ui code model)
QStringList filesInEditorSupports;
- foreach (const EditorDocumentHandle *cppEditor, cppEditors())
- filesInEditorSupports << cppEditor->filePath();
+ foreach (const CppEditorDocumentHandle *editorDocument, cppEditorDocuments())
+ filesInEditorSupports << editorDocument->filePath();
QSetIterator<AbstractEditorSupport *> jt(d->m_extraEditorSupports);
while (jt.hasNext()) {