forked from qt-creator/qt-creator
CppEditor: "Include Hierarchy": using snapshot from snapshotUpdater
For "includes" we should use snapshot from "SnapshotUpdater"(project specific snapshot, not global snapshot) instead of "global" snapshot. The snapshot of the editor's SnapshotUpdater contains the documents parsed with the appropriate include paths/defines etc. and should therefore be used for the include hierarchy. Change-Id: I6bbaf5040536b771d32697aad1db364758ff8382 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
f744372ed3
commit
abdbae3308
@@ -35,10 +35,12 @@
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cppeditor/cppeditor.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <cpptools/cpptoolseditorsupport.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
@@ -48,7 +50,7 @@ CppIncludeHierarchyModel::CppIncludeHierarchyModel(QObject *parent)
|
||||
, m_rootItem(new CppIncludeHierarchyItem(QString()))
|
||||
, m_includesItem(new CppIncludeHierarchyItem(tr("Includes"), m_rootItem))
|
||||
, m_includedByItem(new CppIncludeHierarchyItem(tr("Included by"), m_rootItem))
|
||||
|
||||
, m_editor(0)
|
||||
{
|
||||
m_rootItem->appendChild(m_includesItem);
|
||||
m_rootItem->appendChild(m_includedByItem);
|
||||
@@ -199,6 +201,15 @@ void CppIncludeHierarchyModel::clear()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CppIncludeHierarchyModel::buildHierarchy(CPPEditor *editor, const QString &filePath)
|
||||
{
|
||||
m_editor = editor;
|
||||
beginResetModel();
|
||||
buildHierarchyIncludes(filePath);
|
||||
buildHierarchyIncludedBy(filePath);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
bool CppIncludeHierarchyModel::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid())
|
||||
@@ -210,14 +221,6 @@ bool CppIncludeHierarchyModel::hasChildren(const QModelIndex &parent) const
|
||||
return parentItem->hasChildren();
|
||||
}
|
||||
|
||||
void CppIncludeHierarchyModel::buildHierarchy(const QString &filePath)
|
||||
{
|
||||
beginResetModel();
|
||||
buildHierarchyIncludes(filePath);
|
||||
buildHierarchyIncludedBy(filePath);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
bool CppIncludeHierarchyModel::isEmpty() const
|
||||
{
|
||||
return !m_includesItem->hasChildren() && !m_includedByItem->hasChildren();
|
||||
@@ -233,7 +236,11 @@ void CppIncludeHierarchyModel::buildHierarchyIncludes_helper(const QString &file
|
||||
CppIncludeHierarchyItem *parent,
|
||||
QSet<QString> *cyclic, bool recursive)
|
||||
{
|
||||
const Snapshot &snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
|
||||
if (!m_editor)
|
||||
return;
|
||||
|
||||
CppModelManagerInterface *cppMM = CppModelManagerInterface::instance();
|
||||
const Snapshot &snapshot = cppMM->cppEditorSupport(m_editor)->snapshotUpdater()->snapshot();
|
||||
Document::Ptr doc = snapshot.document(filePath);
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user