CppEditor: introduce include hierarchy

Based on type hierarchy.

Added to context menu ('Open Include Hierarchy')
Shortcut(Ctrl+Shift+I)

'Include Hierarchy' contains:
FileName for which 'Include Hierarchy' is done
Includes(which files are included by current file - tree hierarchy)
Included by(which files include current file - tree hierarchy)

It is possible to open/goto each file by clicking on specific item.
Additionally for 'Included by' files it goes to the line where is include
directive for current file.

Change-Id: I549b1ed64e4c9f6955f60d00efb12950a3259f81
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-08-13 22:58:38 +02:00
committed by Nikolai Kosjar
parent 8c79d5bc23
commit a3eaed4c51
14 changed files with 1101 additions and 2 deletions

View File

@@ -36,6 +36,7 @@
#include "cpphoverhandler.h"
#include "cppoutline.h"
#include "cpptypehierarchy.h"
#include "cppincludehierarchy.h"
#include "cppsnippetprovider.h"
#include "cppquickfixassistant.h"
#include "cppquickfixes.h"
@@ -103,6 +104,7 @@ CppEditorPlugin::CppEditorPlugin() :
m_findUsagesAction(0),
m_updateCodeModelAction(0),
m_openTypeHierarchyAction(0),
m_openIncludeHierarchyAction(0),
m_quickFixProvider(0)
{
m_instance = this;
@@ -156,6 +158,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
addAutoReleasedObject(new CppHoverHandler);
addAutoReleasedObject(new CppOutlineWidgetFactory);
addAutoReleasedObject(new CppTypeHierarchyFactory);
addAutoReleasedObject(new CppIncludeHierarchyFactory);
addAutoReleasedObject(new CppSnippetProvider);
addAutoReleasedObject(new CppHighlighterFactory);
@@ -244,6 +247,13 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_openIncludeHierarchyAction = new QAction(tr("Open Include Hierarchy"), this);
cmd = Core::ActionManager::registerAction(m_openIncludeHierarchyAction, Constants::OPEN_INCLUDE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+I") : tr("Ctrl+Shift+I")));
connect(m_openIncludeHierarchyAction, SIGNAL(triggered()), this, SLOT(openIncludeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
// Refactoring sub-menu
Context globalContext(Core::Constants::C_GLOBAL);
Command *sep = contextMenu->addSeparator(globalContext);
@@ -351,6 +361,7 @@ void CppEditorPlugin::onTaskStarted(Core::Id type)
m_findUsagesAction->setEnabled(false);
m_updateCodeModelAction->setEnabled(false);
m_openTypeHierarchyAction->setEnabled(false);
m_openIncludeHierarchyAction->setEnabled(false);
}
}
@@ -361,6 +372,7 @@ void CppEditorPlugin::onAllTasksFinished(Core::Id type)
m_findUsagesAction->setEnabled(true);
m_updateCodeModelAction->setEnabled(true);
m_openTypeHierarchyAction->setEnabled(true);
m_openIncludeHierarchyAction->setEnabled(true);
}
}
@@ -383,4 +395,15 @@ void CppEditorPlugin::openTypeHierarchy()
}
}
void CppEditorPlugin::openIncludeHierarchy()
{
CPPEditorWidget *editor
= qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget());
if (editor) {
Core::NavigationWidget *navigation = Core::NavigationWidget::instance();
navigation->activateSubWidget(Core::Id(Constants::INCLUDE_HIERARCHY_ID));
emit includeHierarchyRequested();
}
}
Q_EXPORT_PLUGIN(CppEditorPlugin)