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

EnC rude edit for local function attributes #49027

Closed

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Oct 29, 2020

Fixes #48636

@davidwengier
Copy link
Contributor Author

FYI @tmat if you get a chance to take a look before you go, that would be great.

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

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

🕐

@davidwengier davidwengier marked this pull request as ready for review November 4, 2020 02:19
@davidwengier davidwengier requested a review from a team as a code owner November 4, 2020 02:19
@davidwengier
Copy link
Contributor Author

davidwengier commented Jan 14, 2021

I've updated this to now use ClassifyEdit to report the rude edits. I like the approach in general, because it will be easy to add type parameter rude edits, and modifier rude edits etc. but there is an issue that I need to look into (and hence have to talk to you about first 😛)

I've left this in a state that should at least leave the tests green though.

if (!_isTopLevelEdit)
{
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we not report reordering of type parameters, e.g. for local functions?

if (!_isTopLevelEdit)
{
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

else
}

private IEnumerable<SyntaxNode> GetRootChildren(SyntaxNode node)
Copy link
Member

Choose a reason for hiding this comment

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

GetRootChildren [](start = 40, length = 15)

Looks good. I'd just rename this method to EnumerateChildren - GetRootChildren suggests that node is a root. But it is not expected to be a root.
Also, can we now merge ENumerateNonRootChildren and EnumerateRootChildren? Seems like we have one extra layer there.

@@ -1860,6 +1874,7 @@ protected override string GetSuspensionPointDisplayName(SyntaxNode node, EditKin
_kind = kind;
_span = span;
_match = match;
_isTopLevelEdit = isTopLevelEdit;
Copy link
Member

Choose a reason for hiding this comment

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

_isTopLevelEdit [](start = 16, length = 15)

I'm not seeing why is this flag necessary. Wouldn't the syntax kinds that are not found in local functions be just ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think this can be removed now, just haven't gone back to check yet. This is from previous attempts where the method body itself was classified, and I needed a way to ignore more node types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is still an issue because the EditClassifier is now seeing edits for nodes that StatementSyntaxComparer cares about, but TopSyntaxComparer doesn't, and it was written for the latter I guess.

  1. Change _isTopLevelEdit to _throwOnUnexpectedNode and have it just control the throw ExceptionUtilities.UnexpectedValue calls
  2. Check HasLabel before throwing unexpected value
  3. Add all of the missing syntax kinds to the EditClassifier and just return without doing anything
  4. Leave as is

Thoughts? Or have I missed something about when to class the EditClassifier?

Copy link
Member

Choose a reason for hiding this comment

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

I'd check HasLabel before calling the classifier for a specific edit.

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.

EnC: Adding/updating/removing attribute on local function, its return type or parameter should be rude edit
3 participants