Commit 9e75ff8e authored by Christian Kamm's avatar Christian Kamm
Browse files

Don't add the default arguments when completing function definitions.

Fixes QTCREATORBUG-787

Reviewed-by: Erik Verbruggen
parent d700b847
...@@ -41,7 +41,8 @@ Overview::Overview() ...@@ -41,7 +41,8 @@ Overview::Overview()
_showArgumentNames(false), _showArgumentNames(false),
_showReturnTypes(false), _showReturnTypes(false),
_showFunctionSignatures(true), _showFunctionSignatures(true),
_showFullyQualifiedNames(false) _showFullyQualifiedNames(false),
_showDefaultArguments(true)
{ } { }
Overview::~Overview() Overview::~Overview()
...@@ -117,6 +118,16 @@ void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames) ...@@ -117,6 +118,16 @@ void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames)
_showFullyQualifiedNames = showFullyQualifiedNames; _showFullyQualifiedNames = showFullyQualifiedNames;
} }
bool Overview::showDefaultArguments() const
{
return _showDefaultArguments;
}
void Overview::setShowDefaultArguments(bool showDefaultArguments)
{
_showDefaultArguments = showDefaultArguments;
}
QString Overview::prettyName(const Name *name) const QString Overview::prettyName(const Name *name) const
{ {
NamePrettyPrinter pp(this); NamePrettyPrinter pp(this);
......
...@@ -56,6 +56,9 @@ public: ...@@ -56,6 +56,9 @@ public:
bool showFullyQualifiedNames() const; bool showFullyQualifiedNames() const;
void setShowFullyQualifiedNamed(bool showFullyQualifiedNames); void setShowFullyQualifiedNamed(bool showFullyQualifiedNames);
bool showDefaultArguments() const;
void setShowDefaultArguments(bool showDefaultArguments);
// argument index that you want to mark // argument index that you want to mark
unsigned markedArgument() const; unsigned markedArgument() const;
void setMarkedArgument(unsigned position); void setMarkedArgument(unsigned position);
...@@ -84,6 +87,7 @@ private: ...@@ -84,6 +87,7 @@ private:
bool _showReturnTypes: 1; bool _showReturnTypes: 1;
bool _showFunctionSignatures: 1; bool _showFunctionSignatures: 1;
bool _showFullyQualifiedNames: 1; bool _showFullyQualifiedNames: 1;
bool _showDefaultArguments: 1;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus
......
...@@ -340,10 +340,12 @@ void TypePrettyPrinter::visit(Function *type) ...@@ -340,10 +340,12 @@ void TypePrettyPrinter::visit(Function *type)
_text += argumentText(arg->type(), name); _text += argumentText(arg->type(), name);
if (_overview->showDefaultArguments()) {
if (const StringLiteral *initializer = arg->initializer()) { if (const StringLiteral *initializer = arg->initializer()) {
_text += QLatin1String(" ="); _text += QLatin1String(" =");
_text += QString::fromUtf8(initializer->chars(), initializer->size()); _text += QString::fromUtf8(initializer->chars(), initializer->size());
} }
}
if (index + 1 == _overview->markedArgument()) if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentEnd(_text.length()); const_cast<Overview*>(_overview)->setMarkedArgumentEnd(_text.length());
......
...@@ -1096,6 +1096,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r ...@@ -1096,6 +1096,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r
foreach (Function *f, functions) { foreach (Function *f, functions) {
Overview overview; Overview overview;
overview.setShowArgumentNames(true); overview.setShowArgumentNames(true);
overview.setShowDefaultArguments(false);
// gets: "parameter list) cv-spec", // gets: "parameter list) cv-spec",
QString completion = overview(f->type()).mid(1); QString completion = overview(f->type()).mid(1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment