Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed complex trivia tab indentation #10748

Merged
merged 2 commits into from
May 12, 2016

Conversation

michalhosala
Copy link
Contributor

Fix should address bug number #10742. Problem was with formatting of complex trivias in VB.NET only. To fix the issue, logic from Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.ShouldFormat method was copied over to Microsoft.CodeAnalysis.VisualBasic.Formatting.TriviaDataFactory.ComplexTrivia.ShouldFormat.

@Pilchie
Copy link
Member

Pilchie commented Apr 22, 2016

Thanks for the submission @michalhosala. Pinging @roslyn-ide, @CyrusNajmabadi @basoundr @heejaechang for review.

@Pilchie
Copy link
Member

Pilchie commented Apr 22, 2016

@dotnet-bot test eta please, test vsi please.

@basoundr
Copy link
Contributor

@michalhosala Could you please add some unit tests? You can add these unit tests inside of Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting.FormattingTest

@michalhosala
Copy link
Contributor Author

@basoundr unit test added, please review the latest commit in this branch.

@@ -81,6 +81,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting

Debug.Assert(Me.SecondTokenIsFirstTokenOnLine OrElse beginningOfNewLine)

If Me.OptionSet.GetOption(FormattingOptions.UseTabs, LanguageNames.VisualBasic) Then
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix solves the issue but I think the correct location to provide the fix would be, inside of CodeShapeAnalyzer.OnWhiteSpace(trivia, index) which is eventually called by CodeShapeAnalyzer.ShouldFormatMultiLine. With the current fix, we will end up formatting the Complex trivia every time we see the UseTabs is enabled irrespective of the content of the trivia. ComplexTrivia formatting is an expensive operation and it should not be done all the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's entirely possible but as I said in my original comment, the fix is copied over from Microsoft.CodeAnalysis.CSharp.Formatting.TriviaDataFactory.ComplexTrivia.ShouldFormat and I believe the person writing those lines had better understanding of the code than I so I reused them.

Therefore the solution I am providing is entirely up to performance standards set up by current c# complex trivia formatter and ultimately roslyn itself. To improve the performance, feature request should be started.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed

@basoundr
Copy link
Contributor

basoundr commented May 2, 2016

👍

@Pilchie
Copy link
Member

Pilchie commented May 2, 2016

@dotnet-bot retest vsi please

@michalhosala
Copy link
Contributor Author

@Pilchie any way I can help further in order to get this pull request merged?

@Pilchie
Copy link
Member

Pilchie commented May 12, 2016

👍

Thanks for bringing it back to my attention! Let's do a retest of it against the current state, and then we'll merge.

@dotnet-bot retest this please

@Pilchie
Copy link
Member

Pilchie commented May 12, 2016

retest roslyn_prtest_win_vsi0 please

@Pilchie
Copy link
Member

Pilchie commented May 12, 2016

Trying another magic string:
retest vsi p0 please

@Pilchie
Copy link
Member

Pilchie commented May 12, 2016

Okay - looks good (don't work about eta2 - it was an interim thing that doesn't exist anymore, but you can't remove statuses from github).

@Pilchie Pilchie merged commit c624146 into dotnet:master May 12, 2016
@Pilchie
Copy link
Member

Pilchie commented May 12, 2016

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants