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

Fixing some semantic model and refactoring issues with deconstruction #12381

Merged
merged 6 commits into from
Jul 11, 2016

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jul 7, 2016

There are few issues fixed:

  • code getting swallowed while extracting method
// comment
var (x1, x2) = (1, 2);
var x3 = 3; // extract method on "3" causes the two lines above to disappear
  • value of d-declaration not picked up for extract method and extract local
var (x1, x2) = [| (1, 2) |]; // not extract method or extract local refactoring available
  • when inlining a temporary variable into a deconstruction declaration, superfluous parens were left around:
// var temp = new C();
var (x1, x2) = (new C()); // after inlining temp, there are extra parens

CC @dotnet/roslyn-ide @dotnet/roslyn-compiler for review.
Related to #11299

@@ -61,9 +61,13 @@ public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatem
{
node = (LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node);

if (node.Declaration.IsDeconstructionDeclaration)
{// PROTOTYPE(tuples)
Copy link
Member Author

Choose a reason for hiding this comment

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

I wish to remove this marker before merging, but I'm not sure if additional scenarios need to be covered where variables need to be removed.
I'll check with the @dotnet/roslyn-ide team.

Copy link
Member Author

Choose a reason for hiding this comment

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

@heejaechang Let me know if you could review this PR and in particular the ExtractMethod refactoring question above.
I'm happy to stop by and provide some context.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see the benefit of the "PROTOTYPE" comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

@CyrusNajmabadi I intend to remove this PROTOTYPE marker before checking in. The question here is whether this behavior is sufficient, or if I should add logic for removing variables.
I'm not familiar enough with scenarios involving removing variables, so I'm not sure if it could be applicable to deconstructions. I'm guessing it's not applicable.

@rchande
Copy link
Contributor

rchande commented Jul 8, 2016

👍 for tests and inline temp. You might want @heejaechang to look at the extract method changes.

@jcouv
Copy link
Member Author

jcouv commented Jul 8, 2016

@gafter Could you review the compiler changes in this small PR?
The change is that bound nodes for deconstruction steps (that don't directly correspond to syntax) should not be added to the node map. This allows GetTypeInfo to work properly on deconstructions.
They are part of what we discussed Wednesday.

@cston
Copy link
Member

cston commented Jul 8, 2016

Compiler changes LGTM.

}
}";

await TestAsync(code, expected, index: 0, compareTokens: false);
Copy link
Member

Choose a reason for hiding this comment

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

Don't set compareTokens:false unless you are specifically testing formatting for the feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks

@VSadov
Copy link
Member

VSadov commented Jul 9, 2016

other than question about BoundLocalDeconstructionDeclaration, and we can come back to that later, LGTM

@jcouv
Copy link
Member Author

jcouv commented Jul 11, 2016

@heejaechang @CyrusNajmabadi Let me know if you have any other feedback. I plan to merge before lunch (this is blocking merging the feature back into the master branch). Thanks

@heejaechang
Copy link
Contributor

👍

@balajikris extract method has its own syntax node replace since it was written before we had SyntaxNode.Replace API. at some point, probably need to replace extract method's own syntax node replace implementation to just official SyntaxNode.Replace

@CyrusNajmabadi
Copy link
Member

I'm good with the IDE side.

@jcouv
Copy link
Member Author

jcouv commented Jul 11, 2016

Thanks all for the review and feedback!
I'll go ahead with the merge.

@jcouv jcouv merged commit ebc9afb into dotnet:features/tuples Jul 11, 2016
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

8 participants