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

[New Feature]: Extract to configurable code action #42984

Closed
LakshanWeerasinghe opened this issue Jun 26, 2024 · 0 comments · Fixed by #43014
Closed

[New Feature]: Extract to configurable code action #42984

LakshanWeerasinghe opened this issue Jun 26, 2024 · 0 comments · Fixed by #43014
Assignees
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler Type/NewFeature
Milestone

Comments

@LakshanWeerasinghe
Copy link
Contributor

Description

This code action can be broken into two parts.

  • Extract a single literal value
    This part functions similarly to the "extract to local variable" code action. When a single literal value is selected, the user will be prompted with a rename popup to update the configurable variable name.
    Before Applying the Code Action:
final mysql:Client myDb = check new ("<CURSOR>localhost", "my_user", "dummy_password", "dummy_database");

After Applying the Code Action:

configurable string configurableVar = "localhost";
final mysql:Client myDb = check new (configurableVar, "my_user", "dummy_password", "dummy_database");
  • Extract a Selected Range of Function Arguments into Configurable Variables
    In this part, all arguments within the selected cursor range will be extracted into configurable variables. The names of these configurable variables will be derived from the function parameter names.
    Before Applying the Code Action:
final mysql:Client myDb2 = check new (<CURSOR_START>"localhost", "my_user", "dummy_password", "dummy_database"<CURSOR_END>);

After Applying the Code Action:

configurable string host = "localhost";
configurable string username = "my_user";
configurable string password = "dummy_password";
configurable string database = "dummy_database";
final mysql:Client myDb2 = check new (host, username, password, database);

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

#41345

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jun 26, 2024
@LakshanWeerasinghe LakshanWeerasinghe added Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler and removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jun 26, 2024
@LakshanWeerasinghe LakshanWeerasinghe added this to the 2201.10.0 milestone Jun 26, 2024
@LakshanWeerasinghe LakshanWeerasinghe self-assigned this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler Type/NewFeature
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants