Commit 4623f11f authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

C++: only activate insert-declaration quickfix only on the declaration-id.

parent 70e0e5f6
......@@ -116,10 +116,22 @@ QList<CppQuickFixOperation::Ptr> 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<CppQuickFixOperation::Ptr> DeclFromDef::match(const CppQuickFixState &stat
InsertionPointLocator::PrivateSlot,
decl)));
return results;
} //! \todo support insertion into namespaces
} //! \todo support insertion of non-methods into namespaces
}
}
......
Supports Markdown
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