257 bool visitNamespace(const NamespaceList &namespaces, int nsCount, |
257 bool visitNamespace(const NamespaceList &namespaces, int nsCount, |
258 VisitNamespaceCallback callback, void *context) const; |
258 VisitNamespaceCallback callback, void *context) const; |
259 static QStringList stringListifySegments(const QList<HashString> &namespaces); |
259 static QStringList stringListifySegments(const QList<HashString> &namespaces); |
260 bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const; |
260 bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const; |
261 bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const; |
261 bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const; |
|
262 bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
|
263 NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const; |
262 bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
264 bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
263 NamespaceList *resolved) const; |
265 NamespaceList *resolved) const; |
264 bool fullyQualify(const NamespaceList &namespaces, int nsCnt, |
266 bool fullyQualify(const NamespaceList &namespaces, int nsCnt, |
265 const QList<HashString> &segments, bool isDeclaration, |
267 const QList<HashString> &segments, bool isDeclaration, |
266 NamespaceList *resolved, QStringList *unresolved) const; |
268 NamespaceList *resolved, QStringList *unresolved) const; |
1034 ret << segments.at(i).value(); |
1036 ret << segments.at(i).value(); |
1035 return ret; |
1037 return ret; |
1036 } |
1038 } |
1037 |
1039 |
1038 struct QualifyOneData { |
1040 struct QualifyOneData { |
1039 QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd) |
1041 QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd, |
1040 : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd) |
1042 QSet<HashStringList> *visited) |
|
1043 : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd), visitedUsings(visited) |
1041 {} |
1044 {} |
1042 |
1045 |
1043 const NamespaceList &namespaces; |
1046 const NamespaceList &namespaces; |
1044 int nsCount; |
1047 int nsCount; |
1045 const HashString &segment; |
1048 const HashString &segment; |
1046 NamespaceList *resolved; |
1049 NamespaceList *resolved; |
1047 QSet<HashStringList> visitedUsings; |
1050 QSet<HashStringList> *visitedUsings; |
1048 }; |
1051 }; |
1049 |
1052 |
1050 bool CppParser::qualifyOneCallbackOwn(const Namespace *ns, void *context) const |
1053 bool CppParser::qualifyOneCallbackOwn(const Namespace *ns, void *context) const |
1051 { |
1054 { |
1052 QualifyOneData *data = (QualifyOneData *)context; |
1055 QualifyOneData *data = (QualifyOneData *)context; |
1076 |
1079 |
1077 bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) const |
1080 bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) const |
1078 { |
1081 { |
1079 QualifyOneData *data = (QualifyOneData *)context; |
1082 QualifyOneData *data = (QualifyOneData *)context; |
1080 foreach (const HashStringList &use, ns->usings) |
1083 foreach (const HashStringList &use, ns->usings) |
1081 if (!data->visitedUsings.contains(use)) { |
1084 if (!data->visitedUsings->contains(use)) { |
1082 data->visitedUsings.insert(use); |
1085 data->visitedUsings->insert(use); |
1083 if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved)) |
1086 if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved, |
|
1087 data->visitedUsings)) |
1084 return true; |
1088 return true; |
1085 } |
1089 } |
1086 return false; |
1090 return false; |
1087 } |
1091 } |
1088 |
1092 |
1089 bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
1093 bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
1090 NamespaceList *resolved) const |
1094 NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const |
1091 { |
1095 { |
1092 QualifyOneData data(namespaces, nsCnt, segment, resolved); |
1096 QualifyOneData data(namespaces, nsCnt, segment, resolved, visitedUsings); |
1093 |
1097 |
1094 if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data)) |
1098 if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data)) |
1095 return true; |
1099 return true; |
1096 |
1100 |
1097 return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data); |
1101 return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data); |
|
1102 } |
|
1103 |
|
1104 bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, |
|
1105 NamespaceList *resolved) const |
|
1106 { |
|
1107 QSet<HashStringList> visitedUsings; |
|
1108 |
|
1109 return qualifyOne(namespaces, nsCnt, segment, resolved, &visitedUsings); |
1098 } |
1110 } |
1099 |
1111 |
1100 bool CppParser::fullyQualify(const NamespaceList &namespaces, int nsCnt, |
1112 bool CppParser::fullyQualify(const NamespaceList &namespaces, int nsCnt, |
1101 const QList<HashString> &segments, bool isDeclaration, |
1113 const QList<HashString> &segments, bool isDeclaration, |
1102 NamespaceList *resolved, QStringList *unresolved) const |
1114 NamespaceList *resolved, QStringList *unresolved) const |