diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index cd7c0feb5895c1283e5cb0a119f8bd805c2d4d9e..16d3a69e784bd2289a3b2535a24849fec88852c9 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -793,3 +793,26 @@ Symbol *Snapshot::findMatchingDefinition(Symbol *symbol) const return 0; } + +Class *Snapshot::findMatchingClassDeclaration(Symbol *declaration) const +{ + if (! declaration->identifier()) + return 0; + + foreach (Document::Ptr doc, *this) { + if (! doc->control()->findIdentifier(declaration->identifier()->chars(), + declaration->identifier()->size())) + continue; + + LookupContext context(doc, *this); + + ClassOrNamespace *type = context.lookupType(declaration); + if (!type || type->symbols().count() != 1) + continue; + + if (Class *c = type->symbols().first()->asClass()) + return c; + } + + return 0; +} diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index cfdd42c24427c09dd8f4e4e12ee280388f74c7b3..cc1f9c2ff8c6ce62d739c0934ca010632439eb6f 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -372,6 +372,7 @@ public: const QString &fileName) const; Symbol *findMatchingDefinition(Symbol *symbol) const; + Class *findMatchingClassDeclaration(Symbol *symbol) const; private: void simplified_helper(Document::Ptr doc, Snapshot *snapshot) const; diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 4e035dbca3a60fd9c691ed68a496495cc0456ecc..83f118b449f02434764312e2a42c5c638416a8cf 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -64,7 +64,8 @@ static void fullyQualifiedName_helper(Symbol *symbol, QList<const Name *> *names names->append(symbol->name()); } } else if (symbol->isObjCClass() || symbol->isObjCBaseClass() || symbol->isObjCProtocol() - || symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration()) { + || symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration() + || symbol->isForwardClassDeclaration()) { if (symbol->name()) names->append(symbol->name()); } else if (symbol->isFunction()) { diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 19c92b21a76e718d116fa1e5cdc2653e3bd702ed..9471daeaee312787d795b137e9e49a467fee00bb 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1315,6 +1315,10 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor, def = 0; // jump to declaration then. } + if (symbol->isForwardClassDeclaration()) { + def = snapshot.findMatchingClassDeclaration(symbol); + } + link = linkToSymbol(def ? def : symbol); link.begin = beginOfToken; link.end = endOfToken;