forked from qt-creator/qt-creator
Try to get the right overload when switching from a declaration to its definition.
This commit is contained in:
@@ -1108,21 +1108,30 @@ void CPPEditor::switchDeclarationDefinition()
|
|||||||
if (! lastVisibleSymbol)
|
if (! lastVisibleSymbol)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Function *functionScope = lastVisibleSymbol->asFunction();
|
Function *function = lastVisibleSymbol->asFunction();
|
||||||
if (! functionScope)
|
if (! function)
|
||||||
functionScope = lastVisibleSymbol->enclosingFunction();
|
function = lastVisibleSymbol->enclosingFunction();
|
||||||
|
|
||||||
if (functionScope) {
|
if (function) {
|
||||||
LookupContext context(thisDocument, snapshot);
|
LookupContext context(thisDocument, snapshot);
|
||||||
|
|
||||||
Function *functionDefinition = functionScope->asFunction();
|
Function *functionDefinition = function->asFunction();
|
||||||
|
ClassOrNamespace *binding = context.lookupType(functionDefinition);
|
||||||
|
|
||||||
const QList<LookupItem> declarations = context.lookup(functionDefinition->name(), functionDefinition->enclosingScope());
|
const QList<LookupItem> declarations = context.lookup(functionDefinition->name(), functionDefinition->enclosingScope());
|
||||||
|
QList<Symbol *> best;
|
||||||
foreach (const LookupItem &r, declarations) {
|
foreach (const LookupItem &r, declarations) {
|
||||||
Symbol *decl = r.declaration();
|
if (Symbol *decl = r.declaration()) {
|
||||||
// TODO: check decl.
|
if (Function *funTy = decl->type()->asFunctionType()) {
|
||||||
openCppEditorAt(linkToSymbol(decl));
|
if (funTy->isEqualTo(function) && decl != function && binding == r.binding())
|
||||||
break;
|
best.prepend(decl);
|
||||||
|
else
|
||||||
|
best.append(decl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! best.isEmpty())
|
||||||
|
openCppEditorAt(linkToSymbol(best.first()));
|
||||||
|
|
||||||
} else if (lastVisibleSymbol && lastVisibleSymbol->isDeclaration() && lastVisibleSymbol->type()->isFunctionType()) {
|
} else if (lastVisibleSymbol && lastVisibleSymbol->isDeclaration() && lastVisibleSymbol->type()->isFunctionType()) {
|
||||||
if (Symbol *def = snapshot.findMatchingDefinition(lastVisibleSymbol))
|
if (Symbol *def = snapshot.findMatchingDefinition(lastVisibleSymbol))
|
||||||
|
|||||||
Reference in New Issue
Block a user