forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -107,8 +107,8 @@ void BaseEditorDocumentParser::setEditorDefines(const QByteArray &editorDefines)
|
||||
BaseEditorDocumentParser *BaseEditorDocumentParser::get(const QString &filePath)
|
||||
{
|
||||
CppModelManager *cmmi = CppModelManager::instance();
|
||||
if (EditorDocumentHandle *editorDocument = cmmi->editorDocument(filePath)) {
|
||||
if (BaseEditorDocumentProcessor *processor = editorDocument->processor())
|
||||
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
|
||||
if (BaseEditorDocumentProcessor *processor = cppEditorDocument->processor())
|
||||
return processor->parser();
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -66,8 +66,8 @@ TextEditor::TextDocument *BaseEditorDocumentProcessor::baseTextDocument() const
|
||||
BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &filePath)
|
||||
{
|
||||
CppModelManager *cmmi = CppModelManager::instance();
|
||||
if (EditorDocumentHandle *editorDocument = cmmi->editorDocument(filePath))
|
||||
return editorDocument->processor();
|
||||
if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath))
|
||||
return cppEditorDocument->processor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace CppTools {
|
||||
class AbstractEditorSupport;
|
||||
class BaseEditorDocumentProcessor;
|
||||
class CppCompletionAssistProvider;
|
||||
class EditorDocumentHandle;
|
||||
class CppEditorDocumentHandle;
|
||||
class CppIndexingSupport;
|
||||
class ModelManagerSupport;
|
||||
class WorkingCopy;
|
||||
@@ -117,9 +117,9 @@ public:
|
||||
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
||||
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
||||
|
||||
EditorDocumentHandle *editorDocument(const QString &filePath) const;
|
||||
void registerEditorDocument(EditorDocumentHandle *editorDocument);
|
||||
void unregisterEditorDocument(const QString &filePath);
|
||||
CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const;
|
||||
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
||||
void unregisterCppEditorDocument(const QString &filePath);
|
||||
|
||||
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
||||
|
||||
@@ -198,7 +198,7 @@ private:
|
||||
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
|
||||
void removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo);
|
||||
|
||||
QList<EditorDocumentHandle *> cppEditors() const;
|
||||
QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
||||
|
||||
WorkingCopy buildWorkingCopyList();
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@ void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
|
||||
EditorCloser closerA(editorA);
|
||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||
|
||||
EditorDocumentHandle *editorDocumentA = mm->editorDocument(fileA);
|
||||
CppEditorDocumentHandle *editorDocumentA = mm->cppEditorDocument(fileA);
|
||||
QVERIFY(editorDocumentA);
|
||||
ProjectPart::Ptr documentAProjectPart = editorDocumentA->processor()->parser()->projectPart();
|
||||
QVERIFY(!documentAProjectPart->project);
|
||||
@@ -1025,7 +1025,7 @@ void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
|
||||
EditorCloser closerB(editorB);
|
||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
||||
|
||||
EditorDocumentHandle *editorDocumentB = mm->editorDocument(fileB);
|
||||
CppEditorDocumentHandle *editorDocumentB = mm->cppEditorDocument(fileB);
|
||||
QVERIFY(editorDocumentB);
|
||||
ProjectPart::Ptr documentBProjectPart = editorDocumentB->processor()->parser()->projectPart();
|
||||
QVERIFY(!documentBProjectPart->project);
|
||||
|
||||
@@ -39,21 +39,21 @@ namespace CppTools {
|
||||
C++ editor document.
|
||||
*/
|
||||
|
||||
EditorDocumentHandle::EditorDocumentHandle()
|
||||
CppEditorDocumentHandle::CppEditorDocumentHandle()
|
||||
: m_needsRefresh(false)
|
||||
{
|
||||
}
|
||||
|
||||
EditorDocumentHandle::~EditorDocumentHandle()
|
||||
CppEditorDocumentHandle::~CppEditorDocumentHandle()
|
||||
{
|
||||
}
|
||||
|
||||
bool EditorDocumentHandle::needsRefresh() const
|
||||
bool CppEditorDocumentHandle::needsRefresh() const
|
||||
{
|
||||
return m_needsRefresh;
|
||||
}
|
||||
|
||||
void EditorDocumentHandle::setNeedsRefresh(bool needsRefresh)
|
||||
void CppEditorDocumentHandle::setNeedsRefresh(bool needsRefresh)
|
||||
{
|
||||
m_needsRefresh = needsRefresh;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT EditorDocumentHandle
|
||||
class CPPTOOLS_EXPORT CppEditorDocumentHandle
|
||||
{
|
||||
public:
|
||||
EditorDocumentHandle();
|
||||
virtual ~EditorDocumentHandle();
|
||||
CppEditorDocumentHandle();
|
||||
virtual ~CppEditorDocumentHandle();
|
||||
|
||||
bool needsRefresh() const;
|
||||
void setNeedsRefresh(bool needsRefresh);
|
||||
|
||||
Reference in New Issue
Block a user