Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
be1cde6e
Commit
be1cde6e
authored
Aug 11, 2010
by
Roberto Raggi
Browse files
Pretty print templates.
parent
a14016bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/Overview.cpp
View file @
be1cde6e
...
...
@@ -44,7 +44,8 @@ Overview::Overview()
_showArgumentNames
(
false
),
_showReturnTypes
(
false
),
_showFunctionSignatures
(
true
),
_showDefaultArguments
(
true
)
_showDefaultArguments
(
true
),
_showTemplateParameters
(
false
)
{
}
Overview
::~
Overview
()
...
...
@@ -120,6 +121,16 @@ 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
);
...
...
src/libs/cplusplus/Overview.h
View file @
be1cde6e
...
...
@@ -56,6 +56,9 @@ public:
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
);
...
...
@@ -88,6 +91,7 @@ private:
bool
_showReturnTypes
:
1
;
bool
_showFunctionSignatures
:
1
;
bool
_showDefaultArguments
:
1
;
bool
_showTemplateParameters
:
1
;
};
}
// end of namespace CPlusPlus
...
...
src/libs/cplusplus/TypePrettyPrinter.cpp
View file @
be1cde6e
...
...
@@ -142,23 +142,23 @@ void TypePrettyPrinter::visit(Namespace *type)
void
TypePrettyPrinter
::
visit
(
Template
*
type
)
{
const
unsigned
argc
=
type
->
templateParameterCount
();
QString
decl
;
decl
+=
QLatin1String
(
"template <"
);
for
(
unsigned
i
=
0
;
i
<
argc
;
++
i
)
{
if
(
i
!=
0
)
decl
+=
QLatin1String
(
", "
);
decl
+=
QLatin1String
(
"T"
);
decl
+=
QString
::
number
(
i
+
1
);
}
decl
+=
QLatin1Char
(
'<'
);
if
(
Symbol
*
d
=
type
->
declaration
())
{
decl
+=
QLatin1Char
(
' '
);
decl
+=
overview
()
->
prettyType
(
d
->
type
(),
d
->
name
());
if
(
overview
()
->
showTemplateParameters
()
&&
!
_name
.
isEmpty
())
{
_name
+=
QLatin1Char
(
'<'
);
for
(
unsigned
index
=
0
;
index
<
type
->
templateParameterCount
();
++
index
)
{
if
(
index
)
_name
+=
QLatin1String
(
", "
);
QString
arg
=
overview
()
->
prettyName
(
type
->
templateParameterAt
(
index
)
->
name
());
if
(
arg
.
isEmpty
())
{
arg
+=
QLatin1Char
(
'T'
);
arg
+=
QString
::
number
(
index
+
1
);
}
_name
+=
arg
;
}
_name
+=
QLatin1Char
(
'>'
);
}
acceptType
(
d
->
type
());
}
_text
.
prepend
(
decl
);
qWarning
()
<<
"here:"
<<
decl
;
prependCv
(
_fullySpecifiedType
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment