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

Method extraction #737

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ishmum123
Copy link
Contributor

No description provided.

@ishmum123 ishmum123 changed the title [WIP] Method extraction Method extraction Feb 14, 2021
Copy link
Collaborator

@klazuka klazuka left a comment

Choose a reason for hiding this comment

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

Thanks. This has the potential to be an awesome feature, and I like where you're going with it.

Please add some additional tests for more complex situations. I tried it out on an expression in elm-spa-example , and it generated bad code (it didn't extract a function parameter for maybeCred).

@ishmum123 ishmum123 requested a review from klazuka March 16, 2021 07:21
@pravdomil pravdomil mentioned this pull request Mar 16, 2021
@ishmum123
Copy link
Contributor Author

@klazuka hope the new job is going well. If you are too busy would you like to give me or @pravdomil write permission?

@klazuka
Copy link
Collaborator

klazuka commented Apr 4, 2021

I tried out your latest branch on elm-spa-example src/Page/Profile.elm. Attached is a video showing (1) how I perform ad-hoc testing of features like this to verify that it generates correct code and (2) shows several places where the method extraction does not work correctly (although I should say that in many cases it works well).

The main issues I found are:

  1. bad code gen when the expression is nested in case expressions
  2. one case where a value from the lexical scope did not have a function parameter (see video at 1:40)

These issues would need to be fixed before I would merge it. My basic criteria for any refactoring is that if the refactoring is offered by the plugin, then invoking the refactoring should always generate correct code.

Another small issue is that generated functions always have the name fn, even if one already exists. It'd be nice if it added a numeric suffix as needed.

method.extraction.mov

@ishmum123
Copy link
Contributor Author

Thank you so much for the response. Would try to get it done ASAP.

@ishmum123
Copy link
Contributor Author

@klazuka I think the current push fixes the issues you highlighted. Sorry for making you check so much... I would need to give some thought for making the enumerated fn. Please let me know if that is absolutely necessary

@ishmum123
Copy link
Contributor Author

Here's a check with the exact examples you used... Can you please suggest something about the feed case?

Extract.Method.mov

@cies cies added the feature label Apr 3, 2024
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

3 participants