forked from qt-creator/qt-creator
CppEditor: Remove duplicate code in cppeditorplugin.cpp
Change-Id: Ifeff4455b1ce0a0a7299f009beaf6319e9abb523 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
c35a6d610c
commit
18cba4fcf9
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user