diff options
author | Marco Stornelli | 2019-03-02 14:29:19 +0000 |
---|---|---|
committer | Jonah Graham | 2019-03-04 00:21:29 +0000 |
commit | 2bb6839c1ad236c4f733e271885a86e396bfc956 (patch) | |
tree | 713a6035a975d506b738dbf99cfbb6cf304309d8 | |
parent | eadd7c083ab23f637f0886d23a426dcc5287ac72 (diff) | |
download | org.eclipse.cdt-2bb6839c1ad236c4f733e271885a86e396bfc956.tar.gz org.eclipse.cdt-2bb6839c1ad236c4f733e271885a86e396bfc956.tar.xz org.eclipse.cdt-2bb6839c1ad236c4f733e271885a86e396bfc956.zip |
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>
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java | 8 | ||||
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java | 23 |
2 files changed, 29 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 1e402ba02bd..cd502b3f7ef 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -3570,8 +3570,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, IASTName name = node.getTemplateName(); name.accept(this); if (peekNextToken() == Token.tLT) { - scribe.printNextToken(Token.tLT, - preferences.insert_space_before_opening_angle_bracket_in_template_arguments); + char[] simpleId = name.getSimpleID(); + if (simpleId[simpleId.length - 1] == '<') + scribe.printNextToken(Token.tLT, true); + else + scribe.printNextToken(Token.tLT, + preferences.insert_space_before_opening_angle_bracket_in_template_arguments); if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) { scribe.space(); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index d17b169fa64..ec166d5bfa2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -3758,4 +3758,27 @@ public class CodeFormatterTest extends BaseUITestCase { public void testTemplateIdWithMacro4_Bug406231() throws Exception { 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(); + } } |