diff options
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 d5c1eb6..1247bf7 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 |