summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-02-16 17:55:05 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-02-16 18:21:05 +0100
commitfa216de41c7c160a6d79382635628e196626f5ac (patch)
tree001112eb5b1f01f76649418b9f26cf69d5b61abb /src/libs
parent01145fd5524dcc78f9ea34f2e8c9241e6d3a2fca (diff)
downloadqt-creator-fa216de41c7c160a6d79382635628e196626f5ac.tar.gz
Improved the C++ hover handler.
Done with: bjorn
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/cplusplus/Overview.cpp13
-rw-r--r--src/libs/cplusplus/Overview.h4
-rw-r--r--src/libs/cplusplus/TypePrettyPrinter.cpp51
3 files changed, 64 insertions, 4 deletions
diff --git a/src/libs/cplusplus/Overview.cpp b/src/libs/cplusplus/Overview.cpp
index 0f973753d0..331471fe36 100644
--- a/src/libs/cplusplus/Overview.cpp
+++ b/src/libs/cplusplus/Overview.cpp
@@ -42,7 +42,8 @@ Overview::Overview()
: _markArgument(0),
_showArgumentNames(false),
_showReturnTypes(false),
- _showFunctionSignatures(true)
+ _showFunctionSignatures(true),
+ _showFullyQualifiedNames(false)
{ }
Overview::~Overview()
@@ -88,6 +89,16 @@ void Overview::setShowFunctionSignatures(bool showFunctionSignatures)
_showFunctionSignatures = showFunctionSignatures;
}
+bool Overview::showFullyQualifiedNames() const
+{
+ return _showFullyQualifiedNames;
+}
+
+void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames)
+{
+ _showFullyQualifiedNames = showFullyQualifiedNames;
+}
+
QString Overview::prettyName(Name *name) const
{
NamePrettyPrinter pp(this);
diff --git a/src/libs/cplusplus/Overview.h b/src/libs/cplusplus/Overview.h
index 6918ee45ff..f7076559f2 100644
--- a/src/libs/cplusplus/Overview.h
+++ b/src/libs/cplusplus/Overview.h
@@ -57,6 +57,9 @@ public:
bool showFunctionSignatures() const;
void setShowFunctionSignatures(bool showFunctionSignatures);
+ bool showFullyQualifiedNames() const;
+ void setShowFullyQualifiedNamed(bool showFullyQualifiedNames);
+
// 1-based
// ### rename
unsigned markArgument() const;
@@ -77,6 +80,7 @@ private:
bool _showArgumentNames: 1;
bool _showReturnTypes: 1;
bool _showFunctionSignatures: 1;
+ bool _showFullyQualifiedNames: 1;
};
} // end of namespace CPlusPlus
diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp
index 6e46361b7f..a198844499 100644
--- a/src/libs/cplusplus/TypePrettyPrinter.cpp
+++ b/src/libs/cplusplus/TypePrettyPrinter.cpp
@@ -37,9 +37,41 @@
#include <CoreTypes.h>
#include <Symbols.h>
#include <Scope.h>
+#include <QStringList>
+#include <QtDebug>
using namespace CPlusPlus;
+
+static QString fullyQualifiedName(Symbol *symbol, const Overview *overview)
+{
+ QStringList nestedNameSpecifier;
+
+ for (Scope *scope = symbol->scope(); scope && scope->enclosingScope();
+ scope = scope->enclosingScope())
+ {
+ Symbol *owner = scope->owner();
+
+ if (! owner) {
+ qWarning() << "invalid scope."; // ### better message.
+ continue;
+ }
+
+ if (! owner->name())
+ nestedNameSpecifier.prepend(QLatin1String("<anonymous>"));
+
+ else {
+ const QString name = overview->prettyName(owner->name());
+
+ nestedNameSpecifier.prepend(name);
+ }
+ }
+
+ nestedNameSpecifier.append(overview->prettyName(symbol->name()));
+
+ return nestedNameSpecifier.join(QLatin1String("::"));
+}
+
TypePrettyPrinter::TypePrettyPrinter(const Overview *overview)
: _overview(overview),
_name(0)
@@ -150,16 +182,26 @@ void TypePrettyPrinter::visit(Namespace *type)
applyPtrOperators();
}
-void TypePrettyPrinter::visit(Class *type)
+void TypePrettyPrinter::visit(Class *classTy)
{
- _text += overview()->prettyName(type->name());
+ if (overview()->showFullyQualifiedNames())
+ _text += fullyQualifiedName(classTy, overview());
+
+ else
+ _text += overview()->prettyName(classTy->name());
+
applyPtrOperators();
}
void TypePrettyPrinter::visit(Enum *type)
{
- _text += overview()->prettyName(type->name());
+ if (overview()->showFullyQualifiedNames())
+ _text += fullyQualifiedName(type, overview());
+
+ else
+ _text += overview()->prettyName(type->name());
+
applyPtrOperators();
}
@@ -259,11 +301,14 @@ void TypePrettyPrinter::visit(Function *type)
if (! _ptrOperators.isEmpty()) {
out(QLatin1Char('('));
applyPtrOperators(false);
+
if (! _name.isEmpty()) {
_text += _name;
_name.clear();
}
+
out(QLatin1Char(')'));
+
} else if (! _name.isEmpty() && _overview->showFunctionSignatures()) {
space();
out(_name);