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

Code refactoring such as inline or extract as function #5009

Open
2 tasks done
perXautomatik opened this issue Jun 27, 2024 · 1 comment
Open
2 tasks done

Code refactoring such as inline or extract as function #5009

perXautomatik opened this issue Jun 27, 2024 · 1 comment
Labels
Area-Code Formatting Feature: VS Code Request to use or implement a VS Code feature. Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.

Comments

@perXautomatik
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

Add code refactoring features to improve code maintainability and readability. Specifically, allow users to inline variables or extract code blocks into separate functions.

Proposed Design

Inline Variable Refactoring:
Provide an option to inline variables directly where they are used.
When selecting a variable, the user can trigger the refactoring action to replace all occurrences of that variable with its value.
This helps reduce clutter and makes the code more concise.
Extract as Function Refactoring:
Allow users to select a code block (e.g., a series of statements) and extract it into a separate function.
The user can specify the function name, parameters, and return type.
The extracted function should be added to the script/module, and the original code replaced with a function call.
This promotes code reusability and modularization.

note
there might be possibility to include the module FriedrichWeinmann/Refactor
/
Refactor

@perXautomatik perXautomatik added Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed! labels Jun 27, 2024
@JustinGrote JustinGrote added Up for Grabs Will shepherd PRs. Feature: VS Code Request to use or implement a VS Code feature. Area-Code Formatting and removed Needs: Triage Maintainer attention needed! labels Jun 27, 2024
@JustinGrote
Copy link
Collaborator

Thanks for your submission!

As of today we (sort of) have an API for this, and @SeeminglyScience has written refactors for it you should check out.
https://github.com/SeeminglyScience/EditorServicesCommandSuite

In the future, I would like to adjust this API so these contributions can be accessed via the quick fix "lightbulb" and be more intuitive. There may already be a dupe issue for this, will reference if I find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Code Formatting Feature: VS Code Request to use or implement a VS Code feature. Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

2 participants