forked from qt-creator/qt-creator
Fixed: "Follow symbol" on constructor or destructor always jumps to class definition
Task-number: QTCREATORBUG-1776
This commit is contained in:
@@ -703,25 +703,17 @@ public:
|
|||||||
};
|
};
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
Symbol *Snapshot::findMatchingDefinition(Symbol *symbol) const
|
Symbol *Snapshot::findMatchingDefinition(Symbol *declaration) const
|
||||||
{
|
{
|
||||||
if (! symbol->identifier())
|
if (! (declaration && declaration->identifier()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Document::Ptr thisDocument = document(QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()));
|
Document::Ptr thisDocument = document(QString::fromUtf8(declaration->fileName(), declaration->fileNameLength()));
|
||||||
if (! thisDocument) {
|
if (! thisDocument) {
|
||||||
qWarning() << "undefined document:" << symbol->fileName();
|
qWarning() << "undefined document:" << declaration->fileName();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LookupContext thisContext(thisDocument, *this);
|
|
||||||
const QList<Symbol *> declarationCandidates = thisContext.lookup(symbol->name(), symbol->scope());
|
|
||||||
if (declarationCandidates.isEmpty()) {
|
|
||||||
qWarning() << "unresolved declaration:" << symbol->fileName() << symbol->line() << symbol->column();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol *declaration = declarationCandidates.first();
|
|
||||||
Function *declarationTy = declaration->type()->asFunctionType();
|
Function *declarationTy = declaration->type()->asFunctionType();
|
||||||
if (! declarationTy) {
|
if (! declarationTy) {
|
||||||
qWarning() << "not a function:" << declaration->fileName() << declaration->line() << declaration->column();
|
qWarning() << "not a function:" << declaration->fileName() << declaration->line() << declaration->column();
|
||||||
|
|||||||
@@ -1238,7 +1238,20 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
|
|||||||
const QList<LookupItem> resolvedSymbols = typeOfExpression(expression, scope, TypeOfExpression::Preprocess);
|
const QList<LookupItem> resolvedSymbols = typeOfExpression(expression, scope, TypeOfExpression::Preprocess);
|
||||||
|
|
||||||
if (!resolvedSymbols.isEmpty()) {
|
if (!resolvedSymbols.isEmpty()) {
|
||||||
const LookupItem result = skipForwardDeclarations(resolvedSymbols);
|
LookupItem result = skipForwardDeclarations(resolvedSymbols);
|
||||||
|
|
||||||
|
foreach (const LookupItem &r, resolvedSymbols) {
|
||||||
|
if (Symbol *d = r.declaration()) {
|
||||||
|
if (d->isDeclaration() || d->isFunction()) {
|
||||||
|
if (file()->fileName() == QString::fromUtf8(d->fileName(), d->fileNameLength())) {
|
||||||
|
if (unsigned(line) == d->line() && unsigned(column) >= d->column()) { // ### TODO: check the end
|
||||||
|
result = r; // take the symbol under cursor.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Symbol *symbol = result.declaration()) {
|
if (Symbol *symbol = result.declaration()) {
|
||||||
Symbol *def = 0;
|
Symbol *def = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user