Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Extract Method feature #588

Closed
ramya-rao-a opened this issue Oct 31, 2016 · 14 comments
Closed

Extract Method feature #588

ramya-rao-a opened this issue Oct 31, 2016 · 14 comments

Comments

@ramya-rao-a
Copy link
Contributor

No description provided.

@jijeshmohan
Copy link

How about integrating godoctor which has the same feature ?

@ramya-rao-a
Copy link
Contributor Author

We did try godoctor back in July, but it had a few limitations. See #370 for the discussions that followed.

@ramya-rao-a
Copy link
Contributor Author

Another way to go about this would be to use the "free variables" feature from guru if anyone wants to give this a try

@Hades32
Copy link

Hades32 commented Dec 28, 2017

I just tried the current 0.5 version of GoDoctor and it seems to handle simple cases (including the not so simple multiple return values) just fine and would IMO be an improvement over nothing.

Maybe you could re-re-review :)

@ramya-rao-a
Copy link
Contributor Author

Thanks @Hades32! That's good to know

Anyone willing to give this a try can use #370 as a reference

@mgood
Copy link

mgood commented Feb 25, 2018

Sorry to be a bit pedantic, but just wanted to note that this should be called "extract function", since "method" refers specifically to a function with a receiver, e.g. func (p *Point) Length() float64. Extracting code into a method would also be a nice feature to have, but that could be a special case to add after the initial support for extracting functions.

@conradwt
Copy link

conradwt commented Oct 4, 2018

@ramya-rao-a I take it that #588 is the main enhancement for tracking the Extract Method functionality. Thus, I was wondering, is anyone currently working on this feature?

@ramya-rao-a
Copy link
Contributor Author

@conradwt No one is working on this at the moment as far as I know.

@aswinmprabhu
Copy link
Contributor

@ramya-rao-a I had a go at this issue here. I also added "Extract expression to local variable" feature to see if it works here. It seems to work for all the simple examples I tried. I would be happy to make a PR if its good enough.

@ramya-rao-a
Copy link
Contributor Author

I would be happy to make a PR if its good enough.

@aswinmprabhu Make the PR regardless :) I am sure we can work together to get the feature in.

@conradwt
Copy link

@aswinmprabhu Good work and I agree with @ramya-rao-a 200% that you should make a PR regardless.

@aswinmprabhu
Copy link
Contributor

aswinmprabhu commented Nov 26, 2018

Thanks @ramya-rao-a and @conradwt.
Check out #2139

@ramya-rao-a
Copy link
Contributor Author

The latest beta version (0.9.3-beta.2) of this extension has this feature. Please see Refactoring in VS Code on how you can use the refactor feature.

Thanks @aswinmprabhu!

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 18, 2019
@ramya-rao-a
Copy link
Contributor Author

This feature is out in the latest release(0.10.0) of the Go extension

We have noticed a few cases where godoctor doesn't as expected. Therefore, the features are available as the below commands, but not as default refactoring as detailed in Refactoring in VS Code

  • Go: Extract to function
  • Go: Extract to variable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants