Format hash directives inside other hash directives of complex trivia#654
Format hash directives inside other hash directives of complex trivia#654basoundr merged 4 commits intodotnet:masterfrom
Conversation
Fix dotnet#285 : Analyze DisabledTextTrivia appropriately, so that when it is followed by a hash directive, we will be able to determine if we need to format the hash directive.
There was a problem hiding this comment.
this function always returns false. So the condition OnDisabledTextTrivia() in ShouldFormat() is never true.
There was a problem hiding this comment.
OnDisabledTextTrivia() like the other methods in ShouldFormat() is a method which introduces side effects. This is the intended behavior of the method.
There was a problem hiding this comment.
Oh I see. So, it adjusts position of something and says don't format this again.
There was a problem hiding this comment.
CodeShapeAnalyzer is a StateMachine and OnDisabledTextTrivia() just modifies the state.
|
👍 |
|
@heejaechang , a sign off from you and I will merge the PR |
There was a problem hiding this comment.
is last access last char directly? or enumerate through all chars to the end?
There was a problem hiding this comment.
it is really unfortunate that only way to check last char of a trivia is ToString.
There was a problem hiding this comment.
Last() is an extension method which gets the last char. I should introduce a NullEmpty check.
There was a problem hiding this comment.
I don’t what it does, what I mean is, is it internally do string[string.length -1] or is it do
Foreach(var c in string)
{
… get to the last one.
Return ch;
}
-
Heejae
From: Balaji [mailto:[email protected]]
Sent: Thursday, February 19, 2015 3:49 PM
To: dotnet/roslyn
Cc: HeeJae Chang
Subject: Re: [roslyn] Format hash directives inside other hash directives of complex trivia (#654)
In src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.CodeShapeAnalyzer.cshttps://github.com//pull/654#discussion_r25038276:
@@ -300,6 +297,17 @@ private bool ShouldFormat()
return false; }
private bool OnDisabledTextTrivia(SyntaxTrivia trivia, int index){if (trivia.IsKind(SyntaxKind.DisabledTextTrivia) &&SyntaxFacts.IsNewLine(trivia.ToString().Last()))
Last() is an extension method which gets the last char. I should introduce a NullEmpty check.
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/654/files#r25038276.
There was a problem hiding this comment.
It does string[string.length -1]. Hence I added IsNullOrEmpty check.
|
👍 |
Format hash directives inside other hash directives of complex trivia
Fix #285 : Analyze DisabledTextTrivia appropriately, so that when it is followed by a hash directive, we will be able to determine if we need to format the hash directive.