forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user