Skip to content

Keep trailing trivia so single line if statements don't get badly formatted#53414

Merged
davidwengier merged 2 commits intodotnet:mainfrom
davidwengier:DelegateInvocationTrivia
May 17, 2021
Merged

Keep trailing trivia so single line if statements don't get badly formatted#53414
davidwengier merged 2 commits intodotnet:mainfrom
davidwengier:DelegateInvocationTrivia

Conversation

@davidwengier
Copy link
Member

Fixes #51563

@ghost ghost added the Area-IDE label May 14, 2021
@davidwengier davidwengier enabled auto-merge (squash) May 14, 2021 06:37

newStatement = newStatement.WithAdditionalAnnotations(Formatter.Annotation);
newStatement = newStatement.WithAdditionalAnnotations(Formatter.Annotation)
.WithTrailingTrivia(ifStatement.GetTrailingTrivia());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might need to append, as opposed to 'With'. As thsi might blow away trivia that hte user had before which we wanted to keep, right?

Copy link
Member Author

@davidwengier davidwengier May 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do. Do we have any helpers for skipping whitespace EndOfLine trivia when doing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find one.. let me know if you think its worth adding to SyntaxTriviaListExtensions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find one.. let me know if you think its worth adding to SyntaxTriviaListExtensions

It really depends. if it's something you will use in several differnt features, sure. But in general, i don't like one-off extensions that aren't used in multiple places getting put into our Extensions types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thats fair (and I agree). I think I was tripped up by EndOfLine not being whitespace and there is a SkipLeadingWhitespace() extension method.

Though having said that, auto-merge has made the conversation moot it in this case :)

@davidwengier davidwengier merged commit 88d2b73 into dotnet:main May 17, 2021
@ghost ghost added this to the Next milestone May 17, 2021
@davidwengier davidwengier deleted the DelegateInvocationTrivia branch May 17, 2021 20:56
333fred added a commit to 333fred/roslyn that referenced this pull request May 20, 2021
…vice-featureslayer

* upstream/main: (857 commits)
  Update contrib documentation (dotnet#53504)
  SImplify
  Fix out of bound crash in lsp navto.
  Revert changes to TypeScriptWaitContext wrappers
  Switch to ROSLYN_TEST_CI for CI detection
  SImplify
  Simplify LoggerTestChannel using BlockingCollection
  Only require telemetry validation in CI
  Fix out of bound crash in lsp navto.
  Fix locked comment
  Update Compiler Test Plan.md (dotnet#53420)
  Adjust doc comment for NullableWalker.VisitConversion (dotnet#53429)
  Revert "Infer delegate types with -langversion:preview only (dotnet#53241)" (dotnet#53466)
  Fix syntax normalizer to add space around before colon in constructor initializer (dotnet#53326)
  Remove unnecessary property (dotnet#53406)
  EnC - Tell the debugger about updated type def tokens (dotnet#53217)
  Revert an error
  Update PublishData.json
  Keep trailing trivia so single line if statements don't get badly formatted (dotnet#53414)
  Fix dead test code (dotnet#53416)
  ...
@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify delegate invocation (IDE1005) refactoring moves code afterward into the same line

3 participants