diff --git a/src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs b/src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs index 4538e33f295fda808ba8eeecdd8efc367aaf0825..6150c8f9274adcd8520a4f2c226e2c9529ebd8f5 100644 --- a/src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs +++ b/src/EditorFeatures/Core/Wrapping/ChainedExpression/AbstractChainedExpressionWrapper.cs @@ -32,13 +32,13 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.ChainedExpression /// Note: for the sake of simplicity, (arglist) is used both for the argument list of /// an InvocationExpression and an ElementAccessExpression. /// - /// 'remainder' is all the postfix expression that can follow `. name (arglist)`. i.e. + /// 'remainder' is all the postfix expression that can follow . name (arglist). i.e. /// member-access expressions, conditional-access expressions, etc. Effectively, anything /// the language allows at this point as long as it doesn't start another 'chunk' itself. /// /// This approach gives an intuitive wrapping algorithm that matches the common way /// many wrap dotted invocations, while also effectively not limiting the wrapper to - /// only simple forms like `.a(...).b(...).c(...)`. + /// only simple forms like .a(...).b(...).c(...). /// internal abstract partial class AbstractChainedExpressionWrapper< TNameSyntax, @@ -87,8 +87,8 @@ internal abstract partial class AbstractChainedExpressionWrapper< // expression. Break it into the individual chunks. We need to have at least // two chunks or this to be worth wrapping. // - // i.e. if we only have `this.Goo(...)` there's nothing to wrap. However, we can - // wrap when we have `this.Goo(...).Bar(...)`. + // i.e. if we only have this.Goo(...) there's nothing to wrap. However, we can + // wrap when we have this.Goo(...).Bar(...). var chunks = GetChainChunks(node); if (chunks.Length <= 1) { @@ -130,7 +130,7 @@ private ImmutableArray> GetChainChunks(SyntaxN // // These will be the chunks that are wrapped and aligned on that dot. // - // Here 'remainder' is everything up to the next `. Name (...)` chunk. + // Here 'remainder' is everything up to the next . Name (...) chunk. var chunks = ArrayBuilder>.GetInstance(); BreakPiecesIntoChunks(pieces, chunks); @@ -144,11 +144,13 @@ private ImmutableArray> GetChainChunks(SyntaxN ArrayBuilder> chunks) { // Have to look for the first chunk after the first piece. i.e. if the pieces - // starts with `.Foo().Bar().Baz()` then the chunks would be `.Bar()` and `.Baz()`. - // However, if we had `this.Foo().Bar().Baz()` then the chunks would be `.Foo()` - // `.Bar()` and `.Baz()`. + // starts with .Foo().Bar().Baz() then the chunks would be .Bar() + // and .Baz(). // - // Note: the only way to get the `.Foo().Bar().Baz()` case today is in VB in + // However, if we had this.Foo().Bar().Baz() then the chunks would be + // .Foo() .Bar() and .Baz(). + // + // Note: the only way to get the .Foo().Bar().Baz() case today is in VB in // a 'with' statement. if we have that, we don't want to wrap it into: // // @@ -191,9 +193,9 @@ private ImmutableArray> GetChainChunks(SyntaxN } /// - /// Looks for the next sequence of `. Name (ArgList)`. Note, except for the first - /// chunk, this cannot be of the form `? . Name (ArgList)` as we do not want to - /// wrap before a dot in a `?.` form. This doesn't matter for the first chunk as + /// Looks for the next sequence of . Name (ArgList). Note, except for the first + /// chunk, this cannot be of the form ? . Name (ArgList) as we do not want to + /// wrap before a dot in a ?. form. This doesn't matter for the first chunk as /// we won't be wrapping that one. /// private int FindNextChunkStart( @@ -244,13 +246,13 @@ private bool IsToken(int tokenKind, ArrayBuilder pieces, int private bool IsDecomposableChainPart(SyntaxNode node) { // This is the effective set of language constructs that can 'chain' - // off of a call `.M(...)`. They are: + // off of a call .M(...). They are: // - // 1. `.Name` or `->Name`. i.e. `.M(...).Name` - // 2. `(...)`. i.e. `.M(...)(...)` - // 3. `[...]`. i.e. `.M(...)[...]` - // 4. `++`, `--`, `!`. i.e. `.M(...)++` - // 5. `?`. i.e. `.M(...)?. ...` or `.M(...)?[...]` + // 1. .Name or ->Name. i.e. .M(...).Name + // 2. (...). i.e. .M(...)(...) + // 3. [...]. i.e. .M(...)[...] + // 4. ++, --, !. i.e. .M(...)++ + // 5. ?. i.e. .M(...)?. ... or .M(...)?[...] // '5' handles both the ConditionalAccess and MemberBinding cases below. if (node != null) diff --git a/src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs b/src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs index 79b2e5241c6d9c6a3f888a0a39bb2d95266014f1..3334a02615ec38af996d84e4be5089b97fbdde67 100644 --- a/src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs +++ b/src/EditorFeatures/Core/Wrapping/ChainedExpression/ChainedExpressionCodeActionComputer.cs @@ -77,7 +77,7 @@ private class CallExpressionCodeActionComputer : // Both [0][0] indices are safe here. We can only get here if we had more than // two chunks to wrap. And each chunk is required to have at least three elements - // (i.e. `. name (arglist)`). + // (i.e. . name (arglist)). var firstPeriod = chunks[0][0]; _indentAndAlignTrivia = new SyntaxTriviaList(generator.Whitespace( @@ -129,8 +129,7 @@ private ImmutableArray GetWrapEdits(int wrappingColumn, bool align) DeleteAllSpacesInChunk(result, firstChunk); var indentationTrivia = align ? _indentAndAlignTrivia : _smartIndentTrivia; - - var position = indentationTrivia.FullSpan.Length;// _indentationTrivia.FullSpan.Length + NormalizedWidth(firstChunk); + var position = indentationTrivia.FullSpan.Length + NormalizedWidth(firstChunk); // Now, go to each subsequent chunk. If keeping it on the current line would // cause us to go past the requested wrapping column, then wrap it and proceed.