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

[Improvement]: Allow the user to rename the targetType in generated code #41536

Open
nipunayf opened this issue Oct 18, 2023 · 1 comment
Open
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Improvement

Comments

@nipunayf
Copy link
Contributor

nipunayf commented Oct 18, 2023

Description

In dependently-typed functions, there can be cases where the user may trigger a create variable code action without providing the expected type in the context. In this scenario, the code action will generate the variable with targetType as the placeholder. Preferably, the cursor should be placed to rename this value.

Describe your problem(s)

Consider the following example of Bal Persistent, in which the user attempts to create a variable for dependently-typed resource access.

import ballerina/persist;
import ballerina/http;

type EmployeeTask record {|
    readonly int taskId;
    string taskName;
    string description;
|};

service /employees on new http:Listener(9090) {
    private final Client dbClient;

    function init() returns error? {
        self.dbClient = check new();
    }

    isolated resource function get tasks(int id) returns EmployeeTask[]|error {
        self.dbClient->/employees();
    }
}

In this context, the user hasn't provided the expected type yet, so the code action will not replace the targetType as shown: stream<targetType, persist:Error?> streamResult = self.dbClient->/employees();. Ideally, the cursor should be positioned to rename the targetType in this scenario.

Describe your solution(s)

Ideally, the LS should allow the user to rename the targetType, so the user can enter the expected type after the generation.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@nipunayf nipunayf added Type/Improvement Team/LanguageServer Language Server Implementation related issues. #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/CodeAction Language Server Code Actions and removed Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Oct 18, 2023
@nipunayf
Copy link
Contributor Author

Related to #39253

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/Improvement
Projects
None yet
Development

No branches or pull requests

1 participant