summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
committerEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
commit912cd548c0b0950b3a1e80f2597c99b3bf898c83 (patch)
treec9eeb5ac857dcabcfb404f60356ad4522471d9ed /src/libs/cplusplus
parentddde938174f03544182adb79179d192502b50e51 (diff)
parent002820867cc0f4f5c67c5ae976eec26157275d4f (diff)
downloadqt-creator-912cd548c0b0950b3a1e80f2597c99b3bf898c83.tar.gz
Merge remote-tracking branch 'origin/2.4'
Conflicts: src/libs/qmljs/qmljsinterpreter.cpp src/libs/qmljs/qmljsinterpreter.h src/plugins/madde/maemopackagecreationstep.cpp src/plugins/projectexplorer/buildmanager.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.h tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp Change-Id: I63ab2ba5dac006c37ccfbae55b023396a4676ff7
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/CppDocument.cpp6
-rw-r--r--src/libs/cplusplus/CppRewriter.cpp33
-rw-r--r--src/libs/cplusplus/LookupContext.cpp64
-rw-r--r--src/libs/cplusplus/LookupContext.h3
4 files changed, 32 insertions, 74 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp
index 0df7704e09..f8ff42ca9c 100644
--- a/src/libs/cplusplus/CppDocument.cpp
+++ b/src/libs/cplusplus/CppDocument.cpp
@@ -918,11 +918,11 @@ void CPlusPlus::findMatchingDeclaration(const LookupContext &context,
return;
foreach (Symbol *s, binding->symbols()) {
- Class *matchingClass = s->asClass();
- if (!matchingClass)
+ Scope *scope = s->asScope();
+ if (!scope)
continue;
- for (Symbol *s = matchingClass->find(funcId); s; s = s->next()) {
+ for (Symbol *s = scope->find(funcId); s; s = s->next()) {
if (! s->name())
continue;
else if (! funcId->isEqualTo(s->identifier()))
diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp
index 8948b9297e..432f6bcbe4 100644
--- a/src/libs/cplusplus/CppRewriter.cpp
+++ b/src/libs/cplusplus/CppRewriter.cpp
@@ -387,18 +387,6 @@ UseMinimalNames::~UseMinimalNames()
}
-static bool symbolIdentical(Symbol *s1, Symbol *s2)
-{
- if (!s1 || !s2)
- return false;
- if (s1->line() != s2->line())
- return false;
- if (s1->column() != s2->column())
- return false;
-
- return QByteArray(s1->fileName()) == QByteArray(s2->fileName());
-}
-
FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) const
{
SubstitutionEnvironment *env = rewrite->env;
@@ -416,26 +404,7 @@ FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) co
const QList<LookupItem> results = context.lookup(name, scope);
foreach (const LookupItem &r, results) {
if (Symbol *d = r.declaration()) {
- const Name *n = 0;
- QList<const Name *> names = LookupContext::fullyQualifiedName(d);
- for (int i = names.size() - 1; i >= 0; --i) {
- if (! n)
- n = names.at(i);
- else
- n = control->qualifiedNameId(names.at(i), n);
- if (_target) {
- // minimize the qualifications
- const QList<LookupItem> tresults = _target->lookup(n);
- foreach (const LookupItem &tr, tresults) {
- if (symbolIdentical(tr.declaration(), d)) {
- i = 0; // break outer
- break;
- }
- }
- }
- }
-
- return control->namedType(n);
+ return control->namedType(LookupContext::minimalName(d, _target, control));
}
return r.type();
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index f4089d1bec..88110c5da2 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -157,50 +157,40 @@ QList<const Name *> LookupContext::path(Symbol *symbol)
return names;
}
-
-const Name *LookupContext::minimalName(const Name *name,
- Scope *scope,
- ClassOrNamespace *target) const
+static bool symbolIdentical(Symbol *s1, Symbol *s2)
{
- Q_UNUSED(name);
- Q_UNUSED(scope);
- Q_UNUSED(target);
-
- qWarning() << "TODO:" << Q_FUNC_INFO;
- return name;
+ if (!s1 || !s2)
+ return false;
+ if (s1->line() != s2->line())
+ return false;
+ if (s1->column() != s2->column())
+ return false;
-#if 0
- Q_ASSERT(name);
- Q_ASSERT(source);
- Q_ASSERT(target);
+ return QByteArray(s1->fileName()) == QByteArray(s2->fileName());
+}
- QList<Symbol *> symbols = lookup(name, source);
- if (symbols.isEmpty())
- return 0;
+const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control)
+{
+ const Name *n = 0;
+ QList<const Name *> names = LookupContext::fullyQualifiedName(symbol);
- Symbol *canonicalSymbol = symbols.first();
- std::vector<const Name *> fqNames = fullyQualifiedName(canonicalSymbol).toVector().toStdVector();
- if (const QualifiedNameId *qId = name->asQualifiedNameId())
- fqNames.push_back(qId->name());
- else
- fqNames.push_back(name);
-
- const QualifiedNameId *lastWorking = 0;
- for (unsigned i = 0; i < fqNames.size(); ++i) {
- const QualifiedNameId *newName = control()->qualifiedNameId(&fqNames[i],
- fqNames.size() - i);
- QList<Symbol *> candidates = target->lookup(newName);
- if (candidates.contains(canonicalSymbol))
- lastWorking = newName;
+ for (int i = names.size() - 1; i >= 0; --i) {
+ if (! n)
+ n = names.at(i);
else
- break;
+ n = control->qualifiedNameId(names.at(i), n);
+
+ // once we're qualified enough to get the same symbol, break
+ if (target) {
+ const QList<LookupItem> tresults = target->lookup(n);
+ foreach (const LookupItem &tr, tresults) {
+ if (symbolIdentical(tr.declaration(), symbol))
+ return n;
+ }
+ }
}
- if (lastWorking && lastWorking->nameCount() == 1)
- return lastWorking->nameAt(0);
- else
- return lastWorking;
-#endif
+ return n;
}
diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h
index 578e19b094..2fa9655cd5 100644
--- a/src/libs/cplusplus/LookupContext.h
+++ b/src/libs/cplusplus/LookupContext.h
@@ -235,8 +235,7 @@ public:
static QList<const Name *> fullyQualifiedName(Symbol *symbol);
static QList<const Name *> path(Symbol *symbol);
- const Name *minimalName(const Name *name, Scope *source,
- ClassOrNamespace *target) const;
+ static const Name *minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control);
private:
// The current expression.