From bea8343e017a8db73cf3abd85f1c6784999c9036 Mon Sep 17 00:00:00 2001 From: Andrey Mozzhuhin Date: Sun, 5 Jan 2020 23:18:26 +0300 Subject: [PATCH] Bug 537568: Apply correct indentation with template return types Support optional template type specification of return type in method declaration deduction. Change-Id: Ibaa5d5128faefb0b95534918ba9980bd8449b851 Signed-off-by: Andrey Mozzhuhin --- .../org/eclipse/cdt/ui/tests/text/CIndenterTest.java | 11 +++++++++++ .../org/eclipse/cdt/internal/ui/text/CIndenter.java | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index c0e3178f300..c0d5ad56c9c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -1043,4 +1043,15 @@ public class CIndenterTest extends BaseUITestCase { DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); assertIndenterResult(); } + + //vector f() + //{ + //} + + //vector f() + //{ + //} + public void testIndentationAfterFunctionHeaderWithReturnTypeTemplateSpecification_Bug537568() throws Exception { + assertIndenterResult(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index 177b1954643..85ba6a75d32 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -2229,6 +2229,12 @@ public final class CIndenter { while (skipPointerOperators()) { nextToken(); } + // skip template type specification of function return type + if (fToken == Symbols.TokenGREATERTHAN) { + if (!skipScope()) + return false; + nextToken(); + } switch (fToken) { case Symbols.TokenIDENT: return true;