diff options
| author | Christian Kamm <[email protected]> | 2010-06-16 15:35:34 +0200 |
|---|---|---|
| committer | Christian Kamm <[email protected]> | 2010-06-16 15:37:39 +0200 |
| commit | e1a0f5abef4ea9c7b6fff827c054253cb65b7c40 (patch) | |
| tree | 14d6c317c4c65524b1845b439656a78ea76b580f /src/libs/cplusplus/CppDocument.cpp | |
| parent | 2deae8c84a9b5f672900d6c7d10d375e4218db54 (diff) | |
C++: Make 'follow symbol' work with forward declared classes.
If it encounters a forward declaration, it tries to find the class
declaration globally now.
Task-number: QTCREATORBUG-20
Diffstat (limited to 'src/libs/cplusplus/CppDocument.cpp')
| -rw-r--r-- | src/libs/cplusplus/CppDocument.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index cd7c0feb589..16d3a69e784 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; +} |
