Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2019-03-02 09:29:19 -0500
committerJonah Graham2019-03-04 13:52:07 -0500
commitf28b158828d7c7e2d6b5219d31e676483d61b3b9 (patch)
tree290a479c987d55af8a80a65cfe872ef48d4d67c7 /core
parent659432f7e208d41461421200a098d19b15a0dbcc (diff)
downloadorg.eclipse.cdt-f28b158828d7c7e2d6b5219d31e676483d61b3b9.tar.gz
org.eclipse.cdt-f28b158828d7c7e2d6b5219d31e676483d61b3b9.tar.xz
org.eclipse.cdt-f28b158828d7c7e2d6b5219d31e676483d61b3b9.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>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java8
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java23
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 1e402ba02b..cd502b3f7e 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 d17b169fa6..ec166d5bfa 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();
+ }
}

Back to the top