forked from qt-creator/qt-creator
Cpp: No need for accessors for simple structs
Change-Id: Ie09c1fc59dd54d2302a78cfc9769d5cda6012be7 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -38,99 +38,16 @@
|
||||
using namespace CPlusPlus;
|
||||
|
||||
Overview::Overview()
|
||||
: _markedArgument(0),
|
||||
_markedArgumentBegin(0),
|
||||
_markedArgumentEnd(0),
|
||||
_showArgumentNames(false),
|
||||
_showReturnTypes(false),
|
||||
_showFunctionSignatures(true),
|
||||
_showDefaultArguments(true),
|
||||
_showTemplateParameters(false)
|
||||
: markedArgument(0),
|
||||
markedArgumentBegin(0),
|
||||
markedArgumentEnd(0),
|
||||
showArgumentNames(false),
|
||||
showReturnTypes(false),
|
||||
showFunctionSignatures(true),
|
||||
showDefaultArguments(true),
|
||||
showTemplateParameters(false)
|
||||
{ }
|
||||
|
||||
Overview::~Overview()
|
||||
{ }
|
||||
|
||||
bool Overview::showArgumentNames() const
|
||||
{
|
||||
return _showArgumentNames;
|
||||
}
|
||||
|
||||
void Overview::setShowArgumentNames(bool showArgumentNames)
|
||||
{
|
||||
_showArgumentNames = showArgumentNames;
|
||||
}
|
||||
|
||||
void Overview::setShowReturnTypes(bool showReturnTypes)
|
||||
{
|
||||
_showReturnTypes = showReturnTypes;
|
||||
}
|
||||
|
||||
bool Overview::showReturnTypes() const
|
||||
{
|
||||
return _showReturnTypes;
|
||||
}
|
||||
|
||||
unsigned Overview::markedArgument() const
|
||||
{
|
||||
return _markedArgument;
|
||||
}
|
||||
|
||||
void Overview::setMarkedArgument(unsigned position)
|
||||
{
|
||||
_markedArgument = position;
|
||||
}
|
||||
|
||||
int Overview::markedArgumentBegin() const
|
||||
{
|
||||
return _markedArgumentBegin;
|
||||
}
|
||||
|
||||
void Overview::setMarkedArgumentBegin(int begin)
|
||||
{
|
||||
_markedArgumentBegin = begin;
|
||||
}
|
||||
|
||||
int Overview::markedArgumentEnd() const
|
||||
{
|
||||
return _markedArgumentEnd;
|
||||
}
|
||||
|
||||
void Overview::setMarkedArgumentEnd(int end)
|
||||
{
|
||||
_markedArgumentEnd = end;
|
||||
}
|
||||
|
||||
bool Overview::showFunctionSignatures() const
|
||||
{
|
||||
return _showFunctionSignatures;
|
||||
}
|
||||
|
||||
void Overview::setShowFunctionSignatures(bool showFunctionSignatures)
|
||||
{
|
||||
_showFunctionSignatures = showFunctionSignatures;
|
||||
}
|
||||
|
||||
bool Overview::showDefaultArguments() const
|
||||
{
|
||||
return _showDefaultArguments;
|
||||
}
|
||||
|
||||
void Overview::setShowDefaultArguments(bool showDefaultArguments)
|
||||
{
|
||||
_showDefaultArguments = showDefaultArguments;
|
||||
}
|
||||
|
||||
bool Overview::showTemplateParameters() const
|
||||
{
|
||||
return _showTemplateParameters;
|
||||
}
|
||||
|
||||
void Overview::setShowTemplateParameters(bool showTemplateParameters)
|
||||
{
|
||||
_showTemplateParameters = showTemplateParameters;
|
||||
}
|
||||
|
||||
QString Overview::prettyName(const Name *name) const
|
||||
{
|
||||
NamePrettyPrinter pp(this);
|
||||
|
||||
@@ -44,32 +44,6 @@ class CPLUSPLUS_EXPORT Overview
|
||||
|
||||
public:
|
||||
Overview();
|
||||
~Overview();
|
||||
|
||||
bool showArgumentNames() const;
|
||||
void setShowArgumentNames(bool showArgumentNames);
|
||||
|
||||
bool showReturnTypes() const;
|
||||
void setShowReturnTypes(bool showReturnTypes);
|
||||
|
||||
bool showFunctionSignatures() const;
|
||||
void setShowFunctionSignatures(bool showFunctionSignatures);
|
||||
|
||||
bool showDefaultArguments() const;
|
||||
void setShowDefaultArguments(bool showDefaultArguments);
|
||||
|
||||
bool showTemplateParameters() const;
|
||||
void setShowTemplateParameters(bool showTemplateParameters);
|
||||
|
||||
// argument index that you want to mark
|
||||
unsigned markedArgument() const;
|
||||
void setMarkedArgument(unsigned position);
|
||||
|
||||
int markedArgumentBegin() const;
|
||||
void setMarkedArgumentBegin(int begin);
|
||||
|
||||
int markedArgumentEnd() const;
|
||||
void setMarkedArgumentEnd(int end);
|
||||
|
||||
QString operator()(const Name *name) const
|
||||
{ return prettyName(name); }
|
||||
@@ -85,15 +59,15 @@ public:
|
||||
QString prettyType(const FullySpecifiedType &type, const Name *name = 0) const;
|
||||
QString prettyType(const FullySpecifiedType &type, const QString &name) const;
|
||||
|
||||
private:
|
||||
unsigned _markedArgument;
|
||||
int _markedArgumentBegin;
|
||||
int _markedArgumentEnd;
|
||||
bool _showArgumentNames: 1;
|
||||
bool _showReturnTypes: 1;
|
||||
bool _showFunctionSignatures: 1;
|
||||
bool _showDefaultArguments: 1;
|
||||
bool _showTemplateParameters: 1;
|
||||
public:
|
||||
unsigned markedArgument;
|
||||
int markedArgumentBegin;
|
||||
int markedArgumentEnd;
|
||||
bool showArgumentNames: 1;
|
||||
bool showReturnTypes: 1;
|
||||
bool showFunctionSignatures: 1;
|
||||
bool showDefaultArguments: 1;
|
||||
bool showTemplateParameters: 1;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
@@ -143,7 +143,7 @@ void TypePrettyPrinter::visit(Namespace *type)
|
||||
void TypePrettyPrinter::visit(Template *type)
|
||||
{
|
||||
if (Symbol *d = type->declaration()) {
|
||||
if (overview()->showTemplateParameters() && ! _name.isEmpty()) {
|
||||
if (overview()->showTemplateParameters && ! _name.isEmpty()) {
|
||||
_name += QLatin1Char('<');
|
||||
for (unsigned index = 0; index < type->templateParameterCount(); ++index) {
|
||||
if (index)
|
||||
@@ -309,13 +309,13 @@ void TypePrettyPrinter::visit(Function *type)
|
||||
}
|
||||
_text.append(QLatin1Char(')'));
|
||||
_needsParens = false;
|
||||
} else if (! _name.isEmpty() && _overview->showFunctionSignatures()) {
|
||||
} else if (! _name.isEmpty() && _overview->showFunctionSignatures) {
|
||||
appendSpace();
|
||||
_text.append(_name);
|
||||
_name.clear();
|
||||
}
|
||||
|
||||
if (_overview->showReturnTypes()) {
|
||||
if (_overview->showReturnTypes) {
|
||||
const QString returnType = _overview->prettyType(type->returnType());
|
||||
if (!returnType.isEmpty()) {
|
||||
if (!endsWithPtrOrRef(returnType))
|
||||
@@ -324,11 +324,11 @@ void TypePrettyPrinter::visit(Function *type)
|
||||
}
|
||||
}
|
||||
|
||||
if (_overview->showFunctionSignatures()) {
|
||||
if (_overview->showFunctionSignatures) {
|
||||
Overview argumentText;
|
||||
argumentText.setShowReturnTypes(true);
|
||||
argumentText.setShowArgumentNames(false);
|
||||
argumentText.setShowFunctionSignatures(true);
|
||||
argumentText.showReturnTypes = true;
|
||||
argumentText.showArgumentNames = false;
|
||||
argumentText.showFunctionSignatures = true;
|
||||
|
||||
_text += QLatin1Char('(');
|
||||
|
||||
@@ -337,25 +337,25 @@ void TypePrettyPrinter::visit(Function *type)
|
||||
_text += QLatin1String(", ");
|
||||
|
||||
if (Argument *arg = type->argumentAt(index)->asArgument()) {
|
||||
if (index + 1 == _overview->markedArgument())
|
||||
const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length());
|
||||
if (index + 1 == _overview->markedArgument)
|
||||
const_cast<Overview*>(_overview)->markedArgumentBegin = _text.length();
|
||||
|
||||
const Name *name = 0;
|
||||
|
||||
if (_overview->showArgumentNames())
|
||||
if (_overview->showArgumentNames)
|
||||
name = arg->name();
|
||||
|
||||
_text += argumentText(arg->type(), name);
|
||||
|
||||
if (_overview->showDefaultArguments()) {
|
||||
if (_overview->showDefaultArguments) {
|
||||
if (const StringLiteral *initializer = arg->initializer()) {
|
||||
_text += QLatin1String(" =");
|
||||
_text += QString::fromUtf8(initializer->chars(), initializer->size());
|
||||
}
|
||||
}
|
||||
|
||||
if (index + 1 == _overview->markedArgument())
|
||||
const_cast<Overview*>(_overview)->setMarkedArgumentEnd(_text.length());
|
||||
if (index + 1 == _overview->markedArgument)
|
||||
const_cast<Overview*>(_overview)->markedArgumentEnd = _text.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user