mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 540252: Fix formatting operator< with explicit instantiation
A space must be forced in this special case even if preferences say something different. Change-Id: Ie43b988139913f87590f4f1460d28e79f9bd7ef8 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
659432f7e2
commit
f28b158828
2 changed files with 29 additions and 2 deletions
|
@ -3570,6 +3570,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
IASTName name = node.getTemplateName();
|
IASTName name = node.getTemplateName();
|
||||||
name.accept(this);
|
name.accept(this);
|
||||||
if (peekNextToken() == Token.tLT) {
|
if (peekNextToken() == Token.tLT) {
|
||||||
|
char[] simpleId = name.getSimpleID();
|
||||||
|
if (simpleId[simpleId.length - 1] == '<')
|
||||||
|
scribe.printNextToken(Token.tLT, true);
|
||||||
|
else
|
||||||
scribe.printNextToken(Token.tLT,
|
scribe.printNextToken(Token.tLT,
|
||||||
preferences.insert_space_before_opening_angle_bracket_in_template_arguments);
|
preferences.insert_space_before_opening_angle_bracket_in_template_arguments);
|
||||||
if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) {
|
if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) {
|
||||||
|
|
|
@ -3758,4 +3758,27 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
public void testTemplateIdWithMacro4_Bug406231() throws Exception {
|
public void testTemplateIdWithMacro4_Bug406231() throws Exception {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//class data
|
||||||
|
//{
|
||||||
|
//public:
|
||||||
|
// template <class x> bool operator< (x const &n) const
|
||||||
|
// {
|
||||||
|
// return n < 0;
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
////explicit instantiation
|
||||||
|
//template bool data::operator< <int>(int const &) const;
|
||||||
|
|
||||||
|
//class data {
|
||||||
|
//public:
|
||||||
|
// template<class x> bool operator<(x const &n) const {
|
||||||
|
// return n < 0;
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
////explicit instantiation
|
||||||
|
//template bool data::operator< <int>(int const &) const;
|
||||||
|
public void testTemplateInstantiationOperatorLesser_Bug540252() throws Exception {
|
||||||
|
assertFormatterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue