From 45afe49b9c75d805b51d21640077dfc29b898527 Mon Sep 17 00:00:00 2001 From: Andrey Mozzhuhin Date: Tue, 14 Apr 2020 23:24:39 +0300 Subject: [PATCH] Bug 562125: Fix auto indent of function call with scope qualifiers A function call may be mistakenly interpreted in looksLikeMethodDecl() as a method declaration. This was due to simplified processing of functions with a scope qualifiers in the name. Now methods with a scope qualifier are handled similarly to methods without them. Change-Id: Id3075d3387fdf9c4ae2d0dffa6cdf923fd1ef9d5 Signed-off-by: Andrey Mozzhuhin --- .../eclipse/cdt/ui/tests/text/CIndenterTest.java | 15 +++++++++++++++ .../eclipse/cdt/internal/ui/text/CIndenter.java | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) 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 aee44827c18..a9a4a9c3841 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 @@ -1067,4 +1067,19 @@ public class CIndenterTest extends BaseUITestCase { public void testIndentationAfterArgumentWithQualifier_Bug516393() throws Exception { assertIndenterResult(); // global scope } + + //x = f() + //+ ::f() + //+ A::f() + //+ ::A::f() + //+ B::C::f(); + + //x = f() + // + ::f() + // + A::f() + // + ::A::f() + // + B::C::f(); + public void testIndentationAfterFunctionCallWithQualifier_Bug562125() 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 85ba6a75d32..03fb9d8825a 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 @@ -2219,8 +2219,9 @@ public final class CIndenter { if (fToken == Symbols.TokenTILDE) { return true; } - if (skipQualifiers()) { - return true; + // optional class or namespace qualifiers + while (skipQualifiers()) { + nextToken(); } // optional brackets for array valued return types while (skipBrackets()) { @@ -2238,6 +2239,9 @@ public final class CIndenter { switch (fToken) { case Symbols.TokenIDENT: return true; + case Symbols.TokenEOF: + // EOF can be seen in constructor definition outside the class + // at the beginning of the source file case Symbols.TokenSEMICOLON: case Symbols.TokenRBRACE: fPosition = pos;