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

Remove LocateOwner in formatting #9237

Merged
merged 6 commits into from
Sep 5, 2023

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Sep 4, 2023

Also in linked ranges, because no fixes were needed (at least according to tests?)

@@ -224,8 +224,7 @@ private static List<TextChange> AdjustRazorIndentation(FormattingContext context
private static bool IsPartOfHtmlTag(FormattingContext context, int position)
{
var syntaxTree = context.CodeDocument.GetSyntaxTree();
var change = new SourceChange(position, 0, string.Empty);
var owner = syntaxTree.Root.LocateOwner(change);
var owner = syntaxTree.Root.FindInnermostNode(position, includeWhitespace: true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Include whitespace may not be needed here...

Copy link
Contributor

Choose a reason for hiding this comment

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

If the tests all pass with it as false then no objection here, but I didn't check

var syntaxTree = context.CodeDocument.GetSyntaxTree();
var owner = syntaxTree.Root.LocateOwner(change);
var owner = syntaxTree.Root.FindInnermostNode(mappingSpan.Start, includeWhitespace: true);
Copy link
Contributor

Choose a reason for hiding this comment

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

@ryzngard I changed this to the overload that just takes a position, to match the old API. You had it as the one that takes a span, and I don't trust that the formatting engine can handle that sort of change, even if it makes sense with the parameters being passed in here.

IsImplicitExpression() ||
IsInSectionDirectiveCloseBrace() ||
(!allowImplicitStatements && IsImplicitStatementStart()))
if (IsInsideRazorComment())
Copy link
Contributor

Choose a reason for hiding this comment

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

Just spread this out to aid debugging as it was impossible to tell which one of these methods was the thing that returned early. One of these "Should have done it years ago" changes.

@@ -224,8 +224,7 @@ private static List<TextChange> AdjustRazorIndentation(FormattingContext context
private static bool IsPartOfHtmlTag(FormattingContext context, int position)
{
var syntaxTree = context.CodeDocument.GetSyntaxTree();
var change = new SourceChange(position, 0, string.Empty);
var owner = syntaxTree.Root.LocateOwner(change);
var owner = syntaxTree.Root.FindInnermostNode(position, includeWhitespace: true);
Copy link
Contributor

Choose a reason for hiding this comment

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

If the tests all pass with it as false then no objection here, but I didn't check

@@ -12,7 +12,7 @@
<div class="navbar-collapse collapse">
<ul class="nav ">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink( "About", "About", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

This was a surprise, but a pretty good change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🥳

@ryzngard ryzngard marked this pull request as ready for review September 5, 2023 18:46
@ryzngard ryzngard requested a review from a team as a code owner September 5, 2023 18:46
@ryzngard
Copy link
Contributor Author

ryzngard commented Sep 5, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@ryzngard ryzngard enabled auto-merge September 5, 2023 19:58
@ryzngard ryzngard merged commit bb687e5 into dotnet:main Sep 5, 2023
@ghost ghost added this to the Next milestone Sep 5, 2023
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
@ryzngard ryzngard deleted the LocateOwner/formatting branch October 15, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants