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

Move some ComputeRefactoringsAsync to common helpers 3/n #37196

Merged
merged 12 commits into from
Jul 17, 2019

Conversation

petrroll
Copy link
Contributor

Continuation of work on #35525 and #35180

@petrroll petrroll requested a review from a team as a code owner July 12, 2019 21:42
@petrroll petrroll self-assigned this Jul 12, 2019
@petrroll
Copy link
Contributor Author

petrroll commented Jul 12, 2019

WIP:

  • Rework IsInHeader(...) so that it also return the node in question.

Question:

  • Regression in IntroduceUsingStatement tests: Dim name = [||]disposable"

ToDo:

  • Add RefactoringHelper tests.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Looks good. Minor cleanup/improvement suggestions.

Comment
Submit general feedback without explicit approval.

@petrroll petrroll changed the title [WIP] Move refactorings to common helpers Move refactorings to common helpers Jul 15, 2019
@petrroll
Copy link
Contributor Author

Ready to merge.
I'll have at least two more PRs soon (one for the move to ISyntaxKindsService I promised to do) and one for attempting to use the helper for a at least some of the If/for/foreach refactorings.

@@ -71,7 +71,7 @@ private async Task HandleNonSelectionAsync(CodeRefactoringContext context)

// We offer the refactoring when the user is either on the header of a class/struct,
// or if they're between any members of a class/struct and are on a blank line.
if (!syntaxFacts.IsOnTypeHeader(root, textSpan.Start) &&
if (!syntaxFacts.IsOnTypeHeader(root, textSpan.Start, out _) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

we could just have 2 overloads with and without out param?

Copy link
Contributor

Choose a reason for hiding this comment

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

saying it since there is 1 usage case where we want out param and all other cases it is not needed so, it feels reversed that all has to be changed for 1 usage case.

Copy link
Contributor

Choose a reason for hiding this comment

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

or create extension method in same namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to be consistent with other IsOnXXXHeader methods. And since having the out param is essentially free I feel like the clutter of having overload isn't worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally, being consistent doesn't cost us anything (since we can discard the result) and makes everything simpler to understand.

/// - Selection is zero-width and touching a Token whose ancestor ends/starts precisely on current selection .
/// - Selection is zero-width and touching a Token whose ancestor of type <typeparamref name="TSyntaxNode"/> ends/starts precisely on current selection.
/// - Selection is zero-width and in whitespace that corresponds to a Token whose direct ancestor is of type of type <typeparamref name="TSyntaxNode"/>.
/// - Selection is zero-width and in a header (defined by ISyntaxFacts helpers) of an node of type of type <typeparamref name="TSyntaxNode"/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

so plan would be sharing it in all referactoring get node? even thought it is only 1 place used right now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I follow the question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The TrySelectedNode is used only by one place because cyrus prepared a helpful extension method helper on Context (and that one is used by a number (> 10) of refactorings already)

@heejaechang
Copy link
Contributor

test failures?

@petrroll petrroll merged commit 7e24bd6 into dotnet:master Jul 17, 2019
@petrroll petrroll changed the title Move refactorings to common helpers Move ComputeRefAsync of some Refactorings to common helpers 3/n Aug 1, 2019
@petrroll petrroll changed the title Move ComputeRefAsync of some Refactorings to common helpers 3/n Move some ComputeRefactoringsAsync to common helpers 3/n Aug 1, 2019
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.

None yet

5 participants