Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -116,10 +116,22 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(const CppQuickFixState &stat ...@@ -116,10 +116,22 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(const CppQuickFixState &stat
int idx = 0; int idx = 0;
for (; idx < path.size(); ++idx) { for (; idx < path.size(); ++idx) {
AST *node = path.at(idx); AST *node = path.at(idx);
if (FunctionDefinitionAST *candidate = node->asFunctionDefinition()) { if (idx > 1) {
if (!funDef && file.isCursorOn(candidate) && !file.isCursorOn(candidate->function_body)) if (DeclaratorIdAST *declId = node->asDeclaratorId()) {
funDef = candidate; if (file.isCursorOn(declId)) {
} else if (node->asClassSpecifier()) { if (FunctionDefinitionAST *candidate = path.at(idx - 2)->asFunctionDefinition()) {
if (funDef) {
return noResult();
} else {
funDef = candidate;
break;
}
}
}
}
}
if (node->asClassSpecifier()) {
return noResult(); return noResult();
} }
} }
...@@ -156,7 +168,7 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(const CppQuickFixState &stat ...@@ -156,7 +168,7 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(const CppQuickFixState &stat
InsertionPointLocator::PrivateSlot, InsertionPointLocator::PrivateSlot,
decl))); decl)));
return results; return results;
} //! \todo support insertion into namespaces } //! \todo support insertion of non-methods into namespaces
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment