diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-12-21 18:43:02 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:21 -0300 |
commit | 3fed11c07c214e4c396f2ecfd19236ac1dcedb07 (patch) | |
tree | c0bcc5611a7a52eaa88058355182d03167023a20 /typedatabase.cpp | |
parent | 8550517e9d3a03603ece294e4183853040e16fd8 (diff) |
Fixed type resolution for types inside scopes, but their names omit this information.
Diffstat (limited to 'typedatabase.cpp')
-rw-r--r-- | typedatabase.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/typedatabase.cpp b/typedatabase.cpp index d5c1eb6ce..1247bf7f3 100644 --- a/typedatabase.cpp +++ b/typedatabase.cpp @@ -141,14 +141,29 @@ PrimitiveTypeEntry* TypeDatabase::findTargetLangPrimitiveType(const QString& tar TypeEntry* TypeDatabase::findType(const QString& name) const { - QList<TypeEntry *> entries = findTypes(name); - foreach (TypeEntry *entry, entries) { + TypeEntry* typeEntry = 0; + QList<TypeEntry *> typeEntries = findTypes(name); + + if (typeEntries.isEmpty()) { + SingleTypeEntryHash entriesHash = entries(); + foreach (QString typeName, entriesHash.keys()) { + // Let's try to find the type in different scopes. + // We will prefer the ones with the least depth. + if (typeName.endsWith("::"+name) + && (!typeEntry || typeEntry->qualifiedCppName().count("::") < typeName.count("::"))) { + typeEntry = entriesHash[typeName]; + } + } + } + + foreach (TypeEntry* entry, typeEntries) { if (entry && (!entry->isPrimitive() || static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())) { - return entry; + typeEntry = entry; + break; } } - return 0; + return typeEntry; } SingleTypeEntryHash TypeDatabase::entries() const |