~timo-jyrinki/ubuntu/saucy/qtcreator/add_workaround_back

« back to all changes in this revision

Viewing changes to src/libs/cplusplus/LookupContext.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-11-18 16:18:49 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20111118161849-5t8jugl6egvs4iev
Tags: 2.4.0~rc-0ubuntu1
* New upstream release candidate.
* Drop 04_fix_ftbfs_arm_qreal.diff, merged upstream.
* Refresh 01_fix_installation_paths.diff.
* Compress binary packages with xz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
**
5
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
6
**
7
 
** Contact: Nokia Corporation (info@qt.nokia.com)
 
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8
8
**
9
9
**
10
10
** GNU Lesser General Public License Usage
26
26
** conditions contained in a signed written agreement between you and Nokia.
27
27
**
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.
30
30
**
31
31
**************************************************************************/
32
32
 
157
157
    return names;
158
158
}
159
159
 
160
 
 
161
 
const Name *LookupContext::minimalName(const Name *name,
162
 
                                       Scope *scope,
163
 
                                       ClassOrNamespace *target) const
164
 
{
165
 
    Q_UNUSED(name);
166
 
    Q_UNUSED(scope);
167
 
    Q_UNUSED(target);
168
 
 
169
 
    qWarning() << "TODO:" << Q_FUNC_INFO;
170
 
    return name;
171
 
 
172
 
#if 0
173
 
    Q_ASSERT(name);
174
 
    Q_ASSERT(source);
175
 
    Q_ASSERT(target);
176
 
 
177
 
    QList<Symbol *> symbols = lookup(name, source);
178
 
    if (symbols.isEmpty())
179
 
        return 0;
180
 
 
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());
185
 
    else
186
 
        fqNames.push_back(name);
187
 
 
188
 
    const QualifiedNameId *lastWorking = 0;
189
 
    for (unsigned i = 0; i < fqNames.size(); ++i) {
190
 
        const QualifiedNameId *newName = control()->qualifiedNameId(&fqNames[i],
191
 
                                                                    fqNames.size() - i);
192
 
        QList<Symbol *> candidates = target->lookup(newName);
193
 
        if (candidates.contains(canonicalSymbol))
194
 
            lastWorking = newName;
 
160
static bool symbolIdentical(Symbol *s1, Symbol *s2)
 
161
{
 
162
    if (!s1 || !s2)
 
163
        return false;
 
164
    if (s1->line() != s2->line())
 
165
        return false;
 
166
    if (s1->column() != s2->column())
 
167
        return false;
 
168
 
 
169
    return QByteArray(s1->fileName()) == QByteArray(s2->fileName());
 
170
}
 
171
 
 
172
const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control)
 
173
{
 
174
    const Name *n = 0;
 
175
    QList<const Name *> names = LookupContext::fullyQualifiedName(symbol);
 
176
 
 
177
    for (int i = names.size() - 1; i >= 0; --i) {
 
178
        if (! n)
 
179
            n = names.at(i);
195
180
        else
196
 
            break;
 
181
            n = control->qualifiedNameId(names.at(i), n);
 
182
 
 
183
        // once we're qualified enough to get the same symbol, break
 
184
        if (target) {
 
185
            const QList<LookupItem> tresults = target->lookup(n);
 
186
            foreach (const LookupItem &tr, tresults) {
 
187
                if (symbolIdentical(tr.declaration(), symbol))
 
188
                    return n;
 
189
            }
 
190
        }
197
191
    }
198
192
 
199
 
    if (lastWorking && lastWorking->nameCount() == 1)
200
 
        return lastWorking->nameAt(0);
201
 
    else
202
 
        return lastWorking;
203
 
#endif
 
193
    return n;
204
194
}
205
195
 
206
196