From 4623f11f4fed8323f5fab55a727fda6251e88793 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 22 Sep 2010 16:42:49 +0200 Subject: [PATCH] C++: only activate insert-declaration quickfix only on the declaration-id. --- src/plugins/cppeditor/cppinsertdecldef.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp index 9a8e20c5200..c6aad18336b 100644 --- a/src/plugins/cppeditor/cppinsertdecldef.cpp +++ b/src/plugins/cppeditor/cppinsertdecldef.cpp @@ -116,10 +116,22 @@ QList DeclFromDef::match(const CppQuickFixState &stat int idx = 0; for (; idx < path.size(); ++idx) { AST *node = path.at(idx); - if (FunctionDefinitionAST *candidate = node->asFunctionDefinition()) { - if (!funDef && file.isCursorOn(candidate) && !file.isCursorOn(candidate->function_body)) - funDef = candidate; - } else if (node->asClassSpecifier()) { + if (idx > 1) { + if (DeclaratorIdAST *declId = node->asDeclaratorId()) { + if (file.isCursorOn(declId)) { + if (FunctionDefinitionAST *candidate = path.at(idx - 2)->asFunctionDefinition()) { + if (funDef) { + return noResult(); + } else { + funDef = candidate; + break; + } + } + } + } + } + + if (node->asClassSpecifier()) { return noResult(); } } @@ -156,7 +168,7 @@ QList DeclFromDef::match(const CppQuickFixState &stat InsertionPointLocator::PrivateSlot, decl))); return results; - } //! \todo support insertion into namespaces + } //! \todo support insertion of non-methods into namespaces } }