From e79d4ed2e1aa079884179e04f47cac7ffb29d2f8 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 21 Oct 2013 12:59:48 +0200 Subject: [PATCH] CppEditor: Follow Symbol Under Cursor opens the preprocessor dialog ... when invoked on a macro that is defined inside that dialog. Change-Id: I419c6675d70cfb8dd174f6a33f502b4c584baa3a Reviewed-by: David Schulz --- src/plugins/cppeditor/cppfollowsymbolundercursor.cpp | 10 ++++++---- src/plugins/cpptools/cppmodelmanagerinterface.cpp | 5 +++++ src/plugins/cpptools/cppmodelmanagerinterface.h | 1 + src/plugins/cpptools/cppsnapshotupdater.cpp | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index bd2acf05abf..ad4a8c30121 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -454,16 +454,18 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor & const QByteArray name = CPPEditorWidget::identifierUnderCursor(¯oCursor).toLatin1(); if (macro->name() == name) return link; //already on definition! - } else { - const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1); - if (use && use->macro().fileName() != CppModelManagerInterface::configurationFileName()) { + } else if (const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1)) { + const QString fileName = use->macro().fileName(); + if (fileName == CppModelManagerInterface::editorConfigurationFileName()) { + m_widget->showPreProcessorWidget(); + } else if (fileName != CppModelManagerInterface::configurationFileName()) { const Macro ¯o = use->macro(); link.targetFileName = macro.fileName(); link.targetLine = macro.line(); link.linkTextStart = use->begin(); link.linkTextEnd = use->end(); - return link; } + return link; } // Find the last symbol up to the cursor position diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.cpp b/src/plugins/cpptools/cppmodelmanagerinterface.cpp index e2a7c6f10eb..31f1b55e18f 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.cpp +++ b/src/plugins/cpptools/cppmodelmanagerinterface.cpp @@ -175,6 +175,11 @@ static CppModelManagerInterface *g_instance = 0; const QString CppModelManagerInterface::configurationFileName() { return CPlusPlus::Preprocessor::configurationFileName; } +const QString CppModelManagerInterface::editorConfigurationFileName() +{ + return QLatin1String(""); +} + CppModelManagerInterface::CppModelManagerInterface(QObject *parent) : QObject(parent) { diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index eacfa6f756a..bb6787bd2f2 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -216,6 +216,7 @@ public: public: static const QString configurationFileName(); + static const QString editorConfigurationFileName(); public: CppModelManagerInterface(QObject *parent = 0); diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp index cf4a7cec749..4b3e9fedb4c 100644 --- a/src/plugins/cpptools/cppsnapshotupdater.cpp +++ b/src/plugins/cpptools/cppsnapshotupdater.cpp @@ -138,7 +138,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy) workingCopy.insert(configurationFileName, m_configFile); m_snapshot.remove(m_fileInEditor); - static const QString editorDefinesFileName = QLatin1String(""); + static const QString editorDefinesFileName + = CppModelManagerInterface::editorConfigurationFileName(); if (editorDefinesChanged) { m_snapshot.remove(editorDefinesFileName); workingCopy.insert(editorDefinesFileName, m_editorDefines);