Commit 95eb7733 authored by Max Schwarz's avatar Max Schwarz Committed by Kevin Funk
Browse files

Fix SwitchToBuddy from function definitions

The problem is that `SwitchToBuddy::switchDefinitionDeclaration()` just traverses `DUChainContext::Other` contexts while looking for a parent context owned by a definition. kdev-clang creates a `DUChainContext::Function` context for the definition (as I would expect), and the function fails to find a context.

Fix that by also considering `DUChainContext::Function` contexts. Maybe we can also drop the context type check, not sure why it is there.

REVIEW: 120174
parent 96352463
......@@ -221,11 +221,11 @@ void SwitchToBuddyPlugin::switchDefinitionDeclaration()
ctx = standardCtx;
}
while (ctx && ctx->parentContext() && ctx->parentContext()->type() == DUContext::Other) {
while (ctx && ctx->parentContext() && (ctx->parentContext()->type() == DUContext::Other || ctx->parentContext()->type() == DUContext::Function)) {
ctx = ctx->parentContext();
}
if (ctx && ctx->owner() && ctx->type() == DUContext::Other && ctx->owner()->isDefinition()) {
if (ctx && ctx->owner() && (ctx->type() == DUContext::Other || ctx->type() == DUContext::Function) && ctx->owner()->isDefinition()) {
definition = ctx->owner();
kDebug() << "found definition while traversing:" << definition->toString();
}
......
Markdown is supported
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