From 81735642ddb7efbb862433acd19012829acb1fdd Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Fri, 15 Sep 2023 15:06:19 -0500 Subject: [PATCH 1/5] notes --- .../InvocationExpression.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 5af38ff2f..4d1337096 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -11,6 +11,43 @@ internal record PrintedNode(CSharpSyntaxNode Node, Doc Doc); // https://github.com/prettier/prettier/pull/7889 internal static class InvocationExpression { + /* + why do these break all weird on the array indexer? + + +var x = someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ + 1 +].Property4.Property5 + .Method2() + .Method3("some input") + .Method2() + .Property6.Property7.Array2[2].Property8 + .Method4("some input") + .Property9.Property10; + +someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ + 1 +].Property4.Property5 + .Method2() + .Method3("some input") + .Method2() + .Property6.Property7.Array2[2].Property8 + .Method4("some input") + .Property9.Property10; + +someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ + 1 +].Property4.Property5 + .Method2() + .Method3("some input") + .Method2() + .Property6.Property7.Array2[2].Property8 + .Method4("some input") + .Property9.Property10(); + + + */ + public static Doc Print(InvocationExpressionSyntax node, FormattingContext context) { return PrintMemberChain(node, context); From 13b08a79f5c41ed413a0e5d9c5cfc631a7d6e8b4 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Fri, 29 Sep 2023 13:15:17 -0500 Subject: [PATCH 2/5] Getting element access to break more consistently with invocations. closes #956 --- .../cs/InvocationExpressions_Array.test | 9 +++ .../InvocationExpression.cs | 67 +++++++------------ 2 files changed, 34 insertions(+), 42 deletions(-) create mode 100644 Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test new file mode 100644 index 000000000..8d87b43e0 --- /dev/null +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test @@ -0,0 +1,9 @@ +var x = someLongNameField + .CallMethod____________________________________() + .AccessArray[1] + .Property_______________; + +var x = someLongNameField + .CallMethod____________________________________() + .CallMethod(1) + .Property_______________; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 4d1337096..00ee850a5 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -11,43 +11,6 @@ internal record PrintedNode(CSharpSyntaxNode Node, Doc Doc); // https://github.com/prettier/prettier/pull/7889 internal static class InvocationExpression { - /* - why do these break all weird on the array indexer? - - -var x = someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ - 1 -].Property4.Property5 - .Method2() - .Method3("some input") - .Method2() - .Property6.Property7.Array2[2].Property8 - .Method4("some input") - .Property9.Property10; - -someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ - 1 -].Property4.Property5 - .Method2() - .Method3("some input") - .Method2() - .Property6.Property7.Array2[2].Property8 - .Method4("some input") - .Property9.Property10; - -someLongNameField.Method0().Property0.Property1.Property2.Method1().Property3.Array1[ - 1 -].Property4.Property5 - .Method2() - .Method3("some input") - .Method2() - .Property6.Property7.Array2[2].Property8 - .Method4("some input") - .Property9.Property10(); - - - */ - public static Doc Print(InvocationExpressionSyntax node, FormattingContext context) { return PrintMemberChain(node, context); @@ -153,6 +116,16 @@ And we want to work with them from Left to Right ) ); } + else if (expression is ElementAccessExpressionSyntax elementAccessExpression) + { + FlattenAndPrintNodes(elementAccessExpression.Expression, printedNodes, context); + printedNodes.Add( + new PrintedNode( + elementAccessExpression, + Node.Print(elementAccessExpression.ArgumentList, context) + ) + ); + } else if (expression is MemberAccessExpressionSyntax memberAccessExpressionSyntax) { FlattenAndPrintNodes(memberAccessExpressionSyntax.Expression, printedNodes, context); @@ -315,6 +288,12 @@ printedNodes[index].Node is ConditionalAccessExpressionSyntax continue; } + if (printedNodes[index].Node is ElementAccessExpressionSyntax) + { + currentGroup.Add(printedNodes[index]); + continue; + } + if ( ( IsMemberish(printedNodes[index].Node) @@ -348,7 +327,14 @@ printedNodes[index].Node is ConditionalAccessExpressionSyntax hasSeenInvocationExpression = false; } - if (printedNodes[index].Node is InvocationExpressionSyntax) + if ( + printedNodes[index].Node + is ( + InvocationExpressionSyntax + or MemberAccessExpressionSyntax + or ElementAccessExpressionSyntax + ) + ) { hasSeenInvocationExpression = true; } @@ -407,10 +393,7 @@ private static bool ShouldMergeFirstTwoGroups(List> groups) var firstNode = groups[0][0].Node; - if ( - firstNode is IdentifierNameSyntax identifierNameSyntax - && identifierNameSyntax.Identifier.Text.Length <= 4 - ) + if (firstNode is IdentifierNameSyntax { Identifier.Text.Length: <= 4 }) { return true; } From 4dda697324e501937b089efde4ba0afeb9b86dc3 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 1 Oct 2023 15:29:12 -0500 Subject: [PATCH 3/5] Getting properties breaking consistent with invocations --- .../EditorConfig/EditorConfigParser.cs | 1 - Src/CSharpier.Cli/FormattingCache.cs | 1 - Src/CSharpier.Cli/IgnoreFile.cs | 2 - ...test => MemberChain_ArraysConsistent.test} | 6 ++ .../cs/MemberChain_PropertiesConsistent.test | 33 +++++++ ...tionExpressions.test => MemberChains.test} | 21 +++-- Src/CSharpier/DocTypes/Doc.cs | 5 ++ .../InvocationExpression.cs | 86 +++++++++---------- 8 files changed, 98 insertions(+), 57 deletions(-) rename Src/CSharpier.Tests/FormattingTests/TestFiles/cs/{InvocationExpressions_Array.test => MemberChain_ArraysConsistent.test} (59%) create mode 100644 Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test rename Src/CSharpier.Tests/FormattingTests/TestFiles/cs/{InvocationExpressions.test => MemberChains.test} (94%) diff --git a/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs b/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs index b609e37ac..124699c5e 100644 --- a/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs +++ b/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs @@ -70,7 +70,6 @@ IFileSystem fileSystem { var configFile = ConfigFileParser.Parse(potentialPath, fileSystem); - DebugLogger.Log(potentialPath); yield return configFile; if (configFile.IsRoot) { diff --git a/Src/CSharpier.Cli/FormattingCache.cs b/Src/CSharpier.Cli/FormattingCache.cs index d8418f34c..c49597b09 100644 --- a/Src/CSharpier.Cli/FormattingCache.cs +++ b/Src/CSharpier.Cli/FormattingCache.cs @@ -114,7 +114,6 @@ public bool CanSkipFormatting(FileToFormatInfo fileToFormatInfo) var currentHash = Hash(fileToFormatInfo.FileContents) + this.optionsHash; if (this.cacheDictionary.TryGetValue(fileToFormatInfo.Path, out var cachedHash)) { - DebugLogger.Log(fileToFormatInfo.Path + " " + currentHash + " " + cachedHash); if (currentHash == cachedHash) { return true; diff --git a/Src/CSharpier.Cli/IgnoreFile.cs b/Src/CSharpier.Cli/IgnoreFile.cs index 62e584df0..236fabb4c 100644 --- a/Src/CSharpier.Cli/IgnoreFile.cs +++ b/Src/CSharpier.Cli/IgnoreFile.cs @@ -46,8 +46,6 @@ public static async Task Create( CancellationToken cancellationToken ) { - DebugLogger.Log("Creating ignore file for " + baseDirectoryPath); - var ignore = new Ignore.Ignore(); foreach (var name in alwaysIgnored) diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_ArraysConsistent.test similarity index 59% rename from Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test rename to Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_ArraysConsistent.test index 8d87b43e0..c48758912 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions_Array.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_ArraysConsistent.test @@ -7,3 +7,9 @@ var x = someLongNameField .CallMethod____________________________________() .CallMethod(1) .Property_______________; + +new Action(AssertConfigurationIsValid) + .ShouldThrow() + .Errors[0] + .UnmappedPropertyNames[0] + .ShouldBe(nameof(Destination.Count)); diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test new file mode 100644 index 000000000..2dda4e8e7 --- /dev/null +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test @@ -0,0 +1,33 @@ +var someVariable = someObject + .Property + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________); + +var someVariable = someObject + .Property() + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________); + +var someVariable = someObject + .Property + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________) + .CallMethod(); + +var someVariable = someObject + .Property() + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________) + .CallMethod(); + +// TODO too hard to change this for now, will do it in https://github.com/belav/csharpier/issues/451 +var someVariable = this.Property.CallMethod( + someValue => someValue.SomeProperty == someOtherValue___________________________ +); + +var someVariable = this.Property() + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________); + +var someVariable = this.Property + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________) + .CallMethod(); + +var someVariable = this.Property() + .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________) + .CallMethod(); diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test similarity index 94% rename from Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions.test rename to Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test index a1ababd92..92ddc250b 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InvocationExpressions.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test @@ -51,11 +51,13 @@ class ClassName .Where(o => someLongCondition__________________________) .Where(o => someLongCondition__________________________); - var someValue = someOtherValue!.Thing! + var someValue = someOtherValue! + .Thing! .Where(o => someLongCondition__________________________) .Where(o => someLongCondition__________________________); - var someValue = someOtherValue.Thing + var someValue = someOtherValue + .Thing .Where(o => someLongCondition__________________________) .Where(o => someLongCondition__________________________); @@ -81,7 +83,8 @@ class ClassName this.SomeProperty.Setup(o => longThing_______________________________________) ); - roleNames.Value + roleNames + .Value .Where(o => o.SomeProperty____________________________________) .Select(o => o.SomethingElse); @@ -110,9 +113,12 @@ class ClassName someParameter____________________________________ )!; - var someVariable = someObject.Property.CallMethod( - someValue => someValue.SomeProperty == someOtherValue___________________________________ - ); + var someVariable = someObject + .Property + .CallMethod( + someValue => + someValue.SomeProperty == someOtherValue___________________________________ + ); CallMethod( firstParameter____________________________, @@ -231,7 +237,8 @@ class ClassName ) .CallMethod__________________(); - someThing_______________________.Property + someThing_______________________ + .Property .CallMethod__________________() .CallMethod__________________(); diff --git a/Src/CSharpier/DocTypes/Doc.cs b/Src/CSharpier/DocTypes/Doc.cs index 1ef6eb456..199cef6a3 100644 --- a/Src/CSharpier/DocTypes/Doc.cs +++ b/Src/CSharpier/DocTypes/Doc.cs @@ -2,6 +2,11 @@ namespace CSharpier.DocTypes; internal abstract class Doc { + public string Print() + { + return DocPrinter.DocPrinter.Print(this, new PrinterOptions(), Environment.NewLine); + } + public override string ToString() { return DocSerializer.Serialize(this); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 00ee850a5..e9cdb0492 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -179,8 +179,6 @@ expression is PostfixUnaryExpressionSyntax } } - // TODO maybe this should work more like prettier, where it makes groups in a way that they try to fill lines - // TODO also prettier doesn't seem to use fluid private static List> GroupPrintedNodesOnLines(List printedNodes) { // We want to group the printed nodes in the following manner @@ -233,14 +231,16 @@ List printedNodes // will be grouped as // [ // [Identifier, InvocationExpression], - // [MemberAccessExpression, MemberAccessExpression, InvocationExpression], + // [MemberAccessExpression] + // [MemberAccessExpression, InvocationExpression], // [MemberAccessExpression, InvocationExpression], // [MemberAccessExpression], // ] // so that we can print it as // a() - // .b.c() + // .b + // .c() // .d() // .e @@ -267,50 +267,44 @@ List printedNodes } } - if (printedNodes[0].Node is not InvocationExpressionSyntax) + if ( + printedNodes[0].Node is not (InvocationExpressionSyntax or PostfixUnaryExpressionSyntax) + && index + 1 < printedNodes.Count + ) { - for (; index + 1 < printedNodes.Count; ++index) + /* this handles the special case where we want ?.Property on the same line + someThing_______________________?.Property + .CallMethod__________________() + .CallMethod__________________(); + */ + if ( + printedNodes[index].Node is ConditionalAccessExpressionSyntax + && printedNodes[index + 1].Node + is MemberBindingExpressionSyntax { Parent: MemberAccessExpressionSyntax } + ) { - /* this handles the special case where we want ?.Property on the same line - someThing_______________________?.Property - .CallMethod__________________() - .CallMethod__________________(); - */ - if ( - printedNodes[index].Node is ConditionalAccessExpressionSyntax - && printedNodes[index + 1].Node - is MemberBindingExpressionSyntax { Parent: MemberAccessExpressionSyntax } - ) - { - currentGroup.Add(printedNodes[index]); - currentGroup.Add(printedNodes[index + 1]); - index++; - continue; - } - - if (printedNodes[index].Node is ElementAccessExpressionSyntax) - { - currentGroup.Add(printedNodes[index]); - continue; - } - - if ( - ( - IsMemberish(printedNodes[index].Node) - && ( - IsMemberish(printedNodes[index + 1].Node) - || printedNodes[index + 1].Node is PostfixUnaryExpressionSyntax - ) - ) - || printedNodes[index].Node is PostfixUnaryExpressionSyntax - ) - { - currentGroup.Add(printedNodes[index]); - } - else - { - break; - } + currentGroup.Add(printedNodes[index]); + currentGroup.Add(printedNodes[index + 1]); + index += 2; + } + else if (printedNodes[index].Node is ElementAccessExpressionSyntax) + { + currentGroup.Add(printedNodes[index]); + index++; + } + else if ( + IsMemberish(printedNodes[index].Node) + && printedNodes[index + 1].Node is PostfixUnaryExpressionSyntax + ) + { + currentGroup.Add(printedNodes[index]); + currentGroup.Add(printedNodes[index + 1]); + index += 2; + } + else if (printedNodes[index].Node is PostfixUnaryExpressionSyntax) + { + currentGroup.Add(printedNodes[index]); + index++; } } From c4655d2a2cff818f4997460ab6cd574f553a4848 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 1 Oct 2023 15:57:46 -0500 Subject: [PATCH 4/5] Fixing more edge cases --- .../TestFiles/cs/MemberChains.test | 8 ++- .../InvocationExpression.cs | 62 ++++--------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test index 92ddc250b..aa0d4309a 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test @@ -242,7 +242,13 @@ class ClassName .CallMethod__________________() .CallMethod__________________(); - someThing_______________________?.Property + someThing_______________________ + ?.Property + .CallMethod__________________() + .CallMethod__________________(); + + someThing_______________________ + .Property! .CallMethod__________________() .CallMethod__________________(); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index e9cdb0492..404605dfe 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -244,14 +244,6 @@ List printedNodes // .d() // .e - // The first group is the first node followed by - // - as many InvocationExpression as possible - // < fn()()() >.something() - // - as many array accessors as possible - // < fn()[0][1][2] >.something() - // - then, as many MemberAccessExpression as possible but the last one - // < this.items >.something() - var groups = new List>(); var currentGroup = new List { printedNodes[0] }; var index = 1; @@ -269,43 +261,14 @@ List printedNodes if ( printedNodes[0].Node is not (InvocationExpressionSyntax or PostfixUnaryExpressionSyntax) - && index + 1 < printedNodes.Count + && index < printedNodes.Count + && printedNodes[index].Node + is ElementAccessExpressionSyntax + or PostfixUnaryExpressionSyntax ) { - /* this handles the special case where we want ?.Property on the same line - someThing_______________________?.Property - .CallMethod__________________() - .CallMethod__________________(); - */ - if ( - printedNodes[index].Node is ConditionalAccessExpressionSyntax - && printedNodes[index + 1].Node - is MemberBindingExpressionSyntax { Parent: MemberAccessExpressionSyntax } - ) - { - currentGroup.Add(printedNodes[index]); - currentGroup.Add(printedNodes[index + 1]); - index += 2; - } - else if (printedNodes[index].Node is ElementAccessExpressionSyntax) - { - currentGroup.Add(printedNodes[index]); - index++; - } - else if ( - IsMemberish(printedNodes[index].Node) - && printedNodes[index + 1].Node is PostfixUnaryExpressionSyntax - ) - { - currentGroup.Add(printedNodes[index]); - currentGroup.Add(printedNodes[index + 1]); - index += 2; - } - else if (printedNodes[index].Node is PostfixUnaryExpressionSyntax) - { - currentGroup.Add(printedNodes[index]); - index++; - } + currentGroup.Add(printedNodes[index]); + index++; } groups.Add(currentGroup); @@ -314,7 +277,12 @@ printedNodes[index].Node is ConditionalAccessExpressionSyntax var hasSeenInvocationExpression = false; for (; index < printedNodes.Count; index++) { - if (hasSeenInvocationExpression && IsMemberish(printedNodes[index].Node)) + if ( + hasSeenInvocationExpression + && printedNodes[index].Node + is MemberAccessExpressionSyntax + or ConditionalAccessExpressionSyntax + ) { groups.Add(currentGroup); currentGroup = new List(); @@ -327,6 +295,7 @@ printedNodes[index].Node is ConditionalAccessExpressionSyntax InvocationExpressionSyntax or MemberAccessExpressionSyntax or ElementAccessExpressionSyntax + or MemberBindingExpressionSyntax ) ) { @@ -343,11 +312,6 @@ or ElementAccessExpressionSyntax return groups; } - private static bool IsMemberish(CSharpSyntaxNode node) - { - return node is MemberAccessExpressionSyntax or ConditionalAccessExpressionSyntax; - } - private static Doc PrintIndentedGroup(ExpressionSyntax node, IList> groups) { if (groups.Count == 0) From 2d603a4ac370e08c25b74738996fd774e332ddab Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 1 Oct 2023 16:04:19 -0500 Subject: [PATCH 5/5] some self review --- .../SyntaxNodePrinters/InvocationExpression.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 404605dfe..d92b86f1c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -244,6 +244,9 @@ List printedNodes // .d() // .e + // TODO #451 this whole thing could possibly just turn into a big loop + // based on the current node, and the next/previous node, decide when to create new groups. + // certain nodes need to stay in the current group, other nodes indicate that a new group needs to be created. var groups = new List>(); var currentGroup = new List { printedNodes[0] }; var index = 1; @@ -274,11 +277,11 @@ or PostfixUnaryExpressionSyntax groups.Add(currentGroup); currentGroup = new List(); - var hasSeenInvocationExpression = false; + var hasSeenNodeThatRequiresBreak = false; for (; index < printedNodes.Count; index++) { if ( - hasSeenInvocationExpression + hasSeenNodeThatRequiresBreak && printedNodes[index].Node is MemberAccessExpressionSyntax or ConditionalAccessExpressionSyntax @@ -286,7 +289,7 @@ or ConditionalAccessExpressionSyntax { groups.Add(currentGroup); currentGroup = new List(); - hasSeenInvocationExpression = false; + hasSeenNodeThatRequiresBreak = false; } if ( @@ -299,7 +302,7 @@ or MemberBindingExpressionSyntax ) ) { - hasSeenInvocationExpression = true; + hasSeenNodeThatRequiresBreak = true; } currentGroup.Add(printedNodes[index]); }