Commit 18cba4fc authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by David Schulz

CppEditor: Remove duplicate code in cppeditorplugin.cpp

Change-Id: Ifeff4455b1ce0a0a7299f009beaf6319e9abb523
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent c35a6d61
......@@ -333,39 +333,39 @@ ExtensionSystem::IPlugin::ShutdownFlag CppEditorPlugin::aboutToShutdown()
return SynchronousShutdown;
}
static CPPEditorWidget *currentCppEditorWidget()
{
return qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
}
void CppEditorPlugin::switchDeclarationDefinition()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor)
editor->switchDeclarationDefinition(/*inNextSplit*/ false);
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->switchDeclarationDefinition(/*inNextSplit*/ false);
}
void CppEditorPlugin::openDeclarationDefinitionInNextSplit()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor)
editor->switchDeclarationDefinition(/*inNextSplit*/ true);
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->switchDeclarationDefinition(/*inNextSplit*/ true);
}
void CppEditorPlugin::renameSymbolUnderCursor()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor)
editor->renameSymbolUnderCursor();
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->renameSymbolUnderCursor();
}
void CppEditorPlugin::findUsages()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor)
editor->findUsages();
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->findUsages();
}
void CppEditorPlugin::showPreProcessorDialog()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor)
editor->showPreProcessorWidget();
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->showPreProcessorWidget();
}
void CppEditorPlugin::onTaskStarted(Core::Id type)
......@@ -395,14 +395,13 @@ void CppEditorPlugin::currentEditorChanged(IEditor *editor)
if (!editor)
return;
if (CPPEditorWidget *textEditor = qobject_cast<CPPEditorWidget *>(editor->widget()))
textEditor->semanticRehighlight(/*force = */ true);
if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->semanticRehighlight(/*force = */ true);
}
void CppEditorPlugin::openTypeHierarchy()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(EditorManager::currentEditor()->widget());
if (editor) {
if (currentCppEditorWidget()) {
NavigationWidget *navigation = NavigationWidget::instance();
navigation->activateSubWidget(Constants::TYPE_HIERARCHY_ID);
emit typeHierarchyRequested();
......@@ -411,9 +410,7 @@ void CppEditorPlugin::openTypeHierarchy()
void CppEditorPlugin::openIncludeHierarchy()
{
CPPEditorWidget *editor
= qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget());
if (editor) {
if (currentCppEditorWidget()) {
Core::NavigationWidget *navigation = Core::NavigationWidget::instance();
navigation->activateSubWidget(Core::Id(Constants::INCLUDE_HIERARCHY_ID));
emit includeHierarchyRequested();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment