-
Notifications
You must be signed in to change notification settings - Fork 736
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]: Convert to configurable code action #41345
Comments
Upon the execution of the code action, we should provide two options to capture the user preference:
|
To make this feature complete we need to implement three code actions. 1. Convert to configurable code action The code action targets a module variable defined in the source code. The cursor must be placed within the literal expression of the variable user want to convert. Then it transforms the variable declaration by adding the string githubPAT = "this-is-my-fake-github-pat"; After Applying the Code Action: configurable string githubPAT = "this-is-my-fake-github-pat"; 2. Extract to configurable 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");
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); 3. Add Configurable to Config.toml This code action will perform the following functions:
|
After an offline discussion with @KavinduZoysa, we came to a conclusion to support |
Any particular reason to support only these? I think it would be useful to have the support also (at least) for unary expressions (e.g., Technically we could support this with anything that has a static type belonging to |
One reason to suggest only above syntax kinds was others won't make any sense. As you mentioned we can add |
Description
Consider the following code.
In the code above I have used module variables to define secrets. A new code action to convert them to configurables would be useful.
The code action should add the secrets to the Config.toml file while converting the module vars to configurable variables.
Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Editor
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: