5
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7
** Contact: Nokia Corporation (info@qt.nokia.com)
7
** Contact: Nokia Corporation (qt-info@nokia.com)
10
10
** GNU Lesser General Public License Usage
26
26
** conditions contained in a signed written agreement between you and Nokia.
28
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at info@qt.nokia.com.
29
** Nokia at qt-info@nokia.com.
31
31
**************************************************************************/
161
const Name *LookupContext::minimalName(const Name *name,
163
ClassOrNamespace *target) const
169
qWarning() << "TODO:" << Q_FUNC_INFO;
177
QList<Symbol *> symbols = lookup(name, source);
178
if (symbols.isEmpty())
181
Symbol *canonicalSymbol = symbols.first();
182
std::vector<const Name *> fqNames = fullyQualifiedName(canonicalSymbol).toVector().toStdVector();
183
if (const QualifiedNameId *qId = name->asQualifiedNameId())
184
fqNames.push_back(qId->name());
186
fqNames.push_back(name);
188
const QualifiedNameId *lastWorking = 0;
189
for (unsigned i = 0; i < fqNames.size(); ++i) {
190
const QualifiedNameId *newName = control()->qualifiedNameId(&fqNames[i],
192
QList<Symbol *> candidates = target->lookup(newName);
193
if (candidates.contains(canonicalSymbol))
194
lastWorking = newName;
160
static bool symbolIdentical(Symbol *s1, Symbol *s2)
164
if (s1->line() != s2->line())
166
if (s1->column() != s2->column())
169
return QByteArray(s1->fileName()) == QByteArray(s2->fileName());
172
const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control)
175
QList<const Name *> names = LookupContext::fullyQualifiedName(symbol);
177
for (int i = names.size() - 1; i >= 0; --i) {
181
n = control->qualifiedNameId(names.at(i), n);
183
// once we're qualified enough to get the same symbol, break
185
const QList<LookupItem> tresults = target->lookup(n);
186
foreach (const LookupItem &tr, tresults) {
187
if (symbolIdentical(tr.declaration(), symbol))
199
if (lastWorking && lastWorking->nameCount() == 1)
200
return lastWorking->nameAt(0);