| 635 | } |
| 636 | |
| 637 | static QString getFullyQualifiedClassName( |
| 638 | const QSet<QString> &allClasses, const QStringList &namespaces, |
| 639 | const QHash<QString, QStringList> &namespaceAliases, |
| 640 | const QString &ident, bool hasPrefix) |
| 641 | { |
| 642 | static QString strColons(QLatin1String("::")); |
| 643 | |
| 644 | QString context = ident; |
| 645 | QStringList segments = context.split(strColons); |
| 646 | if (segments.first().isEmpty()) { |
| 647 | // fully qualified |
| 648 | segments.removeFirst(); |
| 649 | context = resolveNamespaces(segments, namespaceAliases).join(strColons); |
| 650 | } else { |
| 651 | for (int n = namespaces.count(); --n >= -1; ) { |
| 652 | QStringList ns; |
| 653 | for (int i = 0; i <= n; ++i) // Note: n == -1 possible |
| 654 | ns.append(namespaces[i]); |
| 655 | foreach (const QString &cns, segments) { |
| 656 | ns.append(cns); |
| 657 | ns = namespaceAliases.value(ns.join(strColons), ns); |
| 658 | } |
| 659 | QString nctx = ns.join(strColons); |
| 660 | if (allClasses.contains(nctx)) { |
| 661 | context = nctx; |
| 662 | goto gotit; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | if (!hasPrefix && namespaces.count()) |
| 667 | context = namespaces.join(strColons) + strColons + context; |
| 668 | } |
| 669 | gotit: |
| 670 | //qDebug() << "CLASSES:" << allClasses << "NAMEPACES:" << namespaces |
| 671 | // << "IDENT:" << ident << "CONTEXT:" << context; |
| 672 | return context; |
| 673 | } |
| 674 | |
| 675 | |
| 676 | static QString transcode(const QString &str, bool utf8) |
no test coverage detected